From 01da51691baef2cb38502ee6f2b0850ba530ee3d Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Fri, 19 Jan 2024 15:18:08 -0500 Subject: [PATCH 01/27] split pages --- .../public_private_calls/main.md | 2 +- .../dev_docs/contracts/syntax/storage/main.md | 424 +----------------- .../contracts/syntax/storage/private_state.md | 315 +++++++++++++ .../contracts/syntax/storage/public_state.md | 96 ++++ docs/sidebars.js | 6 +- 5 files changed, 430 insertions(+), 413 deletions(-) create mode 100644 docs/docs/dev_docs/contracts/syntax/storage/private_state.md create mode 100644 docs/docs/dev_docs/contracts/syntax/storage/public_state.md diff --git a/docs/docs/concepts/foundation/communication/public_private_calls/main.md b/docs/docs/concepts/foundation/communication/public_private_calls/main.md index 34a98047f4fd..15ae6df1c8b7 100644 --- a/docs/docs/concepts/foundation/communication/public_private_calls/main.md +++ b/docs/docs/concepts/foundation/communication/public_private_calls/main.md @@ -1,5 +1,5 @@ --- -title: Private <--> Public execution +title: Private - Public execution --- import Image from "@theme/IdealImage"; diff --git a/docs/docs/dev_docs/contracts/syntax/storage/main.md b/docs/docs/dev_docs/contracts/syntax/storage/main.md index 0be4049fadd0..bed2a65fe384 100644 --- a/docs/docs/dev_docs/contracts/syntax/storage/main.md +++ b/docs/docs/dev_docs/contracts/syntax/storage/main.md @@ -39,14 +39,14 @@ struct Storage { ``` :::danger -If your contract works with storage (has Storage struct defined), you **MUST** include a `compute_note_hash_and_nullifier` function to allow PXE to process encrypted events. See [encrypted events](../events.md#processing-encrypted-events) for more. +If your contract uses storage (has Storage struct defined), you **MUST** include a `compute_note_hash_and_nullifier` function to allow PXE to process encrypted events. See [encrypted events](../events.md#processing-encrypted-events) for more. -If you don't yet have any private state variables defined put there a placeholder function: +If you don't yet have any private state variables defined you can use this placeholder function: #include_code compute_note_hash_and_nullifier_placeholder /yarn-project/noir-contracts/contracts/token_bridge_contract/src/main.nr rust ::: -Since Aztec.nr is written in Noir, which on its own is state-less, we need to specify how the storage struct should be initialized to read and write data correctly. This is done by specifying an `init` function that is run in functions that rely on reading or altering the state variables. This `init` function must declare the storage struct with an instantiation defining how variables are accessed and manipulated. The function MUST be called `init` for the Aztec.nr library to properly handle it (this will be relaxed in the future). +Since Aztec.nr is written in Noir, which is state-less, we need to specify how the storage struct should be initialized to read and write data correctly. This is done by specifying an `init` function that is run in functions that rely on reading or altering the state variables. This `init` function must declare the Storage struct with an instantiation defining how variables are accessed and manipulated. The function MUST be called `init` for the Aztec.nr library to properly handle it (this will be relaxed in the future). ```rust impl Storage { @@ -70,7 +70,7 @@ No storage values should be initialized at slot `0` - storage slots begin at `1` A `map` is a state variable that "maps" a key to a value. It can be used with private or public storage variables. :::info -In Aztec.nr, keys are always `Field`s (or types that can be serialized as Fields) and values can be any type - even other maps. `Field`s are finite field elements, but you can think of them as integers for now. +In Aztec.nr, keys are always `Field`s, or types that can be serialized as Fields, and values can be any type - even other maps. `Field`s are finite field elements, but you can think of them as integers. ::: It includes a [`Context`](../context.mdx) to specify the private or public domain, a `storage_slot` to specify where in storage the map is stored, and a `start_var_constructor` which tells the map how it should operate on the underlying type. This includes how to serialize and deserialize the type, as well as how commitments and nullifiers are computed for the type if it's private. @@ -85,7 +85,7 @@ We will see examples of map constructors for public and private variables in lat #### As private storage -When declaring a mapping in private storage, we have to specify which type of Note to use. In the example below, we are specifying that we want to use the `Singleton` note type. See the [Singleton](#singletonnotetype) section for more information. +When declaring a mapping in private storage, we have to specify which type of Note to use. In the example below, we are specifying that we want to use the `Singleton` note type. In the Storage struct: @@ -109,7 +109,7 @@ In the `Storage::init` function: ### `at` -When dealing with a map, we can access the value at a given key using the `::at` method. This takes the key as an argument and returns the value at that key. +When dealing with a Map, we can access the value at a given key using the `::at` method. This takes the key as an argument and returns the value at that key. This function behaves similarly for both private and public maps. An example could be if we have a map with `minters`, which is mapping addresses to a flag for whether they are allowed to mint tokens or not. @@ -121,411 +121,13 @@ Above, we are specifying that we want to get the storage in the Map `at` the `ms require(minters[msg.sender], "caller is not minter"); ``` -## Public State Variables +## Further Reading -To define that a variable is public, it is wrapped in the `PublicState` struct. +- Managing [Public State](./public_state.md) +- Jump to the page on [Private State](./private_state.md) -The `PublicState` struct is generic over the variable type `T` and its serialized size `T_SERIALIZED_LEN`. -:::info -Currently, the length of the types must be specified when declaring the storage struct but the intention is that this will be inferred in the future. -::: - -The struct contains a `storage_slot` which, similar to Ethereum, is used to figure out _where_ in storage the variable is located. Notice that while we don't have the exact same [state model](../../../../concepts/foundation/state_model/main.md) as EVM chains it will look similar from the contract developers point of view. - -Beyond the struct, the `PublicState` also contains `serialization_methods`, which is a struct with methods that instruct the `PublicState` how to serialize and deserialize the variable. You can find the details of `PublicState` in the implementation [here](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/aztec-nr/aztec/src/state_vars/public_state.nr). - -:::info -The British haven't surrendered fully to US spelling, so serialization is currently inconsistent. -::: - -The Aztec.nr library provides serialization methods for various common types. - -:::info -An example using a larger struct can be found in the [lending example](https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/noir-contracts/contracts/lending_contract)'s use of an [`Asset`](https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/noir-contracts/contracts/lending_contract/src/asset.nr). -::: - -### `new` - -When declaring the storage for `T` as a persistent public storage variable, we use the `PublicState::new()` constructor. As seen below, this takes the `storage_slot` and the `serialization_methods` as arguments along with the [`Context`](../context.mdx), which in this case is used to share interface with other structures. - -#include_code public_state_struct_new /yarn-project/aztec-nr/aztec/src/state_vars/public_state.nr rust - -#### Single value example - -Say that we wish to add `admin` public state variable into our storage struct. In the struct we can define it as: - -#include_code storage_admin /yarn-project/noir-contracts/contracts/token_contract/src/main.nr rust - -And then when initializing it in the `Storage::init` function we can do: - -#include_code storage_admin_init /yarn-project/noir-contracts/contracts/token_contract/src/main.nr rust - -We have specified that we are storing a `Field` that should be placed in storage slot `1`. This is just a single value, and is similar to the following in solidity: - -```solidity -address internal admin; -``` - -:::info -We know its verbose, and are working on making it less so. -::: - -#### Mapping example - -Say we want to have a group of `minters` that are able to mint assets in our contract, and we want them in public storage, because [access control in private is quite cumbersome](../../../../concepts/foundation/communication/public_private_calls/main.md#a-note-on-l2-access-control). In the `Storage` struct we can add it as follows: - -#include_code storage_minters /yarn-project/noir-contracts/contracts/token_contract/src/main.nr rust - -And then when initializing it in the `Storage::init` function we can do it as follows: - -#include_code storage_minters_init /yarn-project/noir-contracts/contracts/token_contract/src/main.nr rust - -In this case, specifying that we are dealing with a map of Fields, and that it should be put at slot 2. - -This would be similar to the following in solidity: - -```solidity -mapping(address => bool) internal minters; -``` - -### `read` - -On the `PublicState` structs we have a `read` method to read the value at the location in storage and using the specified deserialization method to deserialize it. - -#### Reading from our `admin` example - -For our `admin` example from earlier, this could be used as follows to check that the stored value matches the `msg_sender()`. - -#include_code read_admin /yarn-project/noir-contracts/contracts/token_contract/src/main.nr rust - -#### Reading from our `minters` example - -As we saw in the Map earlier, a very similar operation can be done to perform a lookup in a map. - -#include_code read_minter /yarn-project/noir-contracts/contracts/token_contract/src/main.nr rust - -### `write` - -We have a `write` method on the `PublicState` struct that takes the value to write as an input and saves this in storage. It uses the serialization method to serialize the value which inserts (possibly multiple) values into storage. - -#### Writing to our `admin` example - -#include_code write_admin /yarn-project/noir-contracts/contracts/token_contract/src/main.nr rust - -#### Writing to our `minters` example - -#include_code write_minter /yarn-project/noir-contracts/contracts/token_contract/src/main.nr rust - -## Private State Variables - -In contrast to public state, private state is persistent state that is **not** visible to the whole world. Depending on the logic of the smart contract, a private state variable's current value will only be known to one entity, or a closed group of entities. - -The value of a private state variable can either be shared via an [encrypted log](../events.md#encrypted-events), or offchain via web2, or completely offline: it's up to the app developer. - -Aztec private state follows a utxo-based model. That is, a private state's current value is represented as one or many [notes](#notes). Each note is stored as an individual leaf in a utxo-based merkle tree: the [private state tree](../../../../concepts/foundation/state_model/main.md). - -To greatly simplify the experience of writing private state, Aztec.nr provides three different types of private state variable: - -- [Singleton](#singletonnotetype) -- [ImmutableSingleton](#immutablesingletonnotetype) -- [Set](#setnotetype) - -These three structs abstract-away many of Aztec's protocol complexities, by providing intuitive methods to modify notes in the utxo tree in a privacy-preserving way. - -:::info -An app can also choose to emit data via unencrypted log, or to define a note whose data is easy to figure out, then the information is technically not private and could be visible to anyone. -::: - -### Notes - -Unlike public state variables, which can be arbitrary types, private state variables operate on `NoteType`. - -Notes are the fundamental elements in the private world. - -A note should conform to the following interface: - -#include_code NoteInterface /yarn-project/aztec-nr/aztec/src/note/note_interface.nr rust - -The interplay between a private state variable and its notes can be confusing. Here's a summary to aid intuition: - -A private state variable (of type `Singleton`, `ImmutableSingleton` or `Set`) may be declared in storage. - -Every note contains (as a 'header') the contract address and storage slot of the state variable to which it "belongs". A note is said to "belong" to a private state if the storage slot of the private state matches the storage slot contained in the note's header. The header provides information that helps the user interpret the note's data. Without it the user would have to figure out where it belongs by brute-forcing the address and contract space. - -Management of this 'header' is abstracted-away from developers who use the `ImmutableSingleton`, `Singleton` and `Set` types. - -A private state variable is colloquially said to "point" to one or many notes (depending on the type), if those note(s) all "belong" to that private state, and those note(s) haven't-yet been nullified. - -An `ImmutableSingleton` will point to _one_ note over the lifetime of the contract. ("One", hence "Singleton"). This note is a struct of information that is persisted forever. - -A `Singleton` may point to _one_ note at a time. ("One", hence "Singleton"). But since it's not "immutable", the note that it points to may be [replaced](#replace) by functions of the contract, over time. The "current value" of a `Singleton` is interpreted as the one note which has not-yet been nullified. The act of 'replacing' a Singleton's note is how a `Singleton` state may be modified by functions. - -`Singleton` is a useful type when declaring a private state which may only ever be modified by those who are privy to the current value of that state. - -A `Set` may point to _multiple_ notes at a time. The "current value" of a private state variable of type `Set` is some 'accumulation' of all not-yet nullified notes which "belong" to the `Set`. The term "some accumulation" is intentionally vague. The interpretation of the "current value" of a `Set` must be expressed by the smart contract developer. A common use case for a `Set` is to represent the sum of a collection of values (in which case 'accumulation' is 'summation'). - -Think of a ZCash balance (or even a Bitcoin balance). The "current value" of a user's ZCash balance is the sum of all unspent (not-yet nullified) notes belonging to that user. To modify the "current value" of a `Set` state variable, is to [`insert`](#insert) new notes into the `Set`, or [`remove`](#remove) notes from that set. - -Interestingly, if a developer requires a private state to be modifiable by users who _aren't_ privy to the value of that state, a `Set` is a very useful type. The `insert` method allows new notes to be added to the `Set` without knowing any of the other notes in the set! (Like posting an envelope into a post box, you don't know what else is in there!). - -## `Singleton` - -Singleton is a private state variable that is unique in a way. When a Singleton is initialized, a note is created to represent its value. And the way to update the value is to destroy the current note, and create a new one with the updated value. - -Like for public state, we define the struct to have context, a storage slot and `note_interface` specifying how the note should be constructed and manipulated. You can view the implementation [here](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/aztec-nr/aztec/src/state_vars/singleton.nr). - -An example of singleton usage in the account contracts is keeping track of public keys. The `Singleton` is added to the `Storage` struct as follows: - -#include_code storage-singleton-declaration /yarn-project/noir-contracts/contracts/docs_example_contract/src/main.nr rust - -### `new` - -As part of the initialization of the `Storage` struct, the `Singleton` is created as follows, here at the specified storage slot and with the `NoteInterface` for `CardNote`. - -#include_code start_vars_singleton /yarn-project/noir-contracts/contracts/docs_example_contract/src/main.nr rust - -### `initialize` - -As mentioned, the Singleton is initialized to create the first note and value. - -When this function is called, a nullifier of the storage slot is created, preventing this Singleton from being initialized again. If an `owner` is specified, the nullifier will be hashed with the owner's secret key. It's crucial to provide an owner if the Singleton is associated with an account. Initializing it without an owner may inadvertently reveal important information about the owner's intention. - -Unlike public states, which have a default initial value of `0` (or many zeros, in the case of a struct, array or map), a private state (of type `Singleton`, `ImmutableSingleton` or `Set`) does not have a default initial value. The `initialize` method (or `insert`, in the case of a `Set`) must be called. - -:::info -Extend on what happens if you try to use non-initialized state. -::: - -### `is_initialized` - -An unconstrained method to check whether the Singleton has been initialized or not. It takes an optional owner and returns a boolean. You can view the implementation [here](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/aztec-nr/aztec/src/state_vars/singleton.nr). - -### `replace` - -To update the value of a `Singleton`, we can use the `replace` method. The method takes a new note as input, and replaces the current note with the new one. It emits a nullifier for the old value, and inserts the new note into the data tree. - -An example of this is seen in a example card game, where we create a new note (a `CardNote`) containing some new data, and replace the current note with it: - -#include_code state_vars-SingletonReplace /yarn-project/noir-contracts/contracts/docs_example_contract/src/actions.nr rust - -If two people are trying to modify the Singleton at the same time, only one will succeed as we don't allow duplicate nullifiers! Developers should put in place appropriate access controls to avoid race conditions (unless a race is intended!). - -### `get_note` - -This function allows us to get the note of a Singleton, essentially reading the value. - -#include_code state_vars-SingletonGet /yarn-project/noir-contracts/contracts/docs_example_contract/src/actions.nr rust - -#### Nullifying Note reads - -It's possible that at the time this function is called, the system hasn't synced to the block where the latest note was created. Or a malicious user might feed an old state to this function, tricking the proving system into thinking that the value hasn't changed. To avoid an attack around it, this function will destroy the current note, and replace it with a duplicated note that has the same fields. Because the nullifier of the latest note will be emitted, if two people are trying to use this function against the same note, only one will succeed (no duplicate nullifiers allowed). - -### `view_note` - -Functionally similar to [`get_note`](#get_note), but executed in unconstrained functions and can be used by the wallet to fetch notes for use by front-ends etc. - -## `ImmutableSingleton` - -ImmutableSingleton represents a unique private state variable that, as the name suggests, is immutable. Once initialized, its value cannot be altered. - -#include_code struct /yarn-project/aztec-nr/aztec/src/state_vars/immutable_singleton.nr rust - -### `new` - -As part of the initialization of the `Storage` struct, the `Singleton` is created as follows, here at storage slot 1 and with the `NoteInterface` for `PublicKeyNote`. - -#include_code storage_init /yarn-project/noir-contracts/contracts/schnorr_account_contract/src/main.nr rust - -### `initialize` - -When this function is invoked, it creates a nullifier for the storage slot, ensuring that the ImmutableSingleton cannot be initialized again. If an owner is specified, the nullifier will be hashed with the owner's secret key. It is crucial to provide an owner if the ImmutableSingleton is linked to an account; initializing it without one may inadvertently disclose sensitive information about the owner's intent. - -Set the value of an ImmutableSingleton by calling the `initialize` method: - -#include_code initialize /yarn-project/noir-contracts/contracts/schnorr_account_contract/src/main.nr rust - -Once initialized, an ImmutableSingleton's value remains unchangeable. This method can only be called once. - -### `is_initialized` - -An unconstrained method to check if the ImmutableSingleton has been initialized. Takes an optional owner and returns a boolean. You can find the implementation [here](https://github.com/AztecProtocol/aztec-packages/blob/master//yarn-project/aztec-nr/aztec/src/state_vars/immutable_singleton.nr). - -### `get_note` - -Similar to the `Singleton`, we can use the `get_note` method to read the value of an ImmutableSingleton. - -Use this method to retrieve the value of an initialized ImmutableSingleton. - -#include_code get_note /yarn-project/noir-contracts/contracts/schnorr_account_contract/src/main.nr rust - -Unlike a `Singleton`, the `get_note` function for an ImmutableSingleton doesn't destroy the current note in the background. This means that multiple accounts can concurrently call this function to read the value. - -This function will throw if the ImmutableSingleton hasn't been initialized. - -### `view_note` - -Functionally similar to `get_note`, but executed unconstrained and can be used by the wallet to fetch notes for use by front-ends etc. - -## `Set` - -Set is used for managing a collection of notes. All notes in a set are of the same `NoteType`. But whether these notes all belong to one entity, or are accessible and editable by different entities, is totally up to the developer. Due to our state model, the set is a collection of notes inserted into the data-tree, but notes are never removed from the tree itself, they are only nullified. - -#include_code struct /yarn-project/aztec-nr/aztec/src/state_vars/set.nr rust - -And can be added to the `Storage` struct as follows. Here adding a set for a custom note, the TransparentNote (useful for [public -> private communication](../functions.md#public---private)). - -#include_code storage_pending_shields /yarn-project/noir-contracts/contracts/token_contract/src/main.nr rust - -### `new` - -The `new` method tells the contract how to operate on the underlying storage. - -We can initialize the set as follows: - -#include_code storage_pending_shields_init /yarn-project/noir-contracts/contracts/token_contract/src/main.nr rust - -### `insert` - -Allows us to modify the storage by inserting a note into the set. - -A commitment from the note will be generated, and inserted into data-tree, allowing us to later use in contract interactions. - -A commitment from the note will be generated, and inserted into data-tree, allowing us to later use in contract interactions. Recall that the content of the note should be shared with the owner to allow them to use it, as mentioned this can be done via an [encrypted log](../events.md#encrypted-events), or offchain via web2, or completely offline. - -#include_code insert /yarn-project/aztec-nr/easy-private-state/src/easy_private_state.nr rust - -### `insert_from_public` - -While we don't support private functions to directly alter public storage, the opposite direction is possible. The `insert_from_public` allow public function to insert notes into private storage. This is very useful when we want to support private function calls that must have been initiated in public, such as shielding or the like. - -The usage is rather straight-forward and very similar to using the `insert` method with the difference that this one is called in public functions. - -#include_code insert_from_public /yarn-project/noir-contracts/contracts/token_contract/src/main.nr rust - -### `remove` - -Will remove a note from the set if it previously has been read from storage, e.g. you have fetched it through a `get_notes` call. This is useful when you want to remove a note that you have previously read from storage and do not have to read it again. - -Nullifiers are emitted when reading values to make sure that they are up to date. - -An example of how to use this operation is visible in the `easy_private_state`: - -#include_code remove /yarn-project/aztec-nr/easy-private-state/src/easy_private_state.nr rust - -### `get_notes` - -This function returns the notes the account has access to. - -The kernel circuits are constrained to a maximum number of notes this function can return at a time. Check [here](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/noir-protocol-circuits/src/crates/types/src/constants.nr) and look for `MAX_READ_REQUESTS_PER_CALL` for the up-to-date number. - -Because of this limit, we should always consider using the second argument `NoteGetterOptions` to limit the number of notes we need to read and constrain in our programs. This is quite important as every extra call increases the time used to prove the program and we don't want to spend more time than necessary. - -An example of such options is using the [filter_notes_min_sum](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/aztec-nr/value-note/src/filter.nr) to get "enough" notes to cover a given value. Essentially, this function will return just enough notes to cover the amount specified such that we don't need to read all our notes. For users with a lot of notes, this becomes increasingly important. - -#include_code get_notes /yarn-project/aztec-nr/easy-private-state/src/easy_private_state.nr rust - -### `view_notes` - -Functionally similar to [`get_notes`](#get_notes), but executed unconstrained and can be used by the wallet to fetch notes for use by front-ends etc. - -#include_code view_notes /yarn-project/aztec-nr/value-note/src/balance_utils.nr rust - -There's also a limit on the maximum number of notes that can be returned in one go. To find the current limit, refer to [this file](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/noir-protocol-circuits/src/crates/types/src/constants.nr) and look for `MAX_NOTES_PER_PAGE`. - -The key distinction is that this method is unconstrained. It does not perform a check to verify if the notes actually exist, which is something the [`get_notes`](#get_notes) method does under the hood. Therefore, it should only be used in an unconstrained contract function. - -This function requires a `NoteViewerOptions`. The `NoteViewerOptions` is essentially similar to the [`NoteGetterOptions`](#notegetteroptions), except that it doesn't take a custom filter. - -### NoteGetterOptions - -`NoteGetterOptions` encapsulates a set of configurable options for filtering and retrieving a selection of notes from a [data oracle](../functions.md#oracle-functions). Developers can design instances of `NoteGetterOptions`, to determine how notes should be filtered and returned to the functions of their smart contracts. - -#include_code NoteGetterOptions /yarn-project/aztec-nr/aztec/src/note/note_getter_options.nr rust - -#### `selects: BoundedVec, N>` - -`selects` is a collection of filtering criteria, specified by `Select { field_index: u8, value: Field }` structs. It instructs the data oracle to find notes whose (`field_index`)th field matches the provided `value`. - -#### `sorts: BoundedVec, N>` - -`sorts` is a set of sorting instructions defined by `Sort { field_index: u8, order: u2 }` structs. This directs the data oracle to sort the matching notes based on the value of the specified field index and in the indicated order. The value of order is **1** for _DESCENDING_ and **2** for _ASCENDING_. - -#### `limit: u32` - -When the `limit` is set to a non-zero value, the data oracle will return a maximum of `limit` notes. - -#### `offset: u32` - -This setting enables us to skip the first `offset` notes. It's particularly useful for pagination. - -#### `filter: fn ([Option; MAX_READ_REQUESTS_PER_CALL], FILTER_ARGS) -> [Option; MAX_READ_REQUESTS_PER_CALL]` - -Developers have the option to provide a custom filter. This allows specific logic to be applied to notes that meet the criteria outlined above. The filter takes the notes returned from the oracle and `filter_args` as its parameters. - -It's important to note that the process of applying the custom filter to get the final notes is not constrained. It's crucial to verify the returned notes even if certain assumptions are made in the custom filter. - -#### `filter_args: FILTER_ARGS` - -`filter_args` provides a means to furnish additional data or context to the custom filter. - -#### Methods - -Several methods are available on `NoteGetterOptions` to construct the options in a more readable manner: - -#### `fn new() -> NoteGetterOptions` - -This function initializes a `NoteGetterOptions` that simply returns the maximum number of notes allowed in a call. - -#### `fn with_filter(filter, filter_args) -> NoteGetterOptions` - -This function initializes a `NoteGetterOptions` with a [`filter`](#filter-fn-optionnote-max_read_requests_per_call-filter_args---optionnote-max_read_requests_per_call) and [`filter_args`](#filter_args-filter_args). - -#### `.select` - -This method adds a [`Select`](#selects-boundedvecoptionselect-n) criterion to the options. - -#### `.sort` - -This method adds a [`Sort`](#sorts-boundedvecoptionsort-n) criterion to the options. - -#### `.set_limit` - -This method lets you set a limit for the maximum number of notes to be retrieved. - -#### `.set_offset` - -This method sets the offset value, which determines where to start retrieving notes. - -#### Examples - -The following code snippet creates an instance of `NoteGetterOptions`, which has been configured to find the cards that belong to `account_address`. The returned cards are sorted by their points in descending order, and the first `offset` cards with the highest points are skipped. - -#include_code state_vars-NoteGetterOptionsSelectSortOffset /yarn-project/noir-contracts/contracts/docs_example_contract/src/options.nr rust - -The first value of `.select` and `.sort` is the index of a field in a note type. For the note type `CardNote` that has the following fields: - -#include_code state_vars-CardNote /yarn-project/noir-contracts/contracts/docs_example_contract/src/types/card_note.nr rust - -The indices are: 0 for `points`, 1 for `secret`, and 2 for `owner`. - -In the example, `.select(2, account_address)` matches the 2nd field of `CardNote`, which is `owner`, and returns the cards whose `owner` field equals `account_address`. - -`.sort(0, SortOrder.DESC)` sorts the 0th field of `CardNote`, which is `points`, in descending order. - -There can be as many conditions as the number of fields a note type has. The following example finds cards whose fields match the three given values: - -#include_code state_vars-NoteGetterOptionsMultiSelects /yarn-project/noir-contracts/contracts/docs_example_contract/src/options.nr rust - -While `selects` lets us find notes with specific values, `filter` lets us find notes in a more dynamic way. The function below picks the cards whose points are at least `min_points`: - -#include_code state_vars-OptionFilter /yarn-project/noir-contracts/contracts/docs_example_contract/src/options.nr rust - -We can use it as a filter to further reduce the number of the final notes: - -#include_code state_vars-NoteGetterOptionsFilter /yarn-project/noir-contracts/contracts/docs_example_contract/src/options.nr rust - -One thing to remember is, `filter` will be applied on the notes after they are picked from the database. Therefore, it's possible that the actual notes we end up getting are fewer than the limit. - -The limit is `MAX_READ_REQUESTS_PER_CALL` by default. But we can set it to any value **smaller** than that: +## Concepts mentioned -#include_code state_vars-NoteGetterOptionsPickOne /yarn-project/noir-contracts/contracts/docs_example_contract/src/options.nr rust +- [State Model](../../../../concepts/foundation/state_model/main.md) +- [Public-private execution](../../../../concepts/foundation/communication/public_private_calls/main.md) +- [Function Contexts](../context.mdx) diff --git a/docs/docs/dev_docs/contracts/syntax/storage/private_state.md b/docs/docs/dev_docs/contracts/syntax/storage/private_state.md new file mode 100644 index 000000000000..bd50c7696a57 --- /dev/null +++ b/docs/docs/dev_docs/contracts/syntax/storage/private_state.md @@ -0,0 +1,315 @@ +--- +title: Private State +--- + +In contrast to public state, private state is persistent state that is **not** visible to the whole world. Depending on the logic of the smart contract, a private state variable's current value will only be known to one entity, or a closed group of entities. + +The value of a private state variable can either be shared via an [encrypted log](../events.md#encrypted-events), or offchain via web2, or completely offline: it's up to the app developer. + +Aztec private state follows a utxo-based model. That is, a private state's current value is represented as one or many [notes](#notes). Each note is stored as an individual leaf in a utxo-based merkle tree: the [private state tree](../../../../concepts/foundation/state_model/main.md). + +To greatly simplify the experience of writing private state, Aztec.nr provides three different types of private state variable: + +- [Singleton](#singletonnotetype) +- [ImmutableSingleton](#immutablesingletonnotetype) +- [Set](#setnotetype) + +These three structs abstract-away many of Aztec's protocol complexities, by providing intuitive methods to modify notes in the utxo tree in a privacy-preserving way. + +:::info +An app can also choose to emit data via unencrypted log, or to define a note whose data is easy to figure out, then the information is technically not private and could be visible to anyone. +::: + +### Notes + +Unlike public state variables, which can be arbitrary types, private state variables operate on `NoteType`. + +Notes are the fundamental elements in the private world. + +A note should conform to the following interface: + +#include_code NoteInterface /yarn-project/aztec-nr/aztec/src/note/note_interface.nr rust + +The interplay between a private state variable and its notes can be confusing. Here's a summary to aid intuition: + +A private state variable (of type `Singleton`, `ImmutableSingleton` or `Set`) may be declared in storage. + +Every note contains (as a 'header') the contract address and storage slot of the state variable to which it "belongs". A note is said to "belong" to a private state if the storage slot of the private state matches the storage slot contained in the note's header. The header provides information that helps the user interpret the note's data. Without it the user would have to figure out where it belongs by brute-forcing the address and contract space. + +Management of this 'header' is abstracted-away from developers who use the `ImmutableSingleton`, `Singleton` and `Set` types. + +A private state variable is colloquially said to "point" to one or many notes (depending on the type), if those note(s) all "belong" to that private state, and those note(s) haven't-yet been nullified. + +An `ImmutableSingleton` will point to _one_ note over the lifetime of the contract. ("One", hence "Singleton"). This note is a struct of information that is persisted forever. + +A `Singleton` may point to _one_ note at a time. ("One", hence "Singleton"). But since it's not "immutable", the note that it points to may be [replaced](#replace) by functions of the contract, over time. The "current value" of a `Singleton` is interpreted as the one note which has not-yet been nullified. The act of 'replacing' a Singleton's note is how a `Singleton` state may be modified by functions. + +`Singleton` is a useful type when declaring a private state which may only ever be modified by those who are privy to the current value of that state. + +A `Set` may point to _multiple_ notes at a time. The "current value" of a private state variable of type `Set` is some 'accumulation' of all not-yet nullified notes which "belong" to the `Set`. The term "some accumulation" is intentionally vague. The interpretation of the "current value" of a `Set` must be expressed by the smart contract developer. A common use case for a `Set` is to represent the sum of a collection of values (in which case 'accumulation' is 'summation'). + +Think of a ZCash balance (or even a Bitcoin balance). The "current value" of a user's ZCash balance is the sum of all unspent (not-yet nullified) notes belonging to that user. To modify the "current value" of a `Set` state variable, is to [`insert`](#insert) new notes into the `Set`, or [`remove`](#remove) notes from that set. + +Interestingly, if a developer requires a private state to be modifiable by users who _aren't_ privy to the value of that state, a `Set` is a very useful type. The `insert` method allows new notes to be added to the `Set` without knowing any of the other notes in the set! (Like posting an envelope into a post box, you don't know what else is in there!). + +## `Singleton` + +Singleton is a private state variable that is unique in a way. When a Singleton is initialized, a note is created to represent its value. And the way to update the value is to destroy the current note, and create a new one with the updated value. + +Like for public state, we define the struct to have context, a storage slot and `note_interface` specifying how the note should be constructed and manipulated. You can view the implementation [here](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/aztec-nr/aztec/src/state_vars/singleton.nr). + +An example of singleton usage in the account contracts is keeping track of public keys. The `Singleton` is added to the `Storage` struct as follows: + +#include_code storage-singleton-declaration /yarn-project/noir-contracts/contracts/docs_example_contract/src/main.nr rust + +### `new` + +As part of the initialization of the `Storage` struct, the `Singleton` is created as follows, here at the specified storage slot and with the `NoteInterface` for `CardNote`. + +#include_code start_vars_singleton /yarn-project/noir-contracts/contracts/docs_example_contract/src/main.nr rust + +### `initialize` + +As mentioned, the Singleton is initialized to create the first note and value. + +When this function is called, a nullifier of the storage slot is created, preventing this Singleton from being initialized again. If an `owner` is specified, the nullifier will be hashed with the owner's secret key. It's crucial to provide an owner if the Singleton is associated with an account. Initializing it without an owner may inadvertently reveal important information about the owner's intention. + +Unlike public states, which have a default initial value of `0` (or many zeros, in the case of a struct, array or map), a private state (of type `Singleton`, `ImmutableSingleton` or `Set`) does not have a default initial value. The `initialize` method (or `insert`, in the case of a `Set`) must be called. + +:::info +Extend on what happens if you try to use non-initialized state. +::: + +### `is_initialized` + +An unconstrained method to check whether the Singleton has been initialized or not. It takes an optional owner and returns a boolean. You can view the implementation [here](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/aztec-nr/aztec/src/state_vars/singleton.nr). + +### `replace` + +To update the value of a `Singleton`, we can use the `replace` method. The method takes a new note as input, and replaces the current note with the new one. It emits a nullifier for the old value, and inserts the new note into the data tree. + +An example of this is seen in a example card game, where we create a new note (a `CardNote`) containing some new data, and replace the current note with it: + +#include_code state_vars-SingletonReplace /yarn-project/noir-contracts/contracts/docs_example_contract/src/actions.nr rust + +If two people are trying to modify the Singleton at the same time, only one will succeed as we don't allow duplicate nullifiers! Developers should put in place appropriate access controls to avoid race conditions (unless a race is intended!). + +### `get_note` + +This function allows us to get the note of a Singleton, essentially reading the value. + +#include_code state_vars-SingletonGet /yarn-project/noir-contracts/contracts/docs_example_contract/src/actions.nr rust + +#### Nullifying Note reads + +It's possible that at the time this function is called, the system hasn't synced to the block where the latest note was created. Or a malicious user might feed an old state to this function, tricking the proving system into thinking that the value hasn't changed. To avoid an attack around it, this function will destroy the current note, and replace it with a duplicated note that has the same fields. Because the nullifier of the latest note will be emitted, if two people are trying to use this function against the same note, only one will succeed (no duplicate nullifiers allowed). + +### `view_note` + +Functionally similar to [`get_note`](#get_note), but executed in unconstrained functions and can be used by the wallet to fetch notes for use by front-ends etc. + +## `ImmutableSingleton` + +ImmutableSingleton represents a unique private state variable that, as the name suggests, is immutable. Once initialized, its value cannot be altered. + +#include_code struct /yarn-project/aztec-nr/aztec/src/state_vars/immutable_singleton.nr rust + +### `new` + +As part of the initialization of the `Storage` struct, the `Singleton` is created as follows, here at storage slot 1 and with the `NoteInterface` for `PublicKeyNote`. + +#include_code storage_init /yarn-project/noir-contracts/contracts/schnorr_account_contract/src/main.nr rust + +### `initialize` + +When this function is invoked, it creates a nullifier for the storage slot, ensuring that the ImmutableSingleton cannot be initialized again. If an owner is specified, the nullifier will be hashed with the owner's secret key. It is crucial to provide an owner if the ImmutableSingleton is linked to an account; initializing it without one may inadvertently disclose sensitive information about the owner's intent. + +Set the value of an ImmutableSingleton by calling the `initialize` method: + +#include_code initialize /yarn-project/noir-contracts/contracts/schnorr_account_contract/src/main.nr rust + +Once initialized, an ImmutableSingleton's value remains unchangeable. This method can only be called once. + +### `is_initialized` + +An unconstrained method to check if the ImmutableSingleton has been initialized. Takes an optional owner and returns a boolean. You can find the implementation [here](https://github.com/AztecProtocol/aztec-packages/blob/master//yarn-project/aztec-nr/aztec/src/state_vars/immutable_singleton.nr). + +### `get_note` + +Similar to the `Singleton`, we can use the `get_note` method to read the value of an ImmutableSingleton. + +Use this method to retrieve the value of an initialized ImmutableSingleton. + +#include_code get_note /yarn-project/noir-contracts/contracts/schnorr_account_contract/src/main.nr rust + +Unlike a `Singleton`, the `get_note` function for an ImmutableSingleton doesn't destroy the current note in the background. This means that multiple accounts can concurrently call this function to read the value. + +This function will throw if the ImmutableSingleton hasn't been initialized. + +### `view_note` + +Functionally similar to `get_note`, but executed unconstrained and can be used by the wallet to fetch notes for use by front-ends etc. + +## `Set` + +Set is used for managing a collection of notes. All notes in a set are of the same `NoteType`. But whether these notes all belong to one entity, or are accessible and editable by different entities, is totally up to the developer. Due to our state model, the set is a collection of notes inserted into the data-tree, but notes are never removed from the tree itself, they are only nullified. + +#include_code struct /yarn-project/aztec-nr/aztec/src/state_vars/set.nr rust + +And can be added to the `Storage` struct as follows. Here adding a set for a custom note, the TransparentNote (useful for [public -> private communication](../functions.md#public---private)). + +#include_code storage_pending_shields /yarn-project/noir-contracts/contracts/token_contract/src/main.nr rust + +### `new` + +The `new` method tells the contract how to operate on the underlying storage. + +We can initialize the set as follows: + +#include_code storage_pending_shields_init /yarn-project/noir-contracts/contracts/token_contract/src/main.nr rust + +### `insert` + +Allows us to modify the storage by inserting a note into the set. + +A commitment from the note will be generated, and inserted into data-tree, allowing us to later use in contract interactions. + +A commitment from the note will be generated, and inserted into data-tree, allowing us to later use in contract interactions. Recall that the content of the note should be shared with the owner to allow them to use it, as mentioned this can be done via an [encrypted log](../events.md#encrypted-events), or offchain via web2, or completely offline. + +#include_code insert /yarn-project/aztec-nr/easy-private-state/src/easy_private_state.nr rust + +### `insert_from_public` + +While we don't support private functions to directly alter public storage, the opposite direction is possible. The `insert_from_public` allow public function to insert notes into private storage. This is very useful when we want to support private function calls that must have been initiated in public, such as shielding or the like. + +The usage is rather straight-forward and very similar to using the `insert` method with the difference that this one is called in public functions. + +#include_code insert_from_public /yarn-project/noir-contracts/contracts/token_contract/src/main.nr rust + +### `remove` + +Will remove a note from the set if it previously has been read from storage, e.g. you have fetched it through a `get_notes` call. This is useful when you want to remove a note that you have previously read from storage and do not have to read it again. + +Nullifiers are emitted when reading values to make sure that they are up to date. + +An example of how to use this operation is visible in the `easy_private_state`: + +#include_code remove /yarn-project/aztec-nr/easy-private-state/src/easy_private_state.nr rust + +### `get_notes` + +This function returns the notes the account has access to. + +The kernel circuits are constrained to a maximum number of notes this function can return at a time. Check [here](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/noir-protocol-circuits/src/crates/types/src/constants.nr) and look for `MAX_READ_REQUESTS_PER_CALL` for the up-to-date number. + +Because of this limit, we should always consider using the second argument `NoteGetterOptions` to limit the number of notes we need to read and constrain in our programs. This is quite important as every extra call increases the time used to prove the program and we don't want to spend more time than necessary. + +An example of such options is using the [filter_notes_min_sum](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/aztec-nr/value-note/src/filter.nr) to get "enough" notes to cover a given value. Essentially, this function will return just enough notes to cover the amount specified such that we don't need to read all our notes. For users with a lot of notes, this becomes increasingly important. + +#include_code get_notes /yarn-project/aztec-nr/easy-private-state/src/easy_private_state.nr rust + +### `view_notes` + +Functionally similar to [`get_notes`](#get_notes), but executed unconstrained and can be used by the wallet to fetch notes for use by front-ends etc. + +#include_code view_notes /yarn-project/aztec-nr/value-note/src/balance_utils.nr rust + +There's also a limit on the maximum number of notes that can be returned in one go. To find the current limit, refer to [this file](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/noir-protocol-circuits/src/crates/types/src/constants.nr) and look for `MAX_NOTES_PER_PAGE`. + +The key distinction is that this method is unconstrained. It does not perform a check to verify if the notes actually exist, which is something the [`get_notes`](#get_notes) method does under the hood. Therefore, it should only be used in an unconstrained contract function. + +This function requires a `NoteViewerOptions`. The `NoteViewerOptions` is essentially similar to the [`NoteGetterOptions`](#notegetteroptions), except that it doesn't take a custom filter. + +### NoteGetterOptions + +`NoteGetterOptions` encapsulates a set of configurable options for filtering and retrieving a selection of notes from a [data oracle](../functions.md#oracle-functions). Developers can design instances of `NoteGetterOptions`, to determine how notes should be filtered and returned to the functions of their smart contracts. + +#include_code NoteGetterOptions /yarn-project/aztec-nr/aztec/src/note/note_getter_options.nr rust + +#### `selects: BoundedVec, N>` + +`selects` is a collection of filtering criteria, specified by `Select { field_index: u8, value: Field }` structs. It instructs the data oracle to find notes whose (`field_index`)th field matches the provided `value`. + +#### `sorts: BoundedVec, N>` + +`sorts` is a set of sorting instructions defined by `Sort { field_index: u8, order: u2 }` structs. This directs the data oracle to sort the matching notes based on the value of the specified field index and in the indicated order. The value of order is **1** for _DESCENDING_ and **2** for _ASCENDING_. + +#### `limit: u32` + +When the `limit` is set to a non-zero value, the data oracle will return a maximum of `limit` notes. + +#### `offset: u32` + +This setting enables us to skip the first `offset` notes. It's particularly useful for pagination. + +#### `filter: fn ([Option; MAX_READ_REQUESTS_PER_CALL], FILTER_ARGS) -> [Option; MAX_READ_REQUESTS_PER_CALL]` + +Developers have the option to provide a custom filter. This allows specific logic to be applied to notes that meet the criteria outlined above. The filter takes the notes returned from the oracle and `filter_args` as its parameters. + +It's important to note that the process of applying the custom filter to get the final notes is not constrained. It's crucial to verify the returned notes even if certain assumptions are made in the custom filter. + +#### `filter_args: FILTER_ARGS` + +`filter_args` provides a means to furnish additional data or context to the custom filter. + +#### Methods + +Several methods are available on `NoteGetterOptions` to construct the options in a more readable manner: + +#### `fn new() -> NoteGetterOptions` + +This function initializes a `NoteGetterOptions` that simply returns the maximum number of notes allowed in a call. + +#### `fn with_filter(filter, filter_args) -> NoteGetterOptions` + +This function initializes a `NoteGetterOptions` with a [`filter`](#filter-fn-optionnote-max_read_requests_per_call-filter_args---optionnote-max_read_requests_per_call) and [`filter_args`](#filter_args-filter_args). + +#### `.select` + +This method adds a [`Select`](#selects-boundedvecoptionselect-n) criterion to the options. + +#### `.sort` + +This method adds a [`Sort`](#sorts-boundedvecoptionsort-n) criterion to the options. + +#### `.set_limit` + +This method lets you set a limit for the maximum number of notes to be retrieved. + +#### `.set_offset` + +This method sets the offset value, which determines where to start retrieving notes. + +#### Examples + +The following code snippet creates an instance of `NoteGetterOptions`, which has been configured to find the cards that belong to `account_address`. The returned cards are sorted by their points in descending order, and the first `offset` cards with the highest points are skipped. + +#include_code state_vars-NoteGetterOptionsSelectSortOffset /yarn-project/noir-contracts/contracts/docs_example_contract/src/options.nr rust + +The first value of `.select` and `.sort` is the index of a field in a note type. For the note type `CardNote` that has the following fields: + +#include_code state_vars-CardNote /yarn-project/noir-contracts/contracts/docs_example_contract/src/types/card_note.nr rust + +The indices are: 0 for `points`, 1 for `secret`, and 2 for `owner`. + +In the example, `.select(2, account_address)` matches the 2nd field of `CardNote`, which is `owner`, and returns the cards whose `owner` field equals `account_address`. + +`.sort(0, SortOrder.DESC)` sorts the 0th field of `CardNote`, which is `points`, in descending order. + +There can be as many conditions as the number of fields a note type has. The following example finds cards whose fields match the three given values: + +#include_code state_vars-NoteGetterOptionsMultiSelects /yarn-project/noir-contracts/contracts/docs_example_contract/src/options.nr rust + +While `selects` lets us find notes with specific values, `filter` lets us find notes in a more dynamic way. The function below picks the cards whose points are at least `min_points`: + +#include_code state_vars-OptionFilter /yarn-project/noir-contracts/contracts/docs_example_contract/src/options.nr rust + +We can use it as a filter to further reduce the number of the final notes: + +#include_code state_vars-NoteGetterOptionsFilter /yarn-project/noir-contracts/contracts/docs_example_contract/src/options.nr rust + +One thing to remember is, `filter` will be applied on the notes after they are picked from the database. Therefore, it's possible that the actual notes we end up getting are fewer than the limit. + +The limit is `MAX_READ_REQUESTS_PER_CALL` by default. But we can set it to any value **smaller** than that: + +#include_code state_vars-NoteGetterOptionsPickOne /yarn-project/noir-contracts/contracts/docs_example_contract/src/options.nr rust diff --git a/docs/docs/dev_docs/contracts/syntax/storage/public_state.md b/docs/docs/dev_docs/contracts/syntax/storage/public_state.md new file mode 100644 index 000000000000..f99deee3b4e6 --- /dev/null +++ b/docs/docs/dev_docs/contracts/syntax/storage/public_state.md @@ -0,0 +1,96 @@ +--- +title: Public State +--- + +To define that a variable is public, it is wrapped in the `PublicState` struct. + +The `PublicState` struct is generic over the variable type `T` and its serialized size `T_SERIALIZED_LEN`. +:::info +Currently, the length of the types must be specified when declaring the storage struct but the intention is that this will be inferred in the future. +::: + +The struct contains a `storage_slot` which, similar to Ethereum, is used to figure out _where_ in storage the variable is located. Notice that while we don't have the exact same [state model](../../../../concepts/foundation/state_model/main.md) as EVM chains it will look similar from the contract developers point of view. + +Beyond the struct, the `PublicState` also contains `serialization_methods`, which is a struct with methods that instruct the `PublicState` how to serialize and deserialize the variable. You can find the details of `PublicState` in the implementation [here](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/aztec-nr/aztec/src/state_vars/public_state.nr). + +:::info +The British haven't surrendered fully to US spelling, so serialization is currently inconsistent. +::: + +The Aztec.nr library provides serialization methods for various common types. + +:::info +An example using a larger struct can be found in the [lending example](https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/noir-contracts/contracts/lending_contract)'s use of an [`Asset`](https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/noir-contracts/contracts/lending_contract/src/asset.nr). +::: + +### `new` + +When declaring the storage for `T` as a persistent public storage variable, we use the `PublicState::new()` constructor. As seen below, this takes the `storage_slot` and the `serialization_methods` as arguments along with the [`Context`](../context.mdx), which in this case is used to share interface with other structures. + +#include_code public_state_struct_new /yarn-project/aztec-nr/aztec/src/state_vars/public_state.nr rust + +#### Single value example + +Say that we wish to add `admin` public state variable into our storage struct. In the struct we can define it as: + +#include_code storage_admin /yarn-project/noir-contracts/contracts/token_contract/src/main.nr rust + +And then when initializing it in the `Storage::init` function we can do: + +#include_code storage_admin_init /yarn-project/noir-contracts/contracts/token_contract/src/main.nr rust + +We have specified that we are storing a `Field` that should be placed in storage slot `1`. This is just a single value, and is similar to the following in solidity: + +```solidity +address internal admin; +``` + +:::info +We know its verbose, and are working on making it less so. +::: + +#### Mapping example + +Say we want to have a group of `minters` that are able to mint assets in our contract, and we want them in public storage, because [access control in private is quite cumbersome](../../../../concepts/foundation/communication/public_private_calls/main.md#a-note-on-l2-access-control). In the `Storage` struct we can add it as follows: + +#include_code storage_minters /yarn-project/noir-contracts/contracts/token_contract/src/main.nr rust + +And then when initializing it in the `Storage::init` function we can do it as follows: + +#include_code storage_minters_init /yarn-project/noir-contracts/contracts/token_contract/src/main.nr rust + +In this case, specifying that we are dealing with a map of Fields, and that it should be put at slot 2. + +This would be similar to the following in solidity: + +```solidity +mapping(address => bool) internal minters; +``` + +### `read` + +On the `PublicState` structs we have a `read` method to read the value at the location in storage and using the specified deserialization method to deserialize it. + +#### Reading from our `admin` example + +For our `admin` example from earlier, this could be used as follows to check that the stored value matches the `msg_sender()`. + +#include_code read_admin /yarn-project/noir-contracts/contracts/token_contract/src/main.nr rust + +#### Reading from our `minters` example + +As we saw in the Map earlier, a very similar operation can be done to perform a lookup in a map. + +#include_code read_minter /yarn-project/noir-contracts/contracts/token_contract/src/main.nr rust + +### `write` + +We have a `write` method on the `PublicState` struct that takes the value to write as an input and saves this in storage. It uses the serialization method to serialize the value which inserts (possibly multiple) values into storage. + +#### Writing to our `admin` example + +#include_code write_admin /yarn-project/noir-contracts/contracts/token_contract/src/main.nr rust + +#### Writing to our `minters` example + +#include_code write_minter /yarn-project/noir-contracts/contracts/token_contract/src/main.nr rust diff --git a/docs/sidebars.js b/docs/sidebars.js index b65035ba968a..bfa154565249 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -322,7 +322,11 @@ const sidebars = { type: "doc", id: "dev_docs/contracts/syntax/storage/main", }, - items: ["dev_docs/contracts/syntax/storage/storage_slots"], + items: [ + "dev_docs/contracts/syntax/storage/public_state", + "dev_docs/contracts/syntax/storage/private_state", + "dev_docs/contracts/syntax/storage/storage_slots", + ], }, "dev_docs/contracts/syntax/events", "dev_docs/contracts/syntax/functions", From 11d82f9aaa55f0c4b8545b80423baa6e4d95d6e1 Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Wed, 24 Jan 2024 15:59:45 -0500 Subject: [PATCH 02/27] Revert "Merge branch 'master' into jc/update-contract-storage" This reverts commit 973c2fb01a0da541177222325816dbc2d509400a, reversing changes made to 01da51691baef2cb38502ee6f2b0850ba530ee3d. --- .circleci/config.yml | 26 +- .release-please-manifest.json | 6 +- CHANGELOG.md | 66 - barretenberg/.gitrepo | 4 +- barretenberg/CHANGELOG.md | 24 - barretenberg/acir_tests/Dockerfile.bb | 9 +- barretenberg/acir_tests/Dockerfile.bb.js | 5 +- .../flows/accumulate_and_verify_goblin.sh | 6 - barretenberg/acir_tests/run_acir_tests.sh | 1 - barretenberg/cpp/CMakeLists.txt | 2 +- barretenberg/cpp/pil/avm/README.txt | 21 - barretenberg/cpp/pil/avm/alu_chip.pil | 201 - barretenberg/cpp/pil/avm/avm_mini.pil | 13 +- .../cpp/src/barretenberg/bb/get_bn254_crs.cpp | 20 +- .../cpp/src/barretenberg/bb/get_bn254_crs.hpp | 6 +- .../src/barretenberg/bb/get_grumpkin_crs.cpp | 8 +- .../src/barretenberg/bb/get_grumpkin_crs.hpp | 6 +- barretenberg/cpp/src/barretenberg/bb/main.cpp | 61 +- .../src/barretenberg/benchmark/CMakeLists.txt | 1 - .../benchmark/basics_bench/basics.bench.cpp | 26 +- .../benchmark/commit_bench/CMakeLists.txt | 18 - .../benchmark/commit_bench/commit.bench.cpp | 38 - .../benchmark/commit_bench/main.bench.cpp | 3 - .../benchmark/goblin_bench/eccvm.bench.cpp | 2 +- .../benchmark/goblin_bench/goblin.bench.cpp | 3 +- .../benchmark/ipa_bench/ipa.bench.cpp | 3 +- .../plonk_bench/standard_plonk.bench.cpp | 6 +- .../protogalaxy_bench/protogalaxy.bench.cpp | 6 +- .../relations_bench/barycentric.bench.cpp | 2 +- .../relations_bench/relations.bench.cpp | 2 +- ...ock_proofs.hpp => benchmark_utilities.hpp} | 83 +- .../ultra_bench/ultra_honk.bench.cpp | 20 +- .../ultra_bench/ultra_honk_rounds.bench.cpp | 6 +- .../ultra_bench/ultra_plonk.bench.cpp | 20 +- .../ultra_bench/ultra_plonk_rounds.bench.cpp | 6 +- .../benchmark/widgets_bench/widget.bench.cpp | 6 +- .../commitment_key.test.hpp | 4 +- .../commitment_schemes/gemini/gemini.test.cpp | 7 +- .../commitment_schemes/ipa/ipa.test.cpp | 6 +- .../commitment_schemes/kzg/kzg.test.cpp | 2 +- .../cpp/src/barretenberg/common/ref_array.hpp | 5 +- .../src/barretenberg/common/ref_vector.hpp | 5 +- .../cpp/src/barretenberg/common/std_array.hpp | 4 +- .../src/barretenberg/common/std_vector.hpp | 5 +- .../cpp/src/barretenberg/common/thread.hpp | 19 +- .../src/barretenberg/crypto/aes128/aes128.cpp | 29 +- .../src/barretenberg/crypto/aes128/aes128.hpp | 18 +- .../crypto/aes128/aes128.test.cpp | 10 +- .../src/barretenberg/crypto/aes128/c_bind.cpp | 4 +- .../crypto/blake2s/blake2-impl.hpp | 4 +- .../barretenberg/crypto/blake2s/blake2s.cpp | 10 +- .../barretenberg/crypto/blake2s/blake2s.hpp | 4 +- .../crypto/blake2s/blake2s.test.cpp | 4 +- .../barretenberg/crypto/blake2s/c_bind.cpp | 6 +- .../crypto/blake3s/blake3s.test.cpp | 4 +- .../src/barretenberg/crypto/ecdsa/c_bind.cpp | 12 +- .../src/barretenberg/crypto/ecdsa/ecdsa.hpp | 24 +- .../barretenberg/crypto/ecdsa/ecdsa.test.cpp | 56 +- .../barretenberg/crypto/ecdsa/ecdsa_impl.hpp | 16 +- .../crypto/generators/generator_data.hpp | 4 +- .../barretenberg/crypto/hashers/hashers.hpp | 2 +- .../cpp/src/barretenberg/crypto/hmac/hmac.hpp | 8 +- .../barretenberg/crypto/hmac/hmac.test.cpp | 2 - .../crypto/pedersen_commitment/pedersen.cpp | 4 +- .../crypto/pedersen_commitment/pedersen.hpp | 4 +- .../pedersen_commitment/pedersen.test.cpp | 4 +- .../crypto/pedersen_hash/pedersen.cpp | 4 +- .../crypto/pedersen_hash/pedersen.hpp | 4 +- .../crypto/pedersen_hash/pedersen.test.cpp | 4 +- .../crypto/poseidon2/poseidon2.bench.cpp | 5 +- .../crypto/poseidon2/poseidon2.cpp | 4 +- .../crypto/poseidon2/poseidon2.hpp | 4 +- .../crypto/poseidon2/poseidon2.test.cpp | 34 +- .../poseidon2/poseidon2_cpp_params.sage | 4 +- .../crypto/poseidon2/poseidon2_params.hpp | 4 +- .../poseidon2/poseidon2_permutation.hpp | 4 +- .../poseidon2/poseidon2_permutation.test.cpp | 38 +- .../crypto/poseidon2/sponge/sponge.hpp | 4 +- .../barretenberg/crypto/schnorr/c_bind.cpp | 24 +- .../barretenberg/crypto/schnorr/c_bind.hpp | 2 +- .../barretenberg/crypto/schnorr/multisig.hpp | 34 +- .../crypto/schnorr/multisig.test.cpp | 20 +- .../crypto/schnorr/proof_of_possession.hpp | 16 +- .../schnorr/proof_of_possession.test.cpp | 14 +- .../barretenberg/crypto/schnorr/schnorr.hpp | 24 +- .../barretenberg/crypto/schnorr/schnorr.tcc | 22 +- .../crypto/schnorr/schnorr.test.cpp | 62 +- .../dsl/acir_format/acir_format.cpp | 16 +- .../dsl/acir_format/acir_format.hpp | 15 +- .../dsl/acir_format/acir_format.test.cpp | 182 +- .../acir_format/acir_to_constraint_buf.hpp | 43 +- .../dsl/acir_format/bigint_constraint.cpp | 33 - .../dsl/acir_format/bigint_constraint.hpp | 35 - .../acir_format/bigint_constraint.test.cpp | 88 - .../dsl/acir_format/block_constraint.test.cpp | 23 +- .../dsl/acir_format/ecdsa_secp256k1.cpp | 26 +- .../dsl/acir_format/ecdsa_secp256k1.hpp | 2 +- .../dsl/acir_format/ecdsa_secp256k1.test.cpp | 25 +- .../dsl/acir_format/ecdsa_secp256r1.cpp | 24 +- .../dsl/acir_format/ecdsa_secp256r1.test.cpp | 38 +- .../acir_format/recursion_constraint.test.cpp | 95 +- .../dsl/acir_format/schnorr_verify.cpp | 10 +- .../dsl/acir_format/serde/acir.hpp | 1314 ++---- .../dsl/acir_proofs/acir_composer.cpp | 31 +- .../dsl/acir_proofs/acir_composer.hpp | 10 +- .../barretenberg/dsl/acir_proofs/c_bind.cpp | 47 +- .../barretenberg/dsl/acir_proofs/c_bind.hpp | 37 +- .../dsl/acir_proofs/goblin_acir_composer.cpp | 65 - .../dsl/acir_proofs/goblin_acir_composer.hpp | 73 - .../cpp/src/barretenberg/dsl/types.hpp | 2 +- .../barretenberg/ecc/curves/bn254/bn254.hpp | 4 +- .../barretenberg/ecc/curves/bn254/g1.test.cpp | 4 +- .../barretenberg/ecc/curves/bn254/g2.test.cpp | 2 +- .../ecc/curves/grumpkin/grumpkin.hpp | 4 +- .../ecc/curves/grumpkin/grumpkin.test.cpp | 5 +- .../ecc/curves/secp256k1/secp256k1.hpp | 4 +- .../ecc/curves/secp256k1/secp256k1.test.cpp | 9 +- .../ecc/curves/secp256r1/secp256r1.hpp | 4 +- .../ecc/curves/secp256r1/secp256r1.test.cpp | 9 +- .../src/barretenberg/ecc/fields/field12.hpp | 2 +- .../src/barretenberg/ecc/fields/field2.hpp | 2 +- .../ecc/fields/field2_declarations.hpp | 8 +- .../src/barretenberg/ecc/fields/field6.hpp | 2 +- .../ecc/fields/field_declarations.hpp | 9 +- .../barretenberg/ecc/fields/field_impl.hpp | 4 +- .../ecc/groups/affine_element.hpp | 6 +- .../ecc/groups/affine_element.test.cpp | 2 + .../ecc/groups/affine_element_impl.hpp | 9 +- .../src/barretenberg/ecc/groups/element.hpp | 4 +- .../barretenberg/ecc/groups/element_impl.hpp | 4 +- .../src/barretenberg/ecc/groups/wnaf.test.cpp | 4 +- .../eccvm/eccvm_composer.test.cpp | 14 +- .../eccvm/eccvm_transcript.test.cpp | 11 +- .../cpp/src/barretenberg/flavor/ecc_vm.hpp | 6 +- .../src/barretenberg/flavor/flavor.test.cpp | 10 +- .../flavor/generated/AvmMini_flavor.hpp | 300 +- .../flavor/generated/Toy_flavor.hpp | 6 +- .../src/barretenberg/flavor/goblin_ultra.hpp | 67 +- .../flavor/goblin_ultra_recursive.hpp | 20 +- .../cpp/src/barretenberg/flavor/ultra.hpp | 48 +- .../barretenberg/flavor/ultra_recursive.hpp | 96 +- .../goblin/full_goblin_recursion.test.cpp | 10 +- .../cpp/src/barretenberg/goblin/goblin.hpp | 158 +- .../grumpkin_srs_gen/grumpkin_srs_gen.cpp | 2 +- .../join_split_example/constants.hpp | 6 +- .../fixtures/user_context.hpp | 14 +- .../proofs/compute_circuit_data.hpp | 8 +- .../inner_proof_data/inner_proof_data.cpp | 38 +- .../inner_proof_data/inner_proof_data.hpp | 44 +- .../inner_proof_data.test.cpp | 4 +- .../join_split/compute_circuit_data.cpp | 14 +- .../join_split/compute_circuit_data.hpp | 8 +- .../join_split/compute_signing_data.cpp | 14 +- .../join_split/compute_signing_data.hpp | 8 +- .../proofs/join_split/create_proof.hpp | 8 +- .../proofs/join_split/join_split.cpp | 12 +- .../proofs/join_split/join_split.hpp | 8 +- .../proofs/join_split/join_split.test.cpp | 158 +- .../proofs/join_split/join_split_circuit.cpp | 28 +- .../proofs/join_split/join_split_circuit.hpp | 10 +- .../join_split/join_split_js_parity.test.cpp | 14 +- .../proofs/join_split/join_split_tx.cpp | 8 +- .../proofs/join_split/join_split_tx.hpp | 10 +- .../proofs/join_split/join_split_tx.test.cpp | 4 +- .../proofs/join_split/sign_join_split_tx.cpp | 18 +- .../proofs/join_split/sign_join_split_tx.hpp | 12 +- .../proofs/join_split/verify_signature.hpp | 12 +- .../proofs/mock/mock_circuit.hpp | 8 +- .../proofs/mock/mock_circuit.test.cpp | 8 +- .../notes/circuit/account/account_note.hpp | 12 +- .../proofs/notes/circuit/account/commit.hpp | 12 +- .../proofs/notes/circuit/asset_id.cpp | 4 +- .../proofs/notes/circuit/asset_id.hpp | 4 +- .../proofs/notes/circuit/bridge_call_data.hpp | 10 +- .../proofs/notes/circuit/claim/claim_note.hpp | 12 +- .../claim/complete_partial_commitment.hpp | 12 +- .../notes/circuit/claim/compute_nullifier.hpp | 12 +- .../claim/create_partial_commitment.hpp | 12 +- .../notes/circuit/claim/witness_data.hpp | 4 +- .../proofs/notes/circuit/value/commit.hpp | 4 +- .../value/complete_partial_commitment.hpp | 4 +- .../notes/circuit/value/compute_nullifier.cpp | 4 +- .../notes/circuit/value/compute_nullifier.hpp | 4 +- .../circuit/value/compute_nullifier.test.cpp | 6 +- .../value/create_partial_commitment.hpp | 4 +- .../proofs/notes/circuit/value/value_note.hpp | 4 +- .../notes/circuit/value/value_note.test.cpp | 8 +- .../notes/circuit/value/witness_data.hpp | 4 +- .../proofs/notes/constants.hpp | 8 +- .../notes/native/account/account_note.cpp | 6 +- .../notes/native/account/account_note.hpp | 12 +- .../compute_account_alias_hash_nullifier.hpp | 4 +- .../compute_account_public_key_nullifier.hpp | 4 +- .../proofs/notes/native/asset_id.cpp | 4 +- .../proofs/notes/native/asset_id.hpp | 4 +- .../proofs/notes/native/bridge_call_data.hpp | 10 +- .../proofs/notes/native/claim/claim_note.hpp | 4 +- .../notes/native/claim/claim_note_tx_data.hpp | 12 +- .../claim/complete_partial_commitment.hpp | 4 +- .../notes/native/claim/compute_nullifier.hpp | 4 +- .../claim/create_partial_commitment.hpp | 4 +- .../value/complete_partial_commitment.hpp | 8 +- .../notes/native/value/compute_nullifier.cpp | 6 +- .../notes/native/value/compute_nullifier.hpp | 10 +- .../value/create_partial_commitment.hpp | 8 +- .../proofs/notes/native/value/value_note.hpp | 12 +- .../join_split_example/proofs/verify.hpp | 6 +- .../barretenberg/join_split_example/types.hpp | 8 +- .../numeric/bitop/count_leading_zeros.hpp | 4 +- .../bitop/count_leading_zeros.test.cpp | 2 - .../barretenberg/numeric/bitop/get_msb.hpp | 4 +- .../numeric/bitop/get_msb.test.cpp | 2 - .../barretenberg/numeric/bitop/keep_n_lsb.hpp | 4 +- .../src/barretenberg/numeric/bitop/pow.hpp | 4 +- .../src/barretenberg/numeric/bitop/rotate.hpp | 4 +- .../numeric/bitop/sparse_form.hpp | 4 +- .../barretenberg/numeric/random/engine.cpp | 14 +- .../barretenberg/numeric/random/engine.hpp | 22 +- .../numeric/random/engine.test.cpp | 12 +- .../barretenberg/numeric/uint128/uint128.hpp | 4 +- .../numeric/uint128/uint128.test.cpp | 8 +- .../numeric/uint128/uint128_impl.hpp | 4 +- .../barretenberg/numeric/uint256/uint256.hpp | 6 +- .../numeric/uint256/uint256.test.cpp | 6 +- .../numeric/uint256/uint256_impl.hpp | 4 +- .../src/barretenberg/numeric/uintx/uintx.hpp | 8 +- .../barretenberg/numeric/uintx/uintx.test.cpp | 24 +- .../barretenberg/numeric/uintx/uintx_impl.hpp | 4 +- .../plonk/composer/standard_composer.test.cpp | 3 +- .../plonk/composer/ultra_composer.test.cpp | 13 +- .../commitment_scheme.test.cpp | 2 +- .../plonk/proof_system/prover/prover.test.cpp | 3 +- .../proving_key/proving_key.test.cpp | 5 +- .../public_inputs/public_inputs.test.cpp | 2 +- .../verification_key.test.cpp | 10 +- .../proof_system/verifier/verifier.test.cpp | 2 +- .../plonk/transcript/transcript.cpp | 4 +- .../plonk/transcript/transcript.test.cpp | 6 +- .../polynomials/barycentric.test.cpp | 4 +- .../barretenberg/polynomials/polynomial.hpp | 49 +- .../polynomial_arithmetic.test.cpp | 2 +- .../src/barretenberg/polynomials/pow.test.cpp | 23 +- .../polynomials/univariate.test.cpp | 124 +- .../eccvm/eccvm_builder_types.hpp | 4 +- .../eccvm/eccvm_circuit_builder.hpp | 20 +- .../eccvm/eccvm_circuit_builder.test.cpp | 31 +- .../circuit_builder/eccvm/msm_builder.hpp | 8 +- .../eccvm/precomputed_tables_builder.hpp | 10 +- .../eccvm/transcript_builder.hpp | 4 +- .../generated/AvmMini_circuit_builder.hpp | 93 +- ...goblin_translator_circuit_builder.test.cpp | 13 +- .../goblin_translator_mini.fuzzer.cpp | 7 +- .../goblin_ultra_circuit_builder.cpp | 2 +- .../goblin_ultra_circuit_builder.test.cpp | 2 +- .../standard_circuit_builder.test.cpp | 7 +- .../toy_avm/toy_avm_circuit_builder.test.cpp | 9 +- .../ultra_circuit_builder.test.cpp | 6 +- .../composer/composer_lib.test.cpp | 6 +- .../composer/permutation_lib.test.cpp | 6 +- .../library/grand_product_library.test.cpp | 21 +- .../proof_system/op_queue/ecc_op_queue.hpp | 2 +- .../op_queue/ecc_op_queue.test.cpp | 9 +- .../proof_system/plookup_tables/aes128.hpp | 10 +- .../proof_system/plookup_tables/blake2s.hpp | 6 +- .../proof_system/plookup_tables/dummy.hpp | 6 +- .../plookup_tables/fixed_base/fixed_base.cpp | 4 +- .../plookup_tables/fixed_base/fixed_base.hpp | 4 +- .../fixed_base/fixed_base_params.hpp | 4 +- .../plookup_tables/keccak/keccak_chi.hpp | 6 +- .../plookup_tables/keccak/keccak_input.hpp | 6 +- .../plookup_tables/keccak/keccak_output.hpp | 6 +- .../plookup_tables/keccak/keccak_rho.hpp | 6 +- .../plookup_tables/keccak/keccak_theta.hpp | 6 +- .../non_native_group_generator.cpp | 6 +- .../non_native_group_generator.hpp | 6 +- .../plookup_tables/plookup_tables.cpp | 4 +- .../plookup_tables/plookup_tables.hpp | 4 +- .../proof_system/plookup_tables/sha256.hpp | 6 +- .../proof_system/plookup_tables/sparse.hpp | 6 +- .../proof_system/plookup_tables/types.hpp | 4 +- .../proof_system/plookup_tables/uint.hpp | 6 +- .../protogalaxy/combiner.test.cpp | 51 +- .../protogalaxy/protogalaxy_prover.cpp | 4 + .../protogalaxy/protogalaxy_verifier.cpp | 15 - .../relations/generated/AvmMini/alu_chip.hpp | 280 -- .../relations/generated/AvmMini/avm_mini.hpp | 140 +- .../generated/AvmMini/declare_views.hpp | 40 +- .../relations/generated/AvmMini/mem_trace.hpp | 24 +- .../relations/nested_containers.test.cpp | 12 +- .../relations/relation_manual.test.cpp | 15 +- ...n_translator_relation_consistency.test.cpp | 4 + .../ultra_relation_consistency.test.cpp | 6 +- .../serialize/msgpack_schema.test.cpp | 25 +- .../smt_verification/smt_bigfield.test.cpp | 6 +- .../smt_verification/smt_examples.test.cpp | 9 +- .../smt_verification/smt_polynomials.test.cpp | 9 +- .../circuits/ecdsa_circuit.hpp | 28 +- .../solidity_helpers/proof_gen.cpp | 2 +- .../srs/factories/mem_crs_factory.test.cpp | 4 +- .../factories/mem_grumpkin_crs_factory.cpp | 2 +- .../cpp/src/barretenberg/srs/global_crs.cpp | 8 +- .../srs/scalar_multiplication.test.cpp | 191 +- .../commitment/pedersen/pedersen.test.cpp | 7 +- .../stdlib/encryption/aes128/aes128.cpp | 4 +- .../stdlib/encryption/aes128/aes128.test.cpp | 4 +- .../stdlib/encryption/ecdsa/ecdsa.hpp | 29 +- .../stdlib/encryption/ecdsa/ecdsa.test.cpp | 103 +- .../stdlib/encryption/ecdsa/ecdsa_impl.hpp | 25 +- .../stdlib/encryption/schnorr/schnorr.cpp | 52 +- .../stdlib/encryption/schnorr/schnorr.hpp | 25 +- .../encryption/schnorr/schnorr.test.cpp | 75 +- .../stdlib/hash/blake2s/blake2s.test.cpp | 10 +- .../stdlib/hash/blake2s/blake_util.hpp | 2 +- .../stdlib/hash/blake3s/blake3s.test.cpp | 4 +- .../stdlib/hash/keccak/keccak.cpp | 2 +- .../stdlib/hash/keccak/keccak.test.cpp | 6 +- .../stdlib/hash/pedersen/pedersen.test.cpp | 35 +- .../stdlib/hash/poseidon2/poseidon2.test.cpp | 9 +- .../stdlib/hash/sha256/sha256.test.cpp | 67 +- .../stdlib/hash/sha256/sha256_plookup.cpp | 2 +- .../stdlib/merkle_tree/hash.test.cpp | 5 +- .../stdlib/merkle_tree/membership.test.cpp | 13 +- .../stdlib/merkle_tree/merkle_tree.bench.cpp | 2 +- .../stdlib/merkle_tree/merkle_tree.test.cpp | 9 +- .../nullifier_tree/nullifier_tree.test.cpp | 4 +- .../primitives/bigfield/bigfield.test.cpp | 30 +- .../primitives/biggroup/biggroup.test.cpp | 16 +- .../biggroup/biggroup_goblin.test.cpp | 4 +- .../primitives/bit_array/bit_array.test.cpp | 5 +- .../stdlib/primitives/bool/bool.test.cpp | 4 +- .../primitives/byte_array/byte_array.test.cpp | 3 + .../circuit_builders/circuit_builders_fwd.hpp | 6 +- .../stdlib/primitives/curves/bn254.hpp | 2 - .../stdlib/primitives/curves/secp256k1.hpp | 28 +- .../stdlib/primitives/field/array.test.cpp | 7 +- .../stdlib/primitives/field/field.test.cpp | 50 +- .../primitives/group/cycle_group.test.cpp | 5 +- .../stdlib/primitives/logic/logic.test.cpp | 9 +- .../primitives/memory/dynamic_array.test.cpp | 7 +- .../primitives/memory/ram_table.test.cpp | 17 +- .../primitives/memory/rom_table.test.cpp | 9 +- .../packed_byte_array.test.cpp | 5 +- .../primitives/plookup/plookup.test.cpp | 79 +- .../primitives/safe_uint/safe_uint.test.cpp | 6 +- .../stdlib/primitives/uint/plookup/logic.cpp | 2 +- .../stdlib/primitives/uint/uint.test.cpp | 12 +- .../honk/transcript/transcript.test.cpp | 6 +- .../verifier/decider_recursive_verifier.cpp | 96 - .../verifier/decider_recursive_verifier.hpp | 30 - .../protogalaxy_recursive_verifier.cpp | 320 -- .../protogalaxy_recursive_verifier.hpp | 118 - .../protogalaxy_recursive_verifier.test.cpp | 350 -- .../verifier/ultra_recursive_verifier.hpp | 5 + .../recursion/transcript/transcript.test.cpp | 23 +- .../verification_key.test.cpp | 6 +- .../recursion/verifier/verifier.test.cpp | 18 +- .../src/barretenberg/stdlib/types/ultra.hpp | 4 +- .../barretenberg/stdlib/utility/utility.hpp | 4 - .../instance/prover_instance.test.cpp | 5 +- .../sumcheck/partial_evaluation.test.cpp | 3 + .../barretenberg/sumcheck/sumcheck.test.cpp | 22 +- .../sumcheck/sumcheck_round.test.cpp | 18 +- .../transcript/transcript.test.cpp | 12 +- .../goblin_translator_composer.test.cpp | 16 +- .../ultra_honk/databus_composer.test.cpp | 10 +- .../ultra_honk/goblin_ultra_composer.test.cpp | 16 +- .../goblin_ultra_transcript.test.cpp | 3 +- .../ultra_honk/protogalaxy.test.cpp | 28 +- .../ultra_honk/relation_correctness.test.cpp | 42 +- .../barretenberg/ultra_honk/sumcheck.test.cpp | 17 +- .../ultra_honk/ultra_composer.hpp | 3 +- .../ultra_honk/ultra_composer.test.cpp | 86 +- .../ultra_honk/ultra_transcript.test.cpp | 3 +- .../vm/avm_trace/AvmMini_alu_trace.cpp | 347 -- .../vm/avm_trace/AvmMini_alu_trace.hpp | 49 - .../vm/avm_trace/AvmMini_common.hpp | 4 +- .../vm/avm_trace/AvmMini_helper.cpp | 6 - .../vm/avm_trace/AvmMini_mem_trace.cpp | 48 +- .../vm/avm_trace/AvmMini_mem_trace.hpp | 43 +- .../vm/avm_trace/AvmMini_trace.cpp | 170 +- .../vm/avm_trace/AvmMini_trace.hpp | 5 - .../vm/generated/AvmMini_prover.cpp | 2 - .../vm/generated/AvmMini_verifier.cpp | 51 - .../vm/tests/AvmMini_arithmetic.test.cpp | 1459 +----- .../vm/tests/AvmMini_common.test.hpp | 13 - .../vm/tests/AvmMini_control_flow.test.cpp | 19 +- .../vm/tests/AvmMini_memory.test.cpp | 42 +- .../barretenberg/vm/tests/helpers.test.cpp | 34 +- .../barretenberg/vm/tests/helpers.test.hpp | 7 +- barretenberg/exports.json | 59 +- barretenberg/ts/CHANGELOG.md | 7 - barretenberg/ts/package.json | 2 +- barretenberg/ts/src/barretenberg_api/index.ts | 92 +- barretenberg/ts/src/main.ts | 47 +- .../src/contracts/src/types/balance_set.nr | 6 + .../src/contracts/src/types/token_note.nr | 26 +- .../contracts/src/types/transparent_note.nr | 15 +- .../src/aztec3/utils/types/circuit_types.hpp | 2 +- docs/docs/about_aztec/history/history.mdx | 97 + docs/docs/about_aztec/overview.mdx | 10 +- .../advanced/data_structures/trees.md | 34 +- .../docs/concepts/foundation/accounts/keys.md | 2 +- docs/docs/concepts/foundation/main.md | 47 +- .../history_lib_reference.md | 119 - .../historical_access/how_to_prove_history.md | 102 - .../contracts/syntax/storage/private_state.md | 16 +- .../contracts/syntax/storage/public_state.md | 3 +- .../dev_docs/getting_started/core-concepts.md | 44 +- docs/docs/dev_docs/getting_started/main.md | 10 +- .../dev_docs/getting_started/quickstart.md | 6 +- .../token_portal/depositing_to_aztec.md | 15 +- .../dev_docs/tutorials/token_portal/setup.md | 30 +- .../token_portal/typescript_glue_code.md | 17 +- .../token_portal/withdrawing_to_l1.md | 20 +- .../writing_private_voting_contract.md | 2 +- docs/docs/intro.md | 64 +- docs/docs/misc/migration_notes.md | 86 +- docs/sidebars.js | 13 +- docs/yarn.lock | 3950 ++++++++--------- .../src/core/libraries/ConstantsGen.sol | 2 +- l1-contracts/test/portals/TokenPortal.sol | 2 +- noir/.github/actions/setup/action.yml | 2 +- noir/.github/workflows/docs-dead-links.yml | 2 +- noir/.github/workflows/docs-pr.yml | 52 +- noir/.github/workflows/publish-docs.yml | 9 +- noir/.github/workflows/release.yml | 14 +- noir/.gitrepo | 4 +- noir/.release-please-manifest.json | 4 +- noir/CHANGELOG.md | 92 - noir/Cargo.lock | 129 +- noir/Cargo.toml | 16 +- noir/acvm-repo/CHANGELOG.md | 32 - noir/acvm-repo/acir/Cargo.toml | 2 +- noir/acvm-repo/acir/codegen/acir.cpp | 644 +-- .../acir/src/circuit/black_box_functions.rs | 25 - .../opcodes/black_box_function_call.rs | 56 +- noir/acvm-repo/acir_field/Cargo.toml | 2 +- noir/acvm-repo/acvm/Cargo.toml | 2 +- .../acvm/src/compiler/transformers/mod.rs | 12 +- noir/acvm-repo/acvm/src/pwg/blackbox/mod.rs | 6 - noir/acvm-repo/acvm_js/Cargo.toml | 2 +- noir/acvm-repo/acvm_js/package.json | 2 +- noir/acvm-repo/blackbox_solver/Cargo.toml | 2 +- .../bn254_blackbox_solver/Cargo.toml | 2 +- noir/acvm-repo/brillig/Cargo.toml | 2 +- noir/acvm-repo/brillig/src/black_box.rs | 79 +- noir/acvm-repo/brillig_vm/Cargo.toml | 2 +- noir/acvm-repo/brillig_vm/src/black_box.rs | 12 - noir/aztec_macros/src/lib.rs | 41 +- noir/bootstrap_cache.sh | 1 - noir/compiler/fm/src/file_map.rs | 4 - .../noirc_driver/tests/stdlib_warnings.rs | 9 +- .../brillig/brillig_gen/brillig_black_box.rs | 101 - .../src/brillig/brillig_ir/debug_show.rs | 53 - noir/compiler/noirc_evaluator/src/ssa.rs | 14 +- .../ssa/acir_gen/acir_ir/generated_acir.rs | 62 - .../noirc_evaluator/src/ssa/acir_gen/mod.rs | 411 +- .../src/ssa/function_builder/mod.rs | 8 +- .../src/ssa/ir/instruction/call.rs | 9 +- .../noirc_evaluator/src/ssa/ir/types.rs | 2 +- .../src/ssa/opt/bubble_up_constrains.rs | 153 - .../src/ssa/opt/fill_internal_slices.rs | 765 ++++ .../noirc_evaluator/src/ssa/opt/mod.rs | 2 +- .../src/ssa/ssa_gen/context.rs | 12 +- .../src/hir/def_collector/dc_crate.rs | 6 +- .../src/hir/def_collector/dc_mod.rs | 4 +- .../noirc_frontend/src/hir/def_map/mod.rs | 2 +- noir/compiler/noirc_frontend/src/hir/mod.rs | 28 +- .../src/hir/resolution/resolver.rs | 21 +- .../src/hir/resolution/traits.rs | 20 +- .../noirc_frontend/src/hir/type_check/expr.rs | 2 +- .../noirc_frontend/src/hir_def/traits.rs | 2 +- .../noirc_frontend/src/hir_def/types.rs | 57 +- .../src/monomorphization/mod.rs | 11 +- .../noirc_frontend/src/node_interner.rs | 36 +- .../noirc_frontend/src/resolve_locations.rs | 52 +- noir/compiler/noirc_frontend/src/tests.rs | 2 +- noir/compiler/noirc_printable_type/src/lib.rs | 113 +- noir/compiler/wasm/package.json | 2 +- noir/compiler/wasm/src/compile.rs | 19 +- noir/compiler/wasm/src/compile_new.rs | 13 +- .../explainers/explainer-oracle.md | 57 + .../version-v0.22.0/how_to/how-to-oracles.md | 280 ++ .../version-v0.22.0/noir/syntax/oracles.md | 23 + noir/flake.nix | 2 +- .../execution_success/bit_and/Prover.toml | 2 - .../execution_success/bit_and/src/main.nr | 8 +- .../execution_success/debug_logs/src/main.nr | 20 - .../Nargo.toml | 2 +- .../Prover.toml | 0 .../src/main.nr | 0 .../test-binaries/mock_backend/Cargo.lock | 171 +- noir/tooling/lsp/Cargo.toml | 2 - noir/tooling/lsp/src/lib.rs | 85 +- noir/tooling/lsp/src/notifications/mod.rs | 9 +- .../lsp/src/requests/code_lens_request.rs | 2 +- .../lsp/src/requests/goto_declaration.rs | 10 +- .../lsp/src/requests/goto_definition.rs | 27 +- noir/tooling/lsp/src/requests/mod.rs | 20 +- noir/tooling/lsp/src/requests/profile_run.rs | 13 +- noir/tooling/lsp/src/requests/test_run.rs | 7 +- noir/tooling/lsp/src/requests/tests.rs | 6 +- noir/tooling/lsp/src/types.rs | 11 +- noir/tooling/nargo/src/lib.rs | 25 +- noir/tooling/nargo/src/ops/compile.rs | 46 +- noir/tooling/nargo/src/ops/mod.rs | 2 +- noir/tooling/nargo_cli/Cargo.toml | 2 +- noir/tooling/nargo_cli/build.rs | 11 +- noir/tooling/nargo_cli/src/cli/check_cmd.rs | 10 +- .../nargo_cli/src/cli/codegen_verifier_cmd.rs | 28 +- noir/tooling/nargo_cli/src/cli/compile_cmd.rs | 115 +- noir/tooling/nargo_cli/src/cli/dap_cmd.rs | 5 +- noir/tooling/nargo_cli/src/cli/debug_cmd.rs | 5 +- noir/tooling/nargo_cli/src/cli/execute_cmd.rs | 5 +- noir/tooling/nargo_cli/src/cli/export_cmd.rs | 8 +- noir/tooling/nargo_cli/src/cli/info_cmd.rs | 19 +- noir/tooling/nargo_cli/src/cli/prove_cmd.rs | 5 +- noir/tooling/nargo_cli/src/cli/test_cmd.rs | 13 +- noir/tooling/nargo_cli/src/cli/verify_cmd.rs | 5 +- noir/tooling/noir_codegen/package.json | 2 +- noir/tooling/noir_js/package.json | 2 +- .../noir_js_backend_barretenberg/package.json | 2 +- noir/tooling/noir_js_types/package.json | 2 +- noir/tooling/noirc_abi_wasm/package.json | 2 +- noir/yarn.lock | 74 +- yarn-project/accounts/.eslintrc.cjs | 2 +- .../acir-simulator/src/acvm/oracle/oracle.ts | 16 +- .../src/acvm/oracle/typed_oracle.ts | 34 +- .../acir-simulator/src/acvm/serialize.ts | 7 +- .../src/avm/avm_message_call_result.ts | 10 +- .../src/avm/interpreter/interpreter.test.ts | 19 +- .../src/avm/interpreter/interpreter.ts | 48 +- .../src/avm/opcodes/bitwise.test.ts | 166 - .../acir-simulator/src/avm/opcodes/bitwise.ts | 3 - .../src/avm/opcodes/control_flow.test.ts | 3 +- .../src/avm/opcodes/instruction_set.ts | 27 +- .../src/avm/opcodes/memory.test.ts | 182 - .../acir-simulator/src/avm/opcodes/memory.ts | 30 +- .../acir-simulator/src/avm/opcodes/opcodes.ts | 118 +- .../acir-simulator/src/client/db_oracle.ts | 18 +- .../src/client/private_execution.test.ts | 331 +- .../src/client/simulator.test.ts | 24 +- .../acir-simulator/src/client/simulator.ts | 4 +- .../src/client/view_data_oracle.ts | 13 +- .../acir-simulator/src/public/index.test.ts | 287 +- .../src/public/public_execution_context.ts | 4 +- yarn-project/aztec-nr/.gitrepo | 4 +- .../aztec-nr/address-note/src/address_note.nr | 26 +- yarn-project/aztec-nr/aztec/src/context.nr | 56 +- .../aztec/src/history/note_validity.nr | 4 +- .../src/history/nullifier_non_inclusion.nr | 6 +- yarn-project/aztec-nr/aztec/src/key.nr | 1 - .../aztec-nr/aztec/src/key/nullifier_key.nr | 24 - yarn-project/aztec-nr/aztec/src/lib.nr | 1 - yarn-project/aztec-nr/aztec/src/messaging.nr | 25 +- .../aztec/src/messaging/l1_to_l2_message.nr | 6 +- .../messaging/l1_to_l2_message_getter_data.nr | 8 +- .../aztec-nr/aztec/src/note/lifecycle.nr | 2 +- .../aztec-nr/aztec/src/note/note_interface.nr | 4 +- yarn-project/aztec-nr/aztec/src/note/utils.nr | 13 +- yarn-project/aztec-nr/aztec/src/oracle.nr | 2 +- .../aztec/src/oracle/get_secret_key.nr | 25 + .../aztec/src/oracle/nullifier_key.nr | 29 - .../src/state_vars/immutable_singleton.nr | 28 +- .../aztec/src/state_vars/singleton.nr | 39 +- .../aztec-nr/field-note/src/field_note.nr | 16 +- .../aztec-nr/value-note/src/value_note.nr | 26 +- yarn-project/aztec.js/.eslintrc.cjs | 2 +- .../circuit-types/src/keys/key_store.ts | 27 +- .../circuit-types/src/l1_to_l2_message.ts | 5 - yarn-project/circuits.js/src/constants.gen.ts | 2 +- yarn-project/circuits.js/src/index.ts | 1 - yarn-project/circuits.js/src/keys/index.ts | 44 - .../src/types/grumpkin_private_key.ts | 2 +- .../src/e2e_cross_chain_messaging.test.ts | 6 +- .../src/e2e_lending_contract.test.ts | 12 + .../e2e_public_cross_chain_messaging.test.ts | 4 +- .../end-to-end/src/e2e_singleton.test.ts | 142 - yarn-project/foundation/.eslintrc.cjs | 59 +- yarn-project/foundation/.eslintrc.docs.cjs | 69 - yarn-project/foundation/package.json | 1 - yarn-project/key-store/src/test_key_store.ts | 25 +- .../src/contract-interface-gen/typescript.ts | 2 +- .../contracts/card_game_contract/src/cards.nr | 5 +- .../contracts/card_game_contract/src/main.nr | 2 +- .../src/account_contract_interface.nr | 11 + .../docs_example_contract/src/actions.nr | 156 + .../docs_example_contract/src/main.nr | 255 +- .../docs_example_contract/src/options.nr | 2 - .../docs_example_contract/src/types.nr | 4 +- .../src/types/card_note.nr | 39 +- .../docs_example_contract/src/types/leader.nr | 23 - .../src/types/profile_note.nr | 119 + .../docs_example_contract/src/types/queen.nr | 26 + .../src/types/rules_note.nr | 119 + .../easy_private_voting_contract/src/main.nr | 3 +- .../src/ecdsa_public_key_note.nr | 26 +- .../ecdsa_account_contract/src/main.nr | 2 +- .../inclusion_proofs_contract/src/main.nr | 28 +- .../schnorr_account_contract/src/main.nr | 2 +- .../src/public_key_note.nr | 26 +- .../contracts/test_contract/src/main.nr | 2 +- .../token_blacklist_contract/src/main.nr | 2 +- .../src/types/balance_set.nr | 6 + .../src/types/token_note.nr | 26 +- .../src/types/transparent_note.nr | 15 +- .../token_contract/src/types/balance_set.nr | 6 + .../token_contract/src/types/token_note.nr | 26 +- .../src/types/transparent_note.nr | 15 +- .../src/crates/types/src/constants.nr | 2 +- .../pxe/src/simulator_oracle/index.ts | 20 +- yarn-project/yarn.lock | 10 +- 612 files changed, 8827 insertions(+), 14768 deletions(-) delete mode 100755 barretenberg/acir_tests/flows/accumulate_and_verify_goblin.sh delete mode 100644 barretenberg/cpp/pil/avm/README.txt delete mode 100644 barretenberg/cpp/pil/avm/alu_chip.pil delete mode 100644 barretenberg/cpp/src/barretenberg/benchmark/commit_bench/CMakeLists.txt delete mode 100644 barretenberg/cpp/src/barretenberg/benchmark/commit_bench/commit.bench.cpp delete mode 100644 barretenberg/cpp/src/barretenberg/benchmark/commit_bench/main.bench.cpp rename barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/{mock_proofs.hpp => benchmark_utilities.hpp} (69%) delete mode 100644 barretenberg/cpp/src/barretenberg/dsl/acir_format/bigint_constraint.cpp delete mode 100644 barretenberg/cpp/src/barretenberg/dsl/acir_format/bigint_constraint.hpp delete mode 100644 barretenberg/cpp/src/barretenberg/dsl/acir_format/bigint_constraint.test.cpp delete mode 100644 barretenberg/cpp/src/barretenberg/dsl/acir_proofs/goblin_acir_composer.cpp delete mode 100644 barretenberg/cpp/src/barretenberg/dsl/acir_proofs/goblin_acir_composer.hpp delete mode 100644 barretenberg/cpp/src/barretenberg/relations/generated/AvmMini/alu_chip.hpp delete mode 100644 barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp delete mode 100644 barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.hpp delete mode 100644 barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp delete mode 100644 barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.hpp delete mode 100644 barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.test.cpp delete mode 100644 barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_alu_trace.cpp delete mode 100644 barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_alu_trace.hpp delete mode 100644 barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_common.test.hpp create mode 100644 docs/docs/about_aztec/history/history.mdx delete mode 100644 docs/docs/dev_docs/contracts/syntax/historical_access/history_lib_reference.md delete mode 100644 docs/docs/dev_docs/contracts/syntax/historical_access/how_to_prove_history.md delete mode 100644 noir/compiler/noirc_evaluator/src/ssa/opt/bubble_up_constrains.rs create mode 100644 noir/compiler/noirc_evaluator/src/ssa/opt/fill_internal_slices.rs create mode 100644 noir/docs/versioned_docs/version-v0.22.0/explainers/explainer-oracle.md create mode 100644 noir/docs/versioned_docs/version-v0.22.0/how_to/how-to-oracles.md create mode 100644 noir/docs/versioned_docs/version-v0.22.0/noir/syntax/oracles.md rename noir/test_programs/execution_success/{nested_array_in_slice => nested_slice_dynamic}/Nargo.toml (62%) rename noir/test_programs/execution_success/{nested_array_in_slice => nested_slice_dynamic}/Prover.toml (100%) rename noir/test_programs/execution_success/{nested_array_in_slice => nested_slice_dynamic}/src/main.nr (100%) delete mode 100644 yarn-project/acir-simulator/src/avm/opcodes/bitwise.test.ts delete mode 100644 yarn-project/acir-simulator/src/avm/opcodes/memory.test.ts delete mode 100644 yarn-project/aztec-nr/aztec/src/key.nr delete mode 100644 yarn-project/aztec-nr/aztec/src/key/nullifier_key.nr create mode 100644 yarn-project/aztec-nr/aztec/src/oracle/get_secret_key.nr delete mode 100644 yarn-project/aztec-nr/aztec/src/oracle/nullifier_key.nr delete mode 100644 yarn-project/circuits.js/src/keys/index.ts delete mode 100644 yarn-project/end-to-end/src/e2e_singleton.test.ts delete mode 100644 yarn-project/foundation/.eslintrc.docs.cjs create mode 100644 yarn-project/noir-contracts/contracts/docs_example_contract/src/account_contract_interface.nr create mode 100644 yarn-project/noir-contracts/contracts/docs_example_contract/src/actions.nr delete mode 100644 yarn-project/noir-contracts/contracts/docs_example_contract/src/types/leader.nr create mode 100644 yarn-project/noir-contracts/contracts/docs_example_contract/src/types/profile_note.nr create mode 100644 yarn-project/noir-contracts/contracts/docs_example_contract/src/types/queen.nr create mode 100644 yarn-project/noir-contracts/contracts/docs_example_contract/src/types/rules_note.nr diff --git a/.circleci/config.yml b/.circleci/config.yml index 07dd2a3ee5ff..81eb7344f1f5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -599,17 +599,6 @@ jobs: name: "Test" command: cond_spot_run_compose end-to-end 4 ./scripts/docker-compose.yml TEST=e2e_sandbox_example.test.ts - e2e-singleton: - docker: - - image: aztecprotocol/alpine-build-image - resource_class: small - steps: - - *checkout - - *setup_env - - run: - name: "Test" - command: cond_spot_run_compose end-to-end 4 ./scripts/docker-compose.yml TEST=e2e_singleton.test.ts - e2e-block-building: docker: - image: aztecprotocol/alpine-build-image @@ -786,6 +775,17 @@ jobs: name: "Test" command: cond_spot_run_compose end-to-end 4 ./scripts/docker-compose-no-sandbox.yml TEST=e2e_persistence.test.ts + e2e-p2p: + docker: + - image: aztecprotocol/alpine-build-image + resource_class: small + steps: + - *checkout + - *setup_env + - run: + name: "Test" + command: cond_spot_run_compose end-to-end 4 ./scripts/docker-compose-no-sandbox.yml TEST=e2e_p2p_network.test.ts + e2e-browser: docker: - image: aztecprotocol/alpine-build-image @@ -1228,7 +1228,6 @@ workflows: # TODO(3458): Investigate intermittent failure # - e2e-slow-tree: *e2e_test - e2e-sandbox-example: *e2e_test - - e2e-singleton: *e2e_test - e2e-block-building: *e2e_test - e2e-nested-contract: *e2e_test - e2e-non-contract-account: *e2e_test @@ -1246,6 +1245,7 @@ workflows: - integration-l1-publisher: *e2e_test - integration-archiver-l1-to-l2: *e2e_test - e2e-persistence: *e2e_test + - e2e-p2p: *e2e_test - e2e-browser: *e2e_test - e2e-card-game: *e2e_test - pxe: *e2e_test @@ -1265,7 +1265,6 @@ workflows: - e2e-token-contract - e2e-blacklist-token-contract - e2e-sandbox-example - - e2e-singleton - e2e-block-building - e2e-nested-contract - e2e-non-contract-account @@ -1283,6 +1282,7 @@ workflows: - integration-l1-publisher - integration-archiver-l1-to-l2 - e2e-persistence + - e2e-p2p - e2e-browser - e2e-card-game - pxe diff --git a/.release-please-manifest.json b/.release-please-manifest.json index fce3dcc81f62..cd45c1c86ae3 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,5 +1,5 @@ { - ".": "0.20.0", - "barretenberg": "0.20.0", - "barretenberg/ts": "0.20.0" + ".": "0.19.0", + "barretenberg": "0.19.0", + "barretenberg/ts": "0.19.0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index d71d1a92c8cd..d8f7898f35b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,71 +1,5 @@ # Changelog -## [0.20.0](https://github.com/AztecProtocol/aztec-packages/compare/aztec-packages-v0.19.0...aztec-packages-v0.20.0) (2024-01-22) - - -### ⚠ BREAKING CHANGES - -* nullifier key ([#4166](https://github.com/AztecProtocol/aztec-packages/issues/4166)) -* Unify ABIs between nargo and yarn-project ([#3989](https://github.com/AztecProtocol/aztec-packages/issues/3989)) - -### Features - -* **avm:** Add internal jump and return, adjust control flow ([#4140](https://github.com/AztecProtocol/aztec-packages/issues/4140)) ([b77afb1](https://github.com/AztecProtocol/aztec-packages/commit/b77afb14c609cfc04663a318eecaa8cbd3b2fa85)) -* **avm:** Better field arithmetic ([#4142](https://github.com/AztecProtocol/aztec-packages/issues/4142)) ([7308e31](https://github.com/AztecProtocol/aztec-packages/commit/7308e31c981ec7c03d0474811b2979e6f418f348)) -* **avm:** Encode TS AVM instructions as bytecode, especially for testing ([#4115](https://github.com/AztecProtocol/aztec-packages/issues/4115)) ([de6e2ed](https://github.com/AztecProtocol/aztec-packages/commit/de6e2edc09b823542f45e14b45c32ec10894f6c7)) -* **avm:** Improve interpreter errors and tests ([#4173](https://github.com/AztecProtocol/aztec-packages/issues/4173)) ([f0fb594](https://github.com/AztecProtocol/aztec-packages/commit/f0fb5942386e2e091cb6d1b23108ac74c1c6b75d)) -* Benchmark commit function ([#4178](https://github.com/AztecProtocol/aztec-packages/issues/4178)) ([ea84085](https://github.com/AztecProtocol/aztec-packages/commit/ea840857d8134c9af6f233b414f6d990cd2abd6d)) -* Goblin acir composer ([#4112](https://github.com/AztecProtocol/aztec-packages/issues/4112)) ([5e85b92](https://github.com/AztecProtocol/aztec-packages/commit/5e85b92f48bc31fe55315de9f45c4907e417cb6a)) -* Nullifier key ([#4166](https://github.com/AztecProtocol/aztec-packages/issues/4166)) ([7c07665](https://github.com/AztecProtocol/aztec-packages/commit/7c076653169771223a378f6c01bd9d3e3aafb682)) -* **public-vm:** Avm journal ([#3945](https://github.com/AztecProtocol/aztec-packages/issues/3945)) ([5658468](https://github.com/AztecProtocol/aztec-packages/commit/56584683340cd29b26adbcc60d3cd58fe889e8ad)) -* Publish block body separately ([#4118](https://github.com/AztecProtocol/aztec-packages/issues/4118)) ([a04e1e3](https://github.com/AztecProtocol/aztec-packages/commit/a04e1e351fe0b42dfa6ef7d1894dffbcff19b187)), closes [#3944](https://github.com/AztecProtocol/aztec-packages/issues/3944) -* Unify ABIs between nargo and yarn-project ([#3989](https://github.com/AztecProtocol/aztec-packages/issues/3989)) ([d083438](https://github.com/AztecProtocol/aztec-packages/commit/d0834380a749a48d31e3075f831f3279f18fc01e)) -* Update noir ([#4082](https://github.com/AztecProtocol/aztec-packages/issues/4082)) ([0e6037a](https://github.com/AztecProtocol/aztec-packages/commit/0e6037ad48fc1eb8ab3524d64755f4f27f64bf36)) -* Updating L2 Block encoding and `Rollup.process` function ([#4015](https://github.com/AztecProtocol/aztec-packages/issues/4015)) ([2d8eb37](https://github.com/AztecProtocol/aztec-packages/commit/2d8eb37edbc9164639fe6d20140364288e2b72a9)), closes [#3936](https://github.com/AztecProtocol/aztec-packages/issues/3936) [#4010](https://github.com/AztecProtocol/aztec-packages/issues/4010) [#4011](https://github.com/AztecProtocol/aztec-packages/issues/4011) - - -### Bug Fixes - -* Bb.js version in yarn lockfile ([7b96760](https://github.com/AztecProtocol/aztec-packages/commit/7b96760f7d201d984bab885b996b218bd427be22)) -* **build:** Publish bb.js from CCI ([#4151](https://github.com/AztecProtocol/aztec-packages/issues/4151)) ([09dbfcd](https://github.com/AztecProtocol/aztec-packages/commit/09dbfcd7e8d3b15cf79686eea44a4032f2aa4bbb)) -* Make CMake version warning fatal ([#4144](https://github.com/AztecProtocol/aztec-packages/issues/4144)) ([b1443fa](https://github.com/AztecProtocol/aztec-packages/commit/b1443faf9d8f308dbad6d0aa365b1feb8385557d)) -* Misleading error message in `PublicState::read` ([#4149](https://github.com/AztecProtocol/aztec-packages/issues/4149)) ([fa4d919](https://github.com/AztecProtocol/aztec-packages/commit/fa4d919d25b5253d1f39b7f2db183771f461fe1b)) -* Nargo destination path in bootstrap cache ([#4103](https://github.com/AztecProtocol/aztec-packages/issues/4103)) ([4901309](https://github.com/AztecProtocol/aztec-packages/commit/490130979a5d3a3e703c7e28417835aa86fa8cd7)) -* Reinstate Ultra arith rec verifier test ([#3886](https://github.com/AztecProtocol/aztec-packages/issues/3886)) ([995973b](https://github.com/AztecProtocol/aztec-packages/commit/995973b0226ddd7ae4cb5c3501859bec10f4eb93)) -* Upload_benchmarks_to_s3.sh missing exit ([#4046](https://github.com/AztecProtocol/aztec-packages/issues/4046)) ([52a9327](https://github.com/AztecProtocol/aztec-packages/commit/52a93279e43ae6780e8bfc253ee0570a443ed472)) - - -### Miscellaneous - -* Archiver store ([#3966](https://github.com/AztecProtocol/aztec-packages/issues/3966)) ([af2be87](https://github.com/AztecProtocol/aztec-packages/commit/af2be878b49aceb668480e5a291aed7dea5319ba)) -* **avm:** List avm opcodes in a (enum => class) map in TS ([#4113](https://github.com/AztecProtocol/aztec-packages/issues/4113)) ([dee564a](https://github.com/AztecProtocol/aztec-packages/commit/dee564a16293ff8f0aa2c6ba9fb0d1d6235ba251)) -* **bb:** More concise namespaces, plookup => bb::plookup ([#4146](https://github.com/AztecProtocol/aztec-packages/issues/4146)) ([14d39ed](https://github.com/AztecProtocol/aztec-packages/commit/14d39edbe1a6753849581a664184d4e98baf923d)) -* **bb:** Namespace plonk::stdlib => stdlib ([#4117](https://github.com/AztecProtocol/aztec-packages/issues/4117)) ([cd2f67f](https://github.com/AztecProtocol/aztec-packages/commit/cd2f67f5cbc471b9120f7c7070b96ba0d4994865)) -* **bb:** Namespace proof_system=>bb ([#4116](https://github.com/AztecProtocol/aztec-packages/issues/4116)) ([7438db3](https://github.com/AztecProtocol/aztec-packages/commit/7438db31b29860aa2c0af54afa8413711a24e1eb)) -* **docs:** Aztec-up doesnt need `latest`, remove warnings around sandbox/cli npm pkgs ([#4138](https://github.com/AztecProtocol/aztec-packages/issues/4138)) ([2bbf7a9](https://github.com/AztecProtocol/aztec-packages/commit/2bbf7a919172bea9842b4e65129160e0e4ee0050)) -* **docs:** Update js release notes for 0.18.0 ([#4051](https://github.com/AztecProtocol/aztec-packages/issues/4051)) ([bdbe963](https://github.com/AztecProtocol/aztec-packages/commit/bdbe963b114813a49017daebe5b34757692328ce)) -* **docs:** Update lsp install instructions ([#4110](https://github.com/AztecProtocol/aztec-packages/issues/4110)) ([3138816](https://github.com/AztecProtocol/aztec-packages/commit/3138816b8b7480bd85eab8739e1d0bc72a5a5361)), closes [#4098](https://github.com/AztecProtocol/aztec-packages/issues/4098) -* Dont mirror build-system mirror_repos.yml ([#4067](https://github.com/AztecProtocol/aztec-packages/issues/4067)) ([04f8e0d](https://github.com/AztecProtocol/aztec-packages/commit/04f8e0dfde5a3d4f54621726891aedc071212a8a)) -* Fixes many broken urls ([#4109](https://github.com/AztecProtocol/aztec-packages/issues/4109)) ([41ae75c](https://github.com/AztecProtocol/aztec-packages/commit/41ae75cdee6285729551965972e8cb039ff3045a)) -* Remove dependency cycles in `sequencer-client` ([#4017](https://github.com/AztecProtocol/aztec-packages/issues/4017)) ([fe4538b](https://github.com/AztecProtocol/aztec-packages/commit/fe4538b36c1cdb19c0c7245f7a73c9f5ee131a4a)) -* Remove lodash times in favor of foundation fn ([#3877](https://github.com/AztecProtocol/aztec-packages/issues/3877)) ([a10eef0](https://github.com/AztecProtocol/aztec-packages/commit/a10eef0a77cb52e00ffedb10ed325bd63fa0c971)) -* Remove mutex dependency ([#4160](https://github.com/AztecProtocol/aztec-packages/issues/4160)) ([3b82be0](https://github.com/AztecProtocol/aztec-packages/commit/3b82be0f266c838c823bbe26cfea99337d7180a9)) -* Remove unnecessary computation ([#4133](https://github.com/AztecProtocol/aztec-packages/issues/4133)) ([f35bdb8](https://github.com/AztecProtocol/aztec-packages/commit/f35bdb84722dbd01535da5542a0ec7c1fb96e5c7)) -* Remove unused noir-version json ([#4105](https://github.com/AztecProtocol/aztec-packages/issues/4105)) ([afca819](https://github.com/AztecProtocol/aztec-packages/commit/afca819166b9b5882b5d94062ac50cbb8dc590fb)) -* Remove unwanted submodules ([#4085](https://github.com/AztecProtocol/aztec-packages/issues/4085)) ([dda7c9c](https://github.com/AztecProtocol/aztec-packages/commit/dda7c9c4fa8da54d28b99b1cf601328030485503)) -* Replace relative paths to noir-protocol-circuits ([59feeb5](https://github.com/AztecProtocol/aztec-packages/commit/59feeb5ed55ab022b99b83a31cf89bdabc0003c5)) -* Replace relative paths to noir-protocol-circuits ([44d9136](https://github.com/AztecProtocol/aztec-packages/commit/44d91361274a54f0e59f0ad5f8869f3f3aa49c2b)) -* Replace relative paths to noir-protocol-circuits ([84b0bad](https://github.com/AztecProtocol/aztec-packages/commit/84b0bad61a5fc751fdf01ae907bb9b7df3bece7b)) -* Simplify and fix DocsExample contract, e2e singleton + codegen to not show internal methods ([#4169](https://github.com/AztecProtocol/aztec-packages/issues/4169)) ([38d262e](https://github.com/AztecProtocol/aztec-packages/commit/38d262eddd4fca80a7726d17303fc084257ad460)) -* Update noir ([#4168](https://github.com/AztecProtocol/aztec-packages/issues/4168)) ([d40ad06](https://github.com/AztecProtocol/aztec-packages/commit/d40ad063606219119b41ba3acc883e62245bd035)) - - -### Documentation - -* Update migration notes ([#4175](https://github.com/AztecProtocol/aztec-packages/issues/4175)) ([dbc8174](https://github.com/AztecProtocol/aztec-packages/commit/dbc8174f010f15422a9485b567b60834a0a4aa2f)) -* **yellow-paper:** Update circuit sections for nullifier keys and static calls ([#4155](https://github.com/AztecProtocol/aztec-packages/issues/4155)) ([ed71a57](https://github.com/AztecProtocol/aztec-packages/commit/ed71a573bca18912e4590a5f8c8044778ad439c5)) -* **yellowpaper:** Refresh of avm instruction set ([#4081](https://github.com/AztecProtocol/aztec-packages/issues/4081)) ([52162ee](https://github.com/AztecProtocol/aztec-packages/commit/52162eed9ace2726c143a34520115c8530876187)) - ## [0.19.0](https://github.com/AztecProtocol/aztec-packages/compare/aztec-packages-v0.18.0...aztec-packages-v0.19.0) (2024-01-17) diff --git a/barretenberg/.gitrepo b/barretenberg/.gitrepo index 7f0d957fa4dd..f0f2d9349891 100644 --- a/barretenberg/.gitrepo +++ b/barretenberg/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/AztecProtocol/barretenberg branch = master - commit = 508a48cd064773b9e78681e6208ed707ecdfa6bf - parent = 6dac6504fdbe85c61ffd7aad7c37cc1b52ebf6d4 + commit = f01329ccb7a07c8828a06a19d0a4d77d3f89087a + parent = b77afb14c609cfc04663a318eecaa8cbd3b2fa85 method = merge cmdver = 0.4.6 diff --git a/barretenberg/CHANGELOG.md b/barretenberg/CHANGELOG.md index 5b5cb064b64f..2d528f556f7a 100644 --- a/barretenberg/CHANGELOG.md +++ b/barretenberg/CHANGELOG.md @@ -1,29 +1,5 @@ # Changelog -## [0.20.0](https://github.com/AztecProtocol/aztec-packages/compare/barretenberg-v0.19.0...barretenberg-v0.20.0) (2024-01-22) - - -### Features - -* Benchmark commit function ([#4178](https://github.com/AztecProtocol/aztec-packages/issues/4178)) ([ea84085](https://github.com/AztecProtocol/aztec-packages/commit/ea840857d8134c9af6f233b414f6d990cd2abd6d)) -* Goblin acir composer ([#4112](https://github.com/AztecProtocol/aztec-packages/issues/4112)) ([5e85b92](https://github.com/AztecProtocol/aztec-packages/commit/5e85b92f48bc31fe55315de9f45c4907e417cb6a)) - - -### Bug Fixes - -* Make CMake version warning fatal ([#4144](https://github.com/AztecProtocol/aztec-packages/issues/4144)) ([b1443fa](https://github.com/AztecProtocol/aztec-packages/commit/b1443faf9d8f308dbad6d0aa365b1feb8385557d)) -* Reinstate Ultra arith rec verifier test ([#3886](https://github.com/AztecProtocol/aztec-packages/issues/3886)) ([995973b](https://github.com/AztecProtocol/aztec-packages/commit/995973b0226ddd7ae4cb5c3501859bec10f4eb93)) -* Upload_benchmarks_to_s3.sh missing exit ([#4046](https://github.com/AztecProtocol/aztec-packages/issues/4046)) ([52a9327](https://github.com/AztecProtocol/aztec-packages/commit/52a93279e43ae6780e8bfc253ee0570a443ed472)) - - -### Miscellaneous - -* **bb:** More concise namespaces, plookup => bb::plookup ([#4146](https://github.com/AztecProtocol/aztec-packages/issues/4146)) ([14d39ed](https://github.com/AztecProtocol/aztec-packages/commit/14d39edbe1a6753849581a664184d4e98baf923d)) -* **bb:** Namespace plonk::stdlib => stdlib ([#4117](https://github.com/AztecProtocol/aztec-packages/issues/4117)) ([cd2f67f](https://github.com/AztecProtocol/aztec-packages/commit/cd2f67f5cbc471b9120f7c7070b96ba0d4994865)) -* **bb:** Namespace proof_system=>bb ([#4116](https://github.com/AztecProtocol/aztec-packages/issues/4116)) ([7438db3](https://github.com/AztecProtocol/aztec-packages/commit/7438db31b29860aa2c0af54afa8413711a24e1eb)) -* Remove mutex dependency ([#4160](https://github.com/AztecProtocol/aztec-packages/issues/4160)) ([3b82be0](https://github.com/AztecProtocol/aztec-packages/commit/3b82be0f266c838c823bbe26cfea99337d7180a9)) -* Remove unwanted submodules ([#4085](https://github.com/AztecProtocol/aztec-packages/issues/4085)) ([dda7c9c](https://github.com/AztecProtocol/aztec-packages/commit/dda7c9c4fa8da54d28b99b1cf601328030485503)) - ## [0.19.0](https://github.com/AztecProtocol/aztec-packages/compare/barretenberg-v0.18.0...barretenberg-v0.19.0) (2024-01-17) diff --git a/barretenberg/acir_tests/Dockerfile.bb b/barretenberg/acir_tests/Dockerfile.bb index 006db0e53335..a20d3d53280b 100644 --- a/barretenberg/acir_tests/Dockerfile.bb +++ b/barretenberg/acir_tests/Dockerfile.bb @@ -7,13 +7,10 @@ COPY --from=0 /usr/src/barretenberg/cpp/build /usr/src/barretenberg/cpp/build COPY --from=noir-acir-tests /usr/src/noir/test_programs /usr/src/noir/test_programs WORKDIR /usr/src/barretenberg/acir_tests COPY . . -# Run every acir test through native bb build prove_then_verify flow for UltraPlonk. +# Run every acir test through native bb build prove_then_verify flow. # This ensures we test independent pk construction through real/garbage witness data paths. RUN FLOW=prove_then_verify ./run_acir_tests.sh -# This flow is essentially the GoblinUltraHonk equivalent to the UltraPlonk "prove and verify". (This functionality is -# accessed via the goblin "accumulate" mechanism). -RUN FLOW=accumulate_and_verify_goblin ./run_acir_tests.sh -# This is a "full" Goblin flow. It constructs and verifies four proofs: GoblinUltraHonk, ECCVM, Translator, and merge -RUN FLOW=prove_and_verify_goblin ./run_acir_tests.sh 6_array +# TODO(https://github.com/AztecProtocol/barretenberg/issues/811) make this able to run the default test +RUN FLOW=prove_and_verify_goblin ./run_acir_tests.sh # Run 1_mul through native bb build, all_cmds flow, to test all cli args. RUN VERBOSE=1 FLOW=all_cmds ./run_acir_tests.sh 1_mul diff --git a/barretenberg/acir_tests/Dockerfile.bb.js b/barretenberg/acir_tests/Dockerfile.bb.js index b894826a5c2f..4409bf7ce22b 100644 --- a/barretenberg/acir_tests/Dockerfile.bb.js +++ b/barretenberg/acir_tests/Dockerfile.bb.js @@ -14,10 +14,7 @@ COPY . . ENV VERBOSE=1 # Run double_verify_proof through bb.js on node to check 512k support. RUN BIN=../ts/dest/node/main.js FLOW=prove_then_verify ./run_acir_tests.sh double_verify_proof -# Run a single arbitrary test not involving recursion through bb.js for GoblinUltraHonk -RUN BIN=../ts/dest/node/main.js FLOW=accumulate_and_verify_goblin ./run_acir_tests.sh 6_array -# Run a single arbitrary test not involving recursion through bb.js for full Goblin -RUN BIN=../ts/dest/node/main.js FLOW=prove_and_verify_goblin ./run_acir_tests.sh 6_array +RUN BIN=../ts/dest/node/main.js FLOW=prove_and_verify_goblin ./run_acir_tests.sh double_verify_proof # Run 1_mul through bb.js build, all_cmds flow, to test all cli args. RUN BIN=../ts/dest/node/main.js FLOW=all_cmds ./run_acir_tests.sh 1_mul # Run double_verify_proof through bb.js on chrome testing multi-threaded browser support. diff --git a/barretenberg/acir_tests/flows/accumulate_and_verify_goblin.sh b/barretenberg/acir_tests/flows/accumulate_and_verify_goblin.sh deleted file mode 100755 index a89e1a1dba11..000000000000 --- a/barretenberg/acir_tests/flows/accumulate_and_verify_goblin.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -set -eu - -VFLAG=${VERBOSE:+-v} - -$BIN accumulate_and_verify_goblin $VFLAG -c $CRS_PATH -b ./target/acir.gz \ No newline at end of file diff --git a/barretenberg/acir_tests/run_acir_tests.sh b/barretenberg/acir_tests/run_acir_tests.sh index 5c7bb60c9e2c..ee28c975113f 100755 --- a/barretenberg/acir_tests/run_acir_tests.sh +++ b/barretenberg/acir_tests/run_acir_tests.sh @@ -29,7 +29,6 @@ fi export BIN CRS_PATH VERBOSE BRANCH -# copy the gzipped acir test data from noir/test_programs to barretenberg/acir_tests ./clone_test_vectors.sh cd acir_tests diff --git a/barretenberg/cpp/CMakeLists.txt b/barretenberg/cpp/CMakeLists.txt index 1bd35206df0e..86a5a1ee2bd8 100644 --- a/barretenberg/cpp/CMakeLists.txt +++ b/barretenberg/cpp/CMakeLists.txt @@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.24 FATAL_ERROR) project( Barretenberg DESCRIPTION "BN254 elliptic curve library, and PLONK SNARK prover" - VERSION 0.20.0 # x-release-please-version + VERSION 0.19.0 # x-release-please-version LANGUAGES CXX C ) # Insert version into `bb` config file diff --git a/barretenberg/cpp/pil/avm/README.txt b/barretenberg/cpp/pil/avm/README.txt deleted file mode 100644 index cf63996a3c26..000000000000 --- a/barretenberg/cpp/pil/avm/README.txt +++ /dev/null @@ -1,21 +0,0 @@ -This folder contains PIL relations for the AVM. - -Applied heuristic to assess the cost of a relation is given below. -This will be used to determine whether it is worth to merge some -relations into one. - -N_mul = number of mulitplication in the relation -N_add = number of additions/subtraction in the relation -deg = degree of the relation (total degree of the polynomial) - -Relation cost: degree * (N_mul + N_add/4) - -Remark: addition/multiplication with a constant counts as well in the above metrics -Remark: For edge case, we prefer keep a good readability rather than merging. - -Future: There is an optimization in sumcheck protocol allowing to skip some - rows for relations which are not enabled for them (applies when not - enabled over 2 adjacent rows). However, this feature is not yet enabled - in the AVM context. This might change the decision on whether some relations - should be merged or not. Basically, merging relations would decrease the - likelihood to be disabled over adjacent rows. \ No newline at end of file diff --git a/barretenberg/cpp/pil/avm/alu_chip.pil b/barretenberg/cpp/pil/avm/alu_chip.pil deleted file mode 100644 index 09cf037b016a..000000000000 --- a/barretenberg/cpp/pil/avm/alu_chip.pil +++ /dev/null @@ -1,201 +0,0 @@ -include "avm_mini.pil"; - -namespace aluChip(256); - - // ========= Table ALU-TR ================================================= - - // References to main trace table of sub-operations, clk, intermediate - // registers, operation selectors. - // TODO: Think on optimizations to decrease the number of such "copied" columns - pol commit alu_clk; - pol commit alu_ia; // Intermediate registers - pol commit alu_ib; - pol commit alu_ic; - pol commit alu_op_add; // Operation selectors - pol commit alu_op_sub; - pol commit alu_op_mul; - pol commit alu_op_div; - - // Flattened boolean instruction tags - pol commit alu_ff_tag; - pol commit alu_u8_tag; - pol commit alu_u16_tag; - pol commit alu_u32_tag; - pol commit alu_u64_tag; - pol commit alu_u128_tag; - - // 8-bit slice registers - pol commit alu_u8_r0; - pol commit alu_u8_r1; - - // 16-bit slice registers - pol commit alu_u16_r0; - pol commit alu_u16_r1; - pol commit alu_u16_r2; - pol commit alu_u16_r3; - pol commit alu_u16_r4; - pol commit alu_u16_r5; - pol commit alu_u16_r6; - pol commit alu_u16_r7; - - // 64-bit slice register - pol commit alu_u64_r0; - - // Carry flag - pol commit alu_cf; - - // ========= Type Constraints ============================================= - // TODO: Range constraints - // - for slice registers - // - intermediate registers ia and ib (inputs) depending on flag (or inherited from previous ops?) - // - intermediate register ic (in some operations it might be inherited based on ia and ib ranges. To be checked.) - // Carry flag: We will have to constraint to ensure that the - // arithmetic expressions are not overflowing finite field size - // Remark: Operation selectors are constrained in the main trace. - // TODO: Enforce the equivalence check for the selectors between both tables. - - // Boolean flattened instructions tags - alu_ff_tag * (1 - alu_ff_tag) = 0; - alu_u8_tag * (1 - alu_u8_tag) = 0; - alu_u16_tag * (1 - alu_u16_tag) = 0; - alu_u32_tag * (1 - alu_u32_tag) = 0; - alu_u64_tag * (1 - alu_u64_tag) = 0; - alu_u128_tag * (1 - alu_u128_tag) = 0; - - // Operation selectors are copied from main table and do not need to be constrained here. - // TODO: Ensure mutual exclusion of alu_op_add and alu_op_sub as some relations below - // requires it. - // TODO: Similarly, ensure the mutual exclusion of instruction tags - - // ========= Inter-table Constraints ====================================== - // TODO: Equivalence between intermediate registers, clk, type flag, operation - // An ALU chiplet flag will be introduced in main trace to select relevant rows. - - - // ========= EXPLANATIONS ================================================= - // Main trick for arithmetic operations modulo 2^k is to perform the operation - // over the integers and expressing the result as low + high * 2^k with low - // smaller than 2^k. low is used as the output. This works as long this does - // not underflow/overflow the underlying finite field order (u128 multiplication - // will be handled differently). If we want to prove that c = OP(a,b) where OP - // denotes an arithmetic operation modulo 2^k, we can achieve this with two relations: - // (1) low + high * 2^k - OP'(a,b) = 0 - // (2) low - c = 0 - // - // where OP' denotes the same operation as OP but over the integers (not mod 2^k). - // We support u8, u16, u32, u64, u128 types and decompose low into - // smaller bit slices, e.g., 16. For instance, low = s_0 + s_1 * 2^16 + s_2 * 2^32 + ... - // The slices have to be range constrained and there is a trade-off between the - // number of registers and complexity of the range constraints. - // - // Optimization: We will capture the relation (1) for all types under the same umbrella - // by re-using the decomposition used for u128 type for the lower types. - // This works because any larger power of 2^k divides 2^l whenever k <= l. - // To be able to express "low" for u8, we need a 8-bit limb for the lowest - // bits. A bit decomposition covering all types is: - // s8_0 + s8_1 * 2^8 + s16_0 * 2^16 + s16_1 * 2^32 ... + s16_6 * 2^112 + carry * 2^128 - OP'(a,b) = 0 - // where s8_i's are 8-bit registers and s16's 16-bit registers. - // For type uk, we set low to the k-bit truncated part of register decomposition. - // As example, for u32: low = s8_0 + s8_1 * 2^8 + s16_0 * 2^16 - // and for u8: low = s8_0 - // - // TODO: It is open whether we might get efficiency gain to use larger registers for the higher - // parts of the bit decomposition. - - // ============= Helper polynomial terms ============================ - // These are intermediate polynomial terms which are not commited but - // serves to an algebraic expression of commited polynomials in a more concise way. - - // Bit slices partial sums - pol sum_8 = alu_u8_r0; - pol sum_16 = sum_8 + alu_u8_r1 * 2**8; - pol sum_32 = sum_16 + alu_u16_r0 * 2**16; - pol sum_64 = sum_32 + alu_u16_r1 * 2**32 + alu_u16_r2 * 2**48; - pol sum_96 = sum_64 + alu_u16_r3 * 2**64 + alu_u16_r4 * 2**80; - pol sum_128 = sum_96 + alu_u16_r5 * 2**96 + alu_u16_r6 * 2**112; - - // ========= ADDITION/SUBTRACTION Operation Constraints =============================== - // - // Addition and subtraction relations are very similar and will be consolidated. - // For the addition we have to replace OP'(a,b) in the above relation by a+b and - // for subtraction by a-b. Using operation selector values to toggle "+b" vs. "-b" - // makes the deal with the adaptation that the carry term needs to be subtracted - // instead of being added. To sumarize, for the first relation, addition needs to - // satisfy: - // sum_128 + carry * 2^128 - a - b = 0 - // while the subtraction satisfies: - // sum_128 - carry * 2^128 - a + b = 0 - // - // Finally, we would like this relation to also satisfy the addition over the finite field. - // For this, we add c in the relation conditoned by the ff type selector alu_ff_tag. We emphasize - // that this relation alone for FF will not imply correctness of the FF addition. We only want - // it to be satisfied. A separate relation will ensure correctness of it. - // - // The second relation will consist in showing that sum_N - c = 0 for N = 8, 16, 32, 64, 128. - - #[ALU_ADD_SUB_1] - (alu_op_add + alu_op_sub) * (sum_128 - alu_ia + alu_ff_tag * alu_ic) + (alu_op_add - alu_op_sub) * (alu_cf * 2**128 - alu_ib) = 0; - - // Helper polynomial - pol sum_tag = alu_u8_tag * sum_8 + alu_u16_tag * sum_16 + alu_u32_tag * sum_32 + alu_u64_tag * sum_64 + alu_u128_tag * sum_128; - - #[ALU_ADD_SUB_2] - (alu_op_add + alu_op_sub) * (sum_tag + alu_ff_tag * alu_ia - alu_ic) + alu_ff_tag * (alu_op_add - alu_op_sub) * alu_ib = 0; - - // ========= MULTIPLICATION Operation Constraints =============================== - - // ff multiplication - #[ALU_MULTIPLICATION_FF] - alu_ff_tag * alu_op_mul * (alu_ia * alu_ib - alu_ic) = 0; - - - // We need 2k bits to express the product (a*b) over the integer, i.e., for type uk - // we express the product as sum_k (u8 is an exception as we need 8-bit registers) - - // We group relations for u8, u16, u32, u64 together. - - // Helper polynomial - pol sum_tag_no_128 = alu_u8_tag * sum_8 + alu_u16_tag * sum_16 + alu_u32_tag * sum_32 + alu_u64_tag * sum_64; - - #[ALU_MUL_COMMON_1] - (1 - alu_ff_tag - alu_u128_tag) * alu_op_mul * (sum_128 - alu_ia * alu_ib) = 0; - - #[ALU_MUL_COMMON_2] - alu_op_mul * (sum_tag_no_128 - (1 - alu_ff_tag - alu_u128_tag) * alu_ic) = 0; - - // ========= u128 MULTIPLICATION Operation Constraints =============================== - // - // We express a, b in 64-bit slices: a = a_l + a_h * 2^64 - // b = b_l + b_h * 2^64 - // We show that c satisfies: a_l * b_l + (a_h * b_l + a_l * b_h) * 2^64 = R * 2^128 + c - // for a R < 2^65. Equivalently: - // a * b_l + a_l * b_h * 2^64 = (CF * 2^64 + R') * 2^128 + c - // for a bit carry flag CF and R' range constrained to 64 bits. - // We use two lines in the execution trace. First line represents a - // as decomposed over 16-bit registers. Second line represents b. - // Selector flag is only toggled in the first line and we access b through - // shifted polynomials. - // R' is stored in alu_u64_r0 - - // 64-bit lower limb - pol sum_low_64 = alu_u16_r0 + alu_u16_r1 * 2**16 + alu_u16_r2 * 2**32 + alu_u16_r3 * 2**48; - - // 64-bit higher limb - pol sum_high_64 = alu_u16_r4 + alu_u16_r5 * 2**16 + alu_u16_r6 * 2**32 + alu_u16_r7 * 2**48; - - // 64-bit lower limb for next row - pol sum_low_shifted_64 = alu_u16_r0' + alu_u16_r1' * 2**16 + alu_u16_r2' * 2**32 + alu_u16_r3' * 2**48; - - // 64-bit higher limb for next row - pol sum_high_shifted_64 = alu_u16_r4' + alu_u16_r5' * 2**16 + alu_u16_r6' * 2**32 + alu_u16_r7' * 2**48; - - // Arithmetic relations - alu_u128_tag * alu_op_mul * (sum_low_64 + sum_high_64 * 2**64 - alu_ia) = 0; - alu_u128_tag * alu_op_mul * (sum_low_shifted_64 + sum_high_shifted_64 * 2**64 - alu_ib) = 0; - #[ALU_MULTIPLICATION_OUT_U128] - alu_u128_tag * alu_op_mul * ( - alu_ia * sum_low_shifted_64 - + sum_low_64 * sum_high_shifted_64 * 2**64 - - (alu_cf * 2**64 + alu_u64_r0) * 2**128 - - alu_ic - ) = 0; diff --git a/barretenberg/cpp/pil/avm/avm_mini.pil b/barretenberg/cpp/pil/avm/avm_mini.pil index 26268fe25cd9..cd3fb8f29e4c 100644 --- a/barretenberg/cpp/pil/avm/avm_mini.pil +++ b/barretenberg/cpp/pil/avm/avm_mini.pil @@ -1,6 +1,5 @@ include "mem_trace.pil"; -include "alu_chip.pil"; namespace avmMini(256); @@ -103,6 +102,18 @@ namespace avmMini(256); tag_err * ib = 0; tag_err * ic = 0; + // Relation for addition over the finite field + #[SUBOP_ADDITION_FF] + sel_op_add * (ia + ib - ic) = 0; + + // Relation for subtraction over the finite field + #[SUBOP_SUBTRACTION_FF] + sel_op_sub * (ia - ib - ic) = 0; + + // Relation for multiplication over the finite field + #[SUBOP_MULTIPLICATION_FF] + sel_op_mul * (ia * ib - ic) = 0; + // Relation for division over the finite field // If tag_err == 1 in a division, then ib == 0 and op_err == 1. #[SUBOP_DIVISION_FF] diff --git a/barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.cpp b/barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.cpp index a0cc5f3b06d5..f724fad7ca0d 100644 --- a/barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.cpp +++ b/barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.cpp @@ -1,7 +1,6 @@ #include "get_bn254_crs.hpp" #include "barretenberg/bb/file_io.hpp" -namespace { std::vector download_bn254_g1_data(size_t num_points) { size_t g1_end = num_points * 64 - 1; @@ -27,10 +26,8 @@ std::vector download_bn254_g2_data() std::string command = "curl -s '" + url + "'"; return exec_pipe(command); } -} // namespace -namespace bb { -std::vector get_bn254_g1_data(const std::filesystem::path& path, size_t num_points) +std::vector get_bn254_g1_data(const std::filesystem::path& path, size_t num_points) { std::filesystem::create_directories(path); @@ -40,9 +37,9 @@ std::vector get_bn254_g1_data(const std::filesystem::path& p if (g1_file_size >= num_points * 64 && g1_file_size % 64 == 0) { vinfo("using cached crs of size ", std::to_string(g1_file_size / 64), " at ", g1_path); auto data = read_file(g1_path, g1_file_size); - auto points = std::vector(num_points); + auto points = std::vector(num_points); for (size_t i = 0; i < num_points; ++i) { - points[i] = from_buffer(data, i * 64); + points[i] = from_buffer(data, i * 64); } return points; } @@ -51,14 +48,14 @@ std::vector get_bn254_g1_data(const std::filesystem::path& p auto data = download_bn254_g1_data(num_points); write_file(g1_path, data); - auto points = std::vector(num_points); + auto points = std::vector(num_points); for (size_t i = 0; i < num_points; ++i) { - points[i] = from_buffer(data, i * 64); + points[i] = from_buffer(data, i * 64); } return points; } -g2::affine_element get_bn254_g2_data(const std::filesystem::path& path) +bb::g2::affine_element get_bn254_g2_data(const std::filesystem::path& path) { std::filesystem::create_directories(path); @@ -67,11 +64,10 @@ g2::affine_element get_bn254_g2_data(const std::filesystem::path& path) if (g2_file_size == 128) { auto data = read_file(g2_path); - return from_buffer(data.data()); + return from_buffer(data.data()); } auto data = download_bn254_g2_data(); write_file(g2_path, data); - return from_buffer(data.data()); + return from_buffer(data.data()); } -} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.hpp b/barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.hpp index 4ceb35578130..230e074f219a 100644 --- a/barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.hpp +++ b/barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.hpp @@ -8,7 +8,5 @@ #include #include -namespace bb { -std::vector get_bn254_g1_data(const std::filesystem::path& path, size_t num_points); -g2::affine_element get_bn254_g2_data(const std::filesystem::path& path); -} // namespace bb \ No newline at end of file +std::vector get_bn254_g1_data(const std::filesystem::path& path, size_t num_points); +bb::g2::affine_element get_bn254_g2_data(const std::filesystem::path& path); \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/bb/get_grumpkin_crs.cpp b/barretenberg/cpp/src/barretenberg/bb/get_grumpkin_crs.cpp index 1942c278ea4a..fca6a54de7b3 100644 --- a/barretenberg/cpp/src/barretenberg/bb/get_grumpkin_crs.cpp +++ b/barretenberg/cpp/src/barretenberg/bb/get_grumpkin_crs.cpp @@ -1,6 +1,5 @@ #include "get_grumpkin_crs.hpp" -namespace { std::vector download_grumpkin_g1_data(size_t num_points) { size_t g1_start = 28; @@ -20,9 +19,7 @@ std::vector download_grumpkin_g1_data(size_t num_points) return data; } -} // namespace -namespace bb { std::vector get_grumpkin_g1_data(const std::filesystem::path& path, size_t num_points) { std::filesystem::create_directories(path); @@ -38,7 +35,7 @@ std::vector get_grumpkin_g1_data(const std::file auto data = read_file(file, 28 + num_points * 64); auto points = std::vector(num_points); auto size_of_points_in_bytes = num_points * 64; - srs::IO::read_affine_elements_from_buffer( + bb::srs::IO::read_affine_elements_from_buffer( points.data(), (char*)data.data(), size_of_points_in_bytes); return points; } @@ -55,7 +52,6 @@ std::vector get_grumpkin_g1_data(const std::file new_size_file.close(); auto points = std::vector(num_points); - srs::IO::read_affine_elements_from_buffer(points.data(), (char*)data.data(), data.size()); + bb::srs::IO::read_affine_elements_from_buffer(points.data(), (char*)data.data(), data.size()); return points; } -} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/bb/get_grumpkin_crs.hpp b/barretenberg/cpp/src/barretenberg/bb/get_grumpkin_crs.hpp index 5c8f9fcef168..894885ce97eb 100644 --- a/barretenberg/cpp/src/barretenberg/bb/get_grumpkin_crs.hpp +++ b/barretenberg/cpp/src/barretenberg/bb/get_grumpkin_crs.hpp @@ -8,8 +8,4 @@ #include #include -namespace bb { - -std::vector get_grumpkin_g1_data(const std::filesystem::path& path, size_t num_points); - -} \ No newline at end of file +std::vector get_grumpkin_g1_data(const std::filesystem::path& path, size_t num_points); \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/bb/main.cpp b/barretenberg/cpp/src/barretenberg/bb/main.cpp index 6c567b00bcd7..5f75206108eb 100644 --- a/barretenberg/cpp/src/barretenberg/bb/main.cpp +++ b/barretenberg/cpp/src/barretenberg/bb/main.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -44,12 +43,6 @@ void init_bn254_crs(size_t dyadic_circuit_size) srs::init_crs_factory(bn254_g1_data, bn254_g2_data); } -/** - * @brief Initialize the global crs_factory for grumpkin based on a known dyadic circuit size - * @details Grumpkin crs is required only for the ECCVM - * - * @param dyadic_circuit_size power-of-2 circuit size - */ void init_grumpkin_crs(size_t eccvm_dyadic_circuit_size) { auto grumpkin_g1_data = get_grumpkin_g1_data(CRS_PATH, eccvm_dyadic_circuit_size); @@ -72,7 +65,7 @@ acir_format::WitnessVector get_witness(std::string const& witness_path) return acir_format::witness_buf_to_witness_data(witness_data); } -acir_format::AcirFormat get_constraint_system(std::string const& bytecode_path) +acir_format::acir_format get_constraint_system(std::string const& bytecode_path) { auto bytecode = get_bytecode(bytecode_path); return acir_format::circuit_buf_to_acir_format(bytecode); @@ -122,43 +115,6 @@ bool proveAndVerify(const std::string& bytecodePath, const std::string& witnessP return verified; } -/** - * @brief Constructs and verifies a Honk proof for an ACIR circuit via the Goblin accumulate mechanism - * - * Communication: - * - proc_exit: A boolean value is returned indicating whether the proof is valid. - * an exit code of 0 will be returned for success and 1 for failure. - * - * @param bytecodePath Path to the file containing the serialized acir constraint system - * @param witnessPath Path to the file containing the serialized witness - * @return verified - */ -bool accumulateAndVerifyGoblin(const std::string& bytecodePath, const std::string& witnessPath) -{ - // Populate the acir constraint system and witness from gzipped data - auto constraint_system = get_constraint_system(bytecodePath); - auto witness = get_witness(witnessPath); - - // Instantiate a Goblin acir composer and construct a bberg circuit from the acir representation - acir_proofs::GoblinAcirComposer acir_composer; - acir_composer.create_circuit(constraint_system, witness); - - // TODO(https://github.com/AztecProtocol/barretenberg/issues/811): Don't hardcode dyadic circuit size. Currently set - // to max circuit size present in acir tests suite. - size_t hardcoded_bn254_dyadic_size_hack = 1 << 18; - init_bn254_crs(hardcoded_bn254_dyadic_size_hack); - size_t hardcoded_grumpkin_dyadic_size_hack = 1 << 10; // For eccvm only - init_grumpkin_crs(hardcoded_grumpkin_dyadic_size_hack); - - // Call accumulate to generate a GoblinUltraHonk proof - auto proof = acir_composer.accumulate(); - - // Verify the GoblinUltraHonk proof - auto verified = acir_composer.verify_accumulator(proof); - - return verified; -} - /** * @brief Proves and Verifies an ACIR circuit * @@ -176,13 +132,11 @@ bool proveAndVerifyGoblin(const std::string& bytecodePath, const std::string& witnessPath, [[maybe_unused]] bool recursive) { - // Populate the acir constraint system and witness from gzipped data auto constraint_system = get_constraint_system(bytecodePath); auto witness = get_witness(witnessPath); - // Instantiate a Goblin acir composer and construct a bberg circuit from the acir representation - acir_proofs::GoblinAcirComposer acir_composer; - acir_composer.create_circuit(constraint_system, witness); + acir_proofs::AcirComposer acir_composer; + acir_composer.create_goblin_circuit(constraint_system, witness); // TODO(https://github.com/AztecProtocol/barretenberg/issues/811): Don't hardcode dyadic circuit size. Currently set // to max circuit size present in acir tests suite. @@ -191,11 +145,9 @@ bool proveAndVerifyGoblin(const std::string& bytecodePath, size_t hardcoded_grumpkin_dyadic_size_hack = 1 << 10; // For eccvm only init_grumpkin_crs(hardcoded_grumpkin_dyadic_size_hack); - // Generate a GoblinUltraHonk proof and a full Goblin proof - auto proof = acir_composer.accumulate_and_prove(); + auto proof = acir_composer.create_goblin_proof(); - // Verify the GoblinUltraHonk proof and the full Goblin proof - auto verified = acir_composer.verify(proof); + auto verified = acir_composer.verify_goblin_proof(proof); return verified; } @@ -506,9 +458,6 @@ int main(int argc, char* argv[]) if (command == "prove_and_verify") { return proveAndVerify(bytecode_path, witness_path, recursive) ? 0 : 1; } - if (command == "accumulate_and_verify_goblin") { - return accumulateAndVerifyGoblin(bytecode_path, witness_path) ? 0 : 1; - } if (command == "prove_and_verify_goblin") { return proveAndVerifyGoblin(bytecode_path, witness_path, recursive) ? 0 : 1; } diff --git a/barretenberg/cpp/src/barretenberg/benchmark/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/benchmark/CMakeLists.txt index e86e72df09d4..285f2bb5937b 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/benchmark/CMakeLists.txt @@ -1,4 +1,3 @@ -add_subdirectory(commit_bench) add_subdirectory(decrypt_bench) add_subdirectory(ipa_bench) add_subdirectory(pippenger_bench) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/basics_bench/basics.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/basics_bench/basics.bench.cpp index c3bf090f2cfa..1d1cc37718a6 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/basics_bench/basics.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/basics_bench/basics.bench.cpp @@ -40,7 +40,7 @@ using Fr = Curve::ScalarField; */ void parallel_for_field_element_addition(State& state) { - numeric::RNG& engine = numeric::get_debug_randomness(); + numeric::random::Engine& engine = numeric::random::get_debug_engine(); size_t num_cpus = get_num_cpus(); std::vector> copy_vector(num_cpus); for (size_t i = 0; i < num_cpus; i++) { @@ -72,7 +72,7 @@ void parallel_for_field_element_addition(State& state) */ void ff_addition(State& state) { - numeric::RNG& engine = numeric::get_debug_randomness(); + numeric::random::Engine& engine = numeric::random::get_debug_engine(); std::vector copy_vector(2); for (size_t j = 0; j < 2; j++) { copy_vector.emplace_back(Fr::random_element(&engine)); @@ -97,7 +97,7 @@ void ff_addition(State& state) */ void ff_multiplication(State& state) { - numeric::RNG& engine = numeric::get_debug_randomness(); + numeric::random::Engine& engine = numeric::random::get_debug_engine(); std::vector copy_vector(2); for (size_t j = 0; j < 2; j++) { copy_vector.emplace_back(Fr::random_element(&engine)); @@ -122,7 +122,7 @@ void ff_multiplication(State& state) */ void ff_sqr(State& state) { - numeric::RNG& engine = numeric::get_debug_randomness(); + numeric::random::Engine& engine = numeric::random::get_debug_engine(); std::vector copy_vector(2); for (size_t j = 0; j < 2; j++) { copy_vector.emplace_back(Fr::random_element(&engine)); @@ -147,7 +147,7 @@ void ff_sqr(State& state) */ void ff_invert(State& state) { - numeric::RNG& engine = numeric::get_debug_randomness(); + numeric::random::Engine& engine = numeric::random::get_debug_engine(); auto element = Fr::random_element(&engine); for (auto _ : state) { @@ -168,7 +168,7 @@ void ff_invert(State& state) */ void ff_to_montgomery(State& state) { - numeric::RNG& engine = numeric::get_debug_randomness(); + numeric::random::Engine& engine = numeric::random::get_debug_engine(); auto element = Fr::random_element(&engine); for (auto _ : state) { @@ -188,7 +188,7 @@ void ff_to_montgomery(State& state) */ void ff_from_montgomery(State& state) { - numeric::RNG& engine = numeric::get_debug_randomness(); + numeric::random::Engine& engine = numeric::random::get_debug_engine(); auto element = Fr::random_element(&engine); for (auto _ : state) { @@ -209,7 +209,7 @@ void ff_from_montgomery(State& state) */ void ff_reduce(State& state) { - numeric::RNG& engine = numeric::get_debug_randomness(); + numeric::random::Engine& engine = numeric::random::get_debug_engine(); auto element = Fr::random_element(&engine); for (auto _ : state) { @@ -230,7 +230,7 @@ void ff_reduce(State& state) */ void projective_point_addition(State& state) { - numeric::RNG& engine = numeric::get_debug_randomness(); + numeric::random::Engine& engine = numeric::random::get_debug_engine(); std::vector copy_vector(2); for (size_t j = 0; j < 2; j++) { copy_vector.emplace_back(Curve::Element::random_element(&engine)); @@ -255,7 +255,7 @@ void projective_point_addition(State& state) */ void projective_point_accidental_doubling(State& state) { - numeric::RNG& engine = numeric::get_debug_randomness(); + numeric::random::Engine& engine = numeric::random::get_debug_engine(); std::vector copy_vector(2); for (size_t j = 0; j < 2; j++) { copy_vector.emplace_back(Curve::Element::random_element(&engine)); @@ -280,7 +280,7 @@ void projective_point_accidental_doubling(State& state) */ void projective_point_doubling(State& state) { - numeric::RNG& engine = numeric::get_debug_randomness(); + numeric::random::Engine& engine = numeric::random::get_debug_engine(); std::vector copy_vector(2); for (size_t j = 0; j < 2; j++) { copy_vector.emplace_back(Curve::Element::random_element(&engine)); @@ -305,7 +305,7 @@ void projective_point_doubling(State& state) */ void scalar_multiplication(State& state) { - numeric::RNG& engine = numeric::get_debug_randomness(); + numeric::random::Engine& engine = numeric::random::get_debug_engine(); Curve::Element element = Curve::Element::random_element(&engine); Fr scalar = Fr::random_element(&engine); @@ -347,7 +347,7 @@ void cycle_waste(State& state) void sequential_copy(State& state) { - numeric::RNG& engine = numeric::get_debug_randomness(); + numeric::random::Engine& engine = numeric::random::get_debug_engine(); for (auto _ : state) { state.PauseTiming(); size_t num_cycles = 1 << static_cast(state.range(0)); diff --git a/barretenberg/cpp/src/barretenberg/benchmark/commit_bench/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/benchmark/commit_bench/CMakeLists.txt deleted file mode 100644 index 3bca58463b1e..000000000000 --- a/barretenberg/cpp/src/barretenberg/benchmark/commit_bench/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -# Each source represents a separate benchmark suite -set(BENCHMARK_SOURCES - commit.bench.cpp -) - -# Required libraries for benchmark suites -set(LINKED_LIBRARIES - commitment_schemes - benchmark::benchmark -) - -# Add executable and custom target for each suite, e.g. ultra_honk_bench -foreach(BENCHMARK_SOURCE ${BENCHMARK_SOURCES}) - get_filename_component(BENCHMARK_NAME ${BENCHMARK_SOURCE} NAME_WE) # extract name without extension - add_executable(${BENCHMARK_NAME}_bench main.bench.cpp ${BENCHMARK_SOURCE}) - target_link_libraries(${BENCHMARK_NAME}_bench ${LINKED_LIBRARIES}) - add_custom_target(run_${BENCHMARK_NAME} COMMAND ${BENCHMARK_NAME} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) -endforeach() \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/benchmark/commit_bench/commit.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/commit_bench/commit.bench.cpp deleted file mode 100644 index 769901042855..000000000000 --- a/barretenberg/cpp/src/barretenberg/benchmark/commit_bench/commit.bench.cpp +++ /dev/null @@ -1,38 +0,0 @@ - -#include "barretenberg/commitment_schemes/commitment_key.hpp" -#include - -namespace bb { - -template -std::shared_ptr> create_commitment_key(const size_t num_points) -{ - std::string srs_path; - if constexpr (std::same_as) { - srs_path = "../srs_db/ignition"; - } else { - static_assert(std::same_as); - srs_path = "../srs_db/grumpkin"; - } - std::shared_ptr> crs_factory( - new bb::srs::factories::FileCrsFactory(srs_path, num_points)); - return std::make_shared>(num_points, crs_factory); -} - -constexpr size_t MAX_LOG_NUM_POINTS = 24; -constexpr size_t MAX_NUM_POINTS = 1 << MAX_LOG_NUM_POINTS; - -auto key = create_commitment_key(MAX_NUM_POINTS); - -template void bench_commit(::benchmark::State& state) -{ - const size_t num_points = 1 << state.range(0); - const auto polynomial = Polynomial(num_points); - for (auto _ : state) { - benchmark::DoNotOptimize(key->commit(polynomial)); - } -} - -BENCHMARK(bench_commit)->DenseRange(10, MAX_LOG_NUM_POINTS)->Unit(benchmark::kMillisecond); - -} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/benchmark/commit_bench/main.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/commit_bench/main.bench.cpp deleted file mode 100644 index 71fefa047228..000000000000 --- a/barretenberg/cpp/src/barretenberg/benchmark/commit_bench/main.bench.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#include - -BENCHMARK_MAIN(); diff --git a/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/eccvm.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/eccvm.bench.cpp index 4c89b375de5c..630484837e11 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/eccvm.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/eccvm.bench.cpp @@ -1,6 +1,6 @@ #include -#include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp" +#include "barretenberg/benchmark/ultra_bench/benchmark_utilities.hpp" #include "barretenberg/eccvm/eccvm_composer.hpp" #include "barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.hpp" diff --git a/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/goblin.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/goblin.bench.cpp index 839c8237de44..40b95b7a7d2d 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/goblin.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/goblin.bench.cpp @@ -1,7 +1,7 @@ #include -#include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp" +#include "barretenberg/benchmark/ultra_bench/benchmark_utilities.hpp" #include "barretenberg/goblin/goblin.hpp" #include "barretenberg/goblin/mock_circuits.hpp" #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" @@ -9,6 +9,7 @@ using namespace benchmark; using namespace bb; +using namespace bb; namespace { void goblin_full(State& state) noexcept diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ipa_bench/ipa.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/ipa_bench/ipa.bench.cpp index 3a25ee93dfd2..e3da4560115d 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ipa_bench/ipa.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ipa_bench/ipa.bench.cpp @@ -3,6 +3,7 @@ using namespace benchmark; using namespace bb; +using namespace bb; using namespace bb::honk::pcs::ipa; namespace { using Curve = curve::Grumpkin; @@ -28,7 +29,7 @@ std::vector opening_claims(MAX_POLYNOMIAL_DEGREE_LOG2 - MIN_POLYNO void ipa_open(State& state) noexcept { - numeric::RNG& engine = numeric::get_debug_randomness(); + numeric::random::Engine& engine = numeric::random::get_debug_engine(); for (auto _ : state) { state.PauseTiming(); size_t n = 1 << static_cast(state.range(0)); diff --git a/barretenberg/cpp/src/barretenberg/benchmark/plonk_bench/standard_plonk.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/plonk_bench/standard_plonk.bench.cpp index 1a1eff70e7a0..71d790519c0b 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/plonk_bench/standard_plonk.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/plonk_bench/standard_plonk.bench.cpp @@ -1,4 +1,4 @@ -#include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp" +#include "barretenberg/benchmark/ultra_bench/benchmark_utilities.hpp" #include "barretenberg/plonk/composer/standard_composer.hpp" #include "barretenberg/proof_system/circuit_builder/standard_circuit_builder.hpp" @@ -13,8 +13,8 @@ using StandardPlonk = bb::plonk::StandardComposer; static void construct_proof_standard_power_of_2(State& state) noexcept { auto log2_of_gates = static_cast(state.range(0)); - bb::mock_proofs::construct_proof_with_specified_num_iterations( - state, &bb::mock_proofs::generate_basic_arithmetic_circuit, log2_of_gates); + bench_utils::construct_proof_with_specified_num_iterations( + state, &bench_utils::generate_basic_arithmetic_circuit, log2_of_gates); } BENCHMARK(construct_proof_standard_power_of_2) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_bench/protogalaxy.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_bench/protogalaxy.bench.cpp index b0a4f05afbf9..80fd2e0d3b52 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_bench/protogalaxy.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_bench/protogalaxy.bench.cpp @@ -1,6 +1,6 @@ #include -#include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp" +#include "barretenberg/benchmark/ultra_bench/benchmark_utilities.hpp" #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" #include "barretenberg/ultra_honk/ultra_composer.hpp" @@ -23,14 +23,14 @@ void fold_one(State& state) noexcept const auto construct_instance = [&]() { Builder builder; - bb::mock_proofs::generate_basic_arithmetic_circuit(builder, log2_num_gates); + bench_utils::generate_basic_arithmetic_circuit(builder, log2_num_gates); return composer.create_instance(builder); }; std::shared_ptr instance_1 = construct_instance(); std::shared_ptr instance_2 = construct_instance(); - auto folding_prover = composer.create_folding_prover({ instance_1, instance_2 }); + auto folding_prover = composer.create_folding_prover({ instance_1, instance_2 }, composer.commitment_key); for (auto _ : state) { auto proof = folding_prover.fold_instances(); diff --git a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/barycentric.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/barycentric.bench.cpp index b11d6b4771a7..19572fe6a0ea 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/barycentric.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/barycentric.bench.cpp @@ -5,7 +5,7 @@ using namespace benchmark; namespace { -auto& engine = bb::numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } using FF = bb::fr; diff --git a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp index 7541c6097544..e683523a7e3f 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp @@ -5,7 +5,7 @@ #include namespace { -auto& engine = bb::numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } using namespace bb::honk::sumcheck; diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_proofs.hpp b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/benchmark_utilities.hpp similarity index 69% rename from barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_proofs.hpp rename to barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/benchmark_utilities.hpp index 6bbc81a58721..d7fe88865074 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_proofs.hpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/benchmark_utilities.hpp @@ -20,7 +20,9 @@ #include "barretenberg/ultra_honk/ultra_composer.hpp" #include "barretenberg/ultra_honk/ultra_prover.hpp" -namespace bb::mock_proofs { +using namespace benchmark; + +namespace bench_utils { /** * @brief Generate test circuit with basic arithmetic operations @@ -30,9 +32,9 @@ namespace bb::mock_proofs { */ template void generate_basic_arithmetic_circuit(Builder& builder, size_t log2_num_gates) { - stdlib::field_t a(stdlib::witness_t(&builder, fr::random_element())); - stdlib::field_t b(stdlib::witness_t(&builder, fr::random_element())); - stdlib::field_t c(&builder); + bb::stdlib::field_t a(bb::stdlib::witness_t(&builder, bb::fr::random_element())); + bb::stdlib::field_t b(bb::stdlib::witness_t(&builder, bb::fr::random_element())); + bb::stdlib::field_t c(&builder); size_t passes = (1UL << log2_num_gates) / 4 - 4; if (static_cast(passes) <= 0) { throw std::runtime_error("too few gates"); @@ -56,9 +58,9 @@ template void generate_sha256_test_circuit(Builder& builder, { std::string in; in.resize(32); - stdlib::packed_byte_array input(&builder, in); + bb::stdlib::packed_byte_array input(&builder, in); for (size_t i = 0; i < num_iterations; i++) { - input = stdlib::sha256(input); + input = bb::stdlib::sha256(input); } } @@ -72,9 +74,9 @@ template void generate_keccak_test_circuit(Builder& builder, { std::string in = "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01"; - stdlib::byte_array input(&builder, in); + bb::stdlib::byte_array input(&builder, in); for (size_t i = 0; i < num_iterations; i++) { - input = stdlib::keccak::hash(input); + input = bb::stdlib::keccak::hash(input); } } @@ -86,24 +88,24 @@ template void generate_keccak_test_circuit(Builder& builder, */ template void generate_ecdsa_verification_test_circuit(Builder& builder, size_t num_iterations) { - using curve = stdlib::secp256k1; + using curve = bb::stdlib::secp256k1; using fr = typename curve::fr; using fq = typename curve::fq; using g1 = typename curve::g1; std::string message_string = "Instructions unclear, ask again later."; - crypto::ecdsa_key_pair account; + crypto::ecdsa::key_pair account; for (size_t i = 0; i < num_iterations; i++) { // Generate unique signature for each iteration account.private_key = curve::fr::random_element(); account.public_key = curve::g1::one * account.private_key; - crypto::ecdsa_signature signature = - crypto::ecdsa_construct_signature(message_string, account); + crypto::ecdsa::signature signature = + crypto::ecdsa::construct_signature(message_string, account); bool first_result = - crypto::ecdsa_verify_signature(message_string, account.public_key, signature); + crypto::ecdsa::verify_signature(message_string, account.public_key, signature); static_cast(first_result); // TODO(Cody): This is not used anywhere. std::vector rr(signature.r.begin(), signature.r.end()); @@ -112,18 +114,18 @@ template void generate_ecdsa_verification_test_circuit(Builde typename curve::g1_bigfr_ct public_key = curve::g1_bigfr_ct::from_witness(&builder, account.public_key); - stdlib::ecdsa_signature sig{ typename curve::byte_array_ct(&builder, rr), - typename curve::byte_array_ct(&builder, ss), - stdlib::uint8(&builder, vv) }; + bb::stdlib::ecdsa::signature sig{ typename curve::byte_array_ct(&builder, rr), + typename curve::byte_array_ct(&builder, ss), + bb::stdlib::uint8(&builder, vv) }; typename curve::byte_array_ct message(&builder, message_string); // Verify ecdsa signature - stdlib::ecdsa_verify_signature(message, public_key, sig); + bb::stdlib::ecdsa::verify_signature(message, public_key, sig); } } @@ -135,7 +137,7 @@ template void generate_ecdsa_verification_test_circuit(Builde */ template void generate_merkle_membership_test_circuit(Builder& builder, size_t num_iterations) { - using namespace stdlib; + using namespace bb::stdlib; using field_ct = field_t; using witness_ct = witness_t; using witness_ct = witness_t; @@ -162,32 +164,33 @@ template void generate_merkle_membership_test_circuit(Builder } // ultrahonk -inline honk::UltraProver get_prover(honk::UltraComposer& composer, - void (*test_circuit_function)(honk::UltraComposer::CircuitBuilder&, size_t), - size_t num_iterations) +inline bb::honk::UltraProver get_prover(bb::honk::UltraComposer& composer, + void (*test_circuit_function)(bb::honk::UltraComposer::CircuitBuilder&, size_t), + size_t num_iterations) { - honk::UltraComposer::CircuitBuilder builder; + bb::honk::UltraComposer::CircuitBuilder builder; test_circuit_function(builder, num_iterations); - std::shared_ptr instance = composer.create_instance(builder); + std::shared_ptr instance = composer.create_instance(builder); return composer.create_prover(instance); } // standard plonk -inline plonk::Prover get_prover(plonk::StandardComposer& composer, - void (*test_circuit_function)(StandardCircuitBuilder&, size_t), - size_t num_iterations) +inline bb::plonk::Prover get_prover(bb::plonk::StandardComposer& composer, + void (*test_circuit_function)(bb::StandardCircuitBuilder&, size_t), + size_t num_iterations) { - StandardCircuitBuilder builder; + bb::StandardCircuitBuilder builder; test_circuit_function(builder, num_iterations); return composer.create_prover(builder); } // ultraplonk -inline plonk::UltraProver get_prover(plonk::UltraComposer& composer, - void (*test_circuit_function)(honk::UltraComposer::CircuitBuilder&, size_t), - size_t num_iterations) +inline bb::plonk::UltraProver get_prover(bb::plonk::UltraComposer& composer, + void (*test_circuit_function)(bb::honk::UltraComposer::CircuitBuilder&, + size_t), + size_t num_iterations) { - plonk::UltraComposer::CircuitBuilder builder; + bb::plonk::UltraComposer::CircuitBuilder builder; test_circuit_function(builder, num_iterations); return composer.create_prover(builder); } @@ -202,12 +205,10 @@ inline plonk::UltraProver get_prover(plonk::UltraComposer& composer, * @param test_circuit_function */ template -void construct_proof_with_specified_num_iterations(benchmark::State& state, - void (*test_circuit_function)(typename Composer::CircuitBuilder&, - size_t), - size_t num_iterations) +void construct_proof_with_specified_num_iterations( + State& state, void (*test_circuit_function)(typename Composer::CircuitBuilder&, size_t), size_t num_iterations) { - srs::init_crs_factory("../srs_db/ignition"); + bb::srs::init_crs_factory("../srs_db/ignition"); Composer composer; @@ -222,4 +223,4 @@ void construct_proof_with_specified_num_iterations(benchmark::State& state, } } -} // namespace bb::mock_proofs +} // namespace bench_utils diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk.bench.cpp index f560475a7af7..1109a928f4ce 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk.bench.cpp @@ -1,6 +1,6 @@ #include -#include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp" +#include "barretenberg/benchmark/ultra_bench/benchmark_utilities.hpp" #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" #include "barretenberg/ultra_honk/ultra_composer.hpp" @@ -14,7 +14,7 @@ static void construct_proof_ultrahonk(State& state, void (*test_circuit_function)(UltraCircuitBuilder&, size_t)) noexcept { size_t num_iterations = 10; // 10x the circuit - bb::mock_proofs::construct_proof_with_specified_num_iterations( + bench_utils::construct_proof_with_specified_num_iterations( state, test_circuit_function, num_iterations); } @@ -24,26 +24,22 @@ static void construct_proof_ultrahonk(State& state, static void construct_proof_ultrahonk_power_of_2(State& state) noexcept { auto log2_of_gates = static_cast(state.range(0)); - bb::mock_proofs::construct_proof_with_specified_num_iterations( - state, &bb::mock_proofs::generate_basic_arithmetic_circuit, log2_of_gates); + bench_utils::construct_proof_with_specified_num_iterations( + state, &bench_utils::generate_basic_arithmetic_circuit, log2_of_gates); } // Define benchmarks -BENCHMARK_CAPTURE(construct_proof_ultrahonk, - sha256, - &bb::mock_proofs::generate_sha256_test_circuit) +BENCHMARK_CAPTURE(construct_proof_ultrahonk, sha256, &bench_utils::generate_sha256_test_circuit) ->Unit(kMillisecond); -BENCHMARK_CAPTURE(construct_proof_ultrahonk, - keccak, - &bb::mock_proofs::generate_keccak_test_circuit) +BENCHMARK_CAPTURE(construct_proof_ultrahonk, keccak, &bench_utils::generate_keccak_test_circuit) ->Unit(kMillisecond); BENCHMARK_CAPTURE(construct_proof_ultrahonk, ecdsa_verification, - &bb::mock_proofs::generate_ecdsa_verification_test_circuit) + &bench_utils::generate_ecdsa_verification_test_circuit) ->Unit(kMillisecond); BENCHMARK_CAPTURE(construct_proof_ultrahonk, merkle_membership, - &bb::mock_proofs::generate_merkle_membership_test_circuit) + &bench_utils::generate_merkle_membership_test_circuit) ->Unit(kMillisecond); BENCHMARK(construct_proof_ultrahonk_power_of_2) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk_rounds.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk_rounds.bench.cpp index 8fd06307cec1..b36e168b446f 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk_rounds.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk_rounds.bench.cpp @@ -1,6 +1,6 @@ #include -#include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp" +#include "barretenberg/benchmark/ultra_bench/benchmark_utilities.hpp" #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" #include "barretenberg/ultra_honk/ultra_composer.hpp" #include "barretenberg/ultra_honk/ultra_prover.hpp" @@ -55,8 +55,8 @@ BBERG_PROFILE static void test_round(State& state, size_t index) noexcept state.PauseTiming(); honk::UltraComposer composer; // TODO(https://github.com/AztecProtocol/barretenberg/issues/761) benchmark both sparse and dense circuits - honk::UltraProver prover = bb::mock_proofs::get_prover( - composer, &bb::mock_proofs::generate_ecdsa_verification_test_circuit, 10); + honk::UltraProver prover = bench_utils::get_prover( + composer, &bench_utils::generate_ecdsa_verification_test_circuit, 10); test_round_inner(state, prover, index); state.ResumeTiming(); // NOTE: google bench is very finnicky, must end in ResumeTiming() for correctness diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk.bench.cpp index a02fba5eb8a5..0f16f152d2ce 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk.bench.cpp @@ -1,4 +1,4 @@ -#include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp" +#include "barretenberg/benchmark/ultra_bench/benchmark_utilities.hpp" #include "barretenberg/plonk/composer/ultra_composer.hpp" #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" @@ -12,7 +12,7 @@ static void construct_proof_ultraplonk(State& state, void (*test_circuit_function)(UltraCircuitBuilder&, size_t)) noexcept { size_t num_iterations = 10; // 10x the circuit - bb::mock_proofs::construct_proof_with_specified_num_iterations( + bench_utils::construct_proof_with_specified_num_iterations( state, test_circuit_function, num_iterations); } @@ -22,26 +22,22 @@ static void construct_proof_ultraplonk(State& state, static void construct_proof_ultraplonk_power_of_2(State& state) noexcept { auto log2_of_gates = static_cast(state.range(0)); - bb::mock_proofs::construct_proof_with_specified_num_iterations( - state, &bb::mock_proofs::generate_basic_arithmetic_circuit, log2_of_gates); + bench_utils::construct_proof_with_specified_num_iterations( + state, &bench_utils::generate_basic_arithmetic_circuit, log2_of_gates); } // Define benchmarks -BENCHMARK_CAPTURE(construct_proof_ultraplonk, - sha256, - &bb::mock_proofs::generate_sha256_test_circuit) +BENCHMARK_CAPTURE(construct_proof_ultraplonk, sha256, &bench_utils::generate_sha256_test_circuit) ->Unit(kMillisecond); -BENCHMARK_CAPTURE(construct_proof_ultraplonk, - keccak, - &bb::mock_proofs::generate_keccak_test_circuit) +BENCHMARK_CAPTURE(construct_proof_ultraplonk, keccak, &bench_utils::generate_keccak_test_circuit) ->Unit(kMillisecond); BENCHMARK_CAPTURE(construct_proof_ultraplonk, ecdsa_verification, - &bb::mock_proofs::generate_ecdsa_verification_test_circuit) + &bench_utils::generate_ecdsa_verification_test_circuit) ->Unit(kMillisecond); BENCHMARK_CAPTURE(construct_proof_ultraplonk, merkle_membership, - &bb::mock_proofs::generate_merkle_membership_test_circuit) + &bench_utils::generate_merkle_membership_test_circuit) ->Unit(kMillisecond); BENCHMARK(construct_proof_ultraplonk_power_of_2) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk_rounds.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk_rounds.bench.cpp index b78b825ce773..8565dd96fbee 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk_rounds.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk_rounds.bench.cpp @@ -1,6 +1,6 @@ #include -#include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp" +#include "barretenberg/benchmark/ultra_bench/benchmark_utilities.hpp" #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" using namespace benchmark; @@ -54,8 +54,8 @@ BBERG_PROFILE static void test_round(State& state, size_t index) noexcept state.PauseTiming(); plonk::UltraComposer composer; // TODO: https://github.com/AztecProtocol/barretenberg/issues/761 benchmark both sparse and dense circuits - plonk::UltraProver prover = bb::mock_proofs::get_prover( - composer, &bb::mock_proofs::generate_ecdsa_verification_test_circuit, 10); + plonk::UltraProver prover = bench_utils::get_prover( + composer, &bench_utils::generate_ecdsa_verification_test_circuit, 10); test_round_inner(state, prover, index); // NOTE: google bench is very finnicky, must end in ResumeTiming() for correctness state.ResumeTiming(); diff --git a/barretenberg/cpp/src/barretenberg/benchmark/widgets_bench/widget.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/widgets_bench/widget.bench.cpp index 9b94063e3c21..b96f9f6ce78c 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/widgets_bench/widget.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/widgets_bench/widget.bench.cpp @@ -1,4 +1,4 @@ -#include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp" +#include "barretenberg/benchmark/ultra_bench/benchmark_utilities.hpp" #include "barretenberg/flavor/goblin_ultra.hpp" #include "barretenberg/flavor/ultra.hpp" #include "barretenberg/plonk/composer/standard_composer.hpp" @@ -19,7 +19,7 @@ // #define GET_PER_ROW_TIME namespace { -auto& engine = bb::numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } namespace bb::plonk { @@ -39,7 +39,7 @@ BasicPlonkKeyAndTranscript get_plonk_key_and_transcript() bb::srs::init_crs_factory("../srs_db/ignition"); auto inner_composer = plonk::UltraComposer(); auto builder = typename plonk::UltraComposer::CircuitBuilder(); - bb::mock_proofs::generate_basic_arithmetic_circuit(builder, 16); + bench_utils::generate_basic_arithmetic_circuit(builder, 16); UltraProver inner_prover = inner_composer.create_prover(builder); #ifdef GET_PER_ROW_TIME if (!(inner_prover.key->circuit_size == WIDGET_BENCH_TEST_CIRCUIT_SIZE)) { diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.test.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.test.hpp index 3350e2ed8671..df031f7404dc 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.test.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.test.hpp @@ -75,7 +75,7 @@ template class CommitmentTest : public ::testing::Test { public: CommitmentTest() - : engine{ &numeric::get_randomness() } + : engine{ &numeric::random::get_engine() } {} std::shared_ptr ck() { return commitment_key; } @@ -170,7 +170,7 @@ template class CommitmentTest : public ::testing::Test { } } - numeric::RNG* engine; + numeric::random::Engine* engine; // Per-test-suite set-up. // Called before the first test in this test suite. diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.test.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.test.cpp index 09f65bbc6356..1d6dd6779c21 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.test.cpp @@ -7,10 +7,7 @@ #include #include -using namespace bb; -using namespace bb::honk; -using namespace bb::honk::pcs; -using namespace bb::honk::pcs::gemini; +namespace bb::honk::pcs::gemini { template class GeminiTest : public CommitmentTest { using GeminiProver = GeminiProver_; @@ -240,3 +237,5 @@ TYPED_TEST(GeminiTest, DoubleWithShift) multilinear_commitments, multilinear_commitments_to_be_shifted); } + +} // namespace bb::honk::pcs::gemini diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp index 6aafab2fd153..3a9c26d1961d 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp @@ -8,11 +8,8 @@ #include "barretenberg/polynomials/polynomial.hpp" #include "barretenberg/polynomials/polynomial_arithmetic.hpp" #include - using namespace bb; -using namespace bb::honk; -using namespace bb::honk::pcs; -using namespace bb::honk::pcs::ipa; +namespace bb::honk::pcs::ipa::test { using Curve = curve::Grumpkin; @@ -179,3 +176,4 @@ TEST_F(IPATest, GeminiShplonkIPAWithShift) EXPECT_EQ(verified, true); } +} // namespace bb::honk::pcs::ipa::test diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.test.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.test.cpp index 30c02c0543a3..5e933bb7d6cd 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.test.cpp @@ -32,7 +32,7 @@ TYPED_TEST(KZGTest, single) using Fr = typename TypeParam::ScalarField; auto witness = this->random_polynomial(n); - g1::element commitment = this->commit(witness); + bb::g1::element commitment = this->commit(witness); auto challenge = Fr::random_element(); auto evaluation = witness.evaluate(challenge); diff --git a/barretenberg/cpp/src/barretenberg/common/ref_array.hpp b/barretenberg/cpp/src/barretenberg/common/ref_array.hpp index b85556fa6d9f..95224d8f7da1 100644 --- a/barretenberg/cpp/src/barretenberg/common/ref_array.hpp +++ b/barretenberg/cpp/src/barretenberg/common/ref_array.hpp @@ -5,7 +5,7 @@ #include #include -namespace bb { +// TODO(https://github.com/AztecProtocol/barretenberg/issues/794) namespace this once convenient /** * @brief A template class for a reference array. Behaves as if std::array was possible. * @@ -134,5 +134,4 @@ template RefArray concatenate(con (..., copy_into(ref_arrays, offset)); return RefArray{ concatenated }; -} -} // namespace bb \ No newline at end of file +} \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp b/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp index c74d1b52c199..523d75b8f5f3 100644 --- a/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp +++ b/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp @@ -6,7 +6,7 @@ #include #include -namespace bb { +// TODO(https://github.com/AztecProtocol/barretenberg/issues/794) namespace this once convenient /** * @brief A template class for a reference vector. Behaves as if std::vector was possible. * @@ -147,5 +147,4 @@ template static std::vector> to_vector_of_ref_vectors( result.push_back(RefVector{ inner }); } return result; -} -} // namespace bb \ No newline at end of file +} \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/common/std_array.hpp b/barretenberg/cpp/src/barretenberg/common/std_array.hpp index cb70e124a67a..850464ae36ad 100644 --- a/barretenberg/cpp/src/barretenberg/common/std_array.hpp +++ b/barretenberg/cpp/src/barretenberg/common/std_array.hpp @@ -2,7 +2,7 @@ #include -namespace bb { +// TODO(https://github.com/AztecProtocol/barretenberg/issues/794) namespace this once convenient /** * @brief Concatenates multiple std::array objects into a single array. * @@ -37,5 +37,3 @@ template std::array concatenate(c return result; } - -} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/common/std_vector.hpp b/barretenberg/cpp/src/barretenberg/common/std_vector.hpp index f363b74635c5..c3bf373820c4 100644 --- a/barretenberg/cpp/src/barretenberg/common/std_vector.hpp +++ b/barretenberg/cpp/src/barretenberg/common/std_vector.hpp @@ -1,7 +1,7 @@ #pragma once #include -namespace bb { +// TODO(https://github.com/AztecProtocol/barretenberg/issues/794) namespace this once convenient /** * @brief Concatenates multiple std::vector objects into a single std::vector. * @@ -22,5 +22,4 @@ template std::vector concatenate(const std::vector& vector, c (append(vectors), ...); return concatenated; -} -} // namespace bb \ No newline at end of file +} \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/common/thread.hpp b/barretenberg/cpp/src/barretenberg/common/thread.hpp index d75ae5d43897..8c67ca84d0ae 100644 --- a/barretenberg/cpp/src/barretenberg/common/thread.hpp +++ b/barretenberg/cpp/src/barretenberg/common/thread.hpp @@ -19,7 +19,7 @@ inline size_t get_num_cpus() // For algorithms that need to be divided amongst power of 2 threads. inline size_t get_num_cpus_pow2() { - return static_cast(1ULL << bb::numeric::get_msb(get_num_cpus())); + return static_cast(1ULL << numeric::get_msb(get_num_cpus())); } void parallel_for(size_t num_iterations, const std::function& func); @@ -28,19 +28,10 @@ void run_loop_in_parallel(size_t num_points, size_t no_multhreading_if_less_or_equal = 0); template -requires( - std::is_same_v> || - std::is_same_v>) void run_loop_in_parallel_if_effective_internal(size_t, - const FunctionType&, - size_t, - size_t, - size_t, - size_t, - size_t, - size_t, - size_t); + requires(std::is_same_v> || + std::is_same_v>) +void run_loop_in_parallel_if_effective_internal( + size_t, const FunctionType&, size_t, size_t, size_t, size_t, size_t, size_t, size_t); /** * @brief Runs loop in parallel if parallelization if useful (costs less than the algorith) * diff --git a/barretenberg/cpp/src/barretenberg/crypto/aes128/aes128.cpp b/barretenberg/cpp/src/barretenberg/crypto/aes128/aes128.cpp index f107d4749c66..629ca4e3c776 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/aes128/aes128.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/aes128/aes128.cpp @@ -6,6 +6,8 @@ #include #include +namespace crypto { +namespace aes128 { namespace { @@ -32,7 +34,7 @@ void sub_bytes(uint8_t* input) uint8_t i, j; for (i = 0; i < 4; ++i) { for (j = 0; j < 4; ++j) { - input[j * 4 + i] = bb::crypto::aes128_sbox[input[j * 4 + i]]; + input[j * 4 + i] = sbox[input[j * 4 + i]]; } } } @@ -41,7 +43,7 @@ void inverse_sub_bytes(uint8_t* input) { for (size_t i = 0; i < 4; ++i) { for (size_t j = 0; j < 4; ++j) { - input[j * 4 + i] = bb::crypto::aes128_sbox_inverse[input[j * 4 + i]]; + input[j * 4 + i] = sbox_inverse[input[j * 4 + i]]; } } } @@ -149,9 +151,7 @@ void inverse_mix_columns(uint8_t* input) } } // namespace -namespace bb::crypto { - -void aes128_expand_key(const uint8_t* key, uint8_t* round_key) +void expand_key(const uint8_t* key, uint8_t* round_key) { uint8_t temp[4]{}; @@ -176,10 +176,10 @@ void aes128_expand_key(const uint8_t* key, uint8_t* round_key) temp[2] = temp[3]; temp[3] = t; - temp[0] = aes128_sbox[temp[0]]; - temp[1] = aes128_sbox[temp[1]]; - temp[2] = aes128_sbox[temp[2]]; - temp[3] = aes128_sbox[temp[3]]; + temp[0] = sbox[temp[0]]; + temp[1] = sbox[temp[1]]; + temp[2] = sbox[temp[2]]; + temp[3] = sbox[temp[3]]; temp[0] = temp[0] ^ round_constants[i >> 2]; } @@ -224,10 +224,10 @@ void aes128_cipher(uint8_t* state, const uint8_t* round_key) add_round_key(state, round_key, 10); } -void aes128_encrypt_buffer_cbc(uint8_t* buffer, uint8_t* iv, const uint8_t* key, const size_t length) +void encrypt_buffer_cbc(uint8_t* buffer, uint8_t* iv, const uint8_t* key, const size_t length) { uint8_t round_key[176]; - aes128_expand_key(key, round_key); + expand_key(key, round_key); uint8_t block_state[16]{}; @@ -244,10 +244,10 @@ void aes128_encrypt_buffer_cbc(uint8_t* buffer, uint8_t* iv, const uint8_t* key, } } -void aes128_decrypt_buffer_cbc(uint8_t* buffer, uint8_t* iv, const uint8_t* key, const size_t length) +void decrypt_buffer_cbc(uint8_t* buffer, uint8_t* iv, const uint8_t* key, const size_t length) { uint8_t round_key[176]; - aes128_expand_key(key, round_key); + expand_key(key, round_key); uint8_t block_state[16]{}; const size_t num_blocks = (length / 16); @@ -262,4 +262,5 @@ void aes128_decrypt_buffer_cbc(uint8_t* buffer, uint8_t* iv, const uint8_t* key, } } -} // namespace bb::crypto \ No newline at end of file +} // namespace aes128 +} // namespace crypto \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/aes128/aes128.hpp b/barretenberg/cpp/src/barretenberg/crypto/aes128/aes128.hpp index 449b698413fb..dcc366f0d634 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/aes128/aes128.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/aes128/aes128.hpp @@ -14,18 +14,19 @@ #include #include -namespace bb::crypto { +namespace crypto { +namespace aes128 { -void aes128_expand_key(const uint8_t* key, uint8_t* round_key); +void expand_key(const uint8_t* key, uint8_t* round_key); void aes128_inverse_cipher(uint8_t* state, const uint8_t* round_key); void aes128_cipher(uint8_t* state, const uint8_t* round_key); // n.b. these methods will update the initialization vector -void aes128_encrypt_buffer_cbc(uint8_t* buffer, uint8_t* iv, const uint8_t* key, const size_t length); -void aes128_decrypt_buffer_cbc(uint8_t* buf, uint8_t* iv, const uint8_t* key, const size_t length); +void encrypt_buffer_cbc(uint8_t* buffer, uint8_t* iv, const uint8_t* key, const size_t length); +void decrypt_buffer_cbc(uint8_t* buf, uint8_t* iv, const uint8_t* key, const size_t length); -constexpr uint64_t aes128_sparse_base = 9; -static constexpr uint8_t aes128_sbox[256] = { +constexpr uint64_t sparse_base = 9; +static constexpr uint8_t sbox[256] = { // 0 1 2 3 4 5 6 7 8 9 A B C D E F 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, @@ -43,7 +44,7 @@ static constexpr uint8_t aes128_sbox[256] = { 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16, }; -static constexpr uint8_t aes128_sbox_inverse[256] = { +static constexpr uint8_t sbox_inverse[256] = { 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb, 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e, 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, @@ -59,4 +60,5 @@ static constexpr uint8_t aes128_sbox_inverse[256] = { 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d }; -} // namespace bb::crypto \ No newline at end of file +} // namespace aes128 +} // namespace crypto \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/aes128/aes128.test.cpp b/barretenberg/cpp/src/barretenberg/crypto/aes128/aes128.test.cpp index eae0f4f1c457..9918545c8a27 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/aes128/aes128.test.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/aes128/aes128.test.cpp @@ -2,8 +2,6 @@ #include -using namespace bb; - TEST(aes128, verify_cipher) { @@ -14,8 +12,8 @@ TEST(aes128, verify_cipher) uint8_t state[16]{ 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a }; uint8_t round_key[176]; - crypto::aes128_expand_key(key, round_key); - crypto::aes128_cipher(state, round_key); + crypto::aes128::expand_key(key, round_key); + crypto::aes128::aes128_cipher(state, round_key); for (size_t i = 0; i < 16; ++i) { EXPECT_EQ(state[i], expected[i]); @@ -35,7 +33,7 @@ TEST(aes128, encrypt_buffer_cbc) 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 }; - crypto::aes128_encrypt_buffer_cbc(in, iv, key, 64); + crypto::aes128::encrypt_buffer_cbc(in, iv, key, 64); for (size_t i = 0; i < 64; ++i) { EXPECT_EQ(in[i], out[i]); @@ -55,7 +53,7 @@ TEST(aes128, decrypt_buffer_cbc) 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 }; - crypto::aes128_decrypt_buffer_cbc(in, iv, key, 64); + crypto::aes128::decrypt_buffer_cbc(in, iv, key, 64); for (size_t i = 0; i < 64; ++i) { EXPECT_EQ(in[i], out[i]); diff --git a/barretenberg/cpp/src/barretenberg/crypto/aes128/c_bind.cpp b/barretenberg/cpp/src/barretenberg/crypto/aes128/c_bind.cpp index e71762fd06dc..1b30cdedbb64 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/aes128/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/aes128/c_bind.cpp @@ -6,7 +6,7 @@ WASM_EXPORT void aes_encrypt_buffer_cbc( uint8_t const* in, uint8_t const* iv, uint8_t const* key, uint32_t const* length, uint8_t** r) { auto len = ntohl(*length); - bb::crypto::aes128_encrypt_buffer_cbc((uint8_t*)in, (uint8_t*)iv, key, len); + crypto::aes128::encrypt_buffer_cbc((uint8_t*)in, (uint8_t*)iv, key, len); std::vector result(in, in + len); *r = to_heap_buffer(result); } @@ -15,7 +15,7 @@ WASM_EXPORT void aes_decrypt_buffer_cbc( uint8_t const* in, uint8_t const* iv, uint8_t const* key, uint32_t const* length, uint8_t** r) { auto len = ntohl(*length); - bb::crypto::aes128_decrypt_buffer_cbc((uint8_t*)in, (uint8_t*)iv, key, len); + crypto::aes128::decrypt_buffer_cbc((uint8_t*)in, (uint8_t*)iv, key, len); std::vector result(in, in + len); *r = to_heap_buffer(result); } diff --git a/barretenberg/cpp/src/barretenberg/crypto/blake2s/blake2-impl.hpp b/barretenberg/cpp/src/barretenberg/crypto/blake2s/blake2-impl.hpp index 4b6addc9ddd3..9d286bd579b2 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/blake2s/blake2-impl.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/blake2s/blake2-impl.hpp @@ -18,7 +18,7 @@ #include #include -namespace bb::crypto { +namespace blake2 { #if !defined(__cplusplus) && (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L) #if defined(_MSC_VER) @@ -146,6 +146,6 @@ static BLAKE2_INLINE void secure_zero_memory(void* v, size_t n) memset_v(v, 0, n); } -} // namespace bb::crypto +} // namespace blake2 #endif \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/blake2s/blake2s.cpp b/barretenberg/cpp/src/barretenberg/crypto/blake2s/blake2s.cpp index ea4d44259db6..6fd5ae3c3493 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/blake2s/blake2s.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/blake2s/blake2s.cpp @@ -13,14 +13,14 @@ https://blake2.net. */ -#include -#include -#include +#include +#include +#include #include "blake2-impl.hpp" #include "blake2s.hpp" -namespace bb::crypto { +namespace blake2 { static const uint32_t blake2s_IV[8] = { 0x6A09E667UL, 0xBB67AE85UL, 0x3C6EF372UL, 0xA54FF53AUL, 0x510E527FUL, 0x9B05688CUL, 0x1F83D9ABUL, 0x5BE0CD19UL }; @@ -233,4 +233,4 @@ std::array blake2s(std::vector const& input) return output; } -} // namespace bb::crypto +} // namespace blake2 diff --git a/barretenberg/cpp/src/barretenberg/crypto/blake2s/blake2s.hpp b/barretenberg/cpp/src/barretenberg/crypto/blake2s/blake2s.hpp index 9c5ce71abe04..c009296e5b91 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/blake2s/blake2s.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/blake2s/blake2s.hpp @@ -19,7 +19,7 @@ #include #include -namespace bb::crypto { +namespace blake2 { #if defined(_MSC_VER) #define BLAKE2_PACKED(x) __pragma(pack(push, 1)) x __pragma(pack(pop)) @@ -73,4 +73,4 @@ int blake2s_final(blake2s_state* S, void* out, size_t outlen); std::array blake2s(std::vector const& input); -} // namespace bb::crypto \ No newline at end of file +} // namespace blake2 \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/blake2s/blake2s.test.cpp b/barretenberg/cpp/src/barretenberg/crypto/blake2s/blake2s.test.cpp index 0ef048a6295d..c76c889a41c6 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/blake2s/blake2s.test.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/blake2s/blake2s.test.cpp @@ -5,8 +5,6 @@ #include #include -using namespace bb; - struct test_vector { std::string input; std::array output; @@ -384,6 +382,6 @@ TEST(misc_blake2s, test_vectors) { for (auto v : test_vectors) { std::vector input(v.input.begin(), v.input.end()); - EXPECT_EQ(crypto::blake2s(input), v.output); + EXPECT_EQ(blake2::blake2s(input), v.output); } } \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/blake2s/c_bind.cpp b/barretenberg/cpp/src/barretenberg/crypto/blake2s/c_bind.cpp index 53c0a84b07be..07dfd3a0b31d 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/blake2s/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/blake2s/c_bind.cpp @@ -10,14 +10,14 @@ WASM_EXPORT void blake2s(uint8_t const* data, out_buf32 out) { std::vector inputv; read(data, inputv); - auto output = bb::crypto::blake2s(inputv); + auto output = blake2::blake2s(inputv); std::copy(output.begin(), output.end(), out); } WASM_EXPORT void blake2s_to_field(uint8_t const* data, size_t length, uint8_t* r) { std::vector inputv(data, data + length); - auto output = bb::crypto::blake2s(inputv); + auto output = blake2::blake2s(inputv); auto result = bb::fr::serialize_from_buffer(output.data()); bb::fr::serialize_to_buffer(result, r); } @@ -27,7 +27,7 @@ WASM_EXPORT void blake2s_to_field_(uint8_t const* data, fr::out_buf r) { std::vector inputv; read(data, inputv); - auto output = bb::crypto::blake2s(inputv); + auto output = blake2::blake2s(inputv); auto result = bb::fr::serialize_from_buffer(output.data()); bb::fr::serialize_to_buffer(result, r); } diff --git a/barretenberg/cpp/src/barretenberg/crypto/blake3s/blake3s.test.cpp b/barretenberg/cpp/src/barretenberg/crypto/blake3s/blake3s.test.cpp index 7f38889e02c3..c4d93f3051dc 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/blake3s/blake3s.test.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/blake3s/blake3s.test.cpp @@ -8,8 +8,6 @@ #include #include -using namespace bb; - struct test_vector { std::string_view input; std::array output; @@ -394,7 +392,7 @@ static constexpr std::array test_vectors{ TEST(MiscBlake3s, TestVectors) { - constexpr_for<0, 1, 73>([&]() { + bb::constexpr_for<0, 1, 73>([&]() { constexpr auto v = test_vectors[index]; std::vector input(v.input.begin(), v.input.end()); auto result_vector = blake3::blake3s(input); diff --git a/barretenberg/cpp/src/barretenberg/crypto/ecdsa/c_bind.cpp b/barretenberg/cpp/src/barretenberg/crypto/ecdsa/c_bind.cpp index db8808a8c84e..f2dfcceb56cb 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/ecdsa/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/ecdsa/c_bind.cpp @@ -18,9 +18,9 @@ WASM_EXPORT void ecdsa__construct_signature(uint8_t const* message, using serialize::write; auto priv_key = from_buffer(private_key); secp256k1::g1::affine_element pub_key = secp256k1::g1::one * priv_key; - bb::crypto::ecdsa_key_pair key_pair = { priv_key, pub_key }; + crypto::ecdsa::key_pair key_pair = { priv_key, pub_key }; - auto sig = bb::crypto::ecdsa_construct_signature( + auto sig = crypto::ecdsa::construct_signature( std::string((char*)message, msg_len), key_pair); write(output_sig_r, sig.r); write(output_sig_s, sig.s); @@ -39,9 +39,9 @@ WASM_EXPORT void ecdsa__recover_public_key_from_signature(uint8_t const* message std::copy(sig_s, sig_s + 32, s.begin()); const uint8_t v = *sig_v; - bb::crypto::ecdsa_signature sig = { r, s, v }; + crypto::ecdsa::signature sig = { r, s, v }; auto recovered_pub_key = - bb::crypto::ecdsa_recover_public_key( + crypto::ecdsa::recover_public_key( std::string((char*)message, msg_len), sig); serialize::write(output_pub_key, recovered_pub_key); } @@ -59,7 +59,7 @@ WASM_EXPORT bool ecdsa__verify_signature(uint8_t const* message, std::copy(sig_s, sig_s + 32, s.begin()); const uint8_t v = *sig_v; - bb::crypto::ecdsa_signature sig = { r, s, v }; - return bb::crypto::ecdsa_verify_signature( + crypto::ecdsa::signature sig = { r, s, v }; + return crypto::ecdsa::verify_signature( std::string((char*)message, msg_len), pubk, sig); } diff --git a/barretenberg/cpp/src/barretenberg/crypto/ecdsa/ecdsa.hpp b/barretenberg/cpp/src/barretenberg/crypto/ecdsa/ecdsa.hpp index dabd63747208..16106a5868ac 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/ecdsa/ecdsa.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/ecdsa/ecdsa.hpp @@ -8,15 +8,16 @@ #include #include -namespace bb::crypto { -template struct ecdsa_key_pair { +namespace crypto { +namespace ecdsa { +template struct key_pair { Fr private_key; typename G1::affine_element public_key; // For serialization, update with any new fields MSGPACK_FIELDS(private_key, public_key); }; -struct ecdsa_signature { +struct signature { std::array r; std::array s; uint8_t v; @@ -25,27 +26,28 @@ struct ecdsa_signature { }; template -ecdsa_signature ecdsa_construct_signature(const std::string& message, const ecdsa_key_pair& account); +signature construct_signature(const std::string& message, const key_pair& account); template -typename G1::affine_element ecdsa_recover_public_key(const std::string& message, const ecdsa_signature& sig); +typename G1::affine_element recover_public_key(const std::string& message, const signature& sig); template -bool ecdsa_verify_signature(const std::string& message, - const typename G1::affine_element& public_key, - const ecdsa_signature& signature); +bool verify_signature(const std::string& message, + const typename G1::affine_element& public_key, + const signature& signature); -inline bool operator==(ecdsa_signature const& lhs, ecdsa_signature const& rhs) +inline bool operator==(signature const& lhs, signature const& rhs) { return lhs.r == rhs.r && lhs.s == rhs.s && lhs.v == rhs.v; } -inline std::ostream& operator<<(std::ostream& os, ecdsa_signature const& sig) +inline std::ostream& operator<<(std::ostream& os, signature const& sig) { os << "{ " << sig.r << ", " << sig.s << ", " << static_cast(sig.v) << " }"; return os; } -} // namespace bb::crypto +} // namespace ecdsa +} // namespace crypto #include "./ecdsa_impl.hpp" diff --git a/barretenberg/cpp/src/barretenberg/crypto/ecdsa/ecdsa.test.cpp b/barretenberg/cpp/src/barretenberg/crypto/ecdsa/ecdsa.test.cpp index 76b324682a05..b15e4a234be3 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/ecdsa/ecdsa.test.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/ecdsa/ecdsa.test.cpp @@ -9,7 +9,7 @@ using namespace bb; TEST(ecdsa, msgpack) { - auto [actual, expected] = msgpack_roundtrip(crypto::ecdsa_signature{}); + auto [actual, expected] = msgpack_roundtrip(crypto::ecdsa::signature{}); EXPECT_EQ(actual, expected); } @@ -17,14 +17,14 @@ TEST(ecdsa, verify_signature_grumpkin_sha256) { std::string message = "The quick brown dog jumped over the lazy fox."; - crypto::ecdsa_key_pair account; + crypto::ecdsa::key_pair account; account.private_key = grumpkin::fr::random_element(); account.public_key = grumpkin::g1::one * account.private_key; - crypto::ecdsa_signature signature = - crypto::ecdsa_construct_signature(message, account); + crypto::ecdsa::signature signature = + crypto::ecdsa::construct_signature(message, account); - bool result = crypto::ecdsa_verify_signature( + bool result = crypto::ecdsa::verify_signature( message, account.public_key, signature); EXPECT_EQ(result, true); @@ -34,14 +34,14 @@ TEST(ecdsa, verify_signature_secp256r1_sha256) { std::string message = "The quick brown dog jumped over the lazy fox."; - crypto::ecdsa_key_pair account; + crypto::ecdsa::key_pair account; account.private_key = secp256r1::fr::random_element(); account.public_key = secp256r1::g1::one * account.private_key; - crypto::ecdsa_signature signature = - crypto::ecdsa_construct_signature(message, account); + crypto::ecdsa::signature signature = + crypto::ecdsa::construct_signature(message, account); - bool result = crypto::ecdsa_verify_signature( + bool result = crypto::ecdsa::verify_signature( message, account.public_key, signature); EXPECT_EQ(result, true); @@ -51,18 +51,19 @@ TEST(ecdsa, recover_public_key_secp256k1_sha256) { std::string message = "The quick brown dog jumped over the lazy fox."; - crypto::ecdsa_key_pair account; + crypto::ecdsa::key_pair account; account.private_key = secp256k1::fr::random_element(); account.public_key = secp256k1::g1::one * account.private_key; - crypto::ecdsa_signature signature = - crypto::ecdsa_construct_signature(message, account); + crypto::ecdsa::signature signature = + crypto::ecdsa::construct_signature(message, account); - bool result = crypto::ecdsa_verify_signature( + bool result = crypto::ecdsa::verify_signature( message, account.public_key, signature); auto recovered_public_key = - crypto::ecdsa_recover_public_key(message, signature); + crypto::ecdsa::recover_public_key(message, + signature); EXPECT_EQ(result, true); EXPECT_EQ(recovered_public_key, account.public_key); @@ -72,18 +73,19 @@ TEST(ecdsa, recover_public_key_secp256r1_sha256) { std::string message = "The quick brown dog jumped over the lazy fox."; - crypto::ecdsa_key_pair account; + crypto::ecdsa::key_pair account; account.private_key = secp256r1::fr::random_element(); account.public_key = secp256r1::g1::one * account.private_key; - crypto::ecdsa_signature signature = - crypto::ecdsa_construct_signature(message, account); + crypto::ecdsa::signature signature = + crypto::ecdsa::construct_signature(message, account); - bool result = crypto::ecdsa_verify_signature( + bool result = crypto::ecdsa::verify_signature( message, account.public_key, signature); auto recovered_public_key = - crypto::ecdsa_recover_public_key(message, signature); + crypto::ecdsa::recover_public_key(message, + signature); EXPECT_EQ(result, true); EXPECT_EQ(recovered_public_key, account.public_key); @@ -108,18 +110,18 @@ TEST(ecdsa, check_overflowing_r_and_s_are_rejected) std::vector message_vec = HexToBytes("41414141"); std::string message(message_vec.begin(), message_vec.end()); - crypto::ecdsa_signature signature; + crypto::ecdsa::signature signature; grumpkin::fr private_key; grumpkin::g1::affine_element public_key; - crypto::ecdsa_key_pair key_pair; + crypto::ecdsa::key_pair key_pair; // We create a private and public key and a signature private_key = grumpkin::fr::random_element(); public_key = grumpkin::g1::affine_element((grumpkin::g1::one * private_key).normalize()); key_pair = { private_key, public_key }; signature = - crypto::ecdsa_construct_signature(message, key_pair); + crypto::ecdsa::construct_signature(message, key_pair); // Check that the signature is correct - bool result = crypto::ecdsa_verify_signature( + bool result = crypto::ecdsa::verify_signature( message, public_key, signature); EXPECT_TRUE(result); using serialize::read; @@ -133,7 +135,7 @@ TEST(ecdsa, check_overflowing_r_and_s_are_rejected) using serialize::write; auto* p_r_m = &signature.r[0]; write(p_r_m, new_r); - result = crypto::ecdsa_verify_signature( + result = crypto::ecdsa::verify_signature( message, public_key, signature); // Signature verification should decline this signature, since it breaks specification EXPECT_FALSE(result); @@ -146,7 +148,7 @@ TEST(ecdsa, check_overflowing_r_and_s_are_rejected) auto* p_r_s = &signature.s[0]; write(p_r_m, old_r); write(p_r_s, new_s); - result = crypto::ecdsa_verify_signature( + result = crypto::ecdsa::verify_signature( message, public_key, signature); EXPECT_FALSE(result); } @@ -180,14 +182,14 @@ TEST(ecdsa, verify_signature_secp256r1_sha256_NIST_1) 0xef, 0x97, 0xb2, 0x18, 0xe9, 0x6f, 0x17, 0x5a, 0x3c, 0xcd, 0xda, 0x2a, 0xcc, 0x05, 0x89, 0x03, }; - crypto::ecdsa_signature sig{ r, s, 27 }; + crypto::ecdsa::signature sig{ r, s, 27 }; std::vector message_vec = HexToBytes("5905238877c77421f73e43ee3da6f2d9e2ccad5fc942dcec0cbd25482935faaf416983fe165b1a045ee2bcd2e6dca3bdf46" "c4310a7461f9a37960ca672d3feb5473e253605fb1ddfd28065b53cb5858a8ad28175bf9bd386a5e471ea7a65c17cc934a9" "d791e91491eb3754d03799790fe2d308d16146d5c9b0d0debd97d79ce8"); std::string message(message_vec.begin(), message_vec.end()); - bool result = crypto::ecdsa_verify_signature( + bool result = crypto::ecdsa::verify_signature( message, public_key, sig); EXPECT_EQ(result, true); } diff --git a/barretenberg/cpp/src/barretenberg/crypto/ecdsa/ecdsa_impl.hpp b/barretenberg/cpp/src/barretenberg/crypto/ecdsa/ecdsa_impl.hpp index 26ae2b140044..085ca7128359 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/ecdsa/ecdsa_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/ecdsa/ecdsa_impl.hpp @@ -4,12 +4,13 @@ #include "barretenberg/common/serialize.hpp" #include "barretenberg/numeric/uint256/uint256.hpp" -namespace bb::crypto { +namespace crypto { +namespace ecdsa { template -ecdsa_signature ecdsa_construct_signature(const std::string& message, const ecdsa_key_pair& account) +signature construct_signature(const std::string& message, const key_pair& account) { - ecdsa_signature sig; + signature sig; // use HMAC in PRF mode to derive 32-byte secret `k` std::vector pkey_buffer; @@ -52,7 +53,7 @@ ecdsa_signature ecdsa_construct_signature(const std::string& message, const ecds } template -typename G1::affine_element ecdsa_recover_public_key(const std::string& message, const ecdsa_signature& sig) +typename G1::affine_element recover_public_key(const std::string& message, const signature& sig) { using serialize::read; uint256_t r_uint; @@ -124,9 +125,7 @@ typename G1::affine_element ecdsa_recover_public_key(const std::string& message, } template -bool ecdsa_verify_signature(const std::string& message, - const typename G1::affine_element& public_key, - const ecdsa_signature& sig) +bool verify_signature(const std::string& message, const typename G1::affine_element& public_key, const signature& sig) { using serialize::read; uint256_t r_uint; @@ -170,4 +169,5 @@ bool ecdsa_verify_signature(const std::string& message, Fr result(Rx); return result == r; } -} // namespace bb::crypto +} // namespace ecdsa +} // namespace crypto diff --git a/barretenberg/cpp/src/barretenberg/crypto/generators/generator_data.hpp b/barretenberg/cpp/src/barretenberg/crypto/generators/generator_data.hpp index 0e695abb02d6..acbe76ef3cdd 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/generators/generator_data.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/generators/generator_data.hpp @@ -7,7 +7,7 @@ #include #include -namespace bb::crypto { +namespace crypto { /** * @brief class that stores precomputed generators used for Pedersen commitments and Pedersen hashes * @@ -143,4 +143,4 @@ template struct GeneratorContext { , domain_separator(_domain_separator) {} }; -} // namespace bb::crypto \ No newline at end of file +} // namespace crypto \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/hashers/hashers.hpp b/barretenberg/cpp/src/barretenberg/crypto/hashers/hashers.hpp index f19224941d12..b3fb6e851056 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/hashers/hashers.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/hashers/hashers.hpp @@ -31,5 +31,5 @@ struct Sha256Hasher { struct Blake2sHasher { static constexpr size_t BLOCK_SIZE = 64; static constexpr size_t OUTPUT_SIZE = 32; - static auto hash(const std::vector& message) { return bb::crypto::blake2s(message); } + static auto hash(const std::vector& message) { return blake2::blake2s(message); } }; diff --git a/barretenberg/cpp/src/barretenberg/crypto/hmac/hmac.hpp b/barretenberg/cpp/src/barretenberg/crypto/hmac/hmac.hpp index a5d811fd21e9..f2f0edfafdf9 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/hmac/hmac.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/hmac/hmac.hpp @@ -8,7 +8,7 @@ #include #include -namespace bb::crypto { +namespace crypto { /** * @brief Compute an HMAC given a secret key and a message * @@ -93,8 +93,8 @@ std::array hmac(const MessageContainer& message, con * @return Fr output field element as uint512_t( H(10...0 || HMAC(k,m)) || H(00...0 || HMAC(k,m)) ) % r */ template -Fr get_unbiased_field_from_hmac(const MessageContainer& message, - const KeyContainer& key) requires(Hash::OUTPUT_SIZE == 32) +Fr get_unbiased_field_from_hmac(const MessageContainer& message, const KeyContainer& key) + requires(Hash::OUTPUT_SIZE == 32) { // Strong assumption that works for now with our suite of Hashers static_assert(Hash::BLOCK_SIZE > Hash::OUTPUT_SIZE); @@ -126,4 +126,4 @@ Fr get_unbiased_field_from_hmac(const MessageContainer& message, Fr result((field_as_u512 % Fr::modulus).lo); return result; } -} // namespace bb::crypto +} // namespace crypto diff --git a/barretenberg/cpp/src/barretenberg/crypto/hmac/hmac.test.cpp b/barretenberg/cpp/src/barretenberg/crypto/hmac/hmac.test.cpp index 020ceedaf2ca..5e66bc8389e8 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/hmac/hmac.test.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/hmac/hmac.test.cpp @@ -8,8 +8,6 @@ #include #include -using namespace bb; - std::array hex_to_bytes(const std::string& hex) { std::array bytes; diff --git a/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.cpp b/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.cpp index 3880bd7ffbe2..691a64b998bc 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.cpp @@ -6,7 +6,7 @@ #include #endif -namespace bb::crypto { +namespace crypto { /** * @brief Given a vector of fields, generate a pedersen commitment using the indexed generators. @@ -30,4 +30,4 @@ typename Curve::AffineElement pedersen_commitment_base::commit_native(con return result.normalize(); } template class pedersen_commitment_base; -} // namespace bb::crypto +} // namespace crypto diff --git a/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.hpp b/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.hpp index 517ede529d9a..fc750591eff8 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.hpp @@ -6,7 +6,7 @@ #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" #include -namespace bb::crypto { +namespace crypto { /** * @brief Performs pedersen commitments! @@ -31,4 +31,4 @@ template class pedersen_commitment_base { }; using pedersen_commitment = pedersen_commitment_base; -} // namespace bb::crypto +} // namespace crypto diff --git a/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.test.cpp b/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.test.cpp index 6d0d4db89ab0..f25ac05f0f2c 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.test.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.test.cpp @@ -3,7 +3,7 @@ #include "barretenberg/crypto/generators/generator_data.hpp" #include -namespace bb::crypto { +namespace crypto { using bb::fr; @@ -51,4 +51,4 @@ TEST(Pedersen, GeneratorPrinter) } } -}; // namespace bb::crypto \ No newline at end of file +}; // namespace crypto \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.cpp b/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.cpp index 38c6f2421b1b..9e702eccb2f3 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.cpp @@ -1,7 +1,7 @@ #include "./pedersen.hpp" #include "../pedersen_commitment/pedersen.hpp" -namespace bb::crypto { +namespace crypto { /** * @brief Converts input uint8_t buffers into vector of field elements. Used to hash the Transcript in a @@ -80,4 +80,4 @@ typename Curve::BaseField pedersen_hash_base::hash_buffer(const std::vect } template class pedersen_hash_base; -} // namespace bb::crypto \ No newline at end of file +} // namespace crypto \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.hpp b/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.hpp index 9e9cd638a7c7..8bd5bf82b05a 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.hpp @@ -2,7 +2,7 @@ #include "../generators/generator_data.hpp" #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" -namespace bb::crypto { +namespace crypto { /** * @brief Performs pedersen hashes! * @@ -37,4 +37,4 @@ template class pedersen_hash_base { }; using pedersen_hash = pedersen_hash_base; -} // namespace bb::crypto +} // namespace crypto diff --git a/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.test.cpp b/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.test.cpp index 0e4ade6fca1c..47c96cba9c78 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.test.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.test.cpp @@ -3,7 +3,7 @@ #include "barretenberg/numeric/uint256/uint256.hpp" #include -namespace bb::crypto { +namespace crypto { using bb::fr; @@ -21,4 +21,4 @@ TEST(Pedersen, HashWithIndex) EXPECT_EQ(r, fr(uint256_t("1c446df60816b897cda124524e6b03f36df0cec333fad87617aab70d7861daa6"))); } -} // namespace bb::crypto \ No newline at end of file +} // namespace crypto \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.bench.cpp b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.bench.cpp index 6673734acdc4..6b1b1457997a 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.bench.cpp @@ -11,7 +11,7 @@ grumpkin::fq poseidon_function(const size_t count) inputs[i] = grumpkin::fq::random_element(); } // hash count many field elements - inputs[0] = bb::crypto::Poseidon2::hash(inputs); + inputs[0] = crypto::Poseidon2::hash(inputs); return inputs[0]; } @@ -24,4 +24,5 @@ void native_poseidon2_commitment_bench(State& state) noexcept } BENCHMARK(native_poseidon2_commitment_bench)->Arg(10)->Arg(1000)->Arg(10000); -BENCHMARK_MAIN(); \ No newline at end of file +BENCHMARK_MAIN(); +// } // namespace crypto \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.cpp b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.cpp index 1fce753975ba..ad96dc312713 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.cpp @@ -1,6 +1,6 @@ #include "poseidon2.hpp" -namespace bb::crypto { +namespace crypto { /** * @brief Hashes a vector of field elements */ @@ -45,4 +45,4 @@ typename Poseidon2::FF Poseidon2::hash_buffer(const std::vector< } template class Poseidon2; -} // namespace bb::crypto \ No newline at end of file +} // namespace crypto \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.hpp b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.hpp index 446361696c2f..6969c680e177 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.hpp @@ -4,7 +4,7 @@ #include "poseidon2_permutation.hpp" #include "sponge/sponge.hpp" -namespace bb::crypto { +namespace crypto { template class Poseidon2 { public: @@ -25,4 +25,4 @@ template class Poseidon2 { }; extern template class Poseidon2; -} // namespace bb::crypto \ No newline at end of file +} // namespace crypto \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.test.cpp b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.test.cpp index 7903d1fceb6d..0360b5696738 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.test.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.test.cpp @@ -6,19 +6,20 @@ using namespace bb; namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } +namespace poseidon2_tests { TEST(Poseidon2, HashBasicTests) { - fr a = fr::random_element(&engine); - fr b = fr::random_element(&engine); - fr c = fr::random_element(&engine); - fr d = fr::random_element(&engine); + bb::fr a = bb::fr::random_element(&engine); + bb::fr b = bb::fr::random_element(&engine); + bb::fr c = bb::fr::random_element(&engine); + bb::fr d = bb::fr::random_element(&engine); - std::vector input1{ a, b, c, d }; - std::vector input2{ d, c, b, a }; + std::vector input1{ a, b, c, d }; + std::vector input2{ d, c, b, a }; auto r0 = crypto::Poseidon2::hash(input1); auto r1 = crypto::Poseidon2::hash(input1); @@ -33,15 +34,15 @@ TEST(Poseidon2, HashBasicTests) // flexibility of Poseidon's parametrisation) TEST(Poseidon2, HashConsistencyCheck) { - fr a(std::string("9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); - fr b(std::string("9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); - fr c(std::string("0x9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); - fr d(std::string("0x9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); + bb::fr a(std::string("9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); + bb::fr b(std::string("9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); + bb::fr c(std::string("0x9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); + bb::fr d(std::string("0x9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); - std::vector input{ a, b, c, d }; + std::vector input{ a, b, c, d }; auto result = crypto::Poseidon2::hash(input); - fr expected(std::string("0x2f43a0f83b51a6f5fc839dea0ecec74947637802a579fa9841930a25a0bcec11")); + bb::fr expected(std::string("0x2f43a0f83b51a6f5fc839dea0ecec74947637802a579fa9841930a25a0bcec11")); EXPECT_EQ(result, expected); } @@ -50,14 +51,15 @@ TEST(Poseidon2, HashBufferConsistencyCheck) { // 31 byte inputs because hash_buffer slicing is only injective with 31 bytes, as it slices 31 bytes for each field // element - fr a(std::string("00000b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); + bb::fr a(std::string("00000b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); auto input_vec = to_buffer(a); // takes field element and converts it to 32 bytes input_vec.erase(input_vec.begin()); // erase first byte since we want 31 bytes - std::vector input{ a }; + std::vector input{ a }; auto expected = crypto::Poseidon2::hash(input); - fr result = crypto::Poseidon2::hash_buffer(input_vec); + bb::fr result = crypto::Poseidon2::hash_buffer(input_vec); EXPECT_EQ(result, expected); } +} // namespace poseidon2_tests \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_cpp_params.sage b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_cpp_params.sage index 685acd21e35b..4250e98e8a92 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_cpp_params.sage +++ b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_cpp_params.sage @@ -661,7 +661,7 @@ print("#pragma once\n") print("#include \"barretenberg/ecc/curves/bn254/fr.hpp\"\n") -print("namespace bb::crypto {\n") +print("namespace crypto {\n") print("struct Poseidon2Bn254ScalarFieldParams{\n") print(" using FF = bb::fr;") @@ -723,4 +723,4 @@ for (i,val) in enumerate(state_out): print("};") print("};") -print("} // namespace bb::crypto") \ No newline at end of file +print("} // namespace crypto") \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_params.hpp b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_params.hpp index 9aeaadc7bf31..7a4a3ab06199 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_params.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_params.hpp @@ -5,7 +5,7 @@ #include "barretenberg/ecc/curves/bn254/fr.hpp" -namespace bb::crypto { +namespace crypto { struct Poseidon2Bn254ScalarFieldParams { @@ -449,4 +449,4 @@ struct Poseidon2Bn254ScalarFieldParams { FF(std::string("0x2e11c5cff2a22c64d01304b778d78f6998eff1ab73163a35603f54794c30847a")), }; }; -} // namespace bb::crypto +} // namespace crypto diff --git a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_permutation.hpp b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_permutation.hpp index 15a3a8bd555f..4f0794b893c8 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_permutation.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_permutation.hpp @@ -8,7 +8,7 @@ #include #include -namespace bb::crypto { +namespace crypto { /** * @brief Applies the Poseidon2 permutation function from https://eprint.iacr.org/2023/323 . @@ -162,4 +162,4 @@ template class Poseidon2Permutation { return current_state; } }; -} // namespace bb::crypto \ No newline at end of file +} // namespace crypto \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_permutation.test.cpp b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_permutation.test.cpp index 744593bcb732..57d4b56a9578 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_permutation.test.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_permutation.test.cpp @@ -6,9 +6,11 @@ using namespace bb; namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } +namespace poseidon2_tests { + TEST(Poseidon2Permutation, TestVectors) { @@ -22,13 +24,13 @@ TEST(Poseidon2Permutation, TestVectors) TEST(Poseidon2Permutation, BasicTests) { - fr a = fr::random_element(&engine); - fr b = fr::random_element(&engine); - fr c = fr::random_element(&engine); - fr d = fr::random_element(&engine); + bb::fr a = bb::fr::random_element(&engine); + bb::fr b = bb::fr::random_element(&engine); + bb::fr c = bb::fr::random_element(&engine); + bb::fr d = bb::fr::random_element(&engine); - std::array input1{ a, b, c, d }; - std::array input2{ d, c, b, a }; + std::array input1{ a, b, c, d }; + std::array input2{ d, c, b, a }; auto r0 = crypto::Poseidon2Permutation::permutation(input1); auto r1 = crypto::Poseidon2Permutation::permutation(input1); @@ -43,19 +45,21 @@ TEST(Poseidon2Permutation, BasicTests) // flexibility of Poseidon's parametrisation) TEST(Poseidon2Permutation, ConsistencyCheck) { - fr a(std::string("9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); - fr b(std::string("9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); - fr c(std::string("0x9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); - fr d(std::string("0x9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); + bb::fr a(std::string("9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); + bb::fr b(std::string("9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); + bb::fr c(std::string("0x9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); + bb::fr d(std::string("0x9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); - std::array input{ a, b, c, d }; + std::array input{ a, b, c, d }; auto result = crypto::Poseidon2Permutation::permutation(input); - std::array expected{ - fr(std::string("0x2bf1eaf87f7d27e8dc4056e9af975985bccc89077a21891d6c7b6ccce0631f95")), - fr(std::string("0x0c01fa1b8d0748becafbe452c0cb0231c38224ea824554c9362518eebdd5701f")), - fr(std::string("0x018555a8eb50cf07f64b019ebaf3af3c925c93e631f3ecd455db07bbb52bbdd3")), - fr(std::string("0x0cbea457c91c22c6c31fd89afd2541efc2edf31736b9f721e823b2165c90fd41")), + std::array expected{ + bb::fr(std::string("0x2bf1eaf87f7d27e8dc4056e9af975985bccc89077a21891d6c7b6ccce0631f95")), + bb::fr(std::string("0x0c01fa1b8d0748becafbe452c0cb0231c38224ea824554c9362518eebdd5701f")), + bb::fr(std::string("0x018555a8eb50cf07f64b019ebaf3af3c925c93e631f3ecd455db07bbb52bbdd3")), + bb::fr(std::string("0x0cbea457c91c22c6c31fd89afd2541efc2edf31736b9f721e823b2165c90fd41")), }; EXPECT_EQ(result, expected); } + +} // namespace poseidon2_tests \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/sponge/sponge.hpp b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/sponge/sponge.hpp index 2a99b88609fd..bc4a2c5c1dcb 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/sponge/sponge.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/sponge/sponge.hpp @@ -7,7 +7,7 @@ #include "barretenberg/numeric/uint256/uint256.hpp" -namespace bb::crypto { +namespace crypto { /** * @brief Implements a cryptographic sponge over prime fields. @@ -165,4 +165,4 @@ template input) { return hash_variable_length<1>(input)[0]; } }; -} // namespace bb::crypto \ No newline at end of file +} // namespace crypto \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/schnorr/c_bind.cpp b/barretenberg/cpp/src/barretenberg/crypto/schnorr/c_bind.cpp index 55abbfa0bdb4..fa7a66811fea 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/schnorr/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/schnorr/c_bind.cpp @@ -6,7 +6,7 @@ extern "C" { using namespace bb; using affine_element = grumpkin::g1::affine_element; -using multisig = crypto::schnorr_multisig; +using multisig = crypto::schnorr::multisig; using multisig_public_key = typename multisig::MultiSigPublicKey; WASM_EXPORT void schnorr_compute_public_key(uint8_t const* private_key, uint8_t* public_key_buf) @@ -32,8 +32,8 @@ WASM_EXPORT void schnorr_construct_signature(uint8_t const* message_buf, auto message = from_buffer(message_buf); auto priv_key = from_buffer(private_key); grumpkin::g1::affine_element pub_key = grumpkin::g1::one * priv_key; - crypto::schnorr_key_pair key_pair = { priv_key, pub_key }; - auto sig = crypto::schnorr_construct_signature(message, key_pair); + crypto::schnorr::key_pair key_pair = { priv_key, pub_key }; + auto sig = crypto::schnorr::construct_signature(message, key_pair); write(s, sig.s); write(e, sig.e); } @@ -47,18 +47,18 @@ WASM_EXPORT void schnorr_verify_signature( std::array e; std::copy(sig_s, sig_s + 32, s.begin()); std::copy(sig_e, sig_e + 32, e.begin()); - crypto::schnorr_signature sig = { s, e }; + crypto::schnorr::signature sig = { s, e }; *result = - crypto::schnorr_verify_signature(message, pubk, sig); + crypto::schnorr::verify_signature(message, pubk, sig); } WASM_EXPORT void schnorr_multisig_create_multisig_public_key(uint8_t const* private_key, uint8_t* multisig_pubkey_buf) { - using multisig = crypto::schnorr_multisig; + using multisig = crypto::schnorr::multisig; using multisig_public_key = typename multisig::MultiSigPublicKey; auto priv_key = from_buffer(private_key); grumpkin::g1::affine_element pub_key = grumpkin::g1::one * priv_key; - crypto::schnorr_key_pair key_pair = { priv_key, pub_key }; + crypto::schnorr::key_pair key_pair = { priv_key, pub_key }; auto agg_pubkey = multisig_public_key(key_pair); @@ -69,7 +69,7 @@ WASM_EXPORT void schnorr_multisig_validate_and_combine_signer_pubkeys(uint8_t co affine_element::out_buf combined_key_buf, bool* success) { - using multisig = crypto::schnorr_multisig; + using multisig = crypto::schnorr::multisig; auto pubkeys = from_buffer>(signer_pubkey_buf); auto combined_key = multisig::validate_and_combine_signer_pubkeys(pubkeys); @@ -86,7 +86,7 @@ WASM_EXPORT void schnorr_multisig_validate_and_combine_signer_pubkeys(uint8_t co WASM_EXPORT void schnorr_multisig_construct_signature_round_1(uint8_t* round_one_public_output_buf, uint8_t* round_one_private_output_buf) { - using multisig = crypto::schnorr_multisig; + using multisig = crypto::schnorr::multisig; auto [public_output, private_output] = multisig::construct_signature_round_1(); serialize::write(round_one_public_output_buf, public_output); @@ -101,11 +101,11 @@ WASM_EXPORT void schnorr_multisig_construct_signature_round_2(uint8_t const* mes uint8_t* round_two_buf, bool* success) { - using multisig = crypto::schnorr_multisig; + using multisig = crypto::schnorr::multisig; auto message = from_buffer(message_buf); auto priv_key = from_buffer(private_key); grumpkin::g1::affine_element pub_key = grumpkin::g1::one * priv_key; - crypto::schnorr_key_pair key_pair = { priv_key, pub_key }; + crypto::schnorr::key_pair key_pair = { priv_key, pub_key }; auto signer_pubkeys = from_buffer>(signer_pubkeys_buf); auto round_one_outputs = from_buffer>(round_one_public_buf); @@ -130,7 +130,7 @@ WASM_EXPORT void schnorr_multisig_combine_signatures(uint8_t const* message_buf, uint8_t* e, bool* success) { - using multisig = crypto::schnorr_multisig; + using multisig = crypto::schnorr::multisig; auto message = from_buffer(message_buf); auto signer_pubkeys = from_buffer>(signer_pubkeys_buf); diff --git a/barretenberg/cpp/src/barretenberg/crypto/schnorr/c_bind.hpp b/barretenberg/cpp/src/barretenberg/crypto/schnorr/c_bind.hpp index ba2049cc1e77..f18caabe3fe9 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/schnorr/c_bind.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/schnorr/c_bind.hpp @@ -7,7 +7,7 @@ extern "C" { using namespace bb; using affine_element = grumpkin::g1::affine_element; -using multisig = crypto::schnorr_multisig; +using multisig = crypto::schnorr::multisig; WASM_EXPORT void schnorr_compute_public_key(fr::in_buf private_key, affine_element::out_buf public_key_buf); WASM_EXPORT void schnorr_negate_public_key(affine_element::in_buf public_key_buffer, affine_element::out_buf output); diff --git a/barretenberg/cpp/src/barretenberg/crypto/schnorr/multisig.hpp b/barretenberg/cpp/src/barretenberg/crypto/schnorr/multisig.hpp index 4d48bfaec94f..7cafe9de2b30 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/schnorr/multisig.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/schnorr/multisig.hpp @@ -12,7 +12,7 @@ #include "proof_of_possession.hpp" #include "schnorr.hpp" -namespace bb::crypto { +namespace crypto::schnorr { /** * @brief Implements the SpeedyMuSig protocol; a secure 2-round interactive multisignature scheme @@ -25,7 +25,7 @@ namespace bb::crypto { * * @details SpeedyMuSig paper at https://eprint.iacr.org/2021/1375.pdf */ -template class schnorr_multisig { +template class multisig { // ensure that a different hash function is used for signature and proof of possession/nonce. // we can apply domain separation for HashRegNon but not for HashSig, so this ensures all hash functions @@ -37,7 +37,7 @@ template cl using Fr = typename G1::subgroup_field; using affine_element = typename G1::affine_element; using element = typename G1::element; - using key_pair = crypto::schnorr_key_pair; + using key_pair = crypto::schnorr::key_pair; /** * @brief MultiSigPublicKey wraps a signer's public key g1::affine_element @@ -56,7 +56,7 @@ template cl affine_element public_key = G1::affine_point_at_infinity; // proof of knowledge of the secret_key for public_key - SchnorrProofOfPossession proof_of_possession; + ProofOfPossession proof_of_possession; // For serialization, update with any new fields MSGPACK_FIELDS(public_key, proof_of_possession); @@ -69,15 +69,15 @@ template cl {} // Needed to appease MSGPACK_FIELDS MultiSigPublicKey(const affine_element& public_key, - const SchnorrProofOfPossession& proof_of_possession) + const ProofOfPossession& proof_of_possession) : public_key(public_key) , proof_of_possession(proof_of_possession) {} }; struct RoundOnePrivateOutput { - using in_buf = const uint8_t*; - using out_buf = uint8_t*; + typedef uint8_t const* in_buf; + typedef uint8_t* out_buf; Fr r; Fr s; @@ -86,10 +86,10 @@ template cl }; struct RoundOnePublicOutput { - using in_buf = const uint8_t*; - using vec_in_buf = const uint8_t*; - using out_buf = uint8_t*; - using vec_out_buf = uint8_t**; + typedef uint8_t const* in_buf; + typedef uint8_t const* vec_in_buf; + typedef uint8_t* out_buf; + typedef uint8_t** vec_out_buf; // R = r⋅G affine_element R; @@ -371,7 +371,7 @@ template cl affine_element R = construct_multisig_nonce(a, round_1_nonces); // Now we have the multisig nonce, compute schnorr challenge e (termed `c` in the speedyMuSig paper) - auto e_buf = schnorr_generate_challenge(message, *aggregate_pubkey, R); + auto e_buf = generate_schnorr_challenge(message, *aggregate_pubkey, R); Fr e = Fr::serialize_from_buffer(&e_buf[0]); // output of round 2 is z @@ -391,7 +391,7 @@ template cl * @return signature it's a Schnorr signature! Looks identical to a regular non-multisig Schnorr signature. * @return std::nullopt if any of the signature shares are invalid */ - static std::optional combine_signatures( + static std::optional combine_signatures( const std::string& message, const std::vector& signer_pubkeys, const std::vector& round_1_nonces, @@ -423,9 +423,9 @@ template cl // compute aggregate nonce R = R1 + ... + Rn + S1 * a + ... + Sn * a affine_element R = construct_multisig_nonce(a, round_1_nonces); - auto e_buf = schnorr_generate_challenge(message, *aggregate_pubkey, R); + auto e_buf = generate_schnorr_challenge(message, *aggregate_pubkey, R); - schnorr_signature sig; + signature sig; // copy e as its raw bit representation (without modular reduction) std::copy(e_buf.begin(), e_buf.end(), sig.e.begin()); @@ -437,11 +437,11 @@ template cl Fr::serialize_to_buffer(s, &sig.s[0]); // verify the final signature before returning - if (!schnorr_verify_signature(message, *aggregate_pubkey, sig)) { + if (!verify_signature(message, *aggregate_pubkey, sig)) { return std::nullopt; } return sig; } }; -} // namespace bb::crypto +} // namespace crypto::schnorr diff --git a/barretenberg/cpp/src/barretenberg/crypto/schnorr/multisig.test.cpp b/barretenberg/cpp/src/barretenberg/crypto/schnorr/multisig.test.cpp index fdff67dfdfb5..e21f8231e7b2 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/schnorr/multisig.test.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/schnorr/multisig.test.cpp @@ -8,8 +8,8 @@ using namespace bb; template struct MultisigTest : public ::testing::Test { using G = grumpkin::g1; using Fr = grumpkin::fr; - using KeyPair = crypto::schnorr_key_pair; - using multisig = crypto::schnorr_multisig; + using KeyPair = crypto::schnorr::key_pair; + using multisig = crypto::schnorr::multisig; using multisig_public_key = typename multisig::MultiSigPublicKey; static KeyPair generate_account() @@ -31,9 +31,9 @@ template struct MultisigTest : public ::testing::Test { return signer_pubkeys; } - static std::optional create_multisig(const std::string& message, - const std::vector& accounts, - const bool tamper_proof_of_possession = false) + static std::optional create_multisig(const std::string& message, + const std::vector& accounts, + const bool tamper_proof_of_possession = false) { std::vector round1_pub; std::vector round1_priv; @@ -70,8 +70,8 @@ TYPED_TEST(MultisigTest, verify_multi_signature_blake2s) using G = grumpkin::g1; using Fr = grumpkin::fr; using Fq = grumpkin::fq; - using KeyPair = crypto::schnorr_key_pair; - using multisig = crypto::schnorr_multisig; + using KeyPair = crypto::schnorr::key_pair; + using multisig = crypto::schnorr::multisig; std::string message = "The quick brown dog jumped over the lazy fox."; @@ -88,7 +88,7 @@ TYPED_TEST(MultisigTest, verify_multi_signature_blake2s) auto pub_key = multisig::validate_and_combine_signer_pubkeys(this->create_signer_pubkeys(accounts)); ASSERT_TRUE(pub_key.has_value()); - bool result = crypto::schnorr_verify_signature(message, *pub_key, *signature); + bool result = crypto::schnorr::verify_signature(message, *pub_key, *signature); EXPECT_EQ(result, true); } @@ -97,7 +97,7 @@ TYPED_TEST(MultisigTest, multi_signature_fails_if_proof_of_possession_invalid) { using G = grumpkin::g1; using Fr = grumpkin::fr; - using KeyPair = crypto::schnorr_key_pair; + using KeyPair = crypto::schnorr::key_pair; std::string message = "The quick brown dog jumped over the lazy fox."; @@ -116,7 +116,7 @@ TYPED_TEST(MultisigTest, multi_signature_fails_if_duplicates) { using G = grumpkin::g1; using Fr = grumpkin::fr; - using KeyPair = crypto::schnorr_key_pair; + using KeyPair = crypto::schnorr::key_pair; std::string message = "The quick brown dog jumped over the lazy fox."; diff --git a/barretenberg/cpp/src/barretenberg/crypto/schnorr/proof_of_possession.hpp b/barretenberg/cpp/src/barretenberg/crypto/schnorr/proof_of_possession.hpp index f99878900c58..eea7cc202dc0 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/schnorr/proof_of_possession.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/schnorr/proof_of_possession.hpp @@ -5,7 +5,7 @@ #include "barretenberg/common/serialize.hpp" #include "schnorr.hpp" -namespace bb::crypto { +namespace crypto::schnorr { /** * @brief A proof of possession is a Schnorr proof of knowledge of a secret key corresponding to a given public key. @@ -15,12 +15,12 @@ namespace bb::crypto { * @tparam G1 group over which the key pair was generated * @tparam Hash function used to derive the Fiat-Shamir challenge */ -template struct SchnorrProofOfPossession { +template struct ProofOfPossession { using Fq = typename G1::coordinate_field; using Fr = typename G1::subgroup_field; using affine_element = typename G1::affine_element; using element = typename G1::element; - using key_pair = crypto::schnorr_key_pair; + using key_pair = crypto::schnorr::key_pair; // challenge = e = H_reg(pk,pk,R) std::array challenge; @@ -28,7 +28,7 @@ template struct SchnorrProofOfPossession { Fr response = Fr::zero(); // restore default constructor to enable deserialization - SchnorrProofOfPossession() = default; + ProofOfPossession() = default; /** * @brief Create a new proof of possession for a given account. @@ -37,7 +37,7 @@ template struct SchnorrProofOfPossession { * * @param account a key_pair (secret_key, public_key) */ - SchnorrProofOfPossession(const key_pair& account) + ProofOfPossession(const key_pair& account) { auto secret_key = account.private_key; auto public_key = account.public_key; @@ -121,17 +121,17 @@ template struct SchnorrProofOfPossession { }; template -inline void read(B& it, SchnorrProofOfPossession& proof_of_possession) +inline void read(B& it, ProofOfPossession& proof_of_possession) { read(it, proof_of_possession.challenge); read(it, proof_of_possession.response); } template -inline void write(B& buf, SchnorrProofOfPossession const& proof_of_possession) +inline void write(B& buf, ProofOfPossession const& proof_of_possession) { write(buf, proof_of_possession.challenge); write(buf, proof_of_possession.response); } -} // namespace bb::crypto +} // namespace crypto::schnorr diff --git a/barretenberg/cpp/src/barretenberg/crypto/schnorr/proof_of_possession.test.cpp b/barretenberg/cpp/src/barretenberg/crypto/schnorr/proof_of_possession.test.cpp index 6432209fc851..92f46cc3ebaa 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/schnorr/proof_of_possession.test.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/schnorr/proof_of_possession.test.cpp @@ -8,7 +8,7 @@ using namespace bb; template struct ProofOfPossessionTest : public ::testing::Test { using G = grumpkin::g1; using Fr = grumpkin::fr; - using KeyPair = crypto::schnorr_key_pair; + using KeyPair = crypto::schnorr::key_pair; static KeyPair generate_account() { @@ -26,7 +26,7 @@ TYPED_TEST(ProofOfPossessionTest, valid_proof) { using G = grumpkin::g1; using Hash = TypeParam; - using Proof = crypto::SchnorrProofOfPossession; + using Proof = crypto::schnorr::ProofOfPossession; const auto account = this->generate_account(); const auto proof = Proof(account); @@ -37,7 +37,7 @@ TYPED_TEST(ProofOfPossessionTest, invalid_empty_proof) { using G = grumpkin::g1; using Hash = TypeParam; - using Proof = crypto::SchnorrProofOfPossession; + using Proof = crypto::schnorr::ProofOfPossession; const auto account = this->generate_account(); const auto proof = Proof(); @@ -48,7 +48,7 @@ TYPED_TEST(ProofOfPossessionTest, fail_with_different_account) { using G = grumpkin::g1; using Hash = TypeParam; - using Proof = crypto::SchnorrProofOfPossession; + using Proof = crypto::schnorr::ProofOfPossession; const auto account1 = this->generate_account(); const auto account2 = this->generate_account(); @@ -60,7 +60,7 @@ TYPED_TEST(ProofOfPossessionTest, fail_zero_challenge) { using G = grumpkin::g1; using Hash = TypeParam; - using Proof = crypto::SchnorrProofOfPossession; + using Proof = crypto::schnorr::ProofOfPossession; const auto account = this->generate_account(); auto proof = Proof(account); @@ -74,7 +74,7 @@ TYPED_TEST(ProofOfPossessionTest, fail_zero_response) { using G = grumpkin::g1; using Hash = TypeParam; - using Proof = crypto::SchnorrProofOfPossession; + using Proof = crypto::schnorr::ProofOfPossession; const auto account = this->generate_account(); auto proof = Proof(account); @@ -87,7 +87,7 @@ TYPED_TEST(ProofOfPossessionTest, serialize) { using G = grumpkin::g1; using Hash = TypeParam; - using Proof = crypto::SchnorrProofOfPossession; + using Proof = crypto::schnorr::ProofOfPossession; const auto account = this->generate_account(); const auto proof = Proof(account); EXPECT_TRUE(proof.verify(account.public_key)); diff --git a/barretenberg/cpp/src/barretenberg/crypto/schnorr/schnorr.hpp b/barretenberg/cpp/src/barretenberg/crypto/schnorr/schnorr.hpp index 81ca306effc6..516e50038c19 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/schnorr/schnorr.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/schnorr/schnorr.hpp @@ -12,8 +12,9 @@ #include "barretenberg/common/streams.hpp" #include "barretenberg/serialize/msgpack.hpp" -namespace bb::crypto { -template struct schnorr_key_pair { +namespace crypto { +namespace schnorr { +template struct key_pair { Fr private_key; typename G1::affine_element public_key; }; @@ -21,7 +22,7 @@ template struct schnorr_key_pair { // Raw representation of a Schnorr signature (e,s). We use the short variant of Schnorr // where we include the challenge hash `e` instead of the group element R representing // the provers initial message. -struct schnorr_signature { +struct signature { // `s` is a serialized field element (also 32 bytes), representing the prover's response to // to the verifier challenge `e`. @@ -35,34 +36,33 @@ struct schnorr_signature { }; template -bool schnorr_verify_signature(const std::string& message, - const typename G1::affine_element& public_key, - const schnorr_signature& sig); +bool verify_signature(const std::string& message, const typename G1::affine_element& public_key, const signature& sig); template -schnorr_signature schnorr_construct_signature(const std::string& message, const schnorr_key_pair& account); +signature construct_signature(const std::string& message, const key_pair& account); -inline bool operator==(schnorr_signature const& lhs, schnorr_signature const& rhs) +inline bool operator==(signature const& lhs, signature const& rhs) { return lhs.s == rhs.s && lhs.e == rhs.e; } -inline std::ostream& operator<<(std::ostream& os, schnorr_signature const& sig) +inline std::ostream& operator<<(std::ostream& os, signature const& sig) { os << "{ " << sig.s << ", " << sig.e << " }"; return os; } -template inline void read(B& it, schnorr_key_pair& keypair) +template inline void read(B& it, key_pair& keypair) { read(it, keypair.private_key); read(it, keypair.public_key); } -template inline void write(B& buf, schnorr_key_pair const& keypair) +template inline void write(B& buf, key_pair const& keypair) { write(buf, keypair.private_key); write(buf, keypair.public_key); } -} // namespace bb::crypto +} // namespace schnorr +} // namespace crypto #include "./schnorr.tcc" diff --git a/barretenberg/cpp/src/barretenberg/crypto/schnorr/schnorr.tcc b/barretenberg/cpp/src/barretenberg/crypto/schnorr/schnorr.tcc index 455101e75489..6156301bfed5 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/schnorr/schnorr.tcc +++ b/barretenberg/cpp/src/barretenberg/crypto/schnorr/schnorr.tcc @@ -5,7 +5,8 @@ #include "schnorr.hpp" -namespace bb::crypto { +namespace crypto { +namespace schnorr { /** * @brief Generate the schnorr signature challenge parameter `e` given a message, signer pubkey and nonce @@ -36,7 +37,7 @@ namespace bb::crypto { * are always private inputs to circuits) then nothing would be revealed anyway. */ template -static auto schnorr_generate_challenge(const std::string& message, +static auto generate_schnorr_challenge(const std::string& message, const typename G1::affine_element& pubkey, const typename G1::affine_element& R) { @@ -70,7 +71,7 @@ static auto schnorr_generate_challenge(const std::string& message, * @return signature */ template -schnorr_signature schnorr_construct_signature(const std::string& message, const schnorr_key_pair& account) +signature construct_signature(const std::string& message, const key_pair& account) { // sanity check to ensure our hash function produces `e_raw` // of exactly 32 bytes. @@ -93,7 +94,7 @@ schnorr_signature schnorr_construct_signature(const std::string& message, const typename G1::affine_element R(G1::one * k); - auto e_raw = schnorr_generate_challenge(message, public_key, R); + auto e_raw = generate_schnorr_challenge(message, public_key, R); // the conversion from e_raw results in a biased field element e Fr e = Fr::serialize_from_buffer(&e_raw[0]); Fr s = k - (private_key * e); @@ -105,19 +106,17 @@ schnorr_signature schnorr_construct_signature(const std::string& message, const // and e = e_uint % r, where r is the order of the curve, // and pk as the point representing the public_key, // then e•pk = e_uint•pk - schnorr_signature sig; + signature sig; Fr::serialize_to_buffer(s, &sig.s[0]); std::copy(e_raw.begin(), e_raw.end(), sig.e.begin()); return sig; } /** - * @brief Verify a Schnorr signature of the sort produced by schnorr_construct_signature. + * @brief Verify a Schnorr signature of the sort produced by construct_signature. */ template -bool schnorr_verify_signature(const std::string& message, - const typename G1::affine_element& public_key, - const schnorr_signature& sig) +bool verify_signature(const std::string& message, const typename G1::affine_element& public_key, const signature& sig) { using affine_element = typename G1::affine_element; using element = typename G1::element; @@ -150,7 +149,8 @@ bool schnorr_verify_signature(const std::string& message, // compare the _hashes_ rather than field elements modulo r // e = H(pedersen(r, pk.x, pk.y), m), where r = x(R) - auto target_e = schnorr_generate_challenge(message, public_key, R); + auto target_e = generate_schnorr_challenge(message, public_key, R); return std::equal(sig.e.begin(), sig.e.end(), target_e.begin(), target_e.end()); } -} // namespace bb::crypto +} // namespace schnorr +} // namespace crypto diff --git a/barretenberg/cpp/src/barretenberg/crypto/schnorr/schnorr.test.cpp b/barretenberg/cpp/src/barretenberg/crypto/schnorr/schnorr.test.cpp index 6946053a4a88..8890d4a5454d 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/schnorr/schnorr.test.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/schnorr/schnorr.test.cpp @@ -3,11 +3,11 @@ #include using namespace bb; -using namespace bb::crypto; +using namespace crypto::schnorr; -crypto::schnorr_key_pair generate_signature() +crypto::schnorr::key_pair generate_signature() { - crypto::schnorr_key_pair account; + crypto::schnorr::key_pair account; account.private_key = grumpkin::fr::random_element(); account.public_key = grumpkin::g1::one * account.private_key; return account; @@ -17,14 +17,14 @@ TEST(schnorr, verify_signature_keccak256) { std::string message = "The quick brown fox jumped over the lazy dog."; - crypto::schnorr_key_pair account; + crypto::schnorr::key_pair account; account.private_key = grumpkin::fr::random_element(); account.public_key = grumpkin::g1::one * account.private_key; - crypto::schnorr_signature signature = - crypto::schnorr_construct_signature(message, account); + crypto::schnorr::signature signature = + crypto::schnorr::construct_signature(message, account); - bool result = crypto::schnorr_verify_signature( + bool result = crypto::schnorr::verify_signature( message, account.public_key, signature); EXPECT_EQ(result, true); @@ -34,14 +34,14 @@ TEST(schnorr, verify_signature_sha256) { std::string message = "The quick brown dog jumped over the lazy fox."; - crypto::schnorr_key_pair account; + crypto::schnorr::key_pair account; account.private_key = grumpkin::fr::random_element(); account.public_key = grumpkin::g1::one * account.private_key; - crypto::schnorr_signature signature = - crypto::schnorr_construct_signature(message, account); + crypto::schnorr::signature signature = + crypto::schnorr::construct_signature(message, account); - bool result = crypto::schnorr_verify_signature( + bool result = crypto::schnorr::verify_signature( message, account.public_key, signature); EXPECT_EQ(result, true); @@ -51,15 +51,15 @@ TEST(schnorr, verify_signature_blake2s) { std::string message = "The quick brown dog jumped over the lazy fox."; - crypto::schnorr_key_pair account; + crypto::schnorr::key_pair account; // account.private_key = grumpkin::fr::random_element(); account.private_key = { 0x55555555, 0x55555555, 0x55555555, 0x55555555 }; account.public_key = grumpkin::g1::one * account.private_key; - crypto::schnorr_signature signature = - crypto::schnorr_construct_signature(message, account); + crypto::schnorr::signature signature = + crypto::schnorr::construct_signature(message, account); - bool result = crypto::schnorr_verify_signature( + bool result = crypto::schnorr::verify_signature( message, account.public_key, signature); EXPECT_EQ(result, true); @@ -78,62 +78,62 @@ TEST(schnorr, hmac_signature_consistency) // k is no longer identical, so signatures should be different. auto signature_a = - schnorr_construct_signature(message_a, account_a); + construct_signature(message_a, account_a); auto signature_b = - schnorr_construct_signature(message_a, account_a); + construct_signature(message_a, account_a); ASSERT_NE(signature_a.e, signature_b.e); ASSERT_NE(signature_a.s, signature_b.s); // same message, different accounts should give different sigs! auto signature_c = - schnorr_construct_signature(message_a, account_a); + construct_signature(message_a, account_a); auto signature_d = - schnorr_construct_signature(message_a, account_b); + construct_signature(message_a, account_b); ASSERT_NE(signature_c.e, signature_d.e); ASSERT_NE(signature_c.s, signature_d.s); // different message, same accounts should give different sigs! auto signature_e = - schnorr_construct_signature(message_a, account_a); + construct_signature(message_a, account_a); auto signature_f = - schnorr_construct_signature(message_b, account_a); + construct_signature(message_b, account_a); ASSERT_NE(signature_e.e, signature_f.e); ASSERT_NE(signature_e.s, signature_f.s); // different message, different accounts should give different sigs!! auto signature_g = - schnorr_construct_signature(message_a, account_a); + construct_signature(message_a, account_a); auto signature_h = - schnorr_construct_signature(message_b, account_b); + construct_signature(message_b, account_b); ASSERT_NE(signature_g.e, signature_h.e); ASSERT_NE(signature_g.s, signature_h.s); - bool res = schnorr_verify_signature( + bool res = verify_signature( message_a, account_a.public_key, signature_a); EXPECT_EQ(res, true); - res = schnorr_verify_signature( + res = verify_signature( message_a, account_a.public_key, signature_b); EXPECT_EQ(res, true); - res = schnorr_verify_signature( + res = verify_signature( message_a, account_a.public_key, signature_c); EXPECT_EQ(res, true); - res = schnorr_verify_signature( + res = verify_signature( message_a, account_b.public_key, signature_d); EXPECT_EQ(res, true); - res = schnorr_verify_signature( + res = verify_signature( message_a, account_a.public_key, signature_e); EXPECT_EQ(res, true); - res = schnorr_verify_signature( + res = verify_signature( message_b, account_a.public_key, signature_f); EXPECT_EQ(res, true); - res = schnorr_verify_signature( + res = verify_signature( message_a, account_a.public_key, signature_g); EXPECT_EQ(res, true); - res = schnorr_verify_signature( + res = verify_signature( message_b, account_b.public_key, signature_h); EXPECT_EQ(res, true); } diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp index 0fb5cebbe555..7299d359bc3b 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp @@ -6,7 +6,7 @@ namespace acir_format { template -void build_constraints(Builder& builder, AcirFormat const& constraint_system, bool has_valid_witness_assignments) +void build_constraints(Builder& builder, acir_format const& constraint_system, bool has_valid_witness_assignments) { // Add arithmetic gates for (const auto& constraint : constraint_system.constraints) { @@ -94,14 +94,6 @@ void build_constraints(Builder& builder, AcirFormat const& constraint_system, bo create_block_constraints(builder, constraint, has_valid_witness_assignments); } - // Add big_int constraints - for (const auto& constraint : constraint_system.bigint_operations) { - create_bigint_operations_constraint(builder, constraint); - } - for (const auto& constraint : constraint_system.bigint_from_le_bytes_constraints) { - create_bigint_from_le_bytes_constraint(builder, constraint); - } - // TODO(https://github.com/AztecProtocol/barretenberg/issues/817): disable these for UGH for now since we're not yet // dealing with proper recursion if constexpr (IsGoblinBuilder) { @@ -196,7 +188,7 @@ void build_constraints(Builder& builder, AcirFormat const& constraint_system, bo * @return Builder */ template -Builder create_circuit(const AcirFormat& constraint_system, size_t size_hint, WitnessVector const& witness) +Builder create_circuit(const acir_format& constraint_system, size_t size_hint, WitnessVector const& witness) { Builder builder{ size_hint, witness, constraint_system.public_inputs, constraint_system.varnum }; @@ -206,9 +198,9 @@ Builder create_circuit(const AcirFormat& constraint_system, size_t size_hint, Wi return builder; } -template UltraCircuitBuilder create_circuit(const AcirFormat& constraint_system, +template UltraCircuitBuilder create_circuit(const acir_format& constraint_system, size_t size_hint, WitnessVector const& witness); -template void build_constraints(GoblinUltraCircuitBuilder&, AcirFormat const&, bool); +template void build_constraints(GoblinUltraCircuitBuilder&, acir_format const&, bool); } // namespace acir_format diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.hpp index 82cf7eccad33..1cd81b2edbbe 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.hpp @@ -1,7 +1,6 @@ #pragma once #include "barretenberg/common/slab_allocator.hpp" #include "barretenberg/serialize/msgpack.hpp" -#include "bigint_constraint.hpp" #include "blake2s_constraint.hpp" #include "blake3_constraint.hpp" #include "block_constraint.hpp" @@ -19,7 +18,7 @@ namespace acir_format { -struct AcirFormat { +struct acir_format { // The number of witnesses in the circuit uint32_t varnum; @@ -42,8 +41,6 @@ struct AcirFormat { std::vector ec_add_constraints; std::vector ec_double_constraints; std::vector recursion_constraints; - std::vector bigint_from_le_bytes_constraints; - std::vector bigint_operations; // A standard plonk arithmetic constraint, as defined in the poly_triple struct, consists of selector values // for q_M,q_L,q_R,q_O,q_C and indices of three variables taking the role of left, right and output wire @@ -72,19 +69,17 @@ struct AcirFormat { fixed_base_scalar_mul_constraints, recursion_constraints, constraints, - block_constraints, - bigint_from_le_bytes_constraints, - bigint_operations); + block_constraints); - friend bool operator==(AcirFormat const& lhs, AcirFormat const& rhs) = default; + friend bool operator==(acir_format const& lhs, acir_format const& rhs) = default; }; using WitnessVector = std::vector>; template -Builder create_circuit(const AcirFormat& constraint_system, size_t size_hint = 0, WitnessVector const& witness = {}); +Builder create_circuit(const acir_format& constraint_system, size_t size_hint = 0, WitnessVector const& witness = {}); template -void build_constraints(Builder& builder, AcirFormat const& constraint_system, bool has_valid_witness_assignments); +void build_constraints(Builder& builder, acir_format const& constraint_system, bool has_valid_witness_assignments); } // namespace acir_format diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.test.cpp index 8804cd0c573f..7aa0a0364ff4 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.test.cpp @@ -7,7 +7,7 @@ #include "barretenberg/serialize/test_helper.hpp" #include "ecdsa_secp256k1.hpp" -using namespace acir_format; +namespace acir_format::tests { class AcirFormatTests : public ::testing::Test { protected: @@ -27,7 +27,7 @@ TEST_F(AcirFormatTests, TestASingleConstraintNoPubInputs) .q_c = 0, }; - AcirFormat constraint_system{ + acir_format constraint_system{ .varnum = 4, .public_inputs = {}, .logic_constraints = {}, @@ -47,8 +47,6 @@ TEST_F(AcirFormatTests, TestASingleConstraintNoPubInputs) .ec_add_constraints = {}, .ec_double_constraints = {}, .recursion_constraints = {}, - .bigint_from_le_bytes_constraints = {}, - .bigint_operations = {}, .constraints = { constraint }, .block_constraints = {}, }; @@ -141,29 +139,27 @@ TEST_F(AcirFormatTests, TestLogicGateFromNoirCircuit) // EXPR [ (1, _4, _6) (-1, _4) 0 ] // EXPR [ (-1, _6) 1 ] - AcirFormat constraint_system{ .varnum = 6, - .public_inputs = { 1 }, - .logic_constraints = { logic_constraint }, - .range_constraints = { range_a, range_b }, - .sha256_constraints = {}, - .schnorr_constraints = {}, - .ecdsa_k1_constraints = {}, - .ecdsa_r1_constraints = {}, - .blake2s_constraints = {}, - .blake3_constraints = {}, - .keccak_constraints = {}, - .keccak_var_constraints = {}, - .keccak_permutations = {}, - .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, - .fixed_base_scalar_mul_constraints = {}, - .ec_add_constraints = {}, - .ec_double_constraints = {}, - .recursion_constraints = {}, - .bigint_from_le_bytes_constraints = {}, - .bigint_operations = {}, - .constraints = { expr_a, expr_b, expr_c, expr_d }, - .block_constraints = {} }; + acir_format constraint_system{ .varnum = 6, + .public_inputs = { 1 }, + .logic_constraints = { logic_constraint }, + .range_constraints = { range_a, range_b }, + .sha256_constraints = {}, + .schnorr_constraints = {}, + .ecdsa_k1_constraints = {}, + .ecdsa_r1_constraints = {}, + .blake2s_constraints = {}, + .blake3_constraints = {}, + .keccak_constraints = {}, + .keccak_var_constraints = {}, + .keccak_permutations = {}, + .pedersen_constraints = {}, + .pedersen_hash_constraints = {}, + .fixed_base_scalar_mul_constraints = {}, + .ec_add_constraints = {}, + .ec_double_constraints = {}, + .recursion_constraints = {}, + .constraints = { expr_a, expr_b, expr_c, expr_d }, + .block_constraints = {} }; uint256_t inverse_of_five = fr(5).invert(); WitnessVector witness{ @@ -206,46 +202,44 @@ TEST_F(AcirFormatTests, TestSchnorrVerifyPass) .result = 76, .signature = signature, }; - AcirFormat constraint_system{ .varnum = 81, - .public_inputs = {}, - .logic_constraints = {}, - .range_constraints = range_constraints, - .sha256_constraints = {}, - .schnorr_constraints = { schnorr_constraint }, - .ecdsa_k1_constraints = {}, - .ecdsa_r1_constraints = {}, - .blake2s_constraints = {}, - .blake3_constraints = {}, - .keccak_constraints = {}, - .keccak_var_constraints = {}, - .keccak_permutations = {}, - .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, - .fixed_base_scalar_mul_constraints = {}, - .ec_add_constraints = {}, - .ec_double_constraints = {}, - .recursion_constraints = {}, - .bigint_from_le_bytes_constraints = {}, - .bigint_operations = {}, - .constraints = { poly_triple{ - .a = schnorr_constraint.result, - .b = schnorr_constraint.result, - .c = schnorr_constraint.result, - .q_m = 0, - .q_l = 0, - .q_r = 0, - .q_o = 1, - .q_c = fr::neg_one(), - } }, - .block_constraints = {} }; + acir_format constraint_system{ .varnum = 81, + .public_inputs = {}, + .logic_constraints = {}, + .range_constraints = range_constraints, + .sha256_constraints = {}, + .schnorr_constraints = { schnorr_constraint }, + .ecdsa_k1_constraints = {}, + .ecdsa_r1_constraints = {}, + .blake2s_constraints = {}, + .blake3_constraints = {}, + .keccak_constraints = {}, + .keccak_var_constraints = {}, + .keccak_permutations = {}, + .pedersen_constraints = {}, + .pedersen_hash_constraints = {}, + .fixed_base_scalar_mul_constraints = {}, + .ec_add_constraints = {}, + .ec_double_constraints = {}, + .recursion_constraints = {}, + .constraints = { poly_triple{ + .a = schnorr_constraint.result, + .b = schnorr_constraint.result, + .c = schnorr_constraint.result, + .q_m = 0, + .q_l = 0, + .q_r = 0, + .q_o = 1, + .q_c = fr::neg_one(), + } }, + .block_constraints = {} }; std::string message_string = "tenletters"; - crypto::schnorr_key_pair account; + crypto::schnorr::key_pair account; account.private_key = grumpkin::fr::random_element(); account.public_key = grumpkin::g1::one * account.private_key; - crypto::schnorr_signature signature_raw = - crypto::schnorr_construct_signature(message_string, - account); + crypto::schnorr::signature signature_raw = + crypto::schnorr::construct_signature(message_string, + account); uint256_t pub_x = account.public_key.x; uint256_t pub_y = account.public_key.y; WitnessVector witness{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, pub_x, pub_y, 5, 202, 31, 146, @@ -298,7 +292,7 @@ TEST_F(AcirFormatTests, TestSchnorrVerifySmallRange) .result = 76, .signature = signature, }; - AcirFormat constraint_system{ + acir_format constraint_system{ .varnum = 81, .public_inputs = {}, .logic_constraints = {}, @@ -318,8 +312,6 @@ TEST_F(AcirFormatTests, TestSchnorrVerifySmallRange) .ec_add_constraints = {}, .ec_double_constraints = {}, .recursion_constraints = {}, - .bigint_from_le_bytes_constraints = {}, - .bigint_operations = {}, .constraints = { poly_triple{ .a = schnorr_constraint.result, .b = schnorr_constraint.result, @@ -334,12 +326,12 @@ TEST_F(AcirFormatTests, TestSchnorrVerifySmallRange) }; std::string message_string = "tenletters"; - crypto::schnorr_key_pair account; + crypto::schnorr::key_pair account; account.private_key = grumpkin::fr::random_element(); account.public_key = grumpkin::g1::one * account.private_key; - crypto::schnorr_signature signature_raw = - crypto::schnorr_construct_signature(message_string, - account); + crypto::schnorr::signature signature_raw = + crypto::schnorr::construct_signature(message_string, + account); uint256_t pub_x = account.public_key.x; uint256_t pub_y = account.public_key.y; WitnessVector witness{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, pub_x, pub_y, 5, 202, 31, 146, @@ -410,7 +402,7 @@ TEST_F(AcirFormatTests, TestVarKeccak) .q_c = fr::neg_one() * fr(4), }; - AcirFormat constraint_system{ + acir_format constraint_system{ .varnum = 36, .public_inputs = {}, .logic_constraints = {}, @@ -430,8 +422,6 @@ TEST_F(AcirFormatTests, TestVarKeccak) .ec_add_constraints = {}, .ec_double_constraints = {}, .recursion_constraints = {}, - .bigint_from_le_bytes_constraints = {}, - .bigint_operations = {}, .constraints = { dummy }, .block_constraints = {}, }; @@ -455,29 +445,27 @@ TEST_F(AcirFormatTests, TestKeccakPermutation) 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50 }, }; - AcirFormat constraint_system{ .varnum = 51, - .public_inputs = {}, - .logic_constraints = {}, - .range_constraints = {}, - .sha256_constraints = {}, - .schnorr_constraints = {}, - .ecdsa_k1_constraints = {}, - .ecdsa_r1_constraints = {}, - .blake2s_constraints = {}, - .blake3_constraints = {}, - .keccak_constraints = {}, - .keccak_var_constraints = {}, - .keccak_permutations = { keccak_permutation }, - .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, - .fixed_base_scalar_mul_constraints = {}, - .ec_add_constraints = {}, - .ec_double_constraints = {}, - .recursion_constraints = {}, - .bigint_from_le_bytes_constraints = {}, - .bigint_operations = {}, - .constraints = {}, - .block_constraints = {} }; + acir_format constraint_system{ .varnum = 51, + .public_inputs = {}, + .logic_constraints = {}, + .range_constraints = {}, + .sha256_constraints = {}, + .schnorr_constraints = {}, + .ecdsa_k1_constraints = {}, + .ecdsa_r1_constraints = {}, + .blake2s_constraints = {}, + .blake3_constraints = {}, + .keccak_constraints = {}, + .keccak_var_constraints = {}, + .keccak_permutations = { keccak_permutation }, + .pedersen_constraints = {}, + .pedersen_hash_constraints = {}, + .fixed_base_scalar_mul_constraints = {}, + .ec_add_constraints = {}, + .ec_double_constraints = {}, + .recursion_constraints = {}, + .constraints = {}, + .block_constraints = {} }; WitnessVector witness{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, @@ -493,3 +481,5 @@ TEST_F(AcirFormatTests, TestKeccakPermutation) EXPECT_EQ(verifier.verify_proof(proof), true); } + +} // namespace acir_format::tests diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp index 5d6cf0063b86..4e6b0f8a617d 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp @@ -2,7 +2,6 @@ #include "acir_format.hpp" #include "barretenberg/common/container.hpp" #include "barretenberg/common/throw_or_abort.hpp" -#include "barretenberg/dsl/acir_format/bigint_constraint.hpp" #include "barretenberg/dsl/acir_format/blake2s_constraint.hpp" #include "barretenberg/dsl/acir_format/blake3_constraint.hpp" #include "barretenberg/dsl/acir_format/block_constraint.hpp" @@ -97,12 +96,12 @@ poly_triple serialize_arithmetic_gate(Circuit::Expression const& arg) return pt; } -void handle_arithmetic(Circuit::Opcode::AssertZero const& arg, AcirFormat& af) +void handle_arithmetic(Circuit::Opcode::AssertZero const& arg, acir_format& af) { af.constraints.push_back(serialize_arithmetic_gate(arg.value)); } -void handle_blackbox_func_call(Circuit::Opcode::BlackBoxFuncCall const& arg, AcirFormat& af) +void handle_blackbox_func_call(Circuit::Opcode::BlackBoxFuncCall const& arg, acir_format& af) { std::visit( [&](auto&& arg) { @@ -241,40 +240,6 @@ void handle_blackbox_func_call(Circuit::Opcode::BlackBoxFuncCall const& arg, Aci .key_hash = arg.key_hash.witness.value, }; af.recursion_constraints.push_back(c); - } else if constexpr (std::is_same_v) { - af.bigint_from_le_bytes_constraints.push_back(BigIntFromLeBytes{ - .inputs = map(arg.inputs, [](auto& e) { return e.witness.value; }), - .modulus = map(arg.modulus, [](auto& e) -> uint32_t { return e; }), - .result = arg.output, - }); - } else if constexpr (std::is_same_v) { - af.bigint_operations.push_back(BigIntOperation{ - .lhs = arg.lhs, - .rhs = arg.rhs, - .result = arg.output, - .opcode = BigIntOperationType::Add, - }); - } else if constexpr (std::is_same_v) { - af.bigint_operations.push_back(BigIntOperation{ - .lhs = arg.lhs, - .rhs = arg.rhs, - .result = arg.output, - .opcode = BigIntOperationType::Neg, - }); - } else if constexpr (std::is_same_v) { - af.bigint_operations.push_back(BigIntOperation{ - .lhs = arg.lhs, - .rhs = arg.rhs, - .result = arg.output, - .opcode = BigIntOperationType::Mul, - }); - } else if constexpr (std::is_same_v) { - af.bigint_operations.push_back(BigIntOperation{ - .lhs = arg.lhs, - .rhs = arg.rhs, - .result = arg.output, - .opcode = BigIntOperationType::Div, - }); } }, arg.value.value); @@ -324,11 +289,11 @@ void handle_memory_op(Circuit::Opcode::MemoryOp const& mem_op, BlockConstraint& block.trace.push_back(acir_mem_op); } -AcirFormat circuit_buf_to_acir_format(std::vector const& buf) +acir_format circuit_buf_to_acir_format(std::vector const& buf) { auto circuit = Circuit::Circuit::bincodeDeserialize(buf); - AcirFormat af; + acir_format af; // `varnum` is the true number of variables, thus we add one to the index which starts at zero af.varnum = circuit.current_witness_index + 1; af.public_inputs = join({ map(circuit.public_parameters.value, [](auto e) { return e.value; }), diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/bigint_constraint.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/bigint_constraint.cpp deleted file mode 100644 index 4780e5ca36c6..000000000000 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/bigint_constraint.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "bigint_constraint.hpp" -#include "barretenberg/dsl/types.hpp" -#include "barretenberg/numeric/uint256/uint256.hpp" -#include "barretenberg/stdlib/primitives/bigfield/bigfield.hpp" - -namespace acir_format { - -template void create_bigint_operations_constraint(Builder& builder, const BigIntOperation& input) -{ - // TODO - (void)builder; - info(input); -} - -template void create_bigint_operations_constraint(UltraCircuitBuilder& builder, - const BigIntOperation& input); -template void create_bigint_operations_constraint(GoblinUltraCircuitBuilder& builder, - const BigIntOperation& input); - -template -void create_bigint_from_le_bytes_constraint(Builder& builder, const BigIntFromLeBytes& input) -{ - // TODO - (void)builder; - info(input); -} - -template void create_bigint_from_le_bytes_constraint(UltraCircuitBuilder& builder, - const BigIntFromLeBytes& input); -template void create_bigint_from_le_bytes_constraint(GoblinUltraCircuitBuilder& builder, - const BigIntFromLeBytes& input); - -} // namespace acir_format diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/bigint_constraint.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/bigint_constraint.hpp deleted file mode 100644 index 8b21ee5e7840..000000000000 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/bigint_constraint.hpp +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once -#include "barretenberg/dsl/types.hpp" -#include "barretenberg/serialize/msgpack.hpp" -#include -#include - -namespace acir_format { - -struct BigIntFromLeBytes { - std::vector inputs; - std::vector modulus; - uint32_t result; - - // For serialization, update with any new fields - MSGPACK_FIELDS(inputs, result); - friend bool operator==(BigIntFromLeBytes const& lhs, BigIntFromLeBytes const& rhs) = default; -}; - -enum BigIntOperationType { Add, Neg, Mul, Div }; - -struct BigIntOperation { - uint32_t lhs; - uint32_t rhs; - uint32_t result; - BigIntOperationType opcode; - - // For serialization, update with any new fields - MSGPACK_FIELDS(lhs, rhs, opcode, result); - friend bool operator==(BigIntOperation const& lhs, BigIntOperation const& rhs) = default; -}; - -template void create_bigint_operations_constraint(Builder& builder, const BigIntOperation& input); -template -void create_bigint_from_le_bytes_constraint(Builder& builder, const BigIntFromLeBytes& input); -} // namespace acir_format \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/bigint_constraint.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/bigint_constraint.test.cpp deleted file mode 100644 index 0762bfd783a8..000000000000 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/bigint_constraint.test.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include "bigint_constraint.hpp" -#include "acir_format.hpp" -#include "barretenberg/plonk/proof_system/types/proof.hpp" -#include "barretenberg/plonk/proof_system/verification_key/verification_key.hpp" - -#include -#include - -namespace acir_format::tests { - -class BigIntTests : public ::testing::Test { - protected: - static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } -}; - -TEST_F(BigIntTests, TestBigIntConstraintDummy) -{ - // Dummy Test: to be updated when big ints opcodes are implemented - BigIntOperation add_constraint{ - .lhs = 1, - .rhs = 2, - .result = 3, - .opcode = BigIntOperationType::Add, - }; - BigIntOperation neg_constraint{ - .lhs = 1, - .rhs = 2, - .result = 3, - .opcode = BigIntOperationType::Neg, - }; - BigIntOperation mul_constraint{ - .lhs = 1, - .rhs = 2, - .result = 3, - .opcode = BigIntOperationType::Mul, - }; - BigIntOperation div_constraint{ - .lhs = 1, - .rhs = 2, - .result = 3, - .opcode = BigIntOperationType::Div, - }; - BigIntFromLeBytes from_le_bytes_constraint{ - .inputs = { 0 }, - .modulus = { 23 }, - .result = 1, - }; - - AcirFormat constraint_system{ - .varnum = 4, - .public_inputs = {}, - .logic_constraints = {}, - .range_constraints = {}, - .sha256_constraints = {}, - .schnorr_constraints = {}, - .ecdsa_k1_constraints = {}, - .ecdsa_r1_constraints = {}, - .blake2s_constraints = {}, - .blake3_constraints = {}, - .keccak_constraints = {}, - .keccak_var_constraints = {}, - .keccak_permutations = {}, - .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, - .fixed_base_scalar_mul_constraints = {}, - .ec_add_constraints = {}, - .ec_double_constraints = {}, - .recursion_constraints = {}, - .bigint_from_le_bytes_constraints = { from_le_bytes_constraint }, - .bigint_operations = { add_constraint, neg_constraint, mul_constraint, div_constraint }, - .constraints = {}, - .block_constraints = {}, - - }; - - WitnessVector witness{ 0, 0, 1 }; - auto builder = create_circuit(constraint_system, /*size_hint*/ 0, witness); - - auto composer = Composer(); - auto prover = composer.create_ultra_with_keccak_prover(builder); - auto proof = prover.construct_proof(); - - auto verifier = composer.create_ultra_with_keccak_verifier(builder); - - EXPECT_EQ(verifier.verify_proof(proof), true); -} - -} // namespace acir_format::tests \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/block_constraint.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/block_constraint.test.cpp index 7c0444f61912..cb87035cae53 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/block_constraint.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/block_constraint.test.cpp @@ -6,7 +6,7 @@ #include #include -using namespace acir_format; +namespace acir_format::tests { class UltraPlonkRAM : public ::testing::Test { protected: @@ -19,7 +19,7 @@ size_t generate_block_constraint(BlockConstraint& constraint, WitnessVector& wit witness_len++; fr two = fr::one() + fr::one(); - poly_triple a0{ + poly_triple a0 = poly_triple{ .a = 0, .b = 0, .c = 0, @@ -30,7 +30,7 @@ size_t generate_block_constraint(BlockConstraint& constraint, WitnessVector& wit .q_c = 0, }; fr three = fr::one() + two; - poly_triple a1{ + poly_triple a1 = poly_triple{ .a = 0, .b = 0, .c = 0, @@ -40,7 +40,7 @@ size_t generate_block_constraint(BlockConstraint& constraint, WitnessVector& wit .q_o = 0, .q_c = three, }; - poly_triple r1{ + poly_triple r1 = poly_triple{ .a = 0, .b = 0, .c = 0, @@ -50,7 +50,7 @@ size_t generate_block_constraint(BlockConstraint& constraint, WitnessVector& wit .q_o = 0, .q_c = fr::neg_one(), }; - poly_triple r2{ + poly_triple r2 = poly_triple{ .a = 0, .b = 0, .c = 0, @@ -60,7 +60,7 @@ size_t generate_block_constraint(BlockConstraint& constraint, WitnessVector& wit .q_o = 0, .q_c = fr::neg_one(), }; - poly_triple y{ + poly_triple y = poly_triple{ .a = 1, .b = 0, .c = 0, @@ -72,7 +72,7 @@ size_t generate_block_constraint(BlockConstraint& constraint, WitnessVector& wit }; witness_values.emplace_back(2); witness_len++; - poly_triple z{ + poly_triple z = poly_triple{ .a = 2, .b = 0, .c = 0, @@ -84,12 +84,12 @@ size_t generate_block_constraint(BlockConstraint& constraint, WitnessVector& wit }; witness_values.emplace_back(3); witness_len++; - MemOp op1{ + MemOp op1 = MemOp{ .access_type = 0, .index = r1, .value = y, }; - MemOp op2{ + MemOp op2 = MemOp{ .access_type = 0, .index = r2, .value = z, @@ -108,7 +108,7 @@ TEST_F(UltraPlonkRAM, TestBlockConstraint) BlockConstraint block; WitnessVector witness_values; size_t num_variables = generate_block_constraint(block, witness_values); - AcirFormat constraint_system{ + acir_format constraint_system{ .varnum = static_cast(num_variables), .public_inputs = {}, .logic_constraints = {}, @@ -128,8 +128,6 @@ TEST_F(UltraPlonkRAM, TestBlockConstraint) .ec_add_constraints = {}, .ec_double_constraints = {}, .recursion_constraints = {}, - .bigint_from_le_bytes_constraints = {}, - .bigint_operations = {}, .constraints = {}, .block_constraints = { block }, }; @@ -143,3 +141,4 @@ TEST_F(UltraPlonkRAM, TestBlockConstraint) auto verifier = composer.create_verifier(builder); EXPECT_EQ(verifier.verify_proof(proof), true); } +} // namespace acir_format::tests diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.cpp index ce6ff2dafc52..3f0d17b86b60 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.cpp @@ -6,10 +6,10 @@ namespace acir_format { using namespace bb::plonk; template -crypto::ecdsa_signature ecdsa_convert_signature(Builder& builder, std::vector signature) +crypto::ecdsa::signature ecdsa_convert_signature(Builder& builder, std::vector signature) { - crypto::ecdsa_signature signature_cr; + crypto::ecdsa::signature signature_cr; // Get the witness assignment for each witness index // Write the witness assignment to the byte_array @@ -117,9 +117,9 @@ void create_ecdsa_k1_verify_constraints(Builder& builder, std::vector ss(new_sig.s.begin(), new_sig.s.end()); uint8_t vv = new_sig.v; - stdlib::ecdsa_signature sig{ stdlib::byte_array(&builder, rr), - stdlib::byte_array(&builder, ss), - stdlib::uint8(&builder, vv) }; + stdlib::ecdsa::signature sig{ stdlib::byte_array(&builder, rr), + stdlib::byte_array(&builder, ss), + stdlib::uint8(&builder, vv) }; pub_key_x_fq.assert_is_in_field(); pub_key_y_fq.assert_is_in_field(); @@ -135,11 +135,11 @@ void create_ecdsa_k1_verify_constraints(Builder& builder, } bool_ct signature_result = - stdlib::ecdsa_verify_signature_prehashed_message_noassert( + stdlib::ecdsa::verify_signature_prehashed_message_noassert( message, public_key, sig); bool_ct signature_result_normalized = signature_result.normalize(); builder.assert_equal(signature_result_normalized.witness_index, input.result); @@ -160,14 +160,14 @@ template void dummy_ecdsa_constraint(Builder& builder, EcdsaS signature_.resize(64); // Create a valid signature with a valid public key - crypto::ecdsa_key_pair account; + crypto::ecdsa::key_pair account; account.private_key = 10; account.public_key = secp256k1_ct::g1::one * account.private_key; uint256_t pub_x_value = account.public_key.x; uint256_t pub_y_value = account.public_key.y; std::string message_string = "Instructions unclear, ask again later."; - crypto::ecdsa_signature signature = - crypto::ecdsa_construct_signature( + crypto::ecdsa::signature signature = + crypto::ecdsa::construct_signature( message_string, account); // Create new variables which will reference the valid public key and signature. diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.hpp index 7dd69f6af90b..45633d1728e4 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.hpp @@ -38,7 +38,7 @@ void create_ecdsa_k1_verify_constraints(Builder& builder, template void dummy_ecdsa_constraint(Builder& builder, EcdsaSecp256k1Constraint const& input); template -crypto::ecdsa_signature ecdsa_convert_signature(Builder& builder, std::vector signature); +crypto::ecdsa::signature ecdsa_convert_signature(Builder& builder, std::vector signature); witness_ct ecdsa_index_to_witness(Builder& builder, uint32_t index); template bb::stdlib::byte_array ecdsa_vector_of_bytes_to_byte_array(Builder& builder, diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.test.cpp index 2e17b97008dd..841e71a148d3 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.test.cpp @@ -7,8 +7,8 @@ #include #include -using namespace acir_format; -using curve_ct = stdlib::secp256k1; +namespace acir_format::tests { +using curve_ct = bb::stdlib::secp256k1; class ECDSASecp256k1 : public ::testing::Test { protected: @@ -25,13 +25,13 @@ size_t generate_ecdsa_constraint(EcdsaSecp256k1Constraint& ecdsa_constraint, Wit std::copy(message_string.begin(), message_string.end(), std::back_inserter(message_buffer)); auto hashed_message = sha256::sha256(message_buffer); - crypto::ecdsa_key_pair account; + crypto::ecdsa::key_pair account; account.private_key = curve_ct::fr::random_element(); account.public_key = curve_ct::g1::one * account.private_key; - crypto::ecdsa_signature signature = - crypto::ecdsa_construct_signature(message_string, - account); + crypto::ecdsa::signature signature = + crypto::ecdsa::construct_signature(message_string, + account); uint256_t pub_x_value = account.public_key.x; uint256_t pub_y_value = account.public_key.y; @@ -87,7 +87,7 @@ TEST_F(ECDSASecp256k1, TestECDSAConstraintSucceed) EcdsaSecp256k1Constraint ecdsa_k1_constraint; WitnessVector witness_values; size_t num_variables = generate_ecdsa_constraint(ecdsa_k1_constraint, witness_values); - AcirFormat constraint_system{ + acir_format constraint_system{ .varnum = static_cast(num_variables), .public_inputs = {}, .logic_constraints = {}, @@ -107,8 +107,6 @@ TEST_F(ECDSASecp256k1, TestECDSAConstraintSucceed) .ec_add_constraints = {}, .ec_double_constraints = {}, .recursion_constraints = {}, - .bigint_from_le_bytes_constraints = {}, - .bigint_operations = {}, .constraints = {}, .block_constraints = {}, }; @@ -133,7 +131,7 @@ TEST_F(ECDSASecp256k1, TestECDSACompilesForVerifier) EcdsaSecp256k1Constraint ecdsa_k1_constraint; WitnessVector witness_values; size_t num_variables = generate_ecdsa_constraint(ecdsa_k1_constraint, witness_values); - AcirFormat constraint_system{ + acir_format constraint_system{ .varnum = static_cast(num_variables), .public_inputs = {}, .logic_constraints = {}, @@ -153,8 +151,6 @@ TEST_F(ECDSASecp256k1, TestECDSACompilesForVerifier) .ec_add_constraints = {}, .ec_double_constraints = {}, .recursion_constraints = {}, - .bigint_from_le_bytes_constraints = {}, - .bigint_operations = {}, .constraints = {}, .block_constraints = {}, }; @@ -174,7 +170,7 @@ TEST_F(ECDSASecp256k1, TestECDSAConstraintFail) // tamper with signature witness_values[witness_values.size() - 20] += 1; - AcirFormat constraint_system{ + acir_format constraint_system{ .varnum = static_cast(num_variables), .public_inputs = {}, .logic_constraints = {}, @@ -194,8 +190,6 @@ TEST_F(ECDSASecp256k1, TestECDSAConstraintFail) .ec_add_constraints = {}, .ec_double_constraints = {}, .recursion_constraints = {}, - .bigint_from_le_bytes_constraints = {}, - .bigint_operations = {}, .constraints = {}, .block_constraints = {}, }; @@ -209,3 +203,4 @@ TEST_F(ECDSASecp256k1, TestECDSAConstraintFail) auto verifier = composer.create_verifier(builder); EXPECT_EQ(verifier.verify_proof(proof), true); } +} // namespace acir_format::tests diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256r1.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256r1.cpp index 079c71697941..59e20aeda0e9 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256r1.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256r1.cpp @@ -49,9 +49,9 @@ void create_ecdsa_r1_verify_constraints(Builder& builder, std::vector ss(new_sig.s.begin(), new_sig.s.end()); uint8_t vv = new_sig.v; - stdlib::ecdsa_signature sig{ stdlib::byte_array(&builder, rr), - stdlib::byte_array(&builder, ss), - stdlib::uint8(&builder, vv) }; + stdlib::ecdsa::signature sig{ stdlib::byte_array(&builder, rr), + stdlib::byte_array(&builder, ss), + stdlib::uint8(&builder, vv) }; pub_key_x_fq.assert_is_in_field(); pub_key_y_fq.assert_is_in_field(); @@ -67,11 +67,11 @@ void create_ecdsa_r1_verify_constraints(Builder& builder, } bool_ct signature_result = - stdlib::ecdsa_verify_signature_prehashed_message_noassert( + stdlib::ecdsa::verify_signature_prehashed_message_noassert( message, public_key, sig); bool_ct signature_result_normalized = signature_result.normalize(); builder.assert_equal(signature_result_normalized.witness_index, input.result); @@ -100,13 +100,13 @@ template void dummy_ecdsa_constraint(Builder& builder, EcdsaS std::copy(message_string.begin(), message_string.end(), std::back_inserter(message_buffer)); auto hashed_message = sha256::sha256(message_buffer); - crypto::ecdsa_key_pair account; + crypto::ecdsa::key_pair account; account.private_key = 10; account.public_key = secp256r1::g1::one * account.private_key; - crypto::ecdsa_signature signature = - crypto::ecdsa_construct_signature(message_string, - account); + crypto::ecdsa::signature signature = + crypto::ecdsa::construct_signature(message_string, + account); uint256_t pub_x_value = account.public_key.x; uint256_t pub_y_value = account.public_key.y; diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256r1.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256r1.test.cpp index c3487e35da0f..72b5a616afc2 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256r1.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256r1.test.cpp @@ -7,9 +7,8 @@ #include #include -using namespace acir_format; - -using curve_ct = stdlib::secp256r1; +namespace acir_format::tests { +using curve_ct = bb::stdlib::secp256r1; // Generate r1 constraints given pre generated pubkey, sig and message values size_t generate_r1_constraints(EcdsaSecp256r1Constraint& ecdsa_r1_constraint, @@ -17,7 +16,7 @@ size_t generate_r1_constraints(EcdsaSecp256r1Constraint& ecdsa_r1_constraint, uint256_t pub_x_value, uint256_t pub_y_value, std::array hashed_message, - crypto::ecdsa_signature signature) + crypto::ecdsa::signature signature) { std::vector message_in; @@ -79,13 +78,13 @@ size_t generate_ecdsa_constraint(EcdsaSecp256r1Constraint& ecdsa_r1_constraint, std::copy(message_string.begin(), message_string.end(), std::back_inserter(message_buffer)); auto hashed_message = sha256::sha256(message_buffer); - crypto::ecdsa_key_pair account; + crypto::ecdsa::key_pair account; account.private_key = curve_ct::fr::random_element(); account.public_key = curve_ct::g1::one * account.private_key; - crypto::ecdsa_signature signature = - crypto::ecdsa_construct_signature(message_string, - account); + crypto::ecdsa::signature signature = + crypto::ecdsa::construct_signature(message_string, + account); return generate_r1_constraints( ecdsa_r1_constraint, witness_values, account.public_key.x, account.public_key.y, hashed_message, signature); @@ -106,7 +105,7 @@ TEST(ECDSASecp256r1, test_hardcoded) uint256_t pub_key_y = uint256_t("136093d7012e509a73715cbd0b00a3cc0ff4b5c01b3ffa196ab1fb327036b8e6"); // 0x2c70a8d084b62bfc5ce03641caf9f72ad4da8c81bfe6ec9487bb5e1bef62a13218ad9ee29eaf351fdc50f1520c425e9b908a07278b43b0ec7b872778c14e0784 - crypto::ecdsa_signature signature = { + crypto::ecdsa::signature signature = { .r = { 44, 112, 168, 208, 132, 182, 43, 252, 92, 224, 54, 65, 202, 249, 247, 42, 212, 218, 140, 129, 191, 230, 236, 148, 135, 187, 94, 27, 239, 98, 161, 50 }, .s = { 24, 173, 158, 226, 158, 175, 53, 31, 220, 80, 241, 82, 12, 66, 94, 155, @@ -114,7 +113,7 @@ TEST(ECDSASecp256r1, test_hardcoded) .v = 0 }; - crypto::ecdsa_key_pair account; + crypto::ecdsa::key_pair account; account.private_key = curve_ct::fr(uint256_t("0202020202020202020202020202020202020202020202020202020202020202")); account.public_key = curve_ct::g1::one * account.private_key; @@ -122,7 +121,7 @@ TEST(ECDSASecp256r1, test_hardcoded) size_t num_variables = generate_r1_constraints(ecdsa_r1_constraint, witness_values, pub_key_x, pub_key_y, hashed_message, signature); - AcirFormat constraint_system{ + acir_format constraint_system{ .varnum = static_cast(num_variables), .public_inputs = {}, .logic_constraints = {}, @@ -142,14 +141,12 @@ TEST(ECDSASecp256r1, test_hardcoded) .ec_add_constraints = {}, .ec_double_constraints = {}, .recursion_constraints = {}, - .bigint_from_le_bytes_constraints = {}, - .bigint_operations = {}, .constraints = {}, .block_constraints = {}, }; secp256r1::g1::affine_element pub_key = { pub_key_x, pub_key_y }; - bool we_ballin = crypto::ecdsa_verify_signature( + bool we_ballin = crypto::ecdsa::verify_signature( message, pub_key, signature); EXPECT_EQ(we_ballin, true); @@ -169,7 +166,7 @@ TEST(ECDSASecp256r1, TestECDSAConstraintSucceed) EcdsaSecp256r1Constraint ecdsa_r1_constraint; WitnessVector witness_values; size_t num_variables = generate_ecdsa_constraint(ecdsa_r1_constraint, witness_values); - AcirFormat constraint_system{ + acir_format constraint_system{ .varnum = static_cast(num_variables), .public_inputs = {}, .logic_constraints = {}, @@ -189,8 +186,6 @@ TEST(ECDSASecp256r1, TestECDSAConstraintSucceed) .ec_add_constraints = {}, .ec_double_constraints = {}, .recursion_constraints = {}, - .bigint_from_le_bytes_constraints = {}, - .bigint_operations = {}, .constraints = {}, .block_constraints = {}, }; @@ -214,7 +209,7 @@ TEST(ECDSASecp256r1, TestECDSACompilesForVerifier) EcdsaSecp256r1Constraint ecdsa_r1_constraint; WitnessVector witness_values; size_t num_variables = generate_ecdsa_constraint(ecdsa_r1_constraint, witness_values); - AcirFormat constraint_system{ + acir_format constraint_system{ .varnum = static_cast(num_variables), .public_inputs = {}, .logic_constraints = {}, @@ -234,8 +229,6 @@ TEST(ECDSASecp256r1, TestECDSACompilesForVerifier) .ec_add_constraints = {}, .ec_double_constraints = {}, .recursion_constraints = {}, - .bigint_from_le_bytes_constraints = {}, - .bigint_operations = {}, .constraints = {}, .block_constraints = {}, }; @@ -254,7 +247,7 @@ TEST(ECDSASecp256r1, TestECDSAConstraintFail) // tamper with signature witness_values[witness_values.size() - 20] += 1; - AcirFormat constraint_system{ + acir_format constraint_system{ .varnum = static_cast(num_variables), .public_inputs = {}, .logic_constraints = {}, @@ -274,8 +267,6 @@ TEST(ECDSASecp256r1, TestECDSAConstraintFail) .ec_add_constraints = {}, .ec_double_constraints = {}, .recursion_constraints = {}, - .bigint_from_le_bytes_constraints = {}, - .bigint_operations = {}, .constraints = {}, .block_constraints = {}, }; @@ -290,3 +281,4 @@ TEST(ECDSASecp256r1, TestECDSAConstraintFail) auto verifier = composer.create_verifier(builder); EXPECT_EQ(verifier.verify_proof(proof), true); } +} // namespace acir_format::tests diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.test.cpp index 20650bf589b0..457184ed0253 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.test.cpp @@ -6,13 +6,13 @@ #include #include -using namespace acir_format; using namespace bb::plonk; class AcirRecursionConstraint : public ::testing::Test { protected: static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } }; +namespace acir_format::test { Builder create_inner_circuit() { /** @@ -81,29 +81,27 @@ Builder create_inner_circuit() .q_c = 1, }; - AcirFormat constraint_system{ .varnum = 6, - .public_inputs = { 1, 2 }, - .logic_constraints = { logic_constraint }, - .range_constraints = { range_a, range_b }, - .sha256_constraints = {}, - .schnorr_constraints = {}, - .ecdsa_k1_constraints = {}, - .ecdsa_r1_constraints = {}, - .blake2s_constraints = {}, - .blake3_constraints = {}, - .keccak_constraints = {}, - .keccak_var_constraints = {}, - .keccak_permutations = {}, - .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, - .fixed_base_scalar_mul_constraints = {}, - .ec_add_constraints = {}, - .ec_double_constraints = {}, - .recursion_constraints = {}, - .bigint_from_le_bytes_constraints = {}, - .bigint_operations = {}, - .constraints = { expr_a, expr_b, expr_c, expr_d }, - .block_constraints = {} }; + acir_format constraint_system{ .varnum = 6, + .public_inputs = { 1, 2 }, + .logic_constraints = { logic_constraint }, + .range_constraints = { range_a, range_b }, + .sha256_constraints = {}, + .schnorr_constraints = {}, + .ecdsa_k1_constraints = {}, + .ecdsa_r1_constraints = {}, + .blake2s_constraints = {}, + .blake3_constraints = {}, + .keccak_constraints = {}, + .keccak_var_constraints = {}, + .keccak_permutations = {}, + .pedersen_constraints = {}, + .pedersen_hash_constraints = {}, + .fixed_base_scalar_mul_constraints = {}, + .ec_add_constraints = {}, + .ec_double_constraints = {}, + .recursion_constraints = {}, + .constraints = { expr_a, expr_b, expr_c, expr_d }, + .block_constraints = {} }; uint256_t inverse_of_five = fr(5).invert(); WitnessVector witness{ @@ -145,10 +143,10 @@ Builder create_outer_circuit(std::vector& inner_circuits) transcript::HashType::PedersenBlake3s, 16); - std::vector proof_witnesses = export_transcript_in_recursion_format(transcript); + std::vector proof_witnesses = export_transcript_in_recursion_format(transcript); // - Save the public inputs so that we can set their values. // - Then truncate them from the proof because the ACIR API expects proofs without public inputs - std::vector inner_public_input_values( + std::vector inner_public_input_values( proof_witnesses.begin(), proof_witnesses.begin() + static_cast(num_inner_public_inputs)); // We want to make sure that we do not remove the nested aggregation object in the case of the proof we want to @@ -235,29 +233,27 @@ Builder create_outer_circuit(std::vector& inner_circuits) circuit_idx++; } - AcirFormat constraint_system{ .varnum = static_cast(witness.size()), - .public_inputs = {}, - .logic_constraints = {}, - .range_constraints = {}, - .sha256_constraints = {}, - .schnorr_constraints = {}, - .ecdsa_k1_constraints = {}, - .ecdsa_r1_constraints = {}, - .blake2s_constraints = {}, - .blake3_constraints = {}, - .keccak_constraints = {}, - .keccak_var_constraints = {}, - .keccak_permutations = {}, - .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, - .fixed_base_scalar_mul_constraints = {}, - .ec_add_constraints = {}, - .ec_double_constraints = {}, - .recursion_constraints = recursion_constraints, - .bigint_from_le_bytes_constraints = {}, - .bigint_operations = {}, - .constraints = {}, - .block_constraints = {} }; + acir_format constraint_system{ .varnum = static_cast(witness.size()), + .public_inputs = {}, + .logic_constraints = {}, + .range_constraints = {}, + .sha256_constraints = {}, + .schnorr_constraints = {}, + .ecdsa_k1_constraints = {}, + .ecdsa_r1_constraints = {}, + .blake2s_constraints = {}, + .blake3_constraints = {}, + .keccak_constraints = {}, + .keccak_var_constraints = {}, + .keccak_permutations = {}, + .pedersen_constraints = {}, + .pedersen_hash_constraints = {}, + .fixed_base_scalar_mul_constraints = {}, + .ec_add_constraints = {}, + .ec_double_constraints = {}, + .recursion_constraints = recursion_constraints, + .constraints = {}, + .block_constraints = {} }; auto outer_circuit = create_circuit(constraint_system, /*size_hint*/ 0, witness); @@ -368,3 +364,4 @@ TEST_F(AcirRecursionConstraint, TestFullRecursiveComposition) auto verifier = layer_3_composer.create_ultra_with_keccak_verifier(layer_3_circuit); EXPECT_EQ(verifier.verify_proof(proof), true); } +} // namespace acir_format::test diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/schnorr_verify.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/schnorr_verify.cpp index b4d7f4737d5d..931ee470903f 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/schnorr_verify.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/schnorr_verify.cpp @@ -7,10 +7,10 @@ namespace acir_format { using namespace bb::stdlib; template -crypto::schnorr_signature convert_signature(Builder& builder, std::vector signature) +crypto::schnorr::signature convert_signature(Builder& builder, std::vector signature) { - crypto::schnorr_signature signature_cr; + crypto::schnorr::signature signature_cr; // Get the witness assignment for each witness index // Write the witness assignment to the byte_array @@ -75,7 +75,7 @@ template void create_schnorr_verify_constraints(Builder& buil { using witness_ct = bb::stdlib::witness_t; using cycle_group_ct = bb::stdlib::cycle_group; - using schnorr_signature_bits_ct = bb::stdlib::schnorr_signature_bits; + using schnorr_signature_bits_ct = bb::stdlib::schnorr::signature_bits; using bool_ct = bb::stdlib::bool_t; auto new_sig = convert_signature(builder, input.signature); @@ -93,9 +93,9 @@ template void create_schnorr_verify_constraints(Builder& buil cycle_group_ct pub_key{ witness_ct(&builder, pubkey_value_x), witness_ct(&builder, pubkey_value_y), false }; - schnorr_signature_bits_ct sig = schnorr_convert_signature(&builder, new_sig); + schnorr_signature_bits_ct sig = schnorr::convert_signature(&builder, new_sig); - bool_ct signature_result = schnorr_signature_verification_result(message, pub_key, sig); + bool_ct signature_result = schnorr::signature_verification_result(message, pub_key, sig); bool_ct signature_result_normalized = signature_result.normalize(); diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp index 8e18e5bc043c..c85f609bbd1b 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp @@ -206,65 +206,6 @@ struct BlackBoxFuncCall { static RecursiveAggregation bincodeDeserialize(std::vector); }; - struct BigIntAdd { - uint32_t lhs; - uint32_t rhs; - uint32_t output; - - friend bool operator==(const BigIntAdd&, const BigIntAdd&); - std::vector bincodeSerialize() const; - static BigIntAdd bincodeDeserialize(std::vector); - }; - - struct BigIntNeg { - uint32_t lhs; - uint32_t rhs; - uint32_t output; - - friend bool operator==(const BigIntNeg&, const BigIntNeg&); - std::vector bincodeSerialize() const; - static BigIntNeg bincodeDeserialize(std::vector); - }; - - struct BigIntMul { - uint32_t lhs; - uint32_t rhs; - uint32_t output; - - friend bool operator==(const BigIntMul&, const BigIntMul&); - std::vector bincodeSerialize() const; - static BigIntMul bincodeDeserialize(std::vector); - }; - - struct BigIntDiv { - uint32_t lhs; - uint32_t rhs; - uint32_t output; - - friend bool operator==(const BigIntDiv&, const BigIntDiv&); - std::vector bincodeSerialize() const; - static BigIntDiv bincodeDeserialize(std::vector); - }; - - struct BigIntFromLeBytes { - std::vector inputs; - std::vector modulus; - uint32_t output; - - friend bool operator==(const BigIntFromLeBytes&, const BigIntFromLeBytes&); - std::vector bincodeSerialize() const; - static BigIntFromLeBytes bincodeDeserialize(std::vector); - }; - - struct BigIntToLeBytes { - uint32_t input; - std::vector outputs; - - friend bool operator==(const BigIntToLeBytes&, const BigIntToLeBytes&); - std::vector bincodeSerialize() const; - static BigIntToLeBytes bincodeDeserialize(std::vector); - }; - std::variant + RecursiveAggregation> value; friend bool operator==(const BlackBoxFuncCall&, const BlackBoxFuncCall&); @@ -304,6 +239,8 @@ struct BlockId { static BlockId bincodeDeserialize(std::vector); }; +// TODO(https://github.com/AztecProtocol/barretenberg/issues/825): This struct is more general than it needs / should be +// allowed to be. We can only accommodate 1 quadratic term and 3 linear terms. struct Expression { std::vector> mul_terms; std::vector> linear_combinations; @@ -626,65 +563,6 @@ struct BlackBoxOp { static EmbeddedCurveDouble bincodeDeserialize(std::vector); }; - struct BigIntAdd { - Circuit::RegisterIndex lhs; - Circuit::RegisterIndex rhs; - Circuit::RegisterIndex output; - - friend bool operator==(const BigIntAdd&, const BigIntAdd&); - std::vector bincodeSerialize() const; - static BigIntAdd bincodeDeserialize(std::vector); - }; - - struct BigIntNeg { - Circuit::RegisterIndex lhs; - Circuit::RegisterIndex rhs; - Circuit::RegisterIndex output; - - friend bool operator==(const BigIntNeg&, const BigIntNeg&); - std::vector bincodeSerialize() const; - static BigIntNeg bincodeDeserialize(std::vector); - }; - - struct BigIntMul { - Circuit::RegisterIndex lhs; - Circuit::RegisterIndex rhs; - Circuit::RegisterIndex output; - - friend bool operator==(const BigIntMul&, const BigIntMul&); - std::vector bincodeSerialize() const; - static BigIntMul bincodeDeserialize(std::vector); - }; - - struct BigIntDiv { - Circuit::RegisterIndex lhs; - Circuit::RegisterIndex rhs; - Circuit::RegisterIndex output; - - friend bool operator==(const BigIntDiv&, const BigIntDiv&); - std::vector bincodeSerialize() const; - static BigIntDiv bincodeDeserialize(std::vector); - }; - - struct BigIntFromLeBytes { - Circuit::HeapVector inputs; - Circuit::HeapVector modulus; - Circuit::RegisterIndex output; - - friend bool operator==(const BigIntFromLeBytes&, const BigIntFromLeBytes&); - std::vector bincodeSerialize() const; - static BigIntFromLeBytes bincodeDeserialize(std::vector); - }; - - struct BigIntToLeBytes { - Circuit::RegisterIndex input; - Circuit::HeapVector output; - - friend bool operator==(const BigIntToLeBytes&, const BigIntToLeBytes&); - std::vector bincodeSerialize() const; - static BigIntToLeBytes bincodeDeserialize(std::vector); - }; - std::variant + EmbeddedCurveDouble> value; friend bool operator==(const BlackBoxOp&, const BlackBoxOp&); @@ -3011,31 +2883,25 @@ Circuit::BlackBoxFuncCall::RecursiveAggregation serde::Deserializable< namespace Circuit { -inline bool operator==(const BlackBoxFuncCall::BigIntAdd& lhs, const BlackBoxFuncCall::BigIntAdd& rhs) +inline bool operator==(const BlackBoxOp& lhs, const BlackBoxOp& rhs) { - if (!(lhs.lhs == rhs.lhs)) { - return false; - } - if (!(lhs.rhs == rhs.rhs)) { - return false; - } - if (!(lhs.output == rhs.output)) { + if (!(lhs.value == rhs.value)) { return false; } return true; } -inline std::vector BlackBoxFuncCall::BigIntAdd::bincodeSerialize() const +inline std::vector BlackBoxOp::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxFuncCall::BigIntAdd BlackBoxFuncCall::BigIntAdd::bincodeDeserialize(std::vector input) +inline BlackBoxOp BlackBoxOp::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3046,34 +2912,29 @@ inline BlackBoxFuncCall::BigIntAdd BlackBoxFuncCall::BigIntAdd::bincodeDeseriali template <> template -void serde::Serializable::serialize( - const Circuit::BlackBoxFuncCall::BigIntAdd& obj, Serializer& serializer) +void serde::Serializable::serialize(const Circuit::BlackBoxOp& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.lhs, serializer); - serde::Serializable::serialize(obj.rhs, serializer); - serde::Serializable::serialize(obj.output, serializer); + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); } template <> template -Circuit::BlackBoxFuncCall::BigIntAdd serde::Deserializable::deserialize( - Deserializer& deserializer) +Circuit::BlackBoxOp serde::Deserializable::deserialize(Deserializer& deserializer) { - Circuit::BlackBoxFuncCall::BigIntAdd obj; - obj.lhs = serde::Deserializable::deserialize(deserializer); - obj.rhs = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); + deserializer.increase_container_depth(); + Circuit::BlackBoxOp obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); return obj; } namespace Circuit { -inline bool operator==(const BlackBoxFuncCall::BigIntNeg& lhs, const BlackBoxFuncCall::BigIntNeg& rhs) +inline bool operator==(const BlackBoxOp::Sha256& lhs, const BlackBoxOp::Sha256& rhs) { - if (!(lhs.lhs == rhs.lhs)) { - return false; - } - if (!(lhs.rhs == rhs.rhs)) { + if (!(lhs.message == rhs.message)) { return false; } if (!(lhs.output == rhs.output)) { @@ -3082,17 +2943,17 @@ inline bool operator==(const BlackBoxFuncCall::BigIntNeg& lhs, const BlackBoxFun return true; } -inline std::vector BlackBoxFuncCall::BigIntNeg::bincodeSerialize() const +inline std::vector BlackBoxOp::Sha256::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxFuncCall::BigIntNeg BlackBoxFuncCall::BigIntNeg::bincodeDeserialize(std::vector input) +inline BlackBoxOp::Sha256 BlackBoxOp::Sha256::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3103,34 +2964,28 @@ inline BlackBoxFuncCall::BigIntNeg BlackBoxFuncCall::BigIntNeg::bincodeDeseriali template <> template -void serde::Serializable::serialize( - const Circuit::BlackBoxFuncCall::BigIntNeg& obj, Serializer& serializer) +void serde::Serializable::serialize(const Circuit::BlackBoxOp::Sha256& obj, + Serializer& serializer) { - serde::Serializable::serialize(obj.lhs, serializer); - serde::Serializable::serialize(obj.rhs, serializer); + serde::Serializable::serialize(obj.message, serializer); serde::Serializable::serialize(obj.output, serializer); } template <> template -Circuit::BlackBoxFuncCall::BigIntNeg serde::Deserializable::deserialize( - Deserializer& deserializer) +Circuit::BlackBoxOp::Sha256 serde::Deserializable::deserialize(Deserializer& deserializer) { - Circuit::BlackBoxFuncCall::BigIntNeg obj; - obj.lhs = serde::Deserializable::deserialize(deserializer); - obj.rhs = serde::Deserializable::deserialize(deserializer); + Circuit::BlackBoxOp::Sha256 obj; + obj.message = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Circuit { -inline bool operator==(const BlackBoxFuncCall::BigIntMul& lhs, const BlackBoxFuncCall::BigIntMul& rhs) +inline bool operator==(const BlackBoxOp::Blake2s& lhs, const BlackBoxOp::Blake2s& rhs) { - if (!(lhs.lhs == rhs.lhs)) { - return false; - } - if (!(lhs.rhs == rhs.rhs)) { + if (!(lhs.message == rhs.message)) { return false; } if (!(lhs.output == rhs.output)) { @@ -3139,17 +2994,17 @@ inline bool operator==(const BlackBoxFuncCall::BigIntMul& lhs, const BlackBoxFun return true; } -inline std::vector BlackBoxFuncCall::BigIntMul::bincodeSerialize() const +inline std::vector BlackBoxOp::Blake2s::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxFuncCall::BigIntMul BlackBoxFuncCall::BigIntMul::bincodeDeserialize(std::vector input) +inline BlackBoxOp::Blake2s BlackBoxOp::Blake2s::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3160,34 +3015,29 @@ inline BlackBoxFuncCall::BigIntMul BlackBoxFuncCall::BigIntMul::bincodeDeseriali template <> template -void serde::Serializable::serialize( - const Circuit::BlackBoxFuncCall::BigIntMul& obj, Serializer& serializer) +void serde::Serializable::serialize(const Circuit::BlackBoxOp::Blake2s& obj, + Serializer& serializer) { - serde::Serializable::serialize(obj.lhs, serializer); - serde::Serializable::serialize(obj.rhs, serializer); + serde::Serializable::serialize(obj.message, serializer); serde::Serializable::serialize(obj.output, serializer); } template <> template -Circuit::BlackBoxFuncCall::BigIntMul serde::Deserializable::deserialize( +Circuit::BlackBoxOp::Blake2s serde::Deserializable::deserialize( Deserializer& deserializer) { - Circuit::BlackBoxFuncCall::BigIntMul obj; - obj.lhs = serde::Deserializable::deserialize(deserializer); - obj.rhs = serde::Deserializable::deserialize(deserializer); + Circuit::BlackBoxOp::Blake2s obj; + obj.message = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Circuit { -inline bool operator==(const BlackBoxFuncCall::BigIntDiv& lhs, const BlackBoxFuncCall::BigIntDiv& rhs) +inline bool operator==(const BlackBoxOp::Blake3& lhs, const BlackBoxOp::Blake3& rhs) { - if (!(lhs.lhs == rhs.lhs)) { - return false; - } - if (!(lhs.rhs == rhs.rhs)) { + if (!(lhs.message == rhs.message)) { return false; } if (!(lhs.output == rhs.output)) { @@ -3196,17 +3046,17 @@ inline bool operator==(const BlackBoxFuncCall::BigIntDiv& lhs, const BlackBoxFun return true; } -inline std::vector BlackBoxFuncCall::BigIntDiv::bincodeSerialize() const +inline std::vector BlackBoxOp::Blake3::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxFuncCall::BigIntDiv BlackBoxFuncCall::BigIntDiv::bincodeDeserialize(std::vector input) +inline BlackBoxOp::Blake3 BlackBoxOp::Blake3::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3217,34 +3067,28 @@ inline BlackBoxFuncCall::BigIntDiv BlackBoxFuncCall::BigIntDiv::bincodeDeseriali template <> template -void serde::Serializable::serialize( - const Circuit::BlackBoxFuncCall::BigIntDiv& obj, Serializer& serializer) +void serde::Serializable::serialize(const Circuit::BlackBoxOp::Blake3& obj, + Serializer& serializer) { - serde::Serializable::serialize(obj.lhs, serializer); - serde::Serializable::serialize(obj.rhs, serializer); + serde::Serializable::serialize(obj.message, serializer); serde::Serializable::serialize(obj.output, serializer); } template <> template -Circuit::BlackBoxFuncCall::BigIntDiv serde::Deserializable::deserialize( - Deserializer& deserializer) +Circuit::BlackBoxOp::Blake3 serde::Deserializable::deserialize(Deserializer& deserializer) { - Circuit::BlackBoxFuncCall::BigIntDiv obj; - obj.lhs = serde::Deserializable::deserialize(deserializer); - obj.rhs = serde::Deserializable::deserialize(deserializer); + Circuit::BlackBoxOp::Blake3 obj; + obj.message = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Circuit { -inline bool operator==(const BlackBoxFuncCall::BigIntFromLeBytes& lhs, const BlackBoxFuncCall::BigIntFromLeBytes& rhs) +inline bool operator==(const BlackBoxOp::Keccak256& lhs, const BlackBoxOp::Keccak256& rhs) { - if (!(lhs.inputs == rhs.inputs)) { - return false; - } - if (!(lhs.modulus == rhs.modulus)) { + if (!(lhs.message == rhs.message)) { return false; } if (!(lhs.output == rhs.output)) { @@ -3253,18 +3097,17 @@ inline bool operator==(const BlackBoxFuncCall::BigIntFromLeBytes& lhs, const Bla return true; } -inline std::vector BlackBoxFuncCall::BigIntFromLeBytes::bincodeSerialize() const +inline std::vector BlackBoxOp::Keccak256::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxFuncCall::BigIntFromLeBytes BlackBoxFuncCall::BigIntFromLeBytes::bincodeDeserialize( - std::vector input) +inline BlackBoxOp::Keccak256 BlackBoxOp::Keccak256::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3275,51 +3118,48 @@ inline BlackBoxFuncCall::BigIntFromLeBytes BlackBoxFuncCall::BigIntFromLeBytes:: template <> template -void serde::Serializable::serialize( - const Circuit::BlackBoxFuncCall::BigIntFromLeBytes& obj, Serializer& serializer) +void serde::Serializable::serialize(const Circuit::BlackBoxOp::Keccak256& obj, + Serializer& serializer) { - serde::Serializable::serialize(obj.inputs, serializer); - serde::Serializable::serialize(obj.modulus, serializer); + serde::Serializable::serialize(obj.message, serializer); serde::Serializable::serialize(obj.output, serializer); } template <> template -Circuit::BlackBoxFuncCall::BigIntFromLeBytes serde::Deserializable< - Circuit::BlackBoxFuncCall::BigIntFromLeBytes>::deserialize(Deserializer& deserializer) +Circuit::BlackBoxOp::Keccak256 serde::Deserializable::deserialize( + Deserializer& deserializer) { - Circuit::BlackBoxFuncCall::BigIntFromLeBytes obj; - obj.inputs = serde::Deserializable::deserialize(deserializer); - obj.modulus = serde::Deserializable::deserialize(deserializer); + Circuit::BlackBoxOp::Keccak256 obj; + obj.message = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Circuit { -inline bool operator==(const BlackBoxFuncCall::BigIntToLeBytes& lhs, const BlackBoxFuncCall::BigIntToLeBytes& rhs) +inline bool operator==(const BlackBoxOp::Keccakf1600& lhs, const BlackBoxOp::Keccakf1600& rhs) { - if (!(lhs.input == rhs.input)) { + if (!(lhs.message == rhs.message)) { return false; } - if (!(lhs.outputs == rhs.outputs)) { + if (!(lhs.output == rhs.output)) { return false; } return true; } -inline std::vector BlackBoxFuncCall::BigIntToLeBytes::bincodeSerialize() const +inline std::vector BlackBoxOp::Keccakf1600::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxFuncCall::BigIntToLeBytes BlackBoxFuncCall::BigIntToLeBytes::bincodeDeserialize( - std::vector input) +inline BlackBoxOp::Keccakf1600 BlackBoxOp::Keccakf1600::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3330,45 +3170,57 @@ inline BlackBoxFuncCall::BigIntToLeBytes BlackBoxFuncCall::BigIntToLeBytes::binc template <> template -void serde::Serializable::serialize( - const Circuit::BlackBoxFuncCall::BigIntToLeBytes& obj, Serializer& serializer) +void serde::Serializable::serialize(const Circuit::BlackBoxOp::Keccakf1600& obj, + Serializer& serializer) { - serde::Serializable::serialize(obj.input, serializer); - serde::Serializable::serialize(obj.outputs, serializer); + serde::Serializable::serialize(obj.message, serializer); + serde::Serializable::serialize(obj.output, serializer); } template <> template -Circuit::BlackBoxFuncCall::BigIntToLeBytes serde::Deserializable< - Circuit::BlackBoxFuncCall::BigIntToLeBytes>::deserialize(Deserializer& deserializer) +Circuit::BlackBoxOp::Keccakf1600 serde::Deserializable::deserialize( + Deserializer& deserializer) { - Circuit::BlackBoxFuncCall::BigIntToLeBytes obj; - obj.input = serde::Deserializable::deserialize(deserializer); - obj.outputs = serde::Deserializable::deserialize(deserializer); + Circuit::BlackBoxOp::Keccakf1600 obj; + obj.message = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Circuit { -inline bool operator==(const BlackBoxOp& lhs, const BlackBoxOp& rhs) +inline bool operator==(const BlackBoxOp::EcdsaSecp256k1& lhs, const BlackBoxOp::EcdsaSecp256k1& rhs) { - if (!(lhs.value == rhs.value)) { + if (!(lhs.hashed_msg == rhs.hashed_msg)) { + return false; + } + if (!(lhs.public_key_x == rhs.public_key_x)) { + return false; + } + if (!(lhs.public_key_y == rhs.public_key_y)) { + return false; + } + if (!(lhs.signature == rhs.signature)) { + return false; + } + if (!(lhs.result == rhs.result)) { return false; } return true; } -inline std::vector BlackBoxOp::bincodeSerialize() const +inline std::vector BlackBoxOp::EcdsaSecp256k1::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp BlackBoxOp::bincodeDeserialize(std::vector input) +inline BlackBoxOp::EcdsaSecp256k1 BlackBoxOp::EcdsaSecp256k1::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3379,668 +3231,44 @@ inline BlackBoxOp BlackBoxOp::bincodeDeserialize(std::vector input) template <> template -void serde::Serializable::serialize(const Circuit::BlackBoxOp& obj, Serializer& serializer) +void serde::Serializable::serialize(const Circuit::BlackBoxOp::EcdsaSecp256k1& obj, + Serializer& serializer) { - serializer.increase_container_depth(); - serde::Serializable::serialize(obj.value, serializer); - serializer.decrease_container_depth(); + serde::Serializable::serialize(obj.hashed_msg, serializer); + serde::Serializable::serialize(obj.public_key_x, serializer); + serde::Serializable::serialize(obj.public_key_y, serializer); + serde::Serializable::serialize(obj.signature, serializer); + serde::Serializable::serialize(obj.result, serializer); } template <> template -Circuit::BlackBoxOp serde::Deserializable::deserialize(Deserializer& deserializer) +Circuit::BlackBoxOp::EcdsaSecp256k1 serde::Deserializable::deserialize( + Deserializer& deserializer) { - deserializer.increase_container_depth(); - Circuit::BlackBoxOp obj; - obj.value = serde::Deserializable::deserialize(deserializer); - deserializer.decrease_container_depth(); + Circuit::BlackBoxOp::EcdsaSecp256k1 obj; + obj.hashed_msg = serde::Deserializable::deserialize(deserializer); + obj.public_key_x = serde::Deserializable::deserialize(deserializer); + obj.public_key_y = serde::Deserializable::deserialize(deserializer); + obj.signature = serde::Deserializable::deserialize(deserializer); + obj.result = serde::Deserializable::deserialize(deserializer); return obj; } namespace Circuit { -inline bool operator==(const BlackBoxOp::Sha256& lhs, const BlackBoxOp::Sha256& rhs) +inline bool operator==(const BlackBoxOp::EcdsaSecp256r1& lhs, const BlackBoxOp::EcdsaSecp256r1& rhs) { - if (!(lhs.message == rhs.message)) { + if (!(lhs.hashed_msg == rhs.hashed_msg)) { return false; } - if (!(lhs.output == rhs.output)) { + if (!(lhs.public_key_x == rhs.public_key_x)) { return false; } - return true; -} - -inline std::vector BlackBoxOp::Sha256::bincodeSerialize() const -{ - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); -} - -inline BlackBoxOp::Sha256 BlackBoxOp::Sha256::bincodeDeserialize(std::vector input) -{ - auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); - if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); - } - return value; -} - -} // end of namespace Circuit - -template <> -template -void serde::Serializable::serialize(const Circuit::BlackBoxOp::Sha256& obj, - Serializer& serializer) -{ - serde::Serializable::serialize(obj.message, serializer); - serde::Serializable::serialize(obj.output, serializer); -} - -template <> -template -Circuit::BlackBoxOp::Sha256 serde::Deserializable::deserialize(Deserializer& deserializer) -{ - Circuit::BlackBoxOp::Sha256 obj; - obj.message = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); - return obj; -} - -namespace Circuit { - -inline bool operator==(const BlackBoxOp::Blake2s& lhs, const BlackBoxOp::Blake2s& rhs) -{ - if (!(lhs.message == rhs.message)) { - return false; - } - if (!(lhs.output == rhs.output)) { - return false; - } - return true; -} - -inline std::vector BlackBoxOp::Blake2s::bincodeSerialize() const -{ - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); -} - -inline BlackBoxOp::Blake2s BlackBoxOp::Blake2s::bincodeDeserialize(std::vector input) -{ - auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); - if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); - } - return value; -} - -} // end of namespace Circuit - -template <> -template -void serde::Serializable::serialize(const Circuit::BlackBoxOp::Blake2s& obj, - Serializer& serializer) -{ - serde::Serializable::serialize(obj.message, serializer); - serde::Serializable::serialize(obj.output, serializer); -} - -template <> -template -Circuit::BlackBoxOp::Blake2s serde::Deserializable::deserialize( - Deserializer& deserializer) -{ - Circuit::BlackBoxOp::Blake2s obj; - obj.message = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); - return obj; -} - -namespace Circuit { - -inline bool operator==(const BlackBoxOp::Blake3& lhs, const BlackBoxOp::Blake3& rhs) -{ - if (!(lhs.message == rhs.message)) { - return false; - } - if (!(lhs.output == rhs.output)) { - return false; - } - return true; -} - -inline std::vector BlackBoxOp::Blake3::bincodeSerialize() const -{ - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); -} - -inline BlackBoxOp::Blake3 BlackBoxOp::Blake3::bincodeDeserialize(std::vector input) -{ - auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); - if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); - } - return value; -} - -} // end of namespace Circuit - -template <> -template -void serde::Serializable::serialize(const Circuit::BlackBoxOp::Blake3& obj, - Serializer& serializer) -{ - serde::Serializable::serialize(obj.message, serializer); - serde::Serializable::serialize(obj.output, serializer); -} - -template <> -template -Circuit::BlackBoxOp::Blake3 serde::Deserializable::deserialize(Deserializer& deserializer) -{ - Circuit::BlackBoxOp::Blake3 obj; - obj.message = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); - return obj; -} - -namespace Circuit { - -inline bool operator==(const BlackBoxOp::Keccak256& lhs, const BlackBoxOp::Keccak256& rhs) -{ - if (!(lhs.message == rhs.message)) { - return false; - } - if (!(lhs.output == rhs.output)) { - return false; - } - return true; -} - -inline std::vector BlackBoxOp::Keccak256::bincodeSerialize() const -{ - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); -} - -inline BlackBoxOp::Keccak256 BlackBoxOp::Keccak256::bincodeDeserialize(std::vector input) -{ - auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); - if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); - } - return value; -} - -} // end of namespace Circuit - -template <> -template -void serde::Serializable::serialize(const Circuit::BlackBoxOp::Keccak256& obj, - Serializer& serializer) -{ - serde::Serializable::serialize(obj.message, serializer); - serde::Serializable::serialize(obj.output, serializer); -} - -template <> -template -Circuit::BlackBoxOp::Keccak256 serde::Deserializable::deserialize( - Deserializer& deserializer) -{ - Circuit::BlackBoxOp::Keccak256 obj; - obj.message = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); - return obj; -} - -namespace Circuit { - -inline bool operator==(const BlackBoxOp::Keccakf1600& lhs, const BlackBoxOp::Keccakf1600& rhs) -{ - if (!(lhs.message == rhs.message)) { - return false; - } - if (!(lhs.output == rhs.output)) { - return false; - } - return true; -} - -inline std::vector BlackBoxOp::Keccakf1600::bincodeSerialize() const -{ - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); -} - -inline BlackBoxOp::Keccakf1600 BlackBoxOp::Keccakf1600::bincodeDeserialize(std::vector input) -{ - auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); - if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); - } - return value; -} - -} // end of namespace Circuit - -template <> -template -void serde::Serializable::serialize(const Circuit::BlackBoxOp::Keccakf1600& obj, - Serializer& serializer) -{ - serde::Serializable::serialize(obj.message, serializer); - serde::Serializable::serialize(obj.output, serializer); -} - -template <> -template -Circuit::BlackBoxOp::Keccakf1600 serde::Deserializable::deserialize( - Deserializer& deserializer) -{ - Circuit::BlackBoxOp::Keccakf1600 obj; - obj.message = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); - return obj; -} - -namespace Circuit { - -inline bool operator==(const BlackBoxOp::EcdsaSecp256k1& lhs, const BlackBoxOp::EcdsaSecp256k1& rhs) -{ - if (!(lhs.hashed_msg == rhs.hashed_msg)) { - return false; - } - if (!(lhs.public_key_x == rhs.public_key_x)) { - return false; - } - if (!(lhs.public_key_y == rhs.public_key_y)) { - return false; - } - if (!(lhs.signature == rhs.signature)) { - return false; - } - if (!(lhs.result == rhs.result)) { - return false; - } - return true; -} - -inline std::vector BlackBoxOp::EcdsaSecp256k1::bincodeSerialize() const -{ - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); -} - -inline BlackBoxOp::EcdsaSecp256k1 BlackBoxOp::EcdsaSecp256k1::bincodeDeserialize(std::vector input) -{ - auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); - if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); - } - return value; -} - -} // end of namespace Circuit - -template <> -template -void serde::Serializable::serialize(const Circuit::BlackBoxOp::EcdsaSecp256k1& obj, - Serializer& serializer) -{ - serde::Serializable::serialize(obj.hashed_msg, serializer); - serde::Serializable::serialize(obj.public_key_x, serializer); - serde::Serializable::serialize(obj.public_key_y, serializer); - serde::Serializable::serialize(obj.signature, serializer); - serde::Serializable::serialize(obj.result, serializer); -} - -template <> -template -Circuit::BlackBoxOp::EcdsaSecp256k1 serde::Deserializable::deserialize( - Deserializer& deserializer) -{ - Circuit::BlackBoxOp::EcdsaSecp256k1 obj; - obj.hashed_msg = serde::Deserializable::deserialize(deserializer); - obj.public_key_x = serde::Deserializable::deserialize(deserializer); - obj.public_key_y = serde::Deserializable::deserialize(deserializer); - obj.signature = serde::Deserializable::deserialize(deserializer); - obj.result = serde::Deserializable::deserialize(deserializer); - return obj; -} - -namespace Circuit { - -inline bool operator==(const BlackBoxOp::EcdsaSecp256r1& lhs, const BlackBoxOp::EcdsaSecp256r1& rhs) -{ - if (!(lhs.hashed_msg == rhs.hashed_msg)) { - return false; - } - if (!(lhs.public_key_x == rhs.public_key_x)) { - return false; - } - if (!(lhs.public_key_y == rhs.public_key_y)) { - return false; - } - if (!(lhs.signature == rhs.signature)) { - return false; - } - if (!(lhs.result == rhs.result)) { - return false; - } - return true; -} - -inline std::vector BlackBoxOp::EcdsaSecp256r1::bincodeSerialize() const -{ - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); -} - -inline BlackBoxOp::EcdsaSecp256r1 BlackBoxOp::EcdsaSecp256r1::bincodeDeserialize(std::vector input) -{ - auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); - if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); - } - return value; -} - -} // end of namespace Circuit - -template <> -template -void serde::Serializable::serialize(const Circuit::BlackBoxOp::EcdsaSecp256r1& obj, - Serializer& serializer) -{ - serde::Serializable::serialize(obj.hashed_msg, serializer); - serde::Serializable::serialize(obj.public_key_x, serializer); - serde::Serializable::serialize(obj.public_key_y, serializer); - serde::Serializable::serialize(obj.signature, serializer); - serde::Serializable::serialize(obj.result, serializer); -} - -template <> -template -Circuit::BlackBoxOp::EcdsaSecp256r1 serde::Deserializable::deserialize( - Deserializer& deserializer) -{ - Circuit::BlackBoxOp::EcdsaSecp256r1 obj; - obj.hashed_msg = serde::Deserializable::deserialize(deserializer); - obj.public_key_x = serde::Deserializable::deserialize(deserializer); - obj.public_key_y = serde::Deserializable::deserialize(deserializer); - obj.signature = serde::Deserializable::deserialize(deserializer); - obj.result = serde::Deserializable::deserialize(deserializer); - return obj; -} - -namespace Circuit { - -inline bool operator==(const BlackBoxOp::SchnorrVerify& lhs, const BlackBoxOp::SchnorrVerify& rhs) -{ - if (!(lhs.public_key_x == rhs.public_key_x)) { - return false; - } - if (!(lhs.public_key_y == rhs.public_key_y)) { - return false; - } - if (!(lhs.message == rhs.message)) { - return false; - } - if (!(lhs.signature == rhs.signature)) { - return false; - } - if (!(lhs.result == rhs.result)) { - return false; - } - return true; -} - -inline std::vector BlackBoxOp::SchnorrVerify::bincodeSerialize() const -{ - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); -} - -inline BlackBoxOp::SchnorrVerify BlackBoxOp::SchnorrVerify::bincodeDeserialize(std::vector input) -{ - auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); - if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); - } - return value; -} - -} // end of namespace Circuit - -template <> -template -void serde::Serializable::serialize(const Circuit::BlackBoxOp::SchnorrVerify& obj, - Serializer& serializer) -{ - serde::Serializable::serialize(obj.public_key_x, serializer); - serde::Serializable::serialize(obj.public_key_y, serializer); - serde::Serializable::serialize(obj.message, serializer); - serde::Serializable::serialize(obj.signature, serializer); - serde::Serializable::serialize(obj.result, serializer); -} - -template <> -template -Circuit::BlackBoxOp::SchnorrVerify serde::Deserializable::deserialize( - Deserializer& deserializer) -{ - Circuit::BlackBoxOp::SchnorrVerify obj; - obj.public_key_x = serde::Deserializable::deserialize(deserializer); - obj.public_key_y = serde::Deserializable::deserialize(deserializer); - obj.message = serde::Deserializable::deserialize(deserializer); - obj.signature = serde::Deserializable::deserialize(deserializer); - obj.result = serde::Deserializable::deserialize(deserializer); - return obj; -} - -namespace Circuit { - -inline bool operator==(const BlackBoxOp::PedersenCommitment& lhs, const BlackBoxOp::PedersenCommitment& rhs) -{ - if (!(lhs.inputs == rhs.inputs)) { - return false; - } - if (!(lhs.domain_separator == rhs.domain_separator)) { - return false; - } - if (!(lhs.output == rhs.output)) { - return false; - } - return true; -} - -inline std::vector BlackBoxOp::PedersenCommitment::bincodeSerialize() const -{ - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); -} - -inline BlackBoxOp::PedersenCommitment BlackBoxOp::PedersenCommitment::bincodeDeserialize(std::vector input) -{ - auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); - if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); - } - return value; -} - -} // end of namespace Circuit - -template <> -template -void serde::Serializable::serialize( - const Circuit::BlackBoxOp::PedersenCommitment& obj, Serializer& serializer) -{ - serde::Serializable::serialize(obj.inputs, serializer); - serde::Serializable::serialize(obj.domain_separator, serializer); - serde::Serializable::serialize(obj.output, serializer); -} - -template <> -template -Circuit::BlackBoxOp::PedersenCommitment serde::Deserializable::deserialize( - Deserializer& deserializer) -{ - Circuit::BlackBoxOp::PedersenCommitment obj; - obj.inputs = serde::Deserializable::deserialize(deserializer); - obj.domain_separator = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); - return obj; -} - -namespace Circuit { - -inline bool operator==(const BlackBoxOp::PedersenHash& lhs, const BlackBoxOp::PedersenHash& rhs) -{ - if (!(lhs.inputs == rhs.inputs)) { - return false; - } - if (!(lhs.domain_separator == rhs.domain_separator)) { - return false; - } - if (!(lhs.output == rhs.output)) { - return false; - } - return true; -} - -inline std::vector BlackBoxOp::PedersenHash::bincodeSerialize() const -{ - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); -} - -inline BlackBoxOp::PedersenHash BlackBoxOp::PedersenHash::bincodeDeserialize(std::vector input) -{ - auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); - if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); - } - return value; -} - -} // end of namespace Circuit - -template <> -template -void serde::Serializable::serialize(const Circuit::BlackBoxOp::PedersenHash& obj, - Serializer& serializer) -{ - serde::Serializable::serialize(obj.inputs, serializer); - serde::Serializable::serialize(obj.domain_separator, serializer); - serde::Serializable::serialize(obj.output, serializer); -} - -template <> -template -Circuit::BlackBoxOp::PedersenHash serde::Deserializable::deserialize( - Deserializer& deserializer) -{ - Circuit::BlackBoxOp::PedersenHash obj; - obj.inputs = serde::Deserializable::deserialize(deserializer); - obj.domain_separator = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); - return obj; -} - -namespace Circuit { - -inline bool operator==(const BlackBoxOp::FixedBaseScalarMul& lhs, const BlackBoxOp::FixedBaseScalarMul& rhs) -{ - if (!(lhs.low == rhs.low)) { - return false; - } - if (!(lhs.high == rhs.high)) { - return false; - } - if (!(lhs.result == rhs.result)) { - return false; - } - return true; -} - -inline std::vector BlackBoxOp::FixedBaseScalarMul::bincodeSerialize() const -{ - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); -} - -inline BlackBoxOp::FixedBaseScalarMul BlackBoxOp::FixedBaseScalarMul::bincodeDeserialize(std::vector input) -{ - auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); - if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); - } - return value; -} - -} // end of namespace Circuit - -template <> -template -void serde::Serializable::serialize( - const Circuit::BlackBoxOp::FixedBaseScalarMul& obj, Serializer& serializer) -{ - serde::Serializable::serialize(obj.low, serializer); - serde::Serializable::serialize(obj.high, serializer); - serde::Serializable::serialize(obj.result, serializer); -} - -template <> -template -Circuit::BlackBoxOp::FixedBaseScalarMul serde::Deserializable::deserialize( - Deserializer& deserializer) -{ - Circuit::BlackBoxOp::FixedBaseScalarMul obj; - obj.low = serde::Deserializable::deserialize(deserializer); - obj.high = serde::Deserializable::deserialize(deserializer); - obj.result = serde::Deserializable::deserialize(deserializer); - return obj; -} - -namespace Circuit { - -inline bool operator==(const BlackBoxOp::EmbeddedCurveAdd& lhs, const BlackBoxOp::EmbeddedCurveAdd& rhs) -{ - if (!(lhs.input1_x == rhs.input1_x)) { - return false; - } - if (!(lhs.input1_y == rhs.input1_y)) { - return false; - } - if (!(lhs.input2_x == rhs.input2_x)) { + if (!(lhs.public_key_y == rhs.public_key_y)) { return false; } - if (!(lhs.input2_y == rhs.input2_y)) { + if (!(lhs.signature == rhs.signature)) { return false; } if (!(lhs.result == rhs.result)) { @@ -4049,17 +3277,17 @@ inline bool operator==(const BlackBoxOp::EmbeddedCurveAdd& lhs, const BlackBoxOp return true; } -inline std::vector BlackBoxOp::EmbeddedCurveAdd::bincodeSerialize() const +inline std::vector BlackBoxOp::EcdsaSecp256r1::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::EmbeddedCurveAdd BlackBoxOp::EmbeddedCurveAdd::bincodeDeserialize(std::vector input) +inline BlackBoxOp::EcdsaSecp256r1 BlackBoxOp::EcdsaSecp256r1::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -4070,38 +3298,44 @@ inline BlackBoxOp::EmbeddedCurveAdd BlackBoxOp::EmbeddedCurveAdd::bincodeDeseria template <> template -void serde::Serializable::serialize( - const Circuit::BlackBoxOp::EmbeddedCurveAdd& obj, Serializer& serializer) +void serde::Serializable::serialize(const Circuit::BlackBoxOp::EcdsaSecp256r1& obj, + Serializer& serializer) { - serde::Serializable::serialize(obj.input1_x, serializer); - serde::Serializable::serialize(obj.input1_y, serializer); - serde::Serializable::serialize(obj.input2_x, serializer); - serde::Serializable::serialize(obj.input2_y, serializer); + serde::Serializable::serialize(obj.hashed_msg, serializer); + serde::Serializable::serialize(obj.public_key_x, serializer); + serde::Serializable::serialize(obj.public_key_y, serializer); + serde::Serializable::serialize(obj.signature, serializer); serde::Serializable::serialize(obj.result, serializer); } template <> template -Circuit::BlackBoxOp::EmbeddedCurveAdd serde::Deserializable::deserialize( +Circuit::BlackBoxOp::EcdsaSecp256r1 serde::Deserializable::deserialize( Deserializer& deserializer) { - Circuit::BlackBoxOp::EmbeddedCurveAdd obj; - obj.input1_x = serde::Deserializable::deserialize(deserializer); - obj.input1_y = serde::Deserializable::deserialize(deserializer); - obj.input2_x = serde::Deserializable::deserialize(deserializer); - obj.input2_y = serde::Deserializable::deserialize(deserializer); + Circuit::BlackBoxOp::EcdsaSecp256r1 obj; + obj.hashed_msg = serde::Deserializable::deserialize(deserializer); + obj.public_key_x = serde::Deserializable::deserialize(deserializer); + obj.public_key_y = serde::Deserializable::deserialize(deserializer); + obj.signature = serde::Deserializable::deserialize(deserializer); obj.result = serde::Deserializable::deserialize(deserializer); return obj; } namespace Circuit { -inline bool operator==(const BlackBoxOp::EmbeddedCurveDouble& lhs, const BlackBoxOp::EmbeddedCurveDouble& rhs) +inline bool operator==(const BlackBoxOp::SchnorrVerify& lhs, const BlackBoxOp::SchnorrVerify& rhs) { - if (!(lhs.input1_x == rhs.input1_x)) { + if (!(lhs.public_key_x == rhs.public_key_x)) { return false; } - if (!(lhs.input1_y == rhs.input1_y)) { + if (!(lhs.public_key_y == rhs.public_key_y)) { + return false; + } + if (!(lhs.message == rhs.message)) { + return false; + } + if (!(lhs.signature == rhs.signature)) { return false; } if (!(lhs.result == rhs.result)) { @@ -4110,17 +3344,17 @@ inline bool operator==(const BlackBoxOp::EmbeddedCurveDouble& lhs, const BlackBo return true; } -inline std::vector BlackBoxOp::EmbeddedCurveDouble::bincodeSerialize() const +inline std::vector BlackBoxOp::SchnorrVerify::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::EmbeddedCurveDouble BlackBoxOp::EmbeddedCurveDouble::bincodeDeserialize(std::vector input) +inline BlackBoxOp::SchnorrVerify BlackBoxOp::SchnorrVerify::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -4131,34 +3365,38 @@ inline BlackBoxOp::EmbeddedCurveDouble BlackBoxOp::EmbeddedCurveDouble::bincodeD template <> template -void serde::Serializable::serialize( - const Circuit::BlackBoxOp::EmbeddedCurveDouble& obj, Serializer& serializer) +void serde::Serializable::serialize(const Circuit::BlackBoxOp::SchnorrVerify& obj, + Serializer& serializer) { - serde::Serializable::serialize(obj.input1_x, serializer); - serde::Serializable::serialize(obj.input1_y, serializer); + serde::Serializable::serialize(obj.public_key_x, serializer); + serde::Serializable::serialize(obj.public_key_y, serializer); + serde::Serializable::serialize(obj.message, serializer); + serde::Serializable::serialize(obj.signature, serializer); serde::Serializable::serialize(obj.result, serializer); } template <> template -Circuit::BlackBoxOp::EmbeddedCurveDouble serde::Deserializable::deserialize( +Circuit::BlackBoxOp::SchnorrVerify serde::Deserializable::deserialize( Deserializer& deserializer) { - Circuit::BlackBoxOp::EmbeddedCurveDouble obj; - obj.input1_x = serde::Deserializable::deserialize(deserializer); - obj.input1_y = serde::Deserializable::deserialize(deserializer); + Circuit::BlackBoxOp::SchnorrVerify obj; + obj.public_key_x = serde::Deserializable::deserialize(deserializer); + obj.public_key_y = serde::Deserializable::deserialize(deserializer); + obj.message = serde::Deserializable::deserialize(deserializer); + obj.signature = serde::Deserializable::deserialize(deserializer); obj.result = serde::Deserializable::deserialize(deserializer); return obj; } namespace Circuit { -inline bool operator==(const BlackBoxOp::BigIntAdd& lhs, const BlackBoxOp::BigIntAdd& rhs) +inline bool operator==(const BlackBoxOp::PedersenCommitment& lhs, const BlackBoxOp::PedersenCommitment& rhs) { - if (!(lhs.lhs == rhs.lhs)) { + if (!(lhs.inputs == rhs.inputs)) { return false; } - if (!(lhs.rhs == rhs.rhs)) { + if (!(lhs.domain_separator == rhs.domain_separator)) { return false; } if (!(lhs.output == rhs.output)) { @@ -4167,17 +3405,17 @@ inline bool operator==(const BlackBoxOp::BigIntAdd& lhs, const BlackBoxOp::BigIn return true; } -inline std::vector BlackBoxOp::BigIntAdd::bincodeSerialize() const +inline std::vector BlackBoxOp::PedersenCommitment::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::BigIntAdd BlackBoxOp::BigIntAdd::bincodeDeserialize(std::vector input) +inline BlackBoxOp::PedersenCommitment BlackBoxOp::PedersenCommitment::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -4188,34 +3426,34 @@ inline BlackBoxOp::BigIntAdd BlackBoxOp::BigIntAdd::bincodeDeserialize(std::vect template <> template -void serde::Serializable::serialize(const Circuit::BlackBoxOp::BigIntAdd& obj, - Serializer& serializer) +void serde::Serializable::serialize( + const Circuit::BlackBoxOp::PedersenCommitment& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.lhs, serializer); - serde::Serializable::serialize(obj.rhs, serializer); + serde::Serializable::serialize(obj.inputs, serializer); + serde::Serializable::serialize(obj.domain_separator, serializer); serde::Serializable::serialize(obj.output, serializer); } template <> template -Circuit::BlackBoxOp::BigIntAdd serde::Deserializable::deserialize( +Circuit::BlackBoxOp::PedersenCommitment serde::Deserializable::deserialize( Deserializer& deserializer) { - Circuit::BlackBoxOp::BigIntAdd obj; - obj.lhs = serde::Deserializable::deserialize(deserializer); - obj.rhs = serde::Deserializable::deserialize(deserializer); + Circuit::BlackBoxOp::PedersenCommitment obj; + obj.inputs = serde::Deserializable::deserialize(deserializer); + obj.domain_separator = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Circuit { -inline bool operator==(const BlackBoxOp::BigIntNeg& lhs, const BlackBoxOp::BigIntNeg& rhs) +inline bool operator==(const BlackBoxOp::PedersenHash& lhs, const BlackBoxOp::PedersenHash& rhs) { - if (!(lhs.lhs == rhs.lhs)) { + if (!(lhs.inputs == rhs.inputs)) { return false; } - if (!(lhs.rhs == rhs.rhs)) { + if (!(lhs.domain_separator == rhs.domain_separator)) { return false; } if (!(lhs.output == rhs.output)) { @@ -4224,17 +3462,17 @@ inline bool operator==(const BlackBoxOp::BigIntNeg& lhs, const BlackBoxOp::BigIn return true; } -inline std::vector BlackBoxOp::BigIntNeg::bincodeSerialize() const +inline std::vector BlackBoxOp::PedersenHash::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::BigIntNeg BlackBoxOp::BigIntNeg::bincodeDeserialize(std::vector input) +inline BlackBoxOp::PedersenHash BlackBoxOp::PedersenHash::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -4245,53 +3483,53 @@ inline BlackBoxOp::BigIntNeg BlackBoxOp::BigIntNeg::bincodeDeserialize(std::vect template <> template -void serde::Serializable::serialize(const Circuit::BlackBoxOp::BigIntNeg& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Circuit::BlackBoxOp::PedersenHash& obj, + Serializer& serializer) { - serde::Serializable::serialize(obj.lhs, serializer); - serde::Serializable::serialize(obj.rhs, serializer); + serde::Serializable::serialize(obj.inputs, serializer); + serde::Serializable::serialize(obj.domain_separator, serializer); serde::Serializable::serialize(obj.output, serializer); } template <> template -Circuit::BlackBoxOp::BigIntNeg serde::Deserializable::deserialize( +Circuit::BlackBoxOp::PedersenHash serde::Deserializable::deserialize( Deserializer& deserializer) { - Circuit::BlackBoxOp::BigIntNeg obj; - obj.lhs = serde::Deserializable::deserialize(deserializer); - obj.rhs = serde::Deserializable::deserialize(deserializer); + Circuit::BlackBoxOp::PedersenHash obj; + obj.inputs = serde::Deserializable::deserialize(deserializer); + obj.domain_separator = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Circuit { -inline bool operator==(const BlackBoxOp::BigIntMul& lhs, const BlackBoxOp::BigIntMul& rhs) +inline bool operator==(const BlackBoxOp::FixedBaseScalarMul& lhs, const BlackBoxOp::FixedBaseScalarMul& rhs) { - if (!(lhs.lhs == rhs.lhs)) { + if (!(lhs.low == rhs.low)) { return false; } - if (!(lhs.rhs == rhs.rhs)) { + if (!(lhs.high == rhs.high)) { return false; } - if (!(lhs.output == rhs.output)) { + if (!(lhs.result == rhs.result)) { return false; } return true; } -inline std::vector BlackBoxOp::BigIntMul::bincodeSerialize() const +inline std::vector BlackBoxOp::FixedBaseScalarMul::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::BigIntMul BlackBoxOp::BigIntMul::bincodeDeserialize(std::vector input) +inline BlackBoxOp::FixedBaseScalarMul BlackBoxOp::FixedBaseScalarMul::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -4302,110 +3540,59 @@ inline BlackBoxOp::BigIntMul BlackBoxOp::BigIntMul::bincodeDeserialize(std::vect template <> template -void serde::Serializable::serialize(const Circuit::BlackBoxOp::BigIntMul& obj, - Serializer& serializer) +void serde::Serializable::serialize( + const Circuit::BlackBoxOp::FixedBaseScalarMul& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.lhs, serializer); - serde::Serializable::serialize(obj.rhs, serializer); - serde::Serializable::serialize(obj.output, serializer); + serde::Serializable::serialize(obj.low, serializer); + serde::Serializable::serialize(obj.high, serializer); + serde::Serializable::serialize(obj.result, serializer); } template <> template -Circuit::BlackBoxOp::BigIntMul serde::Deserializable::deserialize( +Circuit::BlackBoxOp::FixedBaseScalarMul serde::Deserializable::deserialize( Deserializer& deserializer) { - Circuit::BlackBoxOp::BigIntMul obj; - obj.lhs = serde::Deserializable::deserialize(deserializer); - obj.rhs = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); + Circuit::BlackBoxOp::FixedBaseScalarMul obj; + obj.low = serde::Deserializable::deserialize(deserializer); + obj.high = serde::Deserializable::deserialize(deserializer); + obj.result = serde::Deserializable::deserialize(deserializer); return obj; } namespace Circuit { -inline bool operator==(const BlackBoxOp::BigIntDiv& lhs, const BlackBoxOp::BigIntDiv& rhs) +inline bool operator==(const BlackBoxOp::EmbeddedCurveAdd& lhs, const BlackBoxOp::EmbeddedCurveAdd& rhs) { - if (!(lhs.lhs == rhs.lhs)) { - return false; - } - if (!(lhs.rhs == rhs.rhs)) { + if (!(lhs.input1_x == rhs.input1_x)) { return false; } - if (!(lhs.output == rhs.output)) { + if (!(lhs.input1_y == rhs.input1_y)) { return false; } - return true; -} - -inline std::vector BlackBoxOp::BigIntDiv::bincodeSerialize() const -{ - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); -} - -inline BlackBoxOp::BigIntDiv BlackBoxOp::BigIntDiv::bincodeDeserialize(std::vector input) -{ - auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); - if (deserializer.get_buffer_offset() < input.size()) { - throw_or_abort("Some input bytes were not read"); - } - return value; -} - -} // end of namespace Circuit - -template <> -template -void serde::Serializable::serialize(const Circuit::BlackBoxOp::BigIntDiv& obj, - Serializer& serializer) -{ - serde::Serializable::serialize(obj.lhs, serializer); - serde::Serializable::serialize(obj.rhs, serializer); - serde::Serializable::serialize(obj.output, serializer); -} - -template <> -template -Circuit::BlackBoxOp::BigIntDiv serde::Deserializable::deserialize( - Deserializer& deserializer) -{ - Circuit::BlackBoxOp::BigIntDiv obj; - obj.lhs = serde::Deserializable::deserialize(deserializer); - obj.rhs = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); - return obj; -} - -namespace Circuit { - -inline bool operator==(const BlackBoxOp::BigIntFromLeBytes& lhs, const BlackBoxOp::BigIntFromLeBytes& rhs) -{ - if (!(lhs.inputs == rhs.inputs)) { + if (!(lhs.input2_x == rhs.input2_x)) { return false; } - if (!(lhs.modulus == rhs.modulus)) { + if (!(lhs.input2_y == rhs.input2_y)) { return false; } - if (!(lhs.output == rhs.output)) { + if (!(lhs.result == rhs.result)) { return false; } return true; } -inline std::vector BlackBoxOp::BigIntFromLeBytes::bincodeSerialize() const +inline std::vector BlackBoxOp::EmbeddedCurveAdd::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::BigIntFromLeBytes BlackBoxOp::BigIntFromLeBytes::bincodeDeserialize(std::vector input) +inline BlackBoxOp::EmbeddedCurveAdd BlackBoxOp::EmbeddedCurveAdd::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -4416,50 +3603,57 @@ inline BlackBoxOp::BigIntFromLeBytes BlackBoxOp::BigIntFromLeBytes::bincodeDeser template <> template -void serde::Serializable::serialize( - const Circuit::BlackBoxOp::BigIntFromLeBytes& obj, Serializer& serializer) +void serde::Serializable::serialize( + const Circuit::BlackBoxOp::EmbeddedCurveAdd& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.inputs, serializer); - serde::Serializable::serialize(obj.modulus, serializer); - serde::Serializable::serialize(obj.output, serializer); + serde::Serializable::serialize(obj.input1_x, serializer); + serde::Serializable::serialize(obj.input1_y, serializer); + serde::Serializable::serialize(obj.input2_x, serializer); + serde::Serializable::serialize(obj.input2_y, serializer); + serde::Serializable::serialize(obj.result, serializer); } template <> template -Circuit::BlackBoxOp::BigIntFromLeBytes serde::Deserializable::deserialize( +Circuit::BlackBoxOp::EmbeddedCurveAdd serde::Deserializable::deserialize( Deserializer& deserializer) { - Circuit::BlackBoxOp::BigIntFromLeBytes obj; - obj.inputs = serde::Deserializable::deserialize(deserializer); - obj.modulus = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); + Circuit::BlackBoxOp::EmbeddedCurveAdd obj; + obj.input1_x = serde::Deserializable::deserialize(deserializer); + obj.input1_y = serde::Deserializable::deserialize(deserializer); + obj.input2_x = serde::Deserializable::deserialize(deserializer); + obj.input2_y = serde::Deserializable::deserialize(deserializer); + obj.result = serde::Deserializable::deserialize(deserializer); return obj; } namespace Circuit { -inline bool operator==(const BlackBoxOp::BigIntToLeBytes& lhs, const BlackBoxOp::BigIntToLeBytes& rhs) +inline bool operator==(const BlackBoxOp::EmbeddedCurveDouble& lhs, const BlackBoxOp::EmbeddedCurveDouble& rhs) { - if (!(lhs.input == rhs.input)) { + if (!(lhs.input1_x == rhs.input1_x)) { return false; } - if (!(lhs.output == rhs.output)) { + if (!(lhs.input1_y == rhs.input1_y)) { + return false; + } + if (!(lhs.result == rhs.result)) { return false; } return true; } -inline std::vector BlackBoxOp::BigIntToLeBytes::bincodeSerialize() const +inline std::vector BlackBoxOp::EmbeddedCurveDouble::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::BigIntToLeBytes BlackBoxOp::BigIntToLeBytes::bincodeDeserialize(std::vector input) +inline BlackBoxOp::EmbeddedCurveDouble BlackBoxOp::EmbeddedCurveDouble::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -4470,21 +3664,23 @@ inline BlackBoxOp::BigIntToLeBytes BlackBoxOp::BigIntToLeBytes::bincodeDeseriali template <> template -void serde::Serializable::serialize( - const Circuit::BlackBoxOp::BigIntToLeBytes& obj, Serializer& serializer) +void serde::Serializable::serialize( + const Circuit::BlackBoxOp::EmbeddedCurveDouble& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.input, serializer); - serde::Serializable::serialize(obj.output, serializer); + serde::Serializable::serialize(obj.input1_x, serializer); + serde::Serializable::serialize(obj.input1_y, serializer); + serde::Serializable::serialize(obj.result, serializer); } template <> template -Circuit::BlackBoxOp::BigIntToLeBytes serde::Deserializable::deserialize( +Circuit::BlackBoxOp::EmbeddedCurveDouble serde::Deserializable::deserialize( Deserializer& deserializer) { - Circuit::BlackBoxOp::BigIntToLeBytes obj; - obj.input = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); + Circuit::BlackBoxOp::EmbeddedCurveDouble obj; + obj.input1_x = serde::Deserializable::deserialize(deserializer); + obj.input1_y = serde::Deserializable::deserialize(deserializer); + obj.result = serde::Deserializable::deserialize(deserializer); return obj; } diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.cpp index 072540db80f7..7c17e46d19bb 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.cpp @@ -3,6 +3,7 @@ #include "barretenberg/common/throw_or_abort.hpp" #include "barretenberg/dsl/acir_format/acir_format.hpp" #include "barretenberg/dsl/types.hpp" +#include "barretenberg/goblin/mock_circuits.hpp" #include "barretenberg/plonk/proof_system/proving_key/serialize.hpp" #include "barretenberg/plonk/proof_system/verification_key/sol_gen.hpp" #include "barretenberg/plonk/proof_system/verification_key/verification_key.hpp" @@ -24,7 +25,7 @@ AcirComposer::AcirComposer(size_t size_hint, bool verbose) * @param witness */ template -void AcirComposer::create_circuit(acir_format::AcirFormat& constraint_system, WitnessVector const& witness) +void AcirComposer::create_circuit(acir_format::acir_format& constraint_system, WitnessVector const& witness) { vinfo("building circuit..."); builder_ = acir_format::create_circuit(constraint_system, size_hint_, witness); @@ -60,6 +61,27 @@ std::vector AcirComposer::create_proof(bool is_recursive) return proof; } +void AcirComposer::create_goblin_circuit(acir_format::acir_format& constraint_system, + acir_format::WitnessVector& witness) +{ + // Construct a builder using the witness and public input data from acir + goblin_builder_ = acir_format::GoblinBuilder{ + goblin.op_queue, witness, constraint_system.public_inputs, constraint_system.varnum + }; + + // Populate constraints in the builder via the data in constraint_system + acir_format::build_constraints(goblin_builder_, constraint_system, true); + + // TODO(https://github.com/AztecProtocol/barretenberg/issues/817): Add some arbitrary op gates to ensure the + // associated polynomials are non-zero and to give ECCVM and Translator some ECC ops to process. + GoblinMockCircuits::construct_goblin_ecc_op_circuit(goblin_builder_); +} + +std::vector AcirComposer::create_goblin_proof() +{ + return goblin.construct_proof(goblin_builder_); +} + std::shared_ptr AcirComposer::init_verification_key() { if (!proving_key_) { @@ -110,6 +132,11 @@ bool AcirComposer::verify_proof(std::vector const& proof, bool is_recur } } +bool AcirComposer::verify_goblin_proof(std::vector const& proof) +{ + return goblin.verify_proof({ proof }); +} + std::string AcirComposer::get_solidity_verifier() { std::ostringstream stream; @@ -149,7 +176,7 @@ std::vector AcirComposer::serialize_verification_key_into_fields() return acir_format::export_key_in_recursion_format(verification_key_); } -template void AcirComposer::create_circuit(acir_format::AcirFormat& constraint_system, +template void AcirComposer::create_circuit(acir_format::acir_format& constraint_system, WitnessVector const& witness); } // namespace acir_proofs diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.hpp index a83d7f85c951..7acad4ff622a 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.hpp @@ -1,5 +1,6 @@ #pragma once #include +#include namespace acir_proofs { @@ -17,7 +18,7 @@ class AcirComposer { AcirComposer(size_t size_hint = 0, bool verbose = true); template - void create_circuit(acir_format::AcirFormat& constraint_system, WitnessVector const& witness = {}); + void create_circuit(acir_format::acir_format& constraint_system, WitnessVector const& witness = {}); std::shared_ptr init_proving_key(); @@ -37,8 +38,15 @@ class AcirComposer { std::vector serialize_verification_key_into_fields(); + // Goblin specific methods + void create_goblin_circuit(acir_format::acir_format& constraint_system, acir_format::WitnessVector& witness); + std::vector create_goblin_proof(); + bool verify_goblin_proof(std::vector const& proof); + private: acir_format::Builder builder_; + acir_format::GoblinBuilder goblin_builder_; + Goblin goblin; size_t size_hint_; std::shared_ptr proving_key_; std::shared_ptr verification_key_; diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp index 18d44941e567..954fe16832e3 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp @@ -6,7 +6,6 @@ #include "barretenberg/common/serialize.hpp" #include "barretenberg/common/slab_allocator.hpp" #include "barretenberg/dsl/acir_format/acir_format.hpp" -#include "barretenberg/dsl/acir_proofs/goblin_acir_composer.hpp" #include "barretenberg/plonk/proof_system/proving_key/serialize.hpp" #include "barretenberg/plonk/proof_system/verification_key/verification_key.hpp" #include "barretenberg/srs/global_crs.hpp" @@ -27,11 +26,6 @@ WASM_EXPORT void acir_new_acir_composer(uint32_t const* size_hint, out_ptr out) *out = new acir_proofs::AcirComposer(ntohl(*size_hint)); } -WASM_EXPORT void acir_new_goblin_acir_composer(out_ptr out) -{ - *out = new acir_proofs::GoblinAcirComposer(); -} - WASM_EXPORT void acir_delete_acir_composer(in_ptr acir_composer_ptr) { delete reinterpret_cast(*acir_composer_ptr); @@ -63,31 +57,17 @@ WASM_EXPORT void acir_create_proof(in_ptr acir_composer_ptr, *out = to_heap_buffer(proof_data); } -WASM_EXPORT void acir_goblin_accumulate(in_ptr acir_composer_ptr, - uint8_t const* acir_vec, - uint8_t const* witness_vec, - uint8_t** out) +WASM_EXPORT void acir_create_goblin_proof(in_ptr acir_composer_ptr, + uint8_t const* acir_vec, + uint8_t const* witness_vec, + uint8_t** out) { - auto acir_composer = reinterpret_cast(*acir_composer_ptr); - auto constraint_system = acir_format::circuit_buf_to_acir_format(from_buffer>(acir_vec)); - auto witness = acir_format::witness_buf_to_witness_data(from_buffer>(witness_vec)); - - acir_composer->create_circuit(constraint_system, witness); - auto proof_data = acir_composer->accumulate(); - *out = to_heap_buffer(proof_data); -} - -WASM_EXPORT void acir_goblin_prove(in_ptr acir_composer_ptr, - uint8_t const* acir_vec, - uint8_t const* witness_vec, - uint8_t** out) -{ - auto acir_composer = reinterpret_cast(*acir_composer_ptr); + auto acir_composer = reinterpret_cast(*acir_composer_ptr); auto constraint_system = acir_format::circuit_buf_to_acir_format(from_buffer>(acir_vec)); auto witness = acir_format::witness_buf_to_witness_data(from_buffer>(witness_vec)); - acir_composer->create_circuit(constraint_system, witness); - auto proof_data = acir_composer->accumulate_and_prove(); + acir_composer->create_goblin_circuit(constraint_system, witness); + auto proof_data = acir_composer->create_goblin_proof(); *out = to_heap_buffer(proof_data); } @@ -122,18 +102,11 @@ WASM_EXPORT void acir_get_proving_key(in_ptr acir_composer_ptr, uint8_t const* a *out = to_heap_buffer(to_buffer(*pk)); } -WASM_EXPORT void acir_goblin_verify_accumulator(in_ptr acir_composer_ptr, uint8_t const* proof_buf, bool* result) +WASM_EXPORT void acir_verify_goblin_proof(in_ptr acir_composer_ptr, uint8_t const* proof_buf, bool* result) { - auto acir_composer = reinterpret_cast(*acir_composer_ptr); - auto proof = from_buffer>(proof_buf); - *result = acir_composer->verify_accumulator(proof); -} - -WASM_EXPORT void acir_goblin_verify(in_ptr acir_composer_ptr, uint8_t const* proof_buf, bool* result) -{ - auto acir_composer = reinterpret_cast(*acir_composer_ptr); + auto acir_composer = reinterpret_cast(*acir_composer_ptr); auto proof = from_buffer>(proof_buf); - *result = acir_composer->verify(proof); + *result = acir_composer->verify_goblin_proof(proof); } WASM_EXPORT void acir_verify_proof(in_ptr acir_composer_ptr, diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.hpp index 76b24886b1d4..cb6b86435128 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.hpp @@ -13,8 +13,6 @@ WASM_EXPORT void acir_get_circuit_sizes(uint8_t const* constraint_system_buf, WASM_EXPORT void acir_new_acir_composer(uint32_t const* size_hint, out_ptr out); -WASM_EXPORT void acir_new_goblin_acir_composer(out_ptr out); - WASM_EXPORT void acir_delete_acir_composer(in_ptr acir_composer_ptr); WASM_EXPORT void acir_create_circuit(in_ptr acir_composer_ptr, @@ -34,25 +32,10 @@ WASM_EXPORT void acir_create_proof(in_ptr acir_composer_ptr, bool const* is_recursive, uint8_t** out); -/** - * @brief Perform the goblin accumulate operation - * @details Constructs a GUH proof and possibly handles transcript merge logic - * - */ -WASM_EXPORT void acir_goblin_accumulate(in_ptr acir_composer_ptr, - uint8_t const* constraint_system_buf, - uint8_t const* witness_buf, - uint8_t** out); - -/** - * @brief Construct a full goblin proof - * @details Makes a call to accumulate to a final circuit before constructing a Goblin proof - * - */ -WASM_EXPORT void acir_goblin_prove(in_ptr acir_composer_ptr, - uint8_t const* constraint_system_buf, - uint8_t const* witness_buf, - uint8_t** out); +WASM_EXPORT void acir_create_goblin_proof(in_ptr acir_composer_ptr, + uint8_t const* constraint_system_buf, + uint8_t const* witness_buf, + uint8_t** out); WASM_EXPORT void acir_load_verification_key(in_ptr acir_composer_ptr, uint8_t const* vk_buf); @@ -67,17 +50,7 @@ WASM_EXPORT void acir_verify_proof(in_ptr acir_composer_ptr, bool const* is_recursive, bool* result); -/** - * @brief Verifies a GUH proof produced during goblin accumulation - * - */ -WASM_EXPORT void acir_goblin_verify_accumulator(in_ptr acir_composer_ptr, uint8_t const* proof_buf, bool* result); - -/** - * @brief Verifies a full goblin proof (and the GUH proof produced by accumulation) - * - */ -WASM_EXPORT void acir_goblin_verify(in_ptr acir_composer_ptr, uint8_t const* proof_buf, bool* result); +WASM_EXPORT void acir_verify_goblin_proof(in_ptr acir_composer_ptr, uint8_t const* proof_buf, bool* result); WASM_EXPORT void acir_get_solidity_verifier(in_ptr acir_composer_ptr, out_str_buf out); diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/goblin_acir_composer.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/goblin_acir_composer.cpp deleted file mode 100644 index 3b0adc0ae5cb..000000000000 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/goblin_acir_composer.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include "goblin_acir_composer.hpp" -#include "barretenberg/common/throw_or_abort.hpp" -#include "barretenberg/dsl/acir_format/acir_format.hpp" -#include "barretenberg/dsl/types.hpp" -#include "barretenberg/goblin/mock_circuits.hpp" - -namespace acir_proofs { - -void GoblinAcirComposer::create_circuit(acir_format::AcirFormat& constraint_system, acir_format::WitnessVector& witness) -{ - // Construct a builder using the witness and public input data from acir and with the goblin-owned op_queue - builder_ = acir_format::GoblinBuilder{ - goblin.op_queue, witness, constraint_system.public_inputs, constraint_system.varnum - }; - - // Populate constraints in the builder via the data in constraint_system - acir_format::build_constraints(builder_, constraint_system, true); - - // TODO(https://github.com/AztecProtocol/barretenberg/issues/817): Add some arbitrary op gates to ensure the - // associated polynomials are non-zero and to give ECCVM and Translator some ECC ops to process. - GoblinMockCircuits::construct_goblin_ecc_op_circuit(builder_); -} - -std::vector GoblinAcirComposer::accumulate() -{ - // // Construct a GUH proof for the circuit via the accumulate mechanism - // return goblin.accumulate_for_acir(builder_); - - // Construct one final GUH proof via the accumulate mechanism - std::vector ultra_proof = goblin.accumulate_for_acir(builder_); - - // Construct a Goblin proof (ECCVM, Translator, Merge); result stored internally - goblin.prove_for_acir(); - - return ultra_proof; -} - -bool GoblinAcirComposer::verify_accumulator(std::vector const& proof) -{ - return goblin.verify_accumulator_for_acir(proof); -} - -std::vector GoblinAcirComposer::accumulate_and_prove() -{ - // Construct one final GUH proof via the accumulate mechanism - std::vector ultra_proof = goblin.accumulate_for_acir(builder_); - - // Construct a Goblin proof (ECCVM, Translator, Merge); result stored internally - goblin.prove_for_acir(); - - return ultra_proof; -} - -bool GoblinAcirComposer::verify(std::vector const& proof) -{ - // Verify the final GUH proof - bool ultra_verified = goblin.verify_accumulator_for_acir(proof); - - // Verify the Goblin proof (ECCVM, Translator, Merge) - bool goblin_verified = goblin.verify_for_acir(); - - return ultra_verified && goblin_verified; -} - -} // namespace acir_proofs diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/goblin_acir_composer.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/goblin_acir_composer.hpp deleted file mode 100644 index 6556b548045f..000000000000 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/goblin_acir_composer.hpp +++ /dev/null @@ -1,73 +0,0 @@ -#pragma once -#include -#include - -namespace acir_proofs { - -/** - * @brief A class responsible for marshalling construction of keys and prover and verifier instances used to prove - * satisfiability of circuits written in ACIR. - * - */ -class GoblinAcirComposer { - - using WitnessVector = std::vector>; - - public: - GoblinAcirComposer() = default; - - /** - * @brief Create a GUH circuit from an acir constraint system and a witness - * - * @param constraint_system ACIR representation of the constraints defining the circuit - * @param witness The witness values known to ACIR during construction of the constraint system - */ - void create_circuit(acir_format::AcirFormat& constraint_system, acir_format::WitnessVector& witness); - - /** - * @brief Accumulate a circuit via Goblin - * @details For the present circuit, construct a GUH proof and the vkey needed to verify it - * - * @return std::vector The GUH proof bytes - */ - std::vector accumulate(); - - /** - * @brief Verify the Goblin accumulator (the GUH proof) using the vkey internal to Goblin - * - * @param proof - * @return bool Whether or not the proof was verified - */ - bool verify_accumulator(std::vector const& proof); - - /** - * @brief Accumulate a final circuit and construct a full Goblin proof - * @details Accumulation means constructing a GUH proof of a single (final) circuit. A full Goblin proof consists of - * a merge proof, an ECCVM proof and a Translator proof. The Goblin proof is only constructed at the end of the - * accumulation phase and establishes the correctness of the ECC operations written to the op queue throughout the - * accumulation phase. - * - */ - std::vector accumulate_and_prove(); - - /** - * @brief Verify the final GUH proof and the full Goblin proof - * - * @return bool verified - */ - bool verify(std::vector const& proof); - - private: - acir_format::GoblinBuilder builder_; - Goblin goblin; - bool verbose_ = true; - - template inline void vinfo(Args... args) - { - if (verbose_) { - info(args...); - } - } -}; - -} // namespace acir_proofs diff --git a/barretenberg/cpp/src/barretenberg/dsl/types.hpp b/barretenberg/cpp/src/barretenberg/dsl/types.hpp index b5bf296cbf53..46e97b14db5b 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/types.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/types.hpp @@ -60,7 +60,7 @@ using secp256r1_ct = bb::stdlib::secp256r1; using hash_path_ct = bb::stdlib::merkle_tree::hash_path; -using schnorr_signature_bits_ct = bb::stdlib::schnorr_signature_bits; +using schnorr_signature_bits_ct = bb::stdlib::schnorr::signature_bits; // Ultra-composer specific typesv using rom_table_ct = bb::stdlib::rom_table; diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/bn254.hpp b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/bn254.hpp index 37d42124c7ec..4b171066d862 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/bn254.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/bn254.hpp @@ -6,7 +6,7 @@ #include "../bn254/g1.hpp" #include "../bn254/g2.hpp" -namespace bb::curve { +namespace curve { class BN254 { public: using ScalarField = bb::fr; @@ -23,4 +23,4 @@ class BN254 { // with stdlib types, and "native" verification will be acheived via a simulated builder. static constexpr bool is_stdlib_type = false; }; -} // namespace bb::curve \ No newline at end of file +} // namespace curve \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/g1.test.cpp b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/g1.test.cpp index e2171981250d..bf7d05d14cef 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/g1.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/g1.test.cpp @@ -3,6 +3,7 @@ using namespace bb; +namespace test_g1 { TEST(g1, RandomElement) { g1::element result = g1::element::random_element(); @@ -415,6 +416,7 @@ template void write(const T t) TEST(g1, InitializationCheck) { // NOLINTNEXTLINE not our fault googletest uses `goto`! - EXPECT_NO_THROW(write({})); + EXPECT_NO_THROW(write({})); } #endif +} // namespace test_g1 \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/g2.test.cpp b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/g2.test.cpp index ce198af48a91..6905aeb10234 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/g2.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/g2.test.cpp @@ -385,6 +385,6 @@ template void write(const T t) TEST(g2, InitializationCheck) { // NOLINTNEXTLINE not our fault googletest uses `goto`! - EXPECT_NO_THROW(write({})); + EXPECT_NO_THROW(write({})); } #endif \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/grumpkin/grumpkin.hpp b/barretenberg/cpp/src/barretenberg/ecc/curves/grumpkin/grumpkin.hpp index cfe12ad286f4..c378aad9ee64 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/grumpkin/grumpkin.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/grumpkin/grumpkin.hpp @@ -30,7 +30,7 @@ using g1 = bb::group; }; // namespace grumpkin -namespace bb::curve { +namespace curve { class Grumpkin { public: using ScalarField = bb::fq; @@ -44,4 +44,4 @@ class Grumpkin { // with stdlib types, and "native" verification will be acheived via a simulated builder. static constexpr bool is_stdlib_type = false; }; -} // namespace bb::curve \ No newline at end of file +} // namespace curve \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/grumpkin/grumpkin.test.cpp b/barretenberg/cpp/src/barretenberg/ecc/curves/grumpkin/grumpkin.test.cpp index 5573e08ea389..fefa6a6d0dcb 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/grumpkin/grumpkin.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/grumpkin/grumpkin.test.cpp @@ -2,12 +2,12 @@ #include #include -using namespace bb; +namespace test_grumpkin { TEST(grumpkin, CheckB) { auto b = grumpkin::g1::curve_b; - fr seventeen = 17; + bb::fr seventeen = 17; EXPECT_EQ(seventeen, -b); } @@ -329,3 +329,4 @@ TEST(grumpkin, BadPoints) } EXPECT_TRUE(res); } +} // namespace test_grumpkin \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/secp256k1/secp256k1.hpp b/barretenberg/cpp/src/barretenberg/ecc/curves/secp256k1/secp256k1.hpp index ce10122791cb..8b4a4d673674 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/secp256k1/secp256k1.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/secp256k1/secp256k1.hpp @@ -121,7 +121,7 @@ struct Secp256k1G1Params { using g1 = bb::group, bb::field, Secp256k1G1Params>; } // namespace secp256k1 -namespace bb::curve { +namespace curve { class SECP256K1 { public: using ScalarField = secp256k1::fr; @@ -130,6 +130,6 @@ class SECP256K1 { using Element = typename Group::element; using AffineElement = typename Group::affine_element; }; -} // namespace bb::curve +} // namespace curve // NOLINTEND(cppcoreguidelines-avoid-c-arrays) diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/secp256k1/secp256k1.test.cpp b/barretenberg/cpp/src/barretenberg/ecc/curves/secp256k1/secp256k1.test.cpp index 7fa8bee9ae68..f89688ecbd75 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/secp256k1/secp256k1.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/secp256k1/secp256k1.test.cpp @@ -2,9 +2,11 @@ #include "barretenberg/numeric/random/engine.hpp" #include -using namespace bb; +namespace test_secp256k1 { + namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); +} constexpr uint256_t test_fq_mod(secp256k1::Secp256k1FqParams::modulus_0, secp256k1::Secp256k1FqParams::modulus_1, @@ -19,7 +21,6 @@ uint256_t get_fq_element() } return res; } -} // namespace TEST(secp256k1, TestAdd) { @@ -503,3 +504,5 @@ TEST(secp256k1, MontgomeryMulBigBug) secp256k1::fq expected(uint256_t{ 0x60381e557e100000, 0x0, 0x0, 0x0 }); EXPECT_EQ((a_sqr == expected), true); } + +} // namespace test_secp256k1 diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/secp256r1/secp256r1.hpp b/barretenberg/cpp/src/barretenberg/ecc/curves/secp256r1/secp256r1.hpp index e28e86c16758..c4478e06b50d 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/secp256r1/secp256r1.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/secp256r1/secp256r1.hpp @@ -107,7 +107,7 @@ struct Secp256r1G1Params { using g1 = bb::group, bb::field, Secp256r1G1Params>; } // namespace secp256r1 -namespace bb::curve { +namespace curve { class SECP256R1 { public: using ScalarField = secp256r1::fr; @@ -116,6 +116,6 @@ class SECP256R1 { using Element = typename Group::element; using AffineElement = typename Group::affine_element; }; -} // namespace bb::curve +} // namespace curve // NOLINTEND(cppcoreguidelines-avoid-c-arrays) diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/secp256r1/secp256r1.test.cpp b/barretenberg/cpp/src/barretenberg/ecc/curves/secp256r1/secp256r1.test.cpp index 03f5a4bc8d15..14c67245092b 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/secp256r1/secp256r1.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/secp256r1/secp256r1.test.cpp @@ -2,9 +2,11 @@ #include "barretenberg/numeric/random/engine.hpp" #include -using namespace bb; +namespace test_secp256r1 { + namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); +} constexpr uint256_t test_fq_mod(secp256r1::Secp256r1FqParams::modulus_0, secp256r1::Secp256r1FqParams::modulus_1, @@ -19,7 +21,6 @@ uint256_t get_fq_element() } return res; } -} // namespace TEST(secp256r1, TestAdd) { @@ -445,3 +446,5 @@ TEST(secp256r1, MontgomeryMulBigBug) secp256r1::fr expected(uint256_t{ 0x57abc6aa0349c084, 0x65b21b232a4cb7a5, 0x5ba781948b0fcd6e, 0xd6e9e0644bda12f7 }); EXPECT_EQ((a_sqr == expected), true); } + +} // namespace test_secp256r1 diff --git a/barretenberg/cpp/src/barretenberg/ecc/fields/field12.hpp b/barretenberg/cpp/src/barretenberg/ecc/fields/field12.hpp index e69ba6888454..77d6dab770d4 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/fields/field12.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/fields/field12.hpp @@ -238,7 +238,7 @@ template cl }; } - static constexpr field12 random_element(numeric::RNG* engine = nullptr) + static constexpr field12 random_element(numeric::random::Engine* engine = nullptr) { return { base_field::random_element(engine), diff --git a/barretenberg/cpp/src/barretenberg/ecc/fields/field2.hpp b/barretenberg/cpp/src/barretenberg/ecc/fields/field2.hpp index b0cad83f0fff..aa42dad75aa2 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/fields/field2.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/fields/field2.hpp @@ -190,7 +190,7 @@ template constexpr void field2::self_frobenius_ma c1.self_neg(); } -template field2 field2::random_element(numeric::RNG* engine) +template field2 field2::random_element(numeric::random::Engine* engine) { return { base::random_element(engine), base::random_element(engine) }; } diff --git a/barretenberg/cpp/src/barretenberg/ecc/fields/field2_declarations.hpp b/barretenberg/cpp/src/barretenberg/ecc/fields/field2_declarations.hpp index d9607abfe89e..ba9a1281526f 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/fields/field2_declarations.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/fields/field2_declarations.hpp @@ -2,9 +2,9 @@ #include "barretenberg/numeric/uint256/uint256.hpp" -// forward declare RNG -namespace bb::numeric { -class RNG; +// forward declare Engine +namespace numeric::random { +class Engine; } namespace bb { @@ -115,7 +115,7 @@ template struct alignas(32) field2 { constexpr field2 frobenius_map() const noexcept; constexpr void self_frobenius_map() noexcept; - static field2 random_element(numeric::RNG* engine = nullptr); + static field2 random_element(numeric::random::Engine* engine = nullptr); static void serialize_to_buffer(const field2& value, uint8_t* buffer) { base_field::serialize_to_buffer(value.c0, buffer); diff --git a/barretenberg/cpp/src/barretenberg/ecc/fields/field6.hpp b/barretenberg/cpp/src/barretenberg/ecc/fields/field6.hpp index 0ee982f3f373..b69df21e2a34 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/fields/field6.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/fields/field6.hpp @@ -190,7 +190,7 @@ template class field6 { }; } - static constexpr field6 random_element(numeric::RNG* engine = nullptr) + static constexpr field6 random_element(numeric::random::Engine* engine = nullptr) { return { base_field::random_element(engine), diff --git a/barretenberg/cpp/src/barretenberg/ecc/fields/field_declarations.hpp b/barretenberg/cpp/src/barretenberg/ecc/fields/field_declarations.hpp index 217e2b42bd2a..192be60d0d28 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/fields/field_declarations.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/fields/field_declarations.hpp @@ -112,13 +112,6 @@ template struct alignas(32) field { *this = field(value); } - constexpr explicit operator bool() const - { - field out = from_montgomery_form(); - ASSERT(out.data[0] == 0 || out.data[0] == 1); - return static_cast(out.data[0]); - } - constexpr explicit operator uint32_t() const { field out = from_montgomery_form(); @@ -444,7 +437,7 @@ template struct alignas(32) field { src = T; } - static field random_element(numeric::RNG* engine = nullptr) noexcept; + static field random_element(numeric::random::Engine* engine = nullptr) noexcept; static constexpr field multiplicative_generator() noexcept; diff --git a/barretenberg/cpp/src/barretenberg/ecc/fields/field_impl.hpp b/barretenberg/cpp/src/barretenberg/ecc/fields/field_impl.hpp index 2149e131241c..ca322101b764 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/fields/field_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/fields/field_impl.hpp @@ -561,10 +561,10 @@ template constexpr field field::get_root_of_unity(size_t subgrou return r; } -template field field::random_element(numeric::RNG* engine) noexcept +template field field::random_element(numeric::random::Engine* engine) noexcept { if (engine == nullptr) { - engine = &numeric::get_randomness(); + engine = &numeric::random::get_engine(); } uint512_t source = engine->get_random_uint512(); diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.hpp b/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.hpp index 44f29ab98a8c..528bed056d3c 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.hpp @@ -77,9 +77,9 @@ template class alignas(64) affine_el * * @return A randomly chosen point on the curve */ - static affine_element random_element(numeric::RNG* engine = nullptr) noexcept; - static constexpr affine_element hash_to_curve( - const std::vector& seed, uint8_t attempt_count = 0) noexcept requires SupportsHashToCurve; + static affine_element random_element(numeric::random::Engine* engine = nullptr) noexcept; + static constexpr affine_element hash_to_curve(const std::vector& seed, uint8_t attempt_count = 0) noexcept + requires SupportsHashToCurve; constexpr bool operator==(const affine_element& other) const noexcept; diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.test.cpp b/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.test.cpp index 4dd06af4c38f..eb2bdfbbffa1 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.test.cpp @@ -7,6 +7,7 @@ #include "barretenberg/serialize/test_helper.hpp" #include +namespace TestAffineElement { template class TestAffineElement : public testing::Test { using element = typename G1::element; using affine_element = typename G1::affine_element; @@ -129,3 +130,4 @@ TEST(AffineElement, Msgpack) auto [actual, expected] = msgpack_roundtrip(secp256k1::g1::affine_element{ 1, 1 }); EXPECT_EQ(actual, expected); } +} // namespace TestAffineElement diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element_impl.hpp b/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element_impl.hpp index 9a87eee6f119..3c8b0d8504fd 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element_impl.hpp @@ -221,8 +221,9 @@ constexpr std::optional> affine_element::de * @return constexpr affine_element */ template -constexpr affine_element affine_element::hash_to_curve( - const std::vector& seed, uint8_t attempt_count) noexcept requires SupportsHashToCurve +constexpr affine_element affine_element::hash_to_curve(const std::vector& seed, + uint8_t attempt_count) noexcept + requires SupportsHashToCurve { std::vector target_seed(seed); @@ -262,10 +263,10 @@ constexpr affine_element affine_element::hash_to_curve( } template -affine_element affine_element::random_element(numeric::RNG* engine) noexcept +affine_element affine_element::random_element(numeric::random::Engine* engine) noexcept { if (engine == nullptr) { - engine = &numeric::get_randomness(); + engine = &numeric::random::get_engine(); } Fq x; diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/element.hpp b/barretenberg/cpp/src/barretenberg/ecc/groups/element.hpp index 637d3dda0a48..639b32b366ba 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/element.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/element.hpp @@ -49,7 +49,7 @@ template class alignas(32) element { constexpr operator affine_element() const noexcept; - static element random_element(numeric::RNG* engine = nullptr) noexcept; + static element random_element(numeric::random::Engine* engine = nullptr) noexcept; constexpr element dbl() const noexcept; constexpr void self_dbl() noexcept; @@ -106,7 +106,7 @@ template class alignas(32) element { element mul_with_endomorphism(const Fr& exponent) const noexcept; template > - static element random_coordinates_on_curve(numeric::RNG* engine = nullptr) noexcept; + static element random_coordinates_on_curve(numeric::random::Engine* engine = nullptr) noexcept; // { // bool found_one = false; // Fq yy; diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/element_impl.hpp b/barretenberg/cpp/src/barretenberg/ecc/groups/element_impl.hpp index 422065e42734..6a7cb0ada760 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/element_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/element_impl.hpp @@ -574,7 +574,7 @@ constexpr bool element::operator==(const element& other) const noexce } template -element element::random_element(numeric::RNG* engine) noexcept +element element::random_element(numeric::random::Engine* engine) noexcept { if constexpr (T::can_hash_to_curve) { element result = random_coordinates_on_curve(engine); @@ -1145,7 +1145,7 @@ void element::batch_normalize(element* elements, const size_t num_ele template template -element element::random_coordinates_on_curve(numeric::RNG* engine) noexcept +element element::random_coordinates_on_curve(numeric::random::Engine* engine) noexcept { bool found_one = false; Fq yy; diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/wnaf.test.cpp b/barretenberg/cpp/src/barretenberg/ecc/groups/wnaf.test.cpp index 7890577d64c1..01916f4c2bb6 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/wnaf.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/wnaf.test.cpp @@ -6,7 +6,7 @@ using namespace bb; namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } // NOLINTBEGIN(cppcoreguidelines-avoid-c-arrays) @@ -60,7 +60,7 @@ TEST(wnaf, WnafTwoBitWindow) constexpr uint32_t num_quads = (num_bits >> 1) + 1; uint64_t wnaf[num_quads] = { 0 }; bool skew = false; - wnaf::fixed_wnaf<256, 1, window>(&input.data[0], wnaf, skew, 0); + bb::wnaf::fixed_wnaf<256, 1, window>(&input.data[0], wnaf, skew, 0); /** * For representing even numbers, we define a skew: diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.test.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.test.cpp index bd9951553141..da81ec37eda3 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.test.cpp @@ -12,18 +12,19 @@ #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/sumcheck/sumcheck_round.hpp" -using namespace bb; using namespace bb::honk; +namespace test_eccvm_composer { + template class ECCVMComposerTests : public ::testing::Test { protected: // TODO(640): The Standard Honk on Grumpkin test suite fails unless the SRS is initialized for every test. void SetUp() override { if constexpr (std::is_same::value) { - srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); + bb::srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); } else { - srs::init_crs_factory("../srs_db/ignition"); + bb::srs::init_crs_factory("../srs_db/ignition"); } }; }; @@ -32,11 +33,11 @@ using FlavorTypes = ::testing::Types; TYPED_TEST_SUITE(ECCVMComposerTests, FlavorTypes); namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } -template ECCVMCircuitBuilder generate_trace(numeric::RNG* engine = nullptr) +template bb::ECCVMCircuitBuilder generate_trace(numeric::random::Engine* engine = nullptr) { - ECCVMCircuitBuilder result; + bb::ECCVMCircuitBuilder result; using G1 = typename Flavor::CycleGroup; using Fr = typename G1::Fr; @@ -101,3 +102,4 @@ TYPED_TEST(ECCVMComposerTests, EqFails) bool verified = verifier.verify_proof(proof); ASSERT_FALSE(verified); } +} // namespace test_eccvm_composer diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_transcript.test.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_transcript.test.cpp index c513bc991c4b..653275023654 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_transcript.test.cpp @@ -6,7 +6,6 @@ #include "barretenberg/transcript/transcript.hpp" #include -using namespace bb; using namespace bb::honk; template class ECCVMTranscriptTests : public ::testing::Test { @@ -14,9 +13,9 @@ template class ECCVMTranscriptTests : public ::testing::Test { void SetUp() override { if constexpr (std::is_same::value) { - srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); + bb::srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); } else { - srs::init_crs_factory("../srs_db/ignition"); + bb::srs::init_crs_factory("../srs_db/ignition"); } }; using FF = typename Flavor::FF; @@ -184,9 +183,9 @@ template class ECCVMTranscriptTests : public ::testing::Test { return manifest_expected; } - ECCVMCircuitBuilder generate_trace(numeric::RNG* engine = nullptr) + bb::ECCVMCircuitBuilder generate_trace(numeric::random::Engine* engine = nullptr) { - ECCVMCircuitBuilder result; + bb::ECCVMCircuitBuilder result; using G1 = typename Flavor::CycleGroup; using Fr = typename G1::Fr; @@ -220,7 +219,7 @@ template class ECCVMTranscriptTests : public ::testing::Test { } }; -numeric::RNG& engine = numeric::get_debug_randomness(); +numeric::random::Engine& engine = numeric::random::get_debug_engine(); using FlavorTypes = testing::Types; diff --git a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp index 2bf24f727f64..6af3285b00cf 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp @@ -26,7 +26,8 @@ // NOLINTBEGIN(cppcoreguidelines-avoid-const-or-ref-data-members) -namespace bb::honk::flavor { +namespace bb::honk { +namespace flavor { template class ECCVMBase { public: @@ -928,4 +929,5 @@ class ECCVM : public ECCVMBase #include -using namespace bb; - +namespace bb::test_flavor { TEST(Flavor, Getters) { - using Flavor = honk::flavor::Ultra; + using Flavor = bb::honk::flavor::Ultra; using FF = Flavor::FF; using ProvingKey = typename Flavor::ProvingKey; @@ -43,7 +42,7 @@ TEST(Flavor, Getters) TEST(Flavor, AllEntitiesSpecialMemberFunctions) { - using Flavor = honk::flavor::Ultra; + using Flavor = bb::honk::flavor::Ultra; using FF = Flavor::FF; using PartiallyEvaluatedMultivariates = Flavor::PartiallyEvaluatedMultivariates; using Polynomial = bb::Polynomial; @@ -69,7 +68,7 @@ TEST(Flavor, AllEntitiesSpecialMemberFunctions) TEST(Flavor, GetRow) { - using Flavor = honk::flavor::Ultra; + using Flavor = bb::honk::flavor::Ultra; using FF = typename Flavor::FF; std::array, Flavor::NUM_ALL_ENTITIES> data; std::generate(data.begin(), data.end(), []() { @@ -84,3 +83,4 @@ TEST(Flavor, GetRow) EXPECT_EQ(row0.q_elliptic, prover_polynomials.q_elliptic[0]); EXPECT_EQ(row1.w_4_shift, prover_polynomials.w_4_shift[1]); } +} // namespace bb::test_flavor diff --git a/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp b/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp index c1f672eb177d..f0ec7f92ee82 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp @@ -13,7 +13,6 @@ #include "barretenberg/flavor/flavor_macros.hpp" #include "barretenberg/polynomials/evaluation_domain.hpp" #include "barretenberg/polynomials/polynomial.hpp" -#include "barretenberg/relations/generated/AvmMini/alu_chip.hpp" #include "barretenberg/relations/generated/AvmMini/avm_mini.hpp" #include "barretenberg/relations/generated/AvmMini/mem_trace.hpp" #include "barretenberg/transcript/transcript.hpp" @@ -37,13 +36,13 @@ class AvmMiniFlavor { using RelationSeparator = FF; static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 2; - static constexpr size_t NUM_WITNESS_ENTITIES = 64; + static constexpr size_t NUM_WITNESS_ENTITIES = 38; static constexpr size_t NUM_WIRES = NUM_WITNESS_ENTITIES + NUM_PRECOMPUTED_ENTITIES; // We have two copies of the witness entities, so we subtract the number of fixed ones (they have no shift), one for // the unshifted and one for the shifted - static constexpr size_t NUM_ALL_ENTITIES = 80; + static constexpr size_t NUM_ALL_ENTITIES = 46; - using Relations = std::tuple, AvmMini_vm::avm_mini, AvmMini_vm::mem_trace>; + using Relations = std::tuple, AvmMini_vm::avm_mini>; static constexpr size_t MAX_PARTIAL_RELATION_LENGTH = compute_max_partial_relation_length(); @@ -88,32 +87,6 @@ class AvmMiniFlavor { memTrace_m_in_tag, memTrace_m_tag_err, memTrace_m_one_min_inv, - aluChip_alu_clk, - aluChip_alu_ia, - aluChip_alu_ib, - aluChip_alu_ic, - aluChip_alu_op_add, - aluChip_alu_op_sub, - aluChip_alu_op_mul, - aluChip_alu_op_div, - aluChip_alu_ff_tag, - aluChip_alu_u8_tag, - aluChip_alu_u16_tag, - aluChip_alu_u32_tag, - aluChip_alu_u64_tag, - aluChip_alu_u128_tag, - aluChip_alu_u8_r0, - aluChip_alu_u8_r1, - aluChip_alu_u16_r0, - aluChip_alu_u16_r1, - aluChip_alu_u16_r2, - aluChip_alu_u16_r3, - aluChip_alu_u16_r4, - aluChip_alu_u16_r5, - aluChip_alu_u16_r6, - aluChip_alu_u16_r7, - aluChip_alu_u64_r0, - aluChip_alu_cf, avmMini_pc, avmMini_internal_return_ptr, avmMini_sel_internal_call, @@ -155,32 +128,6 @@ class AvmMiniFlavor { memTrace_m_in_tag, memTrace_m_tag_err, memTrace_m_one_min_inv, - aluChip_alu_clk, - aluChip_alu_ia, - aluChip_alu_ib, - aluChip_alu_ic, - aluChip_alu_op_add, - aluChip_alu_op_sub, - aluChip_alu_op_mul, - aluChip_alu_op_div, - aluChip_alu_ff_tag, - aluChip_alu_u8_tag, - aluChip_alu_u16_tag, - aluChip_alu_u32_tag, - aluChip_alu_u64_tag, - aluChip_alu_u128_tag, - aluChip_alu_u8_r0, - aluChip_alu_u8_r1, - aluChip_alu_u16_r0, - aluChip_alu_u16_r1, - aluChip_alu_u16_r2, - aluChip_alu_u16_r3, - aluChip_alu_u16_r4, - aluChip_alu_u16_r5, - aluChip_alu_u16_r6, - aluChip_alu_u16_r7, - aluChip_alu_u64_r0, - aluChip_alu_cf, avmMini_pc, avmMini_internal_return_ptr, avmMini_sel_internal_call, @@ -228,32 +175,6 @@ class AvmMiniFlavor { memTrace_m_in_tag, memTrace_m_tag_err, memTrace_m_one_min_inv, - aluChip_alu_clk, - aluChip_alu_ia, - aluChip_alu_ib, - aluChip_alu_ic, - aluChip_alu_op_add, - aluChip_alu_op_sub, - aluChip_alu_op_mul, - aluChip_alu_op_div, - aluChip_alu_ff_tag, - aluChip_alu_u8_tag, - aluChip_alu_u16_tag, - aluChip_alu_u32_tag, - aluChip_alu_u64_tag, - aluChip_alu_u128_tag, - aluChip_alu_u8_r0, - aluChip_alu_u8_r1, - aluChip_alu_u16_r0, - aluChip_alu_u16_r1, - aluChip_alu_u16_r2, - aluChip_alu_u16_r3, - aluChip_alu_u16_r4, - aluChip_alu_u16_r5, - aluChip_alu_u16_r6, - aluChip_alu_u16_r7, - aluChip_alu_u64_r0, - aluChip_alu_cf, avmMini_pc, avmMini_internal_return_ptr, avmMini_sel_internal_call, @@ -281,20 +202,12 @@ class AvmMiniFlavor { avmMini_mem_idx_b, avmMini_mem_idx_c, avmMini_last, - aluChip_alu_u16_r1_shift, - aluChip_alu_u16_r0_shift, - aluChip_alu_u16_r4_shift, - aluChip_alu_u16_r7_shift, - aluChip_alu_u16_r5_shift, - aluChip_alu_u16_r2_shift, - aluChip_alu_u16_r6_shift, - aluChip_alu_u16_r3_shift, - avmMini_pc_shift, - avmMini_internal_return_ptr_shift, + memTrace_m_rw_shift, memTrace_m_tag_shift, memTrace_m_addr_shift, memTrace_m_val_shift, - memTrace_m_rw_shift) + avmMini_internal_return_ptr_shift, + avmMini_pc_shift) RefVector get_wires() { @@ -311,32 +224,6 @@ class AvmMiniFlavor { memTrace_m_in_tag, memTrace_m_tag_err, memTrace_m_one_min_inv, - aluChip_alu_clk, - aluChip_alu_ia, - aluChip_alu_ib, - aluChip_alu_ic, - aluChip_alu_op_add, - aluChip_alu_op_sub, - aluChip_alu_op_mul, - aluChip_alu_op_div, - aluChip_alu_ff_tag, - aluChip_alu_u8_tag, - aluChip_alu_u16_tag, - aluChip_alu_u32_tag, - aluChip_alu_u64_tag, - aluChip_alu_u128_tag, - aluChip_alu_u8_r0, - aluChip_alu_u8_r1, - aluChip_alu_u16_r0, - aluChip_alu_u16_r1, - aluChip_alu_u16_r2, - aluChip_alu_u16_r3, - aluChip_alu_u16_r4, - aluChip_alu_u16_r5, - aluChip_alu_u16_r6, - aluChip_alu_u16_r7, - aluChip_alu_u64_r0, - aluChip_alu_cf, avmMini_pc, avmMini_internal_return_ptr, avmMini_sel_internal_call, @@ -364,20 +251,12 @@ class AvmMiniFlavor { avmMini_mem_idx_b, avmMini_mem_idx_c, avmMini_last, - aluChip_alu_u16_r1_shift, - aluChip_alu_u16_r0_shift, - aluChip_alu_u16_r4_shift, - aluChip_alu_u16_r7_shift, - aluChip_alu_u16_r5_shift, - aluChip_alu_u16_r2_shift, - aluChip_alu_u16_r6_shift, - aluChip_alu_u16_r3_shift, - avmMini_pc_shift, - avmMini_internal_return_ptr_shift, + memTrace_m_rw_shift, memTrace_m_tag_shift, memTrace_m_addr_shift, memTrace_m_val_shift, - memTrace_m_rw_shift }; + avmMini_internal_return_ptr_shift, + avmMini_pc_shift }; }; RefVector get_unshifted() { @@ -394,32 +273,6 @@ class AvmMiniFlavor { memTrace_m_in_tag, memTrace_m_tag_err, memTrace_m_one_min_inv, - aluChip_alu_clk, - aluChip_alu_ia, - aluChip_alu_ib, - aluChip_alu_ic, - aluChip_alu_op_add, - aluChip_alu_op_sub, - aluChip_alu_op_mul, - aluChip_alu_op_div, - aluChip_alu_ff_tag, - aluChip_alu_u8_tag, - aluChip_alu_u16_tag, - aluChip_alu_u32_tag, - aluChip_alu_u64_tag, - aluChip_alu_u128_tag, - aluChip_alu_u8_r0, - aluChip_alu_u8_r1, - aluChip_alu_u16_r0, - aluChip_alu_u16_r1, - aluChip_alu_u16_r2, - aluChip_alu_u16_r3, - aluChip_alu_u16_r4, - aluChip_alu_u16_r5, - aluChip_alu_u16_r6, - aluChip_alu_u16_r7, - aluChip_alu_u64_r0, - aluChip_alu_cf, avmMini_pc, avmMini_internal_return_ptr, avmMini_sel_internal_call, @@ -450,23 +303,17 @@ class AvmMiniFlavor { }; RefVector get_to_be_shifted() { - return { aluChip_alu_u16_r1, aluChip_alu_u16_r0, - aluChip_alu_u16_r4, aluChip_alu_u16_r7, - aluChip_alu_u16_r5, aluChip_alu_u16_r2, - aluChip_alu_u16_r6, aluChip_alu_u16_r3, - avmMini_pc, avmMini_internal_return_ptr, - memTrace_m_tag, memTrace_m_addr, - memTrace_m_val, memTrace_m_rw }; + return { memTrace_m_rw, memTrace_m_tag, memTrace_m_addr, memTrace_m_val, avmMini_internal_return_ptr, + avmMini_pc }; }; RefVector get_shifted() { - return { aluChip_alu_u16_r1_shift, aluChip_alu_u16_r0_shift, - aluChip_alu_u16_r4_shift, aluChip_alu_u16_r7_shift, - aluChip_alu_u16_r5_shift, aluChip_alu_u16_r2_shift, - aluChip_alu_u16_r6_shift, aluChip_alu_u16_r3_shift, - avmMini_pc_shift, avmMini_internal_return_ptr_shift, - memTrace_m_tag_shift, memTrace_m_addr_shift, - memTrace_m_val_shift, memTrace_m_rw_shift }; + return { memTrace_m_rw_shift, + memTrace_m_tag_shift, + memTrace_m_addr_shift, + memTrace_m_val_shift, + avmMini_internal_return_ptr_shift, + avmMini_pc_shift }; }; }; @@ -479,13 +326,8 @@ class AvmMiniFlavor { RefVector get_to_be_shifted() { - return { aluChip_alu_u16_r1, aluChip_alu_u16_r0, - aluChip_alu_u16_r4, aluChip_alu_u16_r7, - aluChip_alu_u16_r5, aluChip_alu_u16_r2, - aluChip_alu_u16_r6, aluChip_alu_u16_r3, - avmMini_pc, avmMini_internal_return_ptr, - memTrace_m_tag, memTrace_m_addr, - memTrace_m_val, memTrace_m_rw }; + return { memTrace_m_rw, memTrace_m_tag, memTrace_m_addr, memTrace_m_val, avmMini_internal_return_ptr, + avmMini_pc }; }; // The plookup wires that store plookup read data. @@ -575,32 +417,6 @@ class AvmMiniFlavor { Base::memTrace_m_in_tag = "MEMTRACE_M_IN_TAG"; Base::memTrace_m_tag_err = "MEMTRACE_M_TAG_ERR"; Base::memTrace_m_one_min_inv = "MEMTRACE_M_ONE_MIN_INV"; - Base::aluChip_alu_clk = "ALUCHIP_ALU_CLK"; - Base::aluChip_alu_ia = "ALUCHIP_ALU_IA"; - Base::aluChip_alu_ib = "ALUCHIP_ALU_IB"; - Base::aluChip_alu_ic = "ALUCHIP_ALU_IC"; - Base::aluChip_alu_op_add = "ALUCHIP_ALU_OP_ADD"; - Base::aluChip_alu_op_sub = "ALUCHIP_ALU_OP_SUB"; - Base::aluChip_alu_op_mul = "ALUCHIP_ALU_OP_MUL"; - Base::aluChip_alu_op_div = "ALUCHIP_ALU_OP_DIV"; - Base::aluChip_alu_ff_tag = "ALUCHIP_ALU_FF_TAG"; - Base::aluChip_alu_u8_tag = "ALUCHIP_ALU_U8_TAG"; - Base::aluChip_alu_u16_tag = "ALUCHIP_ALU_U16_TAG"; - Base::aluChip_alu_u32_tag = "ALUCHIP_ALU_U32_TAG"; - Base::aluChip_alu_u64_tag = "ALUCHIP_ALU_U64_TAG"; - Base::aluChip_alu_u128_tag = "ALUCHIP_ALU_U128_TAG"; - Base::aluChip_alu_u8_r0 = "ALUCHIP_ALU_U8_R0"; - Base::aluChip_alu_u8_r1 = "ALUCHIP_ALU_U8_R1"; - Base::aluChip_alu_u16_r0 = "ALUCHIP_ALU_U16_R0"; - Base::aluChip_alu_u16_r1 = "ALUCHIP_ALU_U16_R1"; - Base::aluChip_alu_u16_r2 = "ALUCHIP_ALU_U16_R2"; - Base::aluChip_alu_u16_r3 = "ALUCHIP_ALU_U16_R3"; - Base::aluChip_alu_u16_r4 = "ALUCHIP_ALU_U16_R4"; - Base::aluChip_alu_u16_r5 = "ALUCHIP_ALU_U16_R5"; - Base::aluChip_alu_u16_r6 = "ALUCHIP_ALU_U16_R6"; - Base::aluChip_alu_u16_r7 = "ALUCHIP_ALU_U16_R7"; - Base::aluChip_alu_u64_r0 = "ALUCHIP_ALU_U64_R0"; - Base::aluChip_alu_cf = "ALUCHIP_ALU_CF"; Base::avmMini_pc = "AVMMINI_PC"; Base::avmMini_internal_return_ptr = "AVMMINI_INTERNAL_RETURN_PTR"; Base::avmMini_sel_internal_call = "AVMMINI_SEL_INTERNAL_CALL"; @@ -658,32 +474,6 @@ class AvmMiniFlavor { Commitment memTrace_m_in_tag; Commitment memTrace_m_tag_err; Commitment memTrace_m_one_min_inv; - Commitment aluChip_alu_clk; - Commitment aluChip_alu_ia; - Commitment aluChip_alu_ib; - Commitment aluChip_alu_ic; - Commitment aluChip_alu_op_add; - Commitment aluChip_alu_op_sub; - Commitment aluChip_alu_op_mul; - Commitment aluChip_alu_op_div; - Commitment aluChip_alu_ff_tag; - Commitment aluChip_alu_u8_tag; - Commitment aluChip_alu_u16_tag; - Commitment aluChip_alu_u32_tag; - Commitment aluChip_alu_u64_tag; - Commitment aluChip_alu_u128_tag; - Commitment aluChip_alu_u8_r0; - Commitment aluChip_alu_u8_r1; - Commitment aluChip_alu_u16_r0; - Commitment aluChip_alu_u16_r1; - Commitment aluChip_alu_u16_r2; - Commitment aluChip_alu_u16_r3; - Commitment aluChip_alu_u16_r4; - Commitment aluChip_alu_u16_r5; - Commitment aluChip_alu_u16_r6; - Commitment aluChip_alu_u16_r7; - Commitment aluChip_alu_u64_r0; - Commitment aluChip_alu_cf; Commitment avmMini_pc; Commitment avmMini_internal_return_ptr; Commitment avmMini_sel_internal_call; @@ -741,32 +531,6 @@ class AvmMiniFlavor { memTrace_m_in_tag = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); memTrace_m_tag_err = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); memTrace_m_one_min_inv = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_clk = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_ia = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_ib = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_ic = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_op_add = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_op_sub = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_op_mul = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_op_div = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_ff_tag = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_u8_tag = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_u16_tag = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_u32_tag = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_u64_tag = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_u128_tag = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_u8_r0 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_u8_r1 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_u16_r0 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_u16_r1 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_u16_r2 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_u16_r3 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_u16_r4 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_u16_r5 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_u16_r6 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_u16_r7 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_u64_r0 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); - aluChip_alu_cf = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); avmMini_pc = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); avmMini_internal_return_ptr = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); avmMini_sel_internal_call = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); @@ -828,32 +592,6 @@ class AvmMiniFlavor { serialize_to_buffer(memTrace_m_in_tag, Transcript::proof_data); serialize_to_buffer(memTrace_m_tag_err, Transcript::proof_data); serialize_to_buffer(memTrace_m_one_min_inv, Transcript::proof_data); - serialize_to_buffer(aluChip_alu_clk, Transcript::proof_data); - serialize_to_buffer(aluChip_alu_ia, Transcript::proof_data); - serialize_to_buffer(aluChip_alu_ib, Transcript::proof_data); - serialize_to_buffer(aluChip_alu_ic, Transcript::proof_data); - serialize_to_buffer(aluChip_alu_op_add, Transcript::proof_data); - serialize_to_buffer(aluChip_alu_op_sub, Transcript::proof_data); - serialize_to_buffer(aluChip_alu_op_mul, Transcript::proof_data); - serialize_to_buffer(aluChip_alu_op_div, Transcript::proof_data); - serialize_to_buffer(aluChip_alu_ff_tag, Transcript::proof_data); - serialize_to_buffer(aluChip_alu_u8_tag, Transcript::proof_data); - serialize_to_buffer(aluChip_alu_u16_tag, Transcript::proof_data); - serialize_to_buffer(aluChip_alu_u32_tag, Transcript::proof_data); - serialize_to_buffer(aluChip_alu_u64_tag, Transcript::proof_data); - serialize_to_buffer(aluChip_alu_u128_tag, Transcript::proof_data); - serialize_to_buffer(aluChip_alu_u8_r0, Transcript::proof_data); - serialize_to_buffer(aluChip_alu_u8_r1, Transcript::proof_data); - serialize_to_buffer(aluChip_alu_u16_r0, Transcript::proof_data); - serialize_to_buffer(aluChip_alu_u16_r1, Transcript::proof_data); - serialize_to_buffer(aluChip_alu_u16_r2, Transcript::proof_data); - serialize_to_buffer(aluChip_alu_u16_r3, Transcript::proof_data); - serialize_to_buffer(aluChip_alu_u16_r4, Transcript::proof_data); - serialize_to_buffer(aluChip_alu_u16_r5, Transcript::proof_data); - serialize_to_buffer(aluChip_alu_u16_r6, Transcript::proof_data); - serialize_to_buffer(aluChip_alu_u16_r7, Transcript::proof_data); - serialize_to_buffer(aluChip_alu_u64_r0, Transcript::proof_data); - serialize_to_buffer(aluChip_alu_cf, Transcript::proof_data); serialize_to_buffer(avmMini_pc, Transcript::proof_data); serialize_to_buffer(avmMini_internal_return_ptr, Transcript::proof_data); serialize_to_buffer(avmMini_sel_internal_call, Transcript::proof_data); diff --git a/barretenberg/cpp/src/barretenberg/flavor/generated/Toy_flavor.hpp b/barretenberg/cpp/src/barretenberg/flavor/generated/Toy_flavor.hpp index faac5550be00..63554a740639 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/generated/Toy_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/generated/Toy_flavor.hpp @@ -17,7 +17,8 @@ #include "barretenberg/relations/generated/Toy/two_column_perm.hpp" #include "barretenberg/transcript/transcript.hpp" -namespace bb::honk::flavor { +namespace bb::honk { +namespace flavor { class ToyFlavor { public: @@ -367,4 +368,5 @@ class ToyFlavor { }; }; -} // namespace bb::honk::flavor +} // namespace flavor +} // namespace bb::honk diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp index 5f13c7ac66b1..8629356b7267 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp @@ -155,7 +155,7 @@ class GoblinUltra { // GoblinUltra needs to expose more public classes than most flavors due to GoblinUltraRecursive reuse, but these // are internal: - public: + private: // WireEntities for basic witness entities template class WireEntities { public: @@ -418,8 +418,42 @@ class GoblinUltra { template class VerifierCommitments_ : public AllEntities { public: + VerifierCommitments_(const std::shared_ptr& verification_key) + { + this->q_m = verification_key->q_m; + this->q_l = verification_key->q_l; + this->q_r = verification_key->q_r; + this->q_o = verification_key->q_o; + this->q_4 = verification_key->q_4; + this->q_c = verification_key->q_c; + this->q_arith = verification_key->q_arith; + this->q_sort = verification_key->q_sort; + this->q_elliptic = verification_key->q_elliptic; + this->q_aux = verification_key->q_aux; + this->q_lookup = verification_key->q_lookup; + this->q_busread = verification_key->q_busread; + this->q_poseidon2_external = verification_key->q_poseidon2_external; + this->q_poseidon2_internal = verification_key->q_poseidon2_internal; + this->sigma_1 = verification_key->sigma_1; + this->sigma_2 = verification_key->sigma_2; + this->sigma_3 = verification_key->sigma_3; + this->sigma_4 = verification_key->sigma_4; + this->id_1 = verification_key->id_1; + this->id_2 = verification_key->id_2; + this->id_3 = verification_key->id_3; + this->id_4 = verification_key->id_4; + this->table_1 = verification_key->table_1; + this->table_2 = verification_key->table_2; + this->table_3 = verification_key->table_3; + this->table_4 = verification_key->table_4; + this->lagrange_first = verification_key->lagrange_first; + this->lagrange_last = verification_key->lagrange_last; + this->lagrange_ecc_op = verification_key->lagrange_ecc_op; + this->databus_id = verification_key->databus_id; + } + VerifierCommitments_(const std::shared_ptr& verification_key, - const std::optional>& witness_commitments = std::nullopt) + const WitnessCommitments& witness_commitments) { this->q_m = verification_key->q_m; this->q_l = verification_key->q_l; @@ -452,22 +486,19 @@ class GoblinUltra { this->lagrange_ecc_op = verification_key->lagrange_ecc_op; this->databus_id = verification_key->databus_id; - if (witness_commitments.has_value()) { - auto commitments = witness_commitments.value(); - this->w_l = commitments.w_l; - this->w_r = commitments.w_r; - this->w_o = commitments.w_o; - this->sorted_accum = commitments.sorted_accum; - this->w_4 = commitments.w_4; - this->z_perm = commitments.z_perm; - this->z_lookup = commitments.z_lookup; - this->ecc_op_wire_1 = commitments.ecc_op_wire_1; - this->ecc_op_wire_2 = commitments.ecc_op_wire_2; - this->ecc_op_wire_3 = commitments.ecc_op_wire_3; - this->calldata = commitments.calldata; - this->calldata = commitments.calldata_read_counts; - this->lookup_inverses = commitments.lookup_inverses; - } + this->w_l = witness_commitments.w_l; + this->w_r = witness_commitments.w_r; + this->w_o = witness_commitments.w_o; + this->sorted_accum = witness_commitments.sorted_accum; + this->w_4 = witness_commitments.w_4; + this->z_perm = witness_commitments.z_perm; + this->z_lookup = witness_commitments.z_lookup; + this->ecc_op_wire_1 = witness_commitments.ecc_op_wire_1; + this->ecc_op_wire_2 = witness_commitments.ecc_op_wire_2; + this->ecc_op_wire_3 = witness_commitments.ecc_op_wire_3; + this->calldata = witness_commitments.calldata; + this->calldata = witness_commitments.calldata_read_counts; + this->lookup_inverses = witness_commitments.lookup_inverses; } }; // Specialize for GoblinUltra (general case used in GoblinUltraRecursive). diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp index e1146ea4b701..8c47654f6fe2 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp @@ -67,14 +67,12 @@ template class GoblinUltraRecursive_ { using Relations = GoblinUltra::Relations_; static constexpr size_t MAX_PARTIAL_RELATION_LENGTH = compute_max_partial_relation_length(); - static constexpr size_t MAX_TOTAL_RELATION_LENGTH = compute_max_total_relation_length(); // BATCHED_RELATION_PARTIAL_LENGTH = algebraic degree of sumcheck relation *after* multiplying by the `pow_zeta` // random polynomial e.g. For \sum(x) [A(x) * B(x) + C(x)] * PowZeta(X), relation length = 2 and random relation // length = 3 static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH = MAX_PARTIAL_RELATION_LENGTH + 1; - static constexpr size_t BATCHED_RELATION_TOTAL_LENGTH = MAX_TOTAL_RELATION_LENGTH + 1; - static constexpr size_t NUM_RELATIONS = std::tuple_size_v; + static constexpr size_t NUM_RELATIONS = std::tuple_size::value; // For instances of this flavour, used in folding, we need a unique sumcheck batching challenge for each // subrelation. This is because using powers of alpha would increase the degree of Protogalaxy polynomial $G$ (the @@ -106,12 +104,6 @@ template class GoblinUltraRecursive_ { */ class VerificationKey : public VerificationKey_> { public: - VerificationKey(const size_t circuit_size, const size_t num_public_inputs) - { - this->circuit_size = circuit_size; - this->log_circuit_size = numeric::get_msb(circuit_size); - this->num_public_inputs = num_public_inputs; - }; /** * @brief Construct a new Verification Key with stdlib types from a provided native verification * key @@ -120,10 +112,9 @@ template class GoblinUltraRecursive_ { * @param native_key Native verification key from which to extract the precomputed commitments */ VerificationKey(CircuitBuilder* builder, const std::shared_ptr& native_key) + : VerificationKey_>(native_key->circuit_size, + native_key->num_public_inputs) { - this->circuit_size = native_key->circuit_size; - this->log_circuit_size = numeric::get_msb(this->circuit_size); - this->num_public_inputs = native_key->num_public_inputs; this->q_m = Commitment::from_witness(builder, native_key->q_m); this->q_l = Commitment::from_witness(builder, native_key->q_l); this->q_r = Commitment::from_witness(builder, native_key->q_r); @@ -157,11 +148,6 @@ template class GoblinUltraRecursive_ { }; }; - /** - * @brief A container for the witness commitments. - */ - using WitnessCommitments = GoblinUltra::WitnessEntities; - using CommitmentLabels = GoblinUltra::CommitmentLabels; // Reuse the VerifierCommitments from GoblinUltra using VerifierCommitments = GoblinUltra::VerifierCommitments_; diff --git a/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp b/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp index 2fd21fab3517..3bf08e29b8f4 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp @@ -412,8 +412,37 @@ class Ultra { */ class VerifierCommitments : public AllEntities { public: + VerifierCommitments(const std::shared_ptr& verification_key) + { + q_m = verification_key->q_m; + q_c = verification_key->q_c; + q_l = verification_key->q_l; + q_r = verification_key->q_r; + q_o = verification_key->q_o; + q_4 = verification_key->q_4; + q_arith = verification_key->q_arith; + q_sort = verification_key->q_sort; + q_elliptic = verification_key->q_elliptic; + q_aux = verification_key->q_aux; + q_lookup = verification_key->q_lookup; + sigma_1 = verification_key->sigma_1; + sigma_2 = verification_key->sigma_2; + sigma_3 = verification_key->sigma_3; + sigma_4 = verification_key->sigma_4; + id_1 = verification_key->id_1; + id_2 = verification_key->id_2; + id_3 = verification_key->id_3; + id_4 = verification_key->id_4; + table_1 = verification_key->table_1; + table_2 = verification_key->table_2; + table_3 = verification_key->table_3; + table_4 = verification_key->table_4; + lagrange_first = verification_key->lagrange_first; + lagrange_last = verification_key->lagrange_last; + } + VerifierCommitments(const std::shared_ptr& verification_key, - const std::optional& witness_commitments = std::nullopt) + const WitnessCommitments& witness_commitments) { q_m = verification_key->q_m; q_c = verification_key->q_c; @@ -441,16 +470,13 @@ class Ultra { lagrange_first = verification_key->lagrange_first; lagrange_last = verification_key->lagrange_last; - if (witness_commitments.has_value()) { - auto commitments = witness_commitments.value(); - this->w_l = commitments.w_l; - this->w_r = commitments.w_r; - this->w_o = commitments.w_o; - this->sorted_accum = commitments.sorted_accum; - this->w_4 = commitments.w_4; - this->z_perm = commitments.z_perm; - this->z_lookup = commitments.z_lookup; - } + w_l = witness_commitments.w_l; + w_r = witness_commitments.w_r; + w_o = witness_commitments.w_o; + sorted_accum = witness_commitments.sorted_accum; + w_4 = witness_commitments.w_4; + z_perm = witness_commitments.z_perm; + z_lookup = witness_commitments.z_lookup; } }; diff --git a/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp b/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp index 94955d72f759..ea9303c7c878 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp @@ -79,15 +79,11 @@ template class UltraRecursive_ { bb::AuxiliaryRelation>; static constexpr size_t MAX_PARTIAL_RELATION_LENGTH = compute_max_partial_relation_length(); - static_assert(MAX_PARTIAL_RELATION_LENGTH == 6); - static constexpr size_t MAX_TOTAL_RELATION_LENGTH = compute_max_total_relation_length(); - static_assert(MAX_TOTAL_RELATION_LENGTH == 12); // BATCHED_RELATION_PARTIAL_LENGTH = algebraic degree of sumcheck relation *after* multiplying by the `pow_zeta` // random polynomial e.g. For \sum(x) [A(x) * B(x) + C(x)] * PowZeta(X), relation length = 2 and random relation // length = 3 static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH = MAX_PARTIAL_RELATION_LENGTH + 1; - static constexpr size_t BATCHED_RELATION_TOTAL_LENGTH = MAX_TOTAL_RELATION_LENGTH + 1; static constexpr size_t NUM_RELATIONS = std::tuple_size::value; // For instances of this flavour, used in folding, we need a unique sumcheck batching challenges for each @@ -165,12 +161,6 @@ template class UltraRecursive_ { RefVector get_wires() { return { w_l, w_r, w_o, w_4 }; }; }; - public: - /** - * @brief A container for the witness commitments. - */ - using WitnessCommitments = WitnessEntities; - /** * @brief A base class labelling all entities (for instance, all of the polynomials used by the prover during * sumcheck) in this Honk variant along with particular subsets of interest @@ -239,17 +229,6 @@ template class UltraRecursive_ { }; }; - RefVector get_precomputed() - { - return { q_m, q_c, q_l, q_r, q_o, q_4, q_arith, q_sort, - q_elliptic, q_aux, q_lookup, sigma_1, sigma_2, sigma_3, sigma_4, id_1, - id_2, id_3, id_4, table_1, table_2, table_3, table_4, lagrange_first, - lagrange_last - - }; - } - - RefVector get_witness() { return { w_l, w_r, w_o, w_4, sorted_accum, z_perm, z_lookup }; }; RefVector get_to_be_shifted() { return { table_1, table_2, table_3, table_4, w_l, w_r, w_o, w_4, sorted_accum, z_perm, z_lookup }; @@ -272,12 +251,6 @@ template class UltraRecursive_ { */ class VerificationKey : public VerificationKey_> { public: - VerificationKey(const size_t circuit_size, const size_t num_public_inputs) - { - this->circuit_size = circuit_size; - this->log_circuit_size = numeric::get_msb(circuit_size); - this->num_public_inputs = num_public_inputs; - }; /** * @brief Construct a new Verification Key with stdlib types from a provided native verification key * @@ -285,10 +258,8 @@ template class UltraRecursive_ { * @param native_key Native verification key from which to extract the precomputed commitments */ VerificationKey(CircuitBuilder* builder, const std::shared_ptr& native_key) + : VerificationKey_>(native_key->circuit_size, native_key->num_public_inputs) { - this->circuit_size = native_key->circuit_size; - this->log_circuit_size = numeric::get_msb(this->circuit_size); - this->num_public_inputs = native_key->num_public_inputs; this->q_m = Commitment::from_witness(builder, native_key->q_m); this->q_l = Commitment::from_witness(builder, native_key->q_l); this->q_r = Commitment::from_witness(builder, native_key->q_r); @@ -346,38 +317,38 @@ template class UltraRecursive_ { this->z_lookup = "Z_LOOKUP"; this->sorted_accum = "SORTED_ACCUM"; - this->q_c = "Q_C"; - this->q_l = "Q_L"; - this->q_r = "Q_R"; - this->q_o = "Q_O"; - this->q_4 = "Q_4"; - this->q_m = "Q_M"; - this->q_arith = "Q_ARITH"; - this->q_sort = "Q_SORT"; - this->q_elliptic = "Q_ELLIPTIC"; - this->q_aux = "Q_AUX"; - this->q_lookup = "Q_LOOKUP"; - this->sigma_1 = "SIGMA_1"; - this->sigma_2 = "SIGMA_2"; - this->sigma_3 = "SIGMA_3"; - this->sigma_4 = "SIGMA_4"; - this->id_1 = "ID_1"; - this->id_2 = "ID_2"; - this->id_3 = "ID_3"; - this->id_4 = "ID_4"; - this->table_1 = "TABLE_1"; - this->table_2 = "TABLE_2"; - this->table_3 = "TABLE_3"; - this->table_4 = "TABLE_4"; - this->lagrange_first = "LAGRANGE_FIRST"; - this->lagrange_last = "LAGRANGE_LAST"; + // The ones beginning with "__" are only used for debugging + this->q_c = "__Q_C"; + this->q_l = "__Q_L"; + this->q_r = "__Q_R"; + this->q_o = "__Q_O"; + this->q_4 = "__Q_4"; + this->q_m = "__Q_M"; + this->q_arith = "__Q_ARITH"; + this->q_sort = "__Q_SORT"; + this->q_elliptic = "__Q_ELLIPTIC"; + this->q_aux = "__Q_AUX"; + this->q_lookup = "__Q_LOOKUP"; + this->sigma_1 = "__SIGMA_1"; + this->sigma_2 = "__SIGMA_2"; + this->sigma_3 = "__SIGMA_3"; + this->sigma_4 = "__SIGMA_4"; + this->id_1 = "__ID_1"; + this->id_2 = "__ID_2"; + this->id_3 = "__ID_3"; + this->id_4 = "__ID_4"; + this->table_1 = "__TABLE_1"; + this->table_2 = "__TABLE_2"; + this->table_3 = "__TABLE_3"; + this->table_4 = "__TABLE_4"; + this->lagrange_first = "__LAGRANGE_FIRST"; + this->lagrange_last = "__LAGRANGE_LAST"; }; }; class VerifierCommitments : public AllEntities { public: - VerifierCommitments(const std::shared_ptr& verification_key, - const std::optional& witness_commitments = std::nullopt) + VerifierCommitments(const std::shared_ptr& verification_key) { this->q_m = verification_key->q_m; this->q_l = verification_key->q_l; @@ -404,17 +375,6 @@ template class UltraRecursive_ { this->table_4 = verification_key->table_4; this->lagrange_first = verification_key->lagrange_first; this->lagrange_last = verification_key->lagrange_last; - - if (witness_commitments.has_value()) { - auto commitments = witness_commitments.value(); - this->w_l = commitments.w_l; - this->w_r = commitments.w_r; - this->w_o = commitments.w_o; - this->sorted_accum = commitments.sorted_accum; - this->w_4 = commitments.w_4; - this->z_perm = commitments.z_perm; - this->z_lookup = commitments.z_lookup; - } } }; diff --git a/barretenberg/cpp/src/barretenberg/goblin/full_goblin_recursion.test.cpp b/barretenberg/cpp/src/barretenberg/goblin/full_goblin_recursion.test.cpp index 5049b197e0ab..088a341e29f5 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/full_goblin_recursion.test.cpp +++ b/barretenberg/cpp/src/barretenberg/goblin/full_goblin_recursion.test.cpp @@ -10,20 +10,21 @@ #include "barretenberg/ultra_honk/ultra_composer.hpp" #include -using namespace bb; + using namespace bb::honk; +namespace goblin_recursion_tests { class GoblinRecursionTests : public ::testing::Test { protected: static void SetUpTestSuite() { - srs::init_crs_factory("../srs_db/ignition"); - srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); + bb::srs::init_crs_factory("../srs_db/ignition"); + bb::srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); } using Curve = curve::BN254; using FF = Curve::ScalarField; - using GoblinUltraBuilder = GoblinUltraCircuitBuilder; + using GoblinUltraBuilder = bb::GoblinUltraCircuitBuilder; using KernelInput = Goblin::AccumulationOutput; }; @@ -60,3 +61,4 @@ TEST_F(GoblinRecursionTests, Pseudo) } // TODO(https://github.com/AztecProtocol/barretenberg/issues/787) Expand these tests. +} // namespace goblin_recursion_tests diff --git a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp index aac0ef305ca9..7ba019a6f8fe 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp +++ b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp @@ -84,12 +84,12 @@ class Goblin { std::unique_ptr eccvm_prover; std::unique_ptr translator_composer; - AccumulationOutput accumulator; // Used only for ACIR methods for now + AccumulationOutput accumulator; // ACIRHACK + Proof proof_; // ACIRHACK public: /** - * @brief Construct a GUH proof and a merge proof for the present circuit. - * @details If there is a previous merge proof, recursively verify it. + * @brief If there is a previous merge proof, recursively verify it. Generate next accmulated proof and merge proof. * * @param circuit_builder */ @@ -118,12 +118,10 @@ class Goblin { return { ultra_proof, instance->verification_key }; }; - /** - * @brief Construct an ECCVM proof and the translation polynomial evaluations - * - */ void prove_eccvm() { + goblin_proof.merge_proof = std::move(merge_proof); + eccvm_builder = std::make_unique(op_queue); eccvm_composer = std::make_unique(); eccvm_prover = std::make_unique(eccvm_composer->create_prover(*eccvm_builder)); @@ -131,10 +129,6 @@ class Goblin { goblin_proof.translation_evaluations = eccvm_prover->translation_evaluations; }; - /** - * @brief Construct a translator proof - * - */ void prove_translator() { translator_builder = std::make_unique( @@ -144,28 +138,13 @@ class Goblin { goblin_proof.translator_proof = translator_prover.construct_proof(); }; - /** - * @brief Constuct a full Goblin proof (ECCVM, Translator, merge) - * @details The merge proof is assumed to already have been constucted in the last accumulate step. It is simply - * moved into the final proof here. - * - * @return Proof - */ Proof prove() { - goblin_proof.merge_proof = std::move(merge_proof); prove_eccvm(); prove_translator(); return goblin_proof; }; - /** - * @brief Verify a full Goblin proof (ECCVM, Translator, merge) - * - * @param proof - * @return true - * @return false - */ bool verify(const Proof& proof) { MergeVerifier merge_verifier; @@ -183,23 +162,14 @@ class Goblin { return merge_verified && eccvm_verified && accumulator_construction_verified && translation_verified; }; - // The methods below this point are to be used only for ACIR. They exist while the interface is in flux. Eventually - // there will be agreement and no acir-specific methods should be needed. - - /** - * @brief Construct a GUH proof for the given circuit. (No merge proof for now) - * - * @param circuit_builder - * @return std::vector - */ - std::vector accumulate_for_acir(GoblinUltraCircuitBuilder& circuit_builder) + // ACIRHACK + AccumulationOutput accumulate_for_acir(GoblinUltraCircuitBuilder& circuit_builder) { - // TODO(https://github.com/AztecProtocol/barretenberg/issues/811): no merge prover for now - // // Complete the circuit logic by recursively verifying previous merge proof if it exists - // if (merge_proof_exists) { - // RecursiveMergeVerifier merge_verifier{ &circuit_builder }; - // [[maybe_unused]] auto pairing_points = merge_verifier.verify_proof(merge_proof); - // } + // Complete the circuit logic by recursively verifying previous merge proof if it exists + if (merge_proof_exists) { + RecursiveMergeVerifier merge_verifier{ &circuit_builder }; + [[maybe_unused]] auto pairing_points = merge_verifier.verify_proof(merge_proof); + } // Construct a Honk proof for the main circuit GoblinUltraComposer composer; @@ -207,8 +177,6 @@ class Goblin { auto prover = composer.create_prover(instance); auto ultra_proof = prover.construct_proof(); - accumulator = { ultra_proof, instance->verification_key }; - // TODO(https://github.com/AztecProtocol/barretenberg/issues/811): no merge prover for now since we're not // mocking the first set of ecc ops // // Construct and store the merge proof to be recursively verified on the next call to accumulate @@ -219,56 +187,88 @@ class Goblin { // merge_proof_exists = true; // } - return ultra_proof.proof_data; + accumulator = { ultra_proof, instance->verification_key }; + return accumulator; }; - /** - * @brief Verify a GUH proof - * - * @param proof_buf - * @return true - * @return false - */ - bool verify_accumulator_for_acir(const std::vector& proof_buf) const + // ACIRHACK + Proof prove_for_acir() { - GoblinUltraVerifier verifier{ accumulator.verification_key }; - HonkProof proof{ proof_buf }; - bool verified = verifier.verify_proof(proof); + Proof proof; - return verified; - } + proof.merge_proof = std::move(merge_proof); - /** - * @brief Construct a Goblin proof - * - * @return Proof - */ - Proof prove_for_acir() { return prove(); }; + eccvm_builder = std::make_unique(op_queue); + eccvm_composer = std::make_unique(); + auto eccvm_prover = eccvm_composer->create_prover(*eccvm_builder); + proof.eccvm_proof = eccvm_prover.construct_proof(); + proof.translation_evaluations = eccvm_prover.translation_evaluations; - /** - * @brief Verify a Goblin proof (excluding the merge proof for now) - * - * @return true - * @return false - */ - bool verify_for_acir() const + translator_builder = std::make_unique( + eccvm_prover.translation_batching_challenge_v, eccvm_prover.evaluation_challenge_x, op_queue); + translator_composer = std::make_unique(); + auto translator_prover = translator_composer->create_prover(*translator_builder, eccvm_prover.transcript); + proof.translator_proof = translator_prover.construct_proof(); + + proof_ = proof; // ACIRHACK + return proof; + }; + + // ACIRHACK + bool verify_for_acir(const Proof& proof) const { - // TODO(https://github.com/AztecProtocol/barretenberg/issues/811): No merge proof for now + // ACIRHACK // MergeVerifier merge_verifier; - // bool merge_verified = merge_verifier.verify_proof(goblin_proof.merge_proof); + // bool merge_verified = merge_verifier.verify_proof(proof.merge_proof); auto eccvm_verifier = eccvm_composer->create_verifier(*eccvm_builder); - bool eccvm_verified = eccvm_verifier.verify_proof(goblin_proof.eccvm_proof); + bool eccvm_verified = eccvm_verifier.verify_proof(proof.eccvm_proof); auto translator_verifier = translator_composer->create_verifier(*translator_builder, eccvm_verifier.transcript); - bool translation_accumulator_construction_verified = - translator_verifier.verify_proof(goblin_proof.translator_proof); + bool accumulator_construction_verified = translator_verifier.verify_proof(proof.translator_proof); // TODO(https://github.com/AztecProtocol/barretenberg/issues/799): Ensure translation_evaluations are passed // correctly - bool translation_verified = translator_verifier.verify_translation(goblin_proof.translation_evaluations); + bool translation_verified = translator_verifier.verify_translation(proof.translation_evaluations); - return /* merge_verified && */ eccvm_verified && translation_accumulator_construction_verified && - translation_verified; + return /* merge_verified && */ eccvm_verified && accumulator_construction_verified && translation_verified; }; + + // ACIRHACK + std::vector construct_proof(GoblinUltraCircuitBuilder& builder) + { + // Construct a GUH proof + accumulate_for_acir(builder); + + std::vector result(accumulator.proof.proof_data.size()); + + const auto insert = [&result](const std::vector& buf) { + result.insert(result.end(), buf.begin(), buf.end()); + }; + + insert(accumulator.proof.proof_data); + + // TODO(https://github.com/AztecProtocol/barretenberg/issues/819): Skip ECCVM/Translator proof for now + // std::vector goblin_proof = prove_for_acir().to_buffer(); + // insert(goblin_proof); + + return result; + } + + // ACIRHACK + bool verify_proof([[maybe_unused]] const bb::plonk::proof& proof) const + { + // ACIRHACK: to do this properly, extract the proof correctly or maybe share transcripts. + const auto extract_final_kernel_proof = [&]([[maybe_unused]] auto& input_proof) { return accumulator.proof; }; + + GoblinUltraVerifier verifier{ accumulator.verification_key }; + bool verified = verifier.verify_proof(extract_final_kernel_proof(proof)); + + // TODO(https://github.com/AztecProtocol/barretenberg/issues/819): Skip ECCVM/Translator verification for now + // const auto extract_goblin_proof = [&]([[maybe_unused]] auto& input_proof) { return proof_; }; + // auto goblin_proof = extract_goblin_proof(proof); + // verified = verified && verify_for_acir(goblin_proof); + + return verified; + } }; } // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/grumpkin_srs_gen/grumpkin_srs_gen.cpp b/barretenberg/cpp/src/barretenberg/grumpkin_srs_gen/grumpkin_srs_gen.cpp index ebd807012aab..f6e1f23c034b 100644 --- a/barretenberg/cpp/src/barretenberg/grumpkin_srs_gen/grumpkin_srs_gen.cpp +++ b/barretenberg/cpp/src/barretenberg/grumpkin_srs_gen/grumpkin_srs_gen.cpp @@ -72,7 +72,7 @@ int main(int argc, char** argv) bb::srs::Manifest manifest{ 0, 1, static_cast(subgroup_size), 0, static_cast(subgroup_size), 0, 0 }; - bb::srs::IO::write_transcript(&srs[0], manifest, srs_path); + bb::srs::IO::write_transcript(&srs[0], manifest, srs_path); return 0; } \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/constants.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/constants.hpp index 395d85ef41a3..b76efe183b04 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/constants.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/constants.hpp @@ -4,7 +4,7 @@ #include #include -namespace bb::join_split_example { +namespace join_split_example { constexpr size_t DATA_TREE_DEPTH = 32; @@ -19,8 +19,8 @@ constexpr size_t MAX_NUM_ASSETS_BIT_LENGTH = 30; constexpr size_t MAX_NUM_ASSETS = 1 << MAX_NUM_ASSETS_BIT_LENGTH; constexpr size_t ALIAS_HASH_BIT_LENGTH = 224; -namespace proof_ids { +namespace ProofIds { enum { PADDING = 0, DEPOSIT = 1, WITHDRAW = 2, SEND = 3, ACCOUNT = 4, DEFI_DEPOSIT = 5, DEFI_CLAIM = 6 }; }; -} // namespace bb::join_split_example +} // namespace join_split_example diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/fixtures/user_context.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/fixtures/user_context.hpp index b5eb6901acea..5a9db57c0596 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/fixtures/user_context.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/fixtures/user_context.hpp @@ -3,9 +3,10 @@ #include "barretenberg/ecc/curves/bn254/fr.hpp" #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" -namespace bb::join_split_example::fixtures { +namespace join_split_example { +namespace fixtures { -using grumpkin_key_pair = bb::crypto::schnorr_key_pair; +typedef crypto::schnorr::key_pair grumpkin_key_pair; struct user_context { bb::fr note_secret; @@ -17,18 +18,18 @@ struct user_context { inline bb::fr generate_alias_hash(std::string const& alias) { std::vector inputv(alias.begin(), alias.end()); - auto output = bb::crypto::blake2s(inputv); + auto output = blake2::blake2s(inputv); return bb::fr(uint256_t(from_buffer(output.data())) >> 32); } -inline grumpkin_key_pair create_key_pair(numeric::RNG* engine) +inline grumpkin_key_pair create_key_pair(numeric::random::Engine* engine) { grumpkin::fr priv_key = grumpkin::fr::random_element(engine); grumpkin::g1::affine_element pub_key = grumpkin::g1::one * priv_key; return { priv_key, pub_key }; } -inline user_context create_user_context(numeric::RNG* engine = nullptr) +inline user_context create_user_context(numeric::random::Engine* engine = nullptr) { uint8_t vk[] = { 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11 }; @@ -37,4 +38,5 @@ inline user_context create_user_context(numeric::RNG* engine = nullptr) return { note_secret, create_key_pair(engine), { create_key_pair(engine), create_key_pair(engine) }, alias_hash }; } -} // namespace bb::join_split_example::fixtures +} // namespace fixtures +} // namespace join_split_example diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/compute_circuit_data.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/compute_circuit_data.hpp index d3c9d30ab3e4..2a1f4b42343b 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/compute_circuit_data.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/compute_circuit_data.hpp @@ -13,7 +13,8 @@ #include #endif -namespace bb::join_split_example::proofs { +namespace join_split_example { +namespace proofs { struct circuit_data { circuit_data() @@ -82,7 +83,7 @@ circuit_data get_circuit_data(std::string const& name, info(name, ": Circuit size: ", builder.get_num_gates()); if (mock) { auto public_inputs = builder.get_public_inputs(); - ::bb::join_split_example::proofs::mock::mock_circuit(mock_builder, public_inputs); + ::join_split_example::proofs::mock::mock_circuit(mock_builder, public_inputs); info(name, ": Mock circuit size: ", mock_builder.get_num_gates()); benchmark_collator.benchmark_info_deferred(Composer::NAME_STRING, "Core", @@ -258,4 +259,5 @@ circuit_data get_circuit_data(std::string const& name, return data; } -} // namespace bb::join_split_example::proofs +} // namespace proofs +} // namespace join_split_example diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.cpp index 5224f662eac1..f9f339d723eb 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.cpp @@ -1,27 +1,29 @@ #include "inner_proof_data.hpp" -namespace bb::join_split_example::proofs { +namespace join_split_example { +namespace proofs { using namespace bb; inner_proof_data::inner_proof_data(std::vector const& proof_data) { - proof_id = from_buffer(proof_data, inner_proof_offsets::PROOF_ID); - note_commitment1 = from_buffer(proof_data, inner_proof_offsets::NOTE_COMMITMENT1); - note_commitment2 = from_buffer(proof_data, inner_proof_offsets::NOTE_COMMITMENT2); - nullifier1 = from_buffer(proof_data, inner_proof_offsets::NULLIFIER1); - nullifier2 = from_buffer(proof_data, inner_proof_offsets::NULLIFIER2); - public_value = from_buffer(proof_data, inner_proof_offsets::PUBLIC_VALUE); - public_owner = from_buffer(proof_data, inner_proof_offsets::PUBLIC_OWNER); - asset_id = from_buffer(proof_data, inner_proof_offsets::PUBLIC_ASSET_ID); - merkle_root = from_buffer(proof_data, inner_proof_offsets::MERKLE_ROOT); - tx_fee = from_buffer(proof_data, inner_proof_offsets::TX_FEE); - tx_fee_asset_id = from_buffer(proof_data, inner_proof_offsets::TX_FEE_ASSET_ID); - bridge_call_data = from_buffer(proof_data, inner_proof_offsets::BRIDGE_CALL_DATA); - defi_deposit_value = from_buffer(proof_data, inner_proof_offsets::DEFI_DEPOSIT_VALUE); - defi_root = from_buffer(proof_data, inner_proof_offsets::DEFI_ROOT); - backward_link = from_buffer(proof_data, inner_proof_offsets::BACKWARD_LINK); - allow_chain = from_buffer(proof_data, inner_proof_offsets::ALLOW_CHAIN); + proof_id = from_buffer(proof_data, InnerProofOffsets::PROOF_ID); + note_commitment1 = from_buffer(proof_data, InnerProofOffsets::NOTE_COMMITMENT1); + note_commitment2 = from_buffer(proof_data, InnerProofOffsets::NOTE_COMMITMENT2); + nullifier1 = from_buffer(proof_data, InnerProofOffsets::NULLIFIER1); + nullifier2 = from_buffer(proof_data, InnerProofOffsets::NULLIFIER2); + public_value = from_buffer(proof_data, InnerProofOffsets::PUBLIC_VALUE); + public_owner = from_buffer(proof_data, InnerProofOffsets::PUBLIC_OWNER); + asset_id = from_buffer(proof_data, InnerProofOffsets::PUBLIC_ASSET_ID); + merkle_root = from_buffer(proof_data, InnerProofOffsets::MERKLE_ROOT); + tx_fee = from_buffer(proof_data, InnerProofOffsets::TX_FEE); + tx_fee_asset_id = from_buffer(proof_data, InnerProofOffsets::TX_FEE_ASSET_ID); + bridge_call_data = from_buffer(proof_data, InnerProofOffsets::BRIDGE_CALL_DATA); + defi_deposit_value = from_buffer(proof_data, InnerProofOffsets::DEFI_DEPOSIT_VALUE); + defi_root = from_buffer(proof_data, InnerProofOffsets::DEFI_ROOT); + backward_link = from_buffer(proof_data, InnerProofOffsets::BACKWARD_LINK); + allow_chain = from_buffer(proof_data, InnerProofOffsets::ALLOW_CHAIN); } -} // namespace bb::join_split_example::proofs +} // namespace proofs +} // namespace join_split_example diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.hpp index 4778ed1eed48..7bc81c657b19 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.hpp @@ -5,9 +5,10 @@ #include "barretenberg/numeric/uint256/uint256.hpp" #include -namespace bb::join_split_example::proofs { +namespace join_split_example { +namespace proofs { -namespace inner_proof_fields { +namespace InnerProofFields { enum { PROOF_ID, NOTE_COMMITMENT1, @@ -27,26 +28,26 @@ enum { ALLOW_CHAIN, NUM_FIELDS }; -} // namespace inner_proof_fields +} // namespace InnerProofFields -namespace inner_proof_offsets { +namespace InnerProofOffsets { enum { - PROOF_ID = inner_proof_fields::PROOF_ID * 32, - NOTE_COMMITMENT1 = inner_proof_fields::NOTE_COMMITMENT1 * 32, - NOTE_COMMITMENT2 = inner_proof_fields::NOTE_COMMITMENT2 * 32, - NULLIFIER1 = inner_proof_fields::NULLIFIER1 * 32, - NULLIFIER2 = inner_proof_fields::NULLIFIER2 * 32, - PUBLIC_VALUE = inner_proof_fields::PUBLIC_VALUE * 32, - PUBLIC_OWNER = inner_proof_fields::PUBLIC_OWNER * 32, - PUBLIC_ASSET_ID = inner_proof_fields::PUBLIC_ASSET_ID * 32, - MERKLE_ROOT = inner_proof_fields::MERKLE_ROOT * 32, - TX_FEE = inner_proof_fields::TX_FEE * 32, - TX_FEE_ASSET_ID = inner_proof_fields::TX_FEE_ASSET_ID * 32, - BRIDGE_CALL_DATA = inner_proof_fields::BRIDGE_CALL_DATA * 32, - DEFI_DEPOSIT_VALUE = inner_proof_fields::DEFI_DEPOSIT_VALUE * 32, - DEFI_ROOT = inner_proof_fields::DEFI_ROOT * 32, - BACKWARD_LINK = inner_proof_fields::BACKWARD_LINK * 32, - ALLOW_CHAIN = inner_proof_fields::ALLOW_CHAIN * 32, + PROOF_ID = InnerProofFields::PROOF_ID * 32, + NOTE_COMMITMENT1 = InnerProofFields::NOTE_COMMITMENT1 * 32, + NOTE_COMMITMENT2 = InnerProofFields::NOTE_COMMITMENT2 * 32, + NULLIFIER1 = InnerProofFields::NULLIFIER1 * 32, + NULLIFIER2 = InnerProofFields::NULLIFIER2 * 32, + PUBLIC_VALUE = InnerProofFields::PUBLIC_VALUE * 32, + PUBLIC_OWNER = InnerProofFields::PUBLIC_OWNER * 32, + PUBLIC_ASSET_ID = InnerProofFields::PUBLIC_ASSET_ID * 32, + MERKLE_ROOT = InnerProofFields::MERKLE_ROOT * 32, + TX_FEE = InnerProofFields::TX_FEE * 32, + TX_FEE_ASSET_ID = InnerProofFields::TX_FEE_ASSET_ID * 32, + BRIDGE_CALL_DATA = InnerProofFields::BRIDGE_CALL_DATA * 32, + DEFI_DEPOSIT_VALUE = InnerProofFields::DEFI_DEPOSIT_VALUE * 32, + DEFI_ROOT = InnerProofFields::DEFI_ROOT * 32, + BACKWARD_LINK = InnerProofFields::BACKWARD_LINK * 32, + ALLOW_CHAIN = InnerProofFields::ALLOW_CHAIN * 32, }; } @@ -97,4 +98,5 @@ inline std::ostream& operator<<(std::ostream& os, inner_proof_data const& data) // clang-format on } -} // namespace bb::join_split_example::proofs +} // namespace proofs +} // namespace join_split_example diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.test.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.test.cpp index 4721089cdc91..f01df175b293 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.test.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.test.cpp @@ -2,10 +2,10 @@ #include using namespace bb; -using namespace bb::join_split_example::proofs; +using namespace join_split_example::proofs; namespace { -auto& rand_engine = numeric::get_debug_randomness(); +auto& rand_engine = numeric::random::get_debug_engine(); } TEST(client_proofs_inner_proof_data, test_proof_to_data) diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_circuit_data.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_circuit_data.cpp index da7f5037d003..c0bc5e6a6c3d 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_circuit_data.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_circuit_data.cpp @@ -5,11 +5,13 @@ #include "join_split_circuit.hpp" #include "sign_join_split_tx.hpp" -namespace bb::join_split_example::proofs::join_split { +namespace join_split_example { +namespace proofs { +namespace join_split { -using namespace bb::join_split_example::proofs::join_split; +using namespace join_split_example::proofs::join_split; using namespace bb::stdlib; -using namespace bb::join_split_example::proofs::notes::native; +using namespace join_split_example::proofs::notes::native; using namespace bb::stdlib::merkle_tree; join_split_tx noop_tx() @@ -27,7 +29,7 @@ join_split_tx noop_tx() auto gibberish_path = fr_hash_path(DATA_TREE_DEPTH, std::make_pair(fr::random_element(), fr::random_element())); join_split_tx tx; - tx.proof_id = proof_ids::DEPOSIT; + tx.proof_id = ProofIds::DEPOSIT; tx.public_value = 1; tx.public_owner = fr::one(); tx.asset_id = 0; @@ -70,4 +72,6 @@ circuit_data get_circuit_data(std::shared_ptr> const& srs, bool mock = false); -} // namespace bb::join_split_example::proofs::join_split \ No newline at end of file +} // namespace join_split +} // namespace proofs +} // namespace join_split_example \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_signing_data.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_signing_data.cpp index 4e8d063ba525..4efcd5323dc6 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_signing_data.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_signing_data.cpp @@ -2,16 +2,18 @@ #include "../notes/native/index.hpp" #include "barretenberg/crypto/pedersen_hash/pedersen.hpp" -namespace bb::join_split_example::proofs::join_split { +namespace join_split_example { +namespace proofs { +namespace join_split { using namespace notes::native; bb::fr compute_signing_data(join_split_tx const& tx) { auto proof_id = tx.proof_id; - auto is_deposit = proof_id == proof_ids::DEPOSIT; - auto is_withdraw = proof_id == proof_ids::WITHDRAW; - auto is_defi = proof_id == proof_ids::DEFI_DEPOSIT; + auto is_deposit = proof_id == ProofIds::DEPOSIT; + auto is_withdraw = proof_id == ProofIds::WITHDRAW; + auto is_defi = proof_id == ProofIds::DEFI_DEPOSIT; auto public_value = tx.public_value; auto public_asset_id = tx.asset_id * (is_deposit || is_withdraw); @@ -34,4 +36,6 @@ bb::fr compute_signing_data(join_split_tx const& tx) return crypto::pedersen_hash::hash(to_hash); } -} // namespace bb::join_split_example::proofs::join_split +} // namespace join_split +} // namespace proofs +} // namespace join_split_example diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_signing_data.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_signing_data.hpp index badab3da9fa8..6a6836220dd1 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_signing_data.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_signing_data.hpp @@ -1,8 +1,12 @@ #pragma once #include "join_split_tx.hpp" -namespace bb::join_split_example::proofs::join_split { +namespace join_split_example { +namespace proofs { +namespace join_split { bb::fr compute_signing_data(join_split_tx const& tx); -} \ No newline at end of file +} // namespace join_split +} // namespace proofs +} // namespace join_split_example \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/create_proof.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/create_proof.hpp index b0f1ddd6c8f1..2c3c3aa3ba15 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/create_proof.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/create_proof.hpp @@ -4,7 +4,9 @@ #include "join_split_circuit.hpp" #include "sign_join_split_tx.hpp" -namespace bb::join_split_example::proofs::join_split { +namespace join_split_example { +namespace proofs { +namespace join_split { inline std::vector create_proof(join_split_tx const& tx, circuit_data const& cd) { @@ -22,4 +24,6 @@ inline std::vector create_proof(join_split_tx const& tx, circuit_data c return proof.proof_data; } -} // namespace bb::join_split_example::proofs::join_split +} // namespace join_split +} // namespace proofs +} // namespace join_split_example diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.cpp index 5eae28bf8de1..60b693723b4c 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.cpp @@ -4,7 +4,9 @@ #include "compute_circuit_data.hpp" #include "join_split_circuit.hpp" -namespace bb::join_split_example::proofs::join_split { +namespace join_split_example { +namespace proofs { +namespace join_split { using namespace bb::plonk; using namespace bb::stdlib::merkle_tree; @@ -30,7 +32,7 @@ void init_proving_key(bool mock) Builder builder; join_split_circuit(builder, tx); Composer composer; - bb::join_split_example::proofs::mock::mock_circuit(builder, builder.get_public_inputs()); + join_split_example::proofs::mock::mock_circuit(builder, builder.get_public_inputs()); proving_key = composer.compute_proving_key(builder); } } @@ -68,7 +70,7 @@ Prover new_join_split_prover(join_split_tx const& tx, bool mock) return composer.create_prover(builder); } else { Composer mock_proof_composer(proving_key, nullptr); - bb::join_split_example::proofs::mock::mock_circuit(builder, builder.get_public_inputs()); + join_split_example::proofs::mock::mock_circuit(builder, builder.get_public_inputs()); info("mock composer gates: ", builder.get_num_gates()); return mock_proof_composer.create_prover(builder); } @@ -95,4 +97,6 @@ std::shared_ptr get_verification_key() return verification_key; } -} // namespace bb::join_split_example::proofs::join_split +} // namespace join_split +} // namespace proofs +} // namespace join_split_example diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.hpp index 42419078aba4..a436d99f884a 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.hpp @@ -3,7 +3,9 @@ #include "barretenberg/srs/factories/crs_factory.hpp" #include "join_split_tx.hpp" -namespace bb::join_split_example::proofs::join_split { +namespace join_split_example { +namespace proofs { +namespace join_split { void init_proving_key(bool mock); @@ -19,4 +21,6 @@ std::shared_ptr get_proving_key(); std::shared_ptr get_verification_key(); -} // namespace bb::join_split_example::proofs::join_split +} // namespace join_split +} // namespace proofs +} // namespace join_split_example diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.test.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.test.cpp index 5d110351dbb8..2ae8253681a2 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.test.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.test.cpp @@ -11,7 +11,7 @@ #include "index.hpp" #include "join_split_circuit.hpp" -namespace bb::join_split_example::proofs::join_split { +namespace join_split_example::proofs::join_split { using namespace bb::stdlib::merkle_tree; @@ -28,7 +28,7 @@ constexpr bool CIRCUIT_CHANGE_EXPECTED = false; using namespace bb; using namespace bb::stdlib; using namespace bb::stdlib::merkle_tree; -using namespace bb::join_split_example::proofs::notes::native; +using namespace join_split_example::proofs::notes::native; using key_pair = join_split_example::fixtures::grumpkin_key_pair; auto create_account_leaf_data(fr const& account_alias_hash, @@ -43,7 +43,7 @@ class join_split_tests : public ::testing::Test { static constexpr size_t ACCOUNT_INDEX = 14; static void SetUpTestCase() { - srs::init_crs_factory("../srs_db/ignition"); + bb::srs::init_crs_factory("../srs_db/ignition"); init_proving_key(false); auto crs_factory = std::make_unique>("../srs_db/ignition"); init_verification_key(); @@ -179,7 +179,7 @@ class join_split_tests : public ::testing::Test { .input_nullifier = input_nullifier2 }; join_split_tx tx; - tx.proof_id = proof_ids::SEND; + tx.proof_id = ProofIds::SEND; tx.public_value = 0; tx.num_input_notes = 2; tx.input_index = input_indices; @@ -195,7 +195,7 @@ class join_split_tests : public ::testing::Test { tx.account_private_key = user.owner.private_key; tx.partial_claim_note.input_nullifier = 0; tx.alias_hash = - !account_required ? bb::join_split_example::fixtures::generate_alias_hash("penguin") : user.alias_hash; + !account_required ? join_split_example::fixtures::generate_alias_hash("penguin") : user.alias_hash; tx.account_required = account_required; // default to no chaining: tx.backward_link = 0; @@ -242,7 +242,7 @@ class join_split_tests : public ::testing::Test { value::value_note output_note2 = { 0, 0, 0, user.owner.public_key, user.note_secret, 0, input_nullifier2 }; join_split_tx tx; - tx.proof_id = proof_ids::SEND; + tx.proof_id = ProofIds::SEND; tx.public_value = 0; tx.public_owner = 0; tx.asset_id = 0; @@ -458,7 +458,7 @@ TEST_F(join_split_tests, test_invalid_num_input_notes_fails) TEST_F(join_split_tests, test_deposit_public_value_invalid_fails) { join_split_tx tx = zero_input_setup(); - tx.proof_id = proof_ids::DEPOSIT; + tx.proof_id = ProofIds::DEPOSIT; tx.public_value = 0; // <-- invalid, should be nonzero tx.public_owner = fr::random_element(); @@ -481,7 +481,7 @@ TEST_F(join_split_tests, test_send_public_value_invalid_fails) TEST_F(join_split_tests, test_withdraw_public_value_invalid_fails) { join_split_tx tx = simple_setup(); - tx.proof_id = proof_ids::WITHDRAW; + tx.proof_id = ProofIds::WITHDRAW; tx.public_value = 0; // <-- invalid - should be nonzero tx.public_owner = fr::random_element(); @@ -493,7 +493,7 @@ TEST_F(join_split_tests, test_withdraw_public_value_invalid_fails) TEST_F(join_split_tests, test_defi_deposit_public_value_invalid_fails) { join_split_tx tx = simple_setup(); - tx.proof_id = proof_ids::DEFI_DEPOSIT; + tx.proof_id = ProofIds::DEFI_DEPOSIT; tx.output_note[0].value = 0; tx.output_note[1].value = 99; tx.partial_claim_note.deposit_value = 50; @@ -512,7 +512,7 @@ TEST_F(join_split_tests, test_defi_deposit_public_value_invalid_fails) TEST_F(join_split_tests, test_deposit_public_owner_invalid_fails) { join_split_tx tx = zero_input_setup(); - tx.proof_id = proof_ids::DEPOSIT; + tx.proof_id = ProofIds::DEPOSIT; tx.public_value = 10; tx.public_owner = 0; // <-- invalid - should be nonzero @@ -535,7 +535,7 @@ TEST_F(join_split_tests, test_send_public_owner_invalid_fails) TEST_F(join_split_tests, test_withdraw_public_owner_invalid_fails) { join_split_tx tx = simple_setup(); - tx.proof_id = proof_ids::WITHDRAW; + tx.proof_id = ProofIds::WITHDRAW; tx.public_value = 10; tx.public_owner = 0; // <-- invalid - should be nonzero @@ -547,7 +547,7 @@ TEST_F(join_split_tests, test_withdraw_public_owner_invalid_fails) TEST_F(join_split_tests, test_defi_deposit_public_owner_invalid_fails) { join_split_tx tx = simple_setup(); - tx.proof_id = proof_ids::DEFI_DEPOSIT; + tx.proof_id = ProofIds::DEFI_DEPOSIT; tx.output_note[0].value = 0; tx.output_note[1].value = 99; tx.partial_claim_note.deposit_value = 50; @@ -566,7 +566,7 @@ TEST_F(join_split_tests, test_defi_deposit_public_owner_invalid_fails) TEST_F(join_split_tests, test_wrong_proof_id) { join_split_tx tx = zero_input_setup(); - tx.proof_id = proof_ids::DEFI_CLAIM; + tx.proof_id = ProofIds::DEFI_CLAIM; auto result = sign_and_verify_logic(tx, user.owner); EXPECT_FALSE(result.valid); @@ -593,7 +593,7 @@ TEST_F(join_split_tests, test_send_with_0_input_notes_fails) TEST_F(join_split_tests, test_withdraw_with_0_input_notes_fails) { join_split_tx tx = zero_input_setup(); - tx.proof_id = proof_ids::WITHDRAW; + tx.proof_id = ProofIds::WITHDRAW; tx.public_value = 10; tx.public_owner = fr::random_element(); @@ -605,7 +605,7 @@ TEST_F(join_split_tests, test_withdraw_with_0_input_notes_fails) TEST_F(join_split_tests, test_defi_deposit_with_0_input_notes_fails) { join_split_tx tx = zero_input_setup(); - tx.proof_id = proof_ids::DEFI_DEPOSIT; + tx.proof_id = ProofIds::DEFI_DEPOSIT; auto result = sign_and_verify_logic(tx, user.owner); EXPECT_FALSE(result.valid); @@ -655,7 +655,7 @@ TEST_F(join_split_tests, test_different_output_note_2_asset_id_fails) TEST_F(join_split_tests, test_deposit_but_different_input_note_2_asset_id_fails) { join_split_tx tx = simple_setup(); - tx.proof_id = proof_ids::DEPOSIT; + tx.proof_id = ProofIds::DEPOSIT; tx.public_value = 10; tx.public_owner = fr::random_element(); tx.input_note[1].asset_id = 3; @@ -678,7 +678,7 @@ TEST_F(join_split_tests, test_send_but_different_input_note_2_asset_id_fails) TEST_F(join_split_tests, test_withdraw_but_different_input_note_2_asset_id_fails) { join_split_tx tx = simple_setup(); - tx.proof_id = proof_ids::WITHDRAW; + tx.proof_id = ProofIds::WITHDRAW; tx.public_value = 10; tx.public_owner = fr::random_element(); tx.input_note[1].asset_id = 3; @@ -695,7 +695,7 @@ TEST_F(join_split_tests, test_withdraw_but_different_input_note_2_asset_id_fails TEST_F(join_split_tests, test_0_input_notes_and_detect_circuit_change) { join_split_tx tx = zero_input_setup(); - tx.proof_id = proof_ids::DEPOSIT; + tx.proof_id = ProofIds::DEPOSIT; tx.public_value = 30; tx.public_owner = fr::random_element(); tx.output_note[0].value = 30; @@ -731,7 +731,7 @@ TEST_F(join_split_tests, test_0_input_notes_create_dupicate_output_notes_fails) { join_split_tx tx = zero_input_setup(); - tx.proof_id = proof_ids::DEPOSIT; + tx.proof_id = ProofIds::DEPOSIT; tx.public_value = 30; tx.public_owner = fr::random_element(); tx.output_note[0].value = 15; @@ -748,7 +748,7 @@ TEST_F(join_split_tests, test_0_input_notes_create_dupicate_output_notes_fails_2 { join_split_tx tx = zero_input_setup(); - tx.proof_id = proof_ids::DEPOSIT; + tx.proof_id = ProofIds::DEPOSIT; tx.public_value = 30; tx.public_owner = fr::random_element(); tx.output_note[0].value = 15; @@ -767,7 +767,7 @@ TEST_F(join_split_tests, test_dummy_input_note_1_non_0_value_fails) { // Note: `tx.num_input_notes = 0` implies both inputs are 'dummy' join_split_tx tx = zero_input_setup(); - tx.proof_id = proof_ids::DEPOSIT; + tx.proof_id = ProofIds::DEPOSIT; tx.public_value = 10; tx.public_owner = fr::random_element(); tx.input_note[0].value = 10; @@ -782,7 +782,7 @@ TEST_F(join_split_tests, test_dummy_input_note_2_non_0_value_fails) { // Note: `tx.num_input_notes = 0` implies both inputs are 'dummy' join_split_tx tx = zero_input_setup(); - tx.proof_id = proof_ids::DEPOSIT; + tx.proof_id = ProofIds::DEPOSIT; tx.public_value = 10; tx.public_owner = fr::random_element(); tx.input_note[1].value = 10; @@ -826,13 +826,13 @@ TEST_F(join_split_tests, test_2_input_notes) join_split_tx tx = simple_setup(); auto result = sign_and_verify_logic(tx, user.owner); EXPECT_TRUE(result.valid); - EXPECT_EQ(result.public_inputs.size(), inner_proof_fields::NUM_FIELDS); + EXPECT_EQ(result.public_inputs.size(), InnerProofFields::NUM_FIELDS); } TEST_F(join_split_tests, test_0_output_notes) { join_split_tx tx = simple_setup(); - tx.proof_id = proof_ids::WITHDRAW; + tx.proof_id = ProofIds::WITHDRAW; tx.output_note[0].value = 0; tx.output_note[1].value = 0; tx.public_value = tx.input_note[0].value + tx.input_note[1].value; @@ -853,7 +853,7 @@ TEST_P(test_valid_allow_chain_permutations, ) tx.allow_chain = GetParam(); auto result = sign_and_verify_logic(tx, user.owner); EXPECT_TRUE(result.valid); - EXPECT_EQ(result.public_inputs[inner_proof_fields::ALLOW_CHAIN], GetParam()); + EXPECT_EQ(result.public_inputs[InnerProofFields::ALLOW_CHAIN], GetParam()); } INSTANTIATE_TEST_SUITE_P(join_split_tests, test_valid_allow_chain_permutations, ::testing::Values(0, 1, 2, 3)); @@ -900,7 +900,7 @@ void assign_backward_link(join_split_tx& tx, size_t& indicator) tx.backward_link = tx.input_note[1].commit(); break; default: - tx.backward_link = fr::random_element(); + tx.backward_link = bb::fr::random_element(); } } @@ -950,7 +950,7 @@ TEST_F(join_split_tests, test_propagated_input_note1_no_double_spend) TEST_F(join_split_tests, test_max_public_input) { join_split_tx tx = zero_input_setup(); - tx.proof_id = proof_ids::DEPOSIT; + tx.proof_id = ProofIds::DEPOSIT; tx.public_value = max_value; tx.output_note[0].value = max_value; tx.public_owner = fr::random_element(); @@ -961,7 +961,7 @@ TEST_F(join_split_tests, test_max_public_input) TEST_F(join_split_tests, test_overflow_public_value_fails) { join_split_tx tx = zero_input_setup(); - tx.proof_id = proof_ids::DEPOSIT; + tx.proof_id = ProofIds::DEPOSIT; tx.public_value = max_value + 1; tx.public_owner = fr::random_element(); @@ -977,13 +977,13 @@ TEST_F(join_split_tests, test_overflow_public_value_fails) TEST_F(join_split_tests, test_non_zero_tx_fee) { join_split_tx tx = zero_input_setup(); - tx.proof_id = proof_ids::DEPOSIT; + tx.proof_id = ProofIds::DEPOSIT; tx.public_value += 10; tx.public_owner = fr::random_element(); auto result = sign_and_verify_logic(tx, user.owner); EXPECT_TRUE(result.valid); - EXPECT_EQ(result.public_inputs[inner_proof_fields::TX_FEE], 10); + EXPECT_EQ(result.public_inputs[InnerProofFields::TX_FEE], 10); } TEST_F(join_split_tests, test_non_zero_tx_fee_zero_public_values) @@ -993,27 +993,27 @@ TEST_F(join_split_tests, test_non_zero_tx_fee_zero_public_values) auto result = sign_and_verify_logic(tx, user.owner); EXPECT_TRUE(result.valid); - EXPECT_EQ(result.public_inputs[inner_proof_fields::TX_FEE], 10); + EXPECT_EQ(result.public_inputs[InnerProofFields::TX_FEE], 10); } TEST_F(join_split_tests, test_max_tx_fee) { join_split_tx tx = zero_input_setup(); - auto tx_fee = (uint256_t(1) << bb::join_split_example::TX_FEE_BIT_LENGTH) - 1; - tx.proof_id = proof_ids::DEPOSIT; + auto tx_fee = (uint256_t(1) << join_split_example::TX_FEE_BIT_LENGTH) - 1; + tx.proof_id = ProofIds::DEPOSIT; tx.public_value += tx_fee; tx.public_owner = fr::random_element(); auto result = sign_and_verify_logic(tx, user.owner); EXPECT_TRUE(result.valid); - EXPECT_EQ(result.public_inputs[inner_proof_fields::TX_FEE], fr(tx_fee)); + EXPECT_EQ(result.public_inputs[InnerProofFields::TX_FEE], fr(tx_fee)); } TEST_F(join_split_tests, test_overflow_tx_fee_fails) { join_split_tx tx = simple_setup(); - auto tx_fee = uint256_t(1) << bb::join_split_example::TX_FEE_BIT_LENGTH; - tx.proof_id = proof_ids::DEPOSIT; + auto tx_fee = uint256_t(1) << join_split_example::TX_FEE_BIT_LENGTH; + tx.proof_id = ProofIds::DEPOSIT; tx.public_value += tx_fee; tx.public_owner = fr::random_element(); @@ -1104,7 +1104,7 @@ TEST_F(join_split_tests, test_random_output_note_owners) TEST_F(join_split_tests, test_tainted_output_owner_fails) { join_split_tx tx = simple_setup(); - tx.proof_id = proof_ids::DEPOSIT; + tx.proof_id = ProofIds::DEPOSIT; tx.public_value = 1; tx.signing_pub_key = user.owner.public_key; uint8_t public_owner[32] = { 0x01, 0xaa, 0x42, 0xd4, 0x72, 0x88, 0x8e, 0xae, 0xa5, 0x56, 0x39, @@ -1116,8 +1116,8 @@ TEST_F(join_split_tests, test_tainted_output_owner_fails) auto prover = new_join_split_prover(tx, false); auto proof = prover.construct_proof(); - EXPECT_EQ(proof.proof_data[inner_proof_offsets::PUBLIC_OWNER], 0x01); - proof.proof_data[inner_proof_fields::PUBLIC_OWNER] = 0x02; + EXPECT_EQ(proof.proof_data[InnerProofOffsets::PUBLIC_OWNER], 0x01); + proof.proof_data[InnerProofFields::PUBLIC_OWNER] = 0x02; EXPECT_FALSE(verify_proof(proof)); } @@ -1139,7 +1139,7 @@ TEST_F(join_split_tests, test_wrong_account_private_key_fails) TEST_F(join_split_tests, test_wrong_public_owner_sig_fail) { join_split_tx tx = simple_setup(); - tx.proof_id = proof_ids::DEPOSIT; + tx.proof_id = ProofIds::DEPOSIT; tx.public_value = 1; tx.public_owner = fr::random_element(); @@ -1265,7 +1265,7 @@ TEST_F(join_split_tests, test_defi_deposit_one_virtual_input) tx.output_note[1].input_nullifier = compute_nullifier(tx.input_note[1].commit(), user.owner.private_key, false); // input note 2 is a dummy note - tx.proof_id = proof_ids::DEFI_DEPOSIT; + tx.proof_id = ProofIds::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1289,7 +1289,7 @@ TEST_F(join_split_tests, test_defi_deposit_one_real_one_virtual_inputs) { join_split_tx tx = simple_setup({ 0, 11 }); - tx.proof_id = proof_ids::DEFI_DEPOSIT; + tx.proof_id = ProofIds::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1316,7 +1316,7 @@ TEST_F(join_split_tests, test_defi_deposit_one_virtual_one_real_inputs) { join_split_tx tx = simple_setup({ 10, 7 }); - tx.proof_id = proof_ids::DEFI_DEPOSIT; + tx.proof_id = ProofIds::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 110; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1342,7 +1342,7 @@ TEST_F(join_split_tests, test_defi_deposit_one_real_one_virtual_inputs_same_asse { join_split_tx tx = simple_setup({ 0, 12 }); - tx.proof_id = proof_ids::DEFI_DEPOSIT; + tx.proof_id = ProofIds::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1369,7 +1369,7 @@ TEST_F(join_split_tests, test_defi_deposit_two_real_inputs_different_asset_ids) { join_split_tx tx = simple_setup({ 0, 6 }); - tx.proof_id = proof_ids::DEFI_DEPOSIT; + tx.proof_id = ProofIds::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1396,7 +1396,7 @@ TEST_F(join_split_tests, test_defi_deposit_two_virtual_inputs_different_asset_id { join_split_tx tx = simple_setup({ 4, 9 }); - tx.proof_id = proof_ids::DEFI_DEPOSIT; + tx.proof_id = ProofIds::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1424,7 +1424,7 @@ TEST_F(join_split_tests, { join_split_tx tx = simple_setup({ 4, 10 }); - tx.proof_id = proof_ids::DEFI_DEPOSIT; + tx.proof_id = ProofIds::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1453,7 +1453,7 @@ TEST_F(join_split_tests, test_defi_deposit_two_real_inputs_different_asset_ids_a { join_split_tx tx = simple_setup({ 0, 7 }); - tx.proof_id = proof_ids::DEFI_DEPOSIT; + tx.proof_id = ProofIds::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1482,7 +1482,7 @@ TEST_F(join_split_tests, test_defi_deposit_two_real_inputs_different_asset_ids_a { join_split_tx tx = simple_setup({ 0, 6 }); - tx.proof_id = proof_ids::DEFI_DEPOSIT; + tx.proof_id = ProofIds::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 95; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1511,7 +1511,7 @@ TEST_F(join_split_tests, test_defi_invalid_tx_fee_asset_id_fails) { join_split_tx tx = simple_setup({ 0, 11 }); - tx.proof_id = proof_ids::DEFI_DEPOSIT; + tx.proof_id = ProofIds::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1541,7 +1541,7 @@ TEST_F(join_split_tests, test_defi_deposit_of_zero_fails) { join_split_tx tx = simple_setup(); - tx.proof_id = proof_ids::DEFI_DEPOSIT; + tx.proof_id = ProofIds::DEFI_DEPOSIT; tx.output_note[0].value = 0; tx.output_note[1].value = 0; tx.partial_claim_note.deposit_value = 0; // <-- should be > 0 @@ -1558,7 +1558,7 @@ TEST_F(join_split_tests, test_defi_deposit_of_zero_fails) TEST_F(join_split_tests, test_defi_non_zero_output_note_1_ignored) { join_split_tx tx = simple_setup(); - tx.proof_id = proof_ids::DEFI_DEPOSIT; + tx.proof_id = ProofIds::DEFI_DEPOSIT; tx.output_note[0].value = 10; // This should be ignored in fee calculation. tx.output_note[1].value = 100; tx.partial_claim_note.deposit_value = 50; @@ -1584,7 +1584,7 @@ TEST_F(join_split_tests, test_defi_non_zero_output_note_1_ignored) TEST_F(join_split_tests, test_defi_allow_chain_1_fails) { join_split_tx tx = simple_setup(); - tx.proof_id = proof_ids::DEFI_DEPOSIT; + tx.proof_id = ProofIds::DEFI_DEPOSIT; tx.output_note[1].value = 100; tx.partial_claim_note.deposit_value = 50; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1618,7 +1618,7 @@ TEST_F(join_split_tests, test_defi_deposit_incorrect_input_nullifier_in_partial_ tx.output_note[1].input_nullifier = compute_nullifier(tx.input_note[1].commit(), user.owner.private_key, false); // input note 2 is a dummy note - tx.proof_id = proof_ids::DEFI_DEPOSIT; + tx.proof_id = ProofIds::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = 1; // incorrect nullifier @@ -1647,7 +1647,7 @@ TEST_F(join_split_tests, test_defi_deposit_bridge_call_data_second_bridge_input_ { join_split_tx tx = simple_setup({ 0, 11 }); - tx.proof_id = proof_ids::DEFI_DEPOSIT; + tx.proof_id = ProofIds::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1679,7 +1679,7 @@ TEST_F(join_split_tests, test_defi_deposit_bridge_call_data_second_bridge_output tx.output_note[1].input_nullifier = compute_nullifier(tx.input_note[1].commit(), user.owner.private_key, false); // input note 2 is a dummy note - tx.proof_id = proof_ids::DEFI_DEPOSIT; + tx.proof_id = ProofIds::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1707,7 +1707,7 @@ TEST_F(join_split_tests, test_defi_deposit_second_bridge_input_in_use_but_same_b { join_split_tx tx = simple_setup(); - tx.proof_id = proof_ids::DEFI_DEPOSIT; + tx.proof_id = ProofIds::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 50; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; tx.output_note[1].value = 90; @@ -1742,7 +1742,7 @@ TEST_F(join_split_tests, test_defi_deposit_second_bridge_output_in_use_and_same_ tx.output_note[1].input_nullifier = compute_nullifier(tx.input_note[1].commit(), user.owner.private_key, false); // input note 2 is a dummy note - tx.proof_id = proof_ids::DEFI_DEPOSIT; + tx.proof_id = ProofIds::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1775,7 +1775,7 @@ TEST_F(join_split_tests, test_defi_deposit_second_bridge_output_in_use_but_same_ tx.output_note[1].input_nullifier = compute_nullifier(tx.input_note[1].commit(), user.owner.private_key, false); // input note 2 is a dummy note - tx.proof_id = proof_ids::DEFI_DEPOSIT; + tx.proof_id = ProofIds::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1809,7 +1809,7 @@ TEST_F(join_split_tests, test_defi_deposit_first_bridge_output_asset_id_virtual_ tx.output_note[1].input_nullifier = compute_nullifier(tx.input_note[1].commit(), user.owner.private_key, false); // input note 2 is a dummy note - tx.proof_id = proof_ids::DEFI_DEPOSIT; + tx.proof_id = ProofIds::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1840,7 +1840,7 @@ TEST_F(join_split_tests, test_defi_deposit_second_bridge_output_asset_id_virtual tx.output_note[1].input_nullifier = compute_nullifier(tx.input_note[1].commit(), user.owner.private_key, false); // input note 2 is a dummy note - tx.proof_id = proof_ids::DEFI_DEPOSIT; + tx.proof_id = ProofIds::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1877,7 +1877,7 @@ TEST_F(join_split_tests, test_defi_wrong_first_asset_id_in_bridge_call_data_fail tx.output_note[1].input_nullifier = compute_nullifier(tx.input_note[1].commit(), user.owner.private_key, false); // input note 2 is a dummy note - tx.proof_id = proof_ids::DEFI_DEPOSIT; + tx.proof_id = ProofIds::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1907,7 +1907,7 @@ TEST_F(join_split_tests, test_defi_bridge_call_data_config_second_input_in_use_b tx.output_note[1].input_nullifier = compute_nullifier(tx.input_note[1].commit(), user.owner.private_key, false); // input note 2 is a dummy note - tx.proof_id = proof_ids::DEFI_DEPOSIT; + tx.proof_id = ProofIds::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1934,7 +1934,7 @@ TEST_F(join_split_tests, test_defi_missing_second_asset_in_bridge_call_data_fail { join_split_tx tx = simple_setup({ 0, 11 }); - tx.proof_id = proof_ids::DEFI_DEPOSIT; + tx.proof_id = ProofIds::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1962,7 +1962,7 @@ TEST_F(join_split_tests, test_defi_wrong_second_asset_id_in_bridge_call_data_fai { join_split_tx tx = simple_setup({ 4, 9 }); - tx.proof_id = proof_ids::DEFI_DEPOSIT; + tx.proof_id = ProofIds::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1996,7 +1996,7 @@ TEST_F(join_split_tests, test_repayment_logic) { join_split_tx tx = simple_setup({ 0, 11 }); - tx.proof_id = proof_ids::DEFI_DEPOSIT; + tx.proof_id = ProofIds::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; tx.output_note[1].value = 10; // <-- repaying some value back to the defi-depositor @@ -2023,7 +2023,7 @@ TEST_F(join_split_tests, test_virtual_note_repay_different_asset_id_fail) { join_split_tx tx = simple_setup({ 0, 11 }); - tx.proof_id = proof_ids::DEFI_DEPOSIT; + tx.proof_id = ProofIds::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; tx.output_note[1].asset_id = 3; // <-- different from any of the input notes' asset_ids @@ -2051,7 +2051,7 @@ TEST_F(join_split_tests, test_virtual_note_repay_different_asset_id_fail) TEST_F(join_split_tests, test_real_input_value_lt_virtual_input_value_fails) { join_split_tx tx = simple_setup({ 1, 11 }); - tx.proof_id = proof_ids::DEFI_DEPOSIT; + tx.proof_id = ProofIds::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -2222,7 +2222,7 @@ TEST_F(join_split_tests, test_incorrect_output_note_creator_pubkey_x) TEST_F(join_split_tests, test_deposit_construct_proof) { join_split_tx tx = zero_input_setup(); - tx.proof_id = proof_ids::DEPOSIT; + tx.proof_id = ProofIds::DEPOSIT; tx.public_value = 10; tx.public_owner = fr::random_element(); tx.output_note[0].value = 7; @@ -2244,7 +2244,7 @@ TEST_F(join_split_tests, test_deposit_construct_proof) auto output_note1_commitment = tx.output_note[0].commit(); auto output_note2_commitment = tx.output_note[1].commit(); - EXPECT_EQ(proof_data.proof_id, proof_ids::DEPOSIT); + EXPECT_EQ(proof_data.proof_id, ProofIds::DEPOSIT); EXPECT_EQ(proof_data.note_commitment1, output_note1_commitment); EXPECT_EQ(proof_data.note_commitment2, output_note2_commitment); EXPECT_EQ(proof_data.nullifier1, nullifier1); @@ -2265,7 +2265,7 @@ TEST_F(join_split_tests, test_deposit_construct_proof) TEST_F(join_split_tests, test_withdraw_full_proof) { join_split_tx tx = simple_setup(); - tx.proof_id = proof_ids::WITHDRAW; + tx.proof_id = ProofIds::WITHDRAW; tx.public_value = 10; tx.public_owner = fr::random_element(); tx.output_note[0].value -= 13; @@ -2289,7 +2289,7 @@ TEST_F(join_split_tests, test_withdraw_full_proof) auto output_note1_commitment = tx.output_note[0].commit(); auto output_note2_commitment = tx.output_note[1].commit(); - EXPECT_EQ(proof_data.proof_id, proof_ids::WITHDRAW); + EXPECT_EQ(proof_data.proof_id, ProofIds::WITHDRAW); EXPECT_EQ(proof_data.note_commitment1, output_note1_commitment); EXPECT_EQ(proof_data.note_commitment2, output_note2_commitment); EXPECT_EQ(proof_data.nullifier1, nullifier1); @@ -2330,7 +2330,7 @@ TEST_F(join_split_tests, test_private_send_full_proof) uint256_t nullifier1 = compute_nullifier(input_note1_commitment, user.owner.private_key, true); uint256_t nullifier2 = compute_nullifier(input_note2_commitment, user.owner.private_key, true); - EXPECT_EQ(proof_data.proof_id, proof_ids::SEND); + EXPECT_EQ(proof_data.proof_id, ProofIds::SEND); EXPECT_EQ(proof_data.note_commitment1, output_note1_commitment); EXPECT_EQ(proof_data.note_commitment2, output_note2_commitment); EXPECT_EQ(proof_data.nullifier1, nullifier1); @@ -2354,7 +2354,7 @@ TEST_F(join_split_tests, test_defi_deposit_full_proof) { join_split_tx tx = simple_setup(); - tx.proof_id = proof_ids::DEFI_DEPOSIT; + tx.proof_id = ProofIds::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 50; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; tx.output_note[1].value = 90; @@ -2394,7 +2394,7 @@ TEST_F(join_split_tests, test_defi_deposit_full_proof) uint256_t nullifier1 = compute_nullifier(input_note1_commitment, user.owner.private_key, true); uint256_t nullifier2 = compute_nullifier(input_note2_commitment, user.owner.private_key, true); - EXPECT_EQ(proof_data.proof_id, proof_ids::DEFI_DEPOSIT); + EXPECT_EQ(proof_data.proof_id, ProofIds::DEFI_DEPOSIT); EXPECT_EQ(proof_data.note_commitment1, output_note1_commitment); EXPECT_EQ(proof_data.note_commitment2, output_note2_commitment); EXPECT_EQ(proof_data.nullifier1, nullifier1); @@ -2416,7 +2416,7 @@ TEST_F(join_split_tests, test_repayment_full_proof) { join_split_tx tx = simple_setup({ 0, 11 }); - tx.proof_id = proof_ids::DEFI_DEPOSIT; + tx.proof_id = ProofIds::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; tx.output_note[1].value = 10; // <-- repaying some value back to the defi-depositor @@ -2456,7 +2456,7 @@ TEST_F(join_split_tests, test_repayment_full_proof) uint256_t nullifier1 = compute_nullifier(input_note1_commitment, user.owner.private_key, true); uint256_t nullifier2 = compute_nullifier(input_note2_commitment, user.owner.private_key, true); - EXPECT_EQ(proof_data.proof_id, proof_ids::DEFI_DEPOSIT); + EXPECT_EQ(proof_data.proof_id, ProofIds::DEFI_DEPOSIT); EXPECT_EQ(proof_data.note_commitment1, output_note1_commitment); EXPECT_EQ(proof_data.note_commitment2, output_note2_commitment); EXPECT_EQ(proof_data.nullifier1, nullifier1); @@ -2497,7 +2497,7 @@ TEST_F(join_split_tests, test_send_two_virtual_notes_full_proof) uint256_t nullifier1 = compute_nullifier(input_note1_commitment, user.owner.private_key, true); uint256_t nullifier2 = compute_nullifier(input_note2_commitment, user.owner.private_key, true); - EXPECT_EQ(proof_data.proof_id, proof_ids::SEND); + EXPECT_EQ(proof_data.proof_id, ProofIds::SEND); EXPECT_EQ(proof_data.note_commitment1, output_note1_commitment); EXPECT_EQ(proof_data.note_commitment2, output_note2_commitment); EXPECT_EQ(proof_data.nullifier1, nullifier1); @@ -2514,4 +2514,4 @@ TEST_F(join_split_tests, test_send_two_virtual_notes_full_proof) EXPECT_TRUE(verify_proof(proof)); } -} // namespace bb::join_split_example::proofs::join_split +} // namespace join_split_example::proofs::join_split diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_circuit.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_circuit.cpp index 847e7d15cff7..8a4523432b3b 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_circuit.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_circuit.cpp @@ -8,12 +8,14 @@ #include "barretenberg/stdlib/merkle_tree/membership.hpp" #include "verify_signature.hpp" -namespace bb::join_split_example::proofs::join_split { +namespace join_split_example { +namespace proofs { +namespace join_split { using namespace bb::plonk; using namespace notes::circuit; using namespace bb::stdlib::merkle_tree; -using namespace bb::crypto; +using namespace crypto::schnorr; /** * Check that the input note data, follows the given hash paths, to the publically given merkle root. @@ -41,10 +43,10 @@ field_ct process_input_note(field_ct const& account_private_key, join_split_outputs join_split_circuit_component(join_split_inputs const& inputs) { - const bool_ct is_deposit = inputs.proof_id == field_ct(proof_ids::DEPOSIT); - const bool_ct is_withdraw = inputs.proof_id == field_ct(proof_ids::WITHDRAW); - const bool_ct is_send = inputs.proof_id == field_ct(proof_ids::SEND); - const bool_ct is_defi_deposit = inputs.proof_id == field_ct(proof_ids::DEFI_DEPOSIT); + const bool_ct is_deposit = inputs.proof_id == field_ct(ProofIds::DEPOSIT); + const bool_ct is_withdraw = inputs.proof_id == field_ct(ProofIds::WITHDRAW); + const bool_ct is_send = inputs.proof_id == field_ct(ProofIds::SEND); + const bool_ct is_defi_deposit = inputs.proof_id == field_ct(ProofIds::DEFI_DEPOSIT); const bool_ct not_defi_deposit = !is_defi_deposit; const bool_ct is_public_tx = is_deposit || is_withdraw; @@ -86,10 +88,10 @@ join_split_outputs join_split_circuit_component(join_split_inputs const& inputs) (is_public_tx == inputs.public_owner.is_zero()).assert_equal(false, "public owner invalid"); // Constrain the proof id. - inputs.proof_id.assert_is_in_set({ field_ct(proof_ids::DEPOSIT), - field_ct(proof_ids::WITHDRAW), - field_ct(proof_ids::SEND), - field_ct(proof_ids::DEFI_DEPOSIT) }, + inputs.proof_id.assert_is_in_set({ field_ct(ProofIds::DEPOSIT), + field_ct(ProofIds::WITHDRAW), + field_ct(ProofIds::SEND), + field_ct(ProofIds::DEFI_DEPOSIT) }, "invalid proof id"); // Check we're not joining the same input note. @@ -286,7 +288,7 @@ void join_split_circuit(Builder& builder, join_split_tx const& tx) // many constraints on the bridge_call_data's format and the bit_config's format: .partial_claim_note = claim::partial_claim_note_witness_data(builder, tx.partial_claim_note), .signing_pub_key = group_ct::from_witness(&builder, tx.signing_pub_key), - .signature = stdlib::schnorr_convert_signature(&builder, tx.signature), + .signature = stdlib::schnorr::convert_signature(&builder, tx.signature), .merkle_root = witness_ct(&builder, tx.old_data_root), .input_path1 = stdlib::merkle_tree::create_witness_hash_path(builder, tx.input_path[0]), .input_path2 = stdlib::merkle_tree::create_witness_hash_path(builder, tx.input_path[1]), @@ -325,4 +327,6 @@ void join_split_circuit(Builder& builder, join_split_tx const& tx) inputs.allow_chain.set_public(); } // namespace join_split -} // namespace bb::join_split_example::proofs::join_split +} // namespace join_split +} // namespace proofs +} // namespace join_split_example diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_circuit.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_circuit.hpp index 799f0228bfd5..82e338fb3c0d 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_circuit.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_circuit.hpp @@ -5,7 +5,9 @@ #include "barretenberg/join_split_example/types.hpp" #include "join_split_tx.hpp" -namespace bb::join_split_example::proofs::join_split { +namespace join_split_example { +namespace proofs { +namespace join_split { struct join_split_inputs { @@ -22,7 +24,7 @@ struct join_split_inputs { notes::circuit::value::witness_data output_note2; notes::circuit::claim::partial_claim_note_witness_data partial_claim_note; group_ct signing_pub_key; - schnorr_signature_bits signature; + schnorr::signature_bits signature; field_ct merkle_root; hash_path_ct input_path1; hash_path_ct input_path2; @@ -50,4 +52,6 @@ join_split_outputs join_split_circuit_component(join_split_inputs const& inputs) void join_split_circuit(Builder& builder, join_split_tx const& tx); -} // namespace bb::join_split_example::proofs::join_split +} // namespace join_split +} // namespace proofs +} // namespace join_split_example diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_js_parity.test.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_js_parity.test.cpp index 6754c48cbd0d..9891530b991f 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_js_parity.test.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_js_parity.test.cpp @@ -8,12 +8,14 @@ #include "barretenberg/stdlib/merkle_tree/index.hpp" #include "index.hpp" -namespace bb::join_split_example::proofs::join_split { +namespace join_split_example { +namespace proofs { +namespace join_split { using namespace bb; // using namespace bb::stdlib::types; using namespace bb::stdlib::merkle_tree; -using namespace bb::join_split_example::proofs::notes::native; +using namespace join_split_example::proofs::notes::native; using key_pair = join_split_example::fixtures::grumpkin_key_pair; /** @@ -102,7 +104,7 @@ TEST_F(join_split_js_parity_tests, test_full_proof) value::value_note output_note2 = { 50, 0, 0, public_key, note_secret, 0, input_note2_nullifier }; join_split_tx tx; - tx.proof_id = proof_ids::SEND; + tx.proof_id = ProofIds::SEND; tx.public_value = 0; tx.public_owner = 0; tx.asset_id = 0; @@ -136,7 +138,7 @@ TEST_F(join_split_js_parity_tests, test_full_proof) auto output_note1_commitment = tx.output_note[0].commit(); auto output_note2_commitment = tx.output_note[1].commit(); - EXPECT_EQ(proof_data.proof_id, proof_ids::SEND); + EXPECT_EQ(proof_data.proof_id, ProofIds::SEND); EXPECT_EQ(proof_data.note_commitment1, output_note1_commitment); EXPECT_EQ(proof_data.note_commitment2, output_note2_commitment); EXPECT_EQ(proof_data.nullifier1, uint256_t(input_note1_nullifier)); @@ -159,4 +161,6 @@ TEST_F(join_split_js_parity_tests, test_full_proof) // } } -} // namespace bb::join_split_example::proofs::join_split +} // namespace join_split +} // namespace proofs +} // namespace join_split_example diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.cpp index 9f7adae976d7..d1543e0123f0 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.cpp @@ -1,7 +1,9 @@ #include "join_split_tx.hpp" #include "barretenberg/crypto/pedersen_commitment/pedersen.hpp" -namespace bb::join_split_example::proofs::join_split { +namespace join_split_example { +namespace proofs { +namespace join_split { using namespace bb; @@ -89,4 +91,6 @@ std::ostream& operator<<(std::ostream& os, join_split_tx const& tx) << "signature: " << tx.signature << "\n"; } -} // namespace bb::join_split_example::proofs::join_split +} // namespace join_split +} // namespace proofs +} // namespace join_split_example diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.hpp index eb1282f00065..3a530778e9bf 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.hpp @@ -5,7 +5,9 @@ #include "barretenberg/join_split_example/types.hpp" #include "barretenberg/stdlib/merkle_tree/hash_path.hpp" -namespace bb::join_split_example::proofs::join_split { +namespace join_split_example { +namespace proofs { +namespace join_split { struct join_split_tx { uint32_t proof_id; @@ -31,7 +33,7 @@ struct join_split_tx { bb::fr backward_link; // 0: no link, otherwise: any commitment. uint32_t allow_chain; // 0: none, 1: output_note1, 2: output_note2 - crypto::schnorr_signature signature; + crypto::schnorr::signature signature; bool operator==(join_split_tx const&) const = default; }; @@ -41,4 +43,6 @@ void write(std::vector& buf, join_split_tx const& tx); std::ostream& operator<<(std::ostream& os, join_split_tx const& tx); -} // namespace bb::join_split_example::proofs::join_split +} // namespace join_split +} // namespace proofs +} // namespace join_split_example diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.test.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.test.cpp index 758ae4c1a30e..0c3c90bd9fd8 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.test.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.test.cpp @@ -11,10 +11,10 @@ #include using namespace bb; -using namespace bb::join_split_example::proofs::join_split; +using namespace join_split_example::proofs::join_split; namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } TEST(client_proofs_join_split_tx, test_serialization) diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/sign_join_split_tx.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/sign_join_split_tx.cpp index f4ec6e2525d1..cf379621bf79 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/sign_join_split_tx.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/sign_join_split_tx.cpp @@ -2,25 +2,29 @@ #include "barretenberg/crypto/schnorr/schnorr.hpp" #include "compute_signing_data.hpp" -namespace bb::join_split_example::proofs::join_split { +namespace join_split_example { +namespace proofs { +namespace join_split { -using namespace bb::crypto; +using namespace crypto::schnorr; -schnorr_signature sign_join_split_tx(join_split_tx const& tx, schnorr_key_pair const& keys) +signature sign_join_split_tx(join_split_tx const& tx, key_pair const& keys) { fr hashed = compute_signing_data(tx); std::vector message(sizeof(fr)); fr::serialize_to_buffer(hashed, &message[0]); - crypto::schnorr_signature signature = - crypto::schnorr_construct_signature( + crypto::schnorr::signature signature = + crypto::schnorr::construct_signature( std::string(message.begin(), message.end()), keys); - auto result = crypto::schnorr_verify_signature( + auto result = crypto::schnorr::verify_signature( std::string(message.begin(), message.end()), keys.public_key, signature); ASSERT(result == true); return signature; } -} // namespace bb::join_split_example::proofs::join_split +} // namespace join_split +} // namespace proofs +} // namespace join_split_example diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/sign_join_split_tx.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/sign_join_split_tx.hpp index a02a35f2f295..af100ddc9126 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/sign_join_split_tx.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/sign_join_split_tx.hpp @@ -3,9 +3,13 @@ #include "barretenberg/crypto/schnorr/schnorr.hpp" #include "join_split_tx.hpp" -namespace bb::join_split_example::proofs::join_split { +namespace join_split_example { +namespace proofs { +namespace join_split { -crypto::schnorr_signature sign_join_split_tx(proofs::join_split::join_split_tx const& tx, - crypto::schnorr_key_pair const& keys); +crypto::schnorr::signature sign_join_split_tx(proofs::join_split::join_split_tx const& tx, + crypto::schnorr::key_pair const& keys); -} +} // namespace join_split +} // namespace proofs +} // namespace join_split_example diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/verify_signature.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/verify_signature.hpp index 2b39536a1357..2836c1cfbba1 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/verify_signature.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/verify_signature.hpp @@ -1,7 +1,9 @@ #include "barretenberg/stdlib/encryption/schnorr/schnorr.hpp" #include "barretenberg/stdlib/hash/pedersen/pedersen.hpp" -namespace bb::join_split_example::proofs::join_split { +namespace join_split_example { +namespace proofs { +namespace join_split { using namespace notes; @@ -15,14 +17,16 @@ inline void verify_signature(field_ct const& public_value, group_ct const& owner_pub_key, field_ct const& backward_link, field_ct const& allow_chain, - schnorr_signature_bits const& signature) + schnorr::signature_bits const& signature) { std::vector to_compress = { public_value, public_owner, public_asset_id, output_note1_commitment, output_note2_commitment, nullifier1, nullifier2, backward_link, allow_chain, }; byte_array_ct message = pedersen_hash::hash(to_compress); - schnorr_verify_signature(message, owner_pub_key, signature); + verify_signature(message, owner_pub_key, signature); } -} // namespace bb::join_split_example::proofs::join_split +} // namespace join_split +} // namespace proofs +} // namespace join_split_example diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/mock/mock_circuit.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/mock/mock_circuit.hpp index 0bd3b9bb7241..3cfe9bbf57e8 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/mock/mock_circuit.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/mock/mock_circuit.hpp @@ -2,7 +2,9 @@ #include "barretenberg/common/map.hpp" #include "barretenberg/stdlib/hash/pedersen/pedersen.hpp" #include "barretenberg/stdlib/primitives/field/field.hpp" -namespace bb::join_split_example::proofs::mock { +namespace join_split_example { +namespace proofs { +namespace mock { using namespace bb::plonk; @@ -17,4 +19,6 @@ template void mock_circuit(Builder& builder, std::vector deflag_asset_id(suint_ct const& asset_id); bool_ct get_asset_id_flag(suint_ct const& asset_id); -} // namespace bb::join_split_example::proofs::notes::circuit +} // namespace join_split_example::proofs::notes::circuit diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/bridge_call_data.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/bridge_call_data.hpp index d0d3015d9741..2ed9f244f554 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/bridge_call_data.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/bridge_call_data.hpp @@ -4,7 +4,10 @@ #include "./asset_id.hpp" #include "barretenberg/join_split_example/types.hpp" -namespace bb::join_split_example::proofs::notes::circuit { +namespace join_split_example { +namespace proofs { +namespace notes { +namespace circuit { using namespace bb::stdlib; @@ -213,4 +216,7 @@ inline std::ostream& operator<<(std::ostream& os, bridge_call_data const& bridge return os; } -} // namespace bb::join_split_example::proofs::notes::circuit +} // namespace circuit +} // namespace notes +} // namespace proofs +} // namespace join_split_example diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/claim_note.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/claim_note.hpp index 385c99ae6300..832b47d1ccd3 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/claim_note.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/claim_note.hpp @@ -7,7 +7,11 @@ #include "create_partial_commitment.hpp" #include "witness_data.hpp" -namespace bb::join_split_example::proofs::notes::circuit::claim { +namespace join_split_example { +namespace proofs { +namespace notes { +namespace circuit { +namespace claim { using namespace bb::stdlib; @@ -58,4 +62,8 @@ struct claim_note { operator byte_array_ct() const { return byte_array_ct(commitment); } }; -} // namespace bb::join_split_example::proofs::notes::circuit::claim +} // namespace claim +} // namespace circuit +} // namespace notes +} // namespace proofs +} // namespace join_split_example diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/complete_partial_commitment.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/complete_partial_commitment.hpp index a9ec8b999200..9272b17abec3 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/complete_partial_commitment.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/complete_partial_commitment.hpp @@ -3,7 +3,11 @@ #include "barretenberg/join_split_example/types.hpp" #include "barretenberg/stdlib/hash/pedersen/pedersen.hpp" -namespace bb::join_split_example::proofs::notes::circuit::claim { +namespace join_split_example { +namespace proofs { +namespace notes { +namespace circuit { +namespace claim { using namespace bb::stdlib; @@ -15,4 +19,8 @@ inline auto complete_partial_commitment(field_ct const& partial_commitment, GeneratorIndex::CLAIM_NOTE_COMMITMENT); } -} // namespace bb::join_split_example::proofs::notes::circuit::claim +} // namespace claim +} // namespace circuit +} // namespace notes +} // namespace proofs +} // namespace join_split_example diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/compute_nullifier.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/compute_nullifier.hpp index cc07f1f4e163..f7bb38511432 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/compute_nullifier.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/compute_nullifier.hpp @@ -4,7 +4,11 @@ #include "barretenberg/join_split_example/types.hpp" #include "barretenberg/stdlib/hash/pedersen/pedersen.hpp" -namespace bb::join_split_example::proofs::notes::circuit::claim { +namespace join_split_example { +namespace proofs { +namespace notes { +namespace circuit { +namespace claim { inline field_ct compute_nullifier(field_ct const& note_commitment) { @@ -19,4 +23,8 @@ inline field_ct compute_nullifier(field_ct const& note_commitment) // later spent, the value note nullifiers will not reveal that it is those notes being spent. } -} // namespace bb::join_split_example::proofs::notes::circuit::claim +} // namespace claim +} // namespace circuit +} // namespace notes +} // namespace proofs +} // namespace join_split_example diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/create_partial_commitment.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/create_partial_commitment.hpp index 5217deb70e1a..ce45e40600cb 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/create_partial_commitment.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/create_partial_commitment.hpp @@ -3,7 +3,11 @@ #include "barretenberg/join_split_example/types.hpp" #include "barretenberg/stdlib/hash/pedersen/pedersen.hpp" -namespace bb::join_split_example::proofs::notes::circuit::claim { +namespace join_split_example { +namespace proofs { +namespace notes { +namespace circuit { +namespace claim { inline auto create_partial_commitment(field_ct const& deposit_value, field_ct const& bridge_call_data, @@ -14,4 +18,8 @@ inline auto create_partial_commitment(field_ct const& deposit_value, GeneratorIndex::CLAIM_NOTE_PARTIAL_COMMITMENT); } -} // namespace bb::join_split_example::proofs::notes::circuit::claim +} // namespace claim +} // namespace circuit +} // namespace notes +} // namespace proofs +} // namespace join_split_example diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/witness_data.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/witness_data.hpp index 32cb510348e6..f84ccdd5132d 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/witness_data.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/witness_data.hpp @@ -6,7 +6,7 @@ #include "../bridge_call_data.hpp" #include "barretenberg/join_split_example/types.hpp" -namespace bb::join_split_example::proofs::notes::circuit::claim { +namespace join_split_example::proofs::notes::circuit::claim { using namespace bb::stdlib; @@ -62,4 +62,4 @@ inline std::ostream& operator<<(std::ostream& os, partial_claim_note_witness_dat return os << "{ deposit_value: " << tx.deposit_value << ", bridge_call_data: " << tx.bridge_call_data_local.to_safe_uint() << " }"; } -} // namespace bb::join_split_example::proofs::notes::circuit::claim +} // namespace join_split_example::proofs::notes::circuit::claim diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/commit.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/commit.hpp index b02dea089d29..07864e8fc9ca 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/commit.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/commit.hpp @@ -3,7 +3,7 @@ #include "create_partial_commitment.hpp" #include "witness_data.hpp" -namespace bb::join_split_example::proofs::notes::circuit::value { +namespace join_split_example::proofs::notes::circuit::value { inline auto commit(const witness_data& plaintext) { @@ -13,4 +13,4 @@ inline auto commit(const witness_data& plaintext) partial_commitment, plaintext.value, plaintext.asset_id, plaintext.input_nullifier); } -} // namespace bb::join_split_example::proofs::notes::circuit::value \ No newline at end of file +} // namespace join_split_example::proofs::notes::circuit::value \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/complete_partial_commitment.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/complete_partial_commitment.hpp index 4ba7092534d1..73ad51bc7c6d 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/complete_partial_commitment.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/complete_partial_commitment.hpp @@ -3,7 +3,7 @@ #include "../../constants.hpp" #include "barretenberg/join_split_example/types.hpp" #include "barretenberg/stdlib/hash/pedersen/pedersen.hpp" -namespace bb::join_split_example::proofs::notes::circuit::value { +namespace join_split_example::proofs::notes::circuit::value { inline auto complete_partial_commitment(field_ct const& value_note_partial_commitment, suint_ct const& value, @@ -14,4 +14,4 @@ inline auto complete_partial_commitment(field_ct const& value_note_partial_commi GeneratorIndex::VALUE_NOTE_COMMITMENT); } -} // namespace bb::join_split_example::proofs::notes::circuit::value +} // namespace join_split_example::proofs::notes::circuit::value diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.cpp index 6a17318dfb1a..29a8567aefd2 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.cpp @@ -2,7 +2,7 @@ #include "../../constants.hpp" #include "barretenberg/join_split_example/types.hpp" -namespace bb::join_split_example::proofs::notes::circuit { +namespace join_split_example::proofs::notes::circuit { using namespace bb; using namespace bb::stdlib; @@ -44,4 +44,4 @@ field_ct compute_nullifier(field_ct const& note_commitment, return field_ct(blake_result); } -} // namespace bb::join_split_example::proofs::notes::circuit +} // namespace join_split_example::proofs::notes::circuit diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.hpp index d2c26d6b2f8e..6d20fd5ada9b 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.hpp @@ -1,10 +1,10 @@ #pragma once #include "barretenberg/join_split_example/types.hpp" -namespace bb::join_split_example::proofs::notes::circuit { +namespace join_split_example::proofs::notes::circuit { field_ct compute_nullifier(field_ct const& note_commitment, field_ct const& account_private_key, bool_ct const& is_note_in_use); -} // namespace bb::join_split_example::proofs::notes::circuit +} // namespace join_split_example::proofs::notes::circuit diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.test.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.test.cpp index adb6b5aed9e0..406fe7b7ed00 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.test.cpp @@ -6,8 +6,8 @@ #include "barretenberg/join_split_example/types.hpp" #include -namespace bb::join_split_example { -using namespace bb::join_split_example::proofs::notes; +namespace join_split_example { +using namespace join_split_example::proofs::notes; TEST(compute_nullifier_circuit, native_consistency) { @@ -26,4 +26,4 @@ TEST(compute_nullifier_circuit, native_consistency) EXPECT_EQ(circuit_nullifier.get_value(), native_nullifier); } -} // namespace bb::join_split_example \ No newline at end of file +} // namespace join_split_example \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/create_partial_commitment.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/create_partial_commitment.hpp index 76247b194bcf..00ab2a189bf5 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/create_partial_commitment.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/create_partial_commitment.hpp @@ -3,7 +3,7 @@ #include "barretenberg/join_split_example/types.hpp" #include "barretenberg/stdlib/hash/pedersen/pedersen.hpp" -namespace bb::join_split_example::proofs::notes::circuit::value { +namespace join_split_example::proofs::notes::circuit::value { inline auto create_partial_commitment(field_ct const& secret, group_ct const& owner, @@ -14,4 +14,4 @@ inline auto create_partial_commitment(field_ct const& secret, GeneratorIndex::VALUE_NOTE_PARTIAL_COMMITMENT); } -} // namespace bb::join_split_example::proofs::notes::circuit::value +} // namespace join_split_example::proofs::notes::circuit::value diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/value_note.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/value_note.hpp index 64af0f9cb416..fbd70519be56 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/value_note.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/value_note.hpp @@ -3,7 +3,7 @@ #include "commit.hpp" #include "witness_data.hpp" -namespace bb::join_split_example::proofs::notes::circuit::value { +namespace join_split_example::proofs::notes::circuit::value { using namespace bb::stdlib; @@ -31,4 +31,4 @@ struct value_note { operator byte_array_ct() const { return byte_array_ct(commitment); } }; -} // namespace bb::join_split_example::proofs::notes::circuit::value +} // namespace join_split_example::proofs::notes::circuit::value diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/value_note.test.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/value_note.test.cpp index 1353b58e8d71..5e4acc727f1c 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/value_note.test.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/value_note.test.cpp @@ -5,11 +5,11 @@ #include "value_note.hpp" #include -namespace bb::join_split_example { +namespace join_split_example { using namespace bb; using namespace bb::stdlib; -using namespace bb::join_split_example::proofs::notes; -using namespace bb::join_split_example::proofs::notes::circuit::value; +using namespace join_split_example::proofs::notes; +using namespace join_split_example::proofs::notes::circuit::value; class ValueNote : public ::testing::Test { protected: @@ -120,4 +120,4 @@ TEST_F(ValueNote, CommitWithOversizedAssetIdFails) bool proof_result = verifier.verify_proof(proof); EXPECT_EQ(proof_result, false); } -} // namespace bb::join_split_example \ No newline at end of file +} // namespace join_split_example \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/witness_data.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/witness_data.hpp index 91cbb5128969..dba13cf16241 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/witness_data.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/witness_data.hpp @@ -2,7 +2,7 @@ #include "../../native/value/value_note.hpp" #include "barretenberg/join_split_example/types.hpp" -namespace bb::join_split_example::proofs::notes::circuit::value { +namespace join_split_example::proofs::notes::circuit::value { using namespace bb::stdlib; @@ -29,4 +29,4 @@ struct witness_data { } }; -} // namespace bb::join_split_example::proofs::notes::circuit::value +} // namespace join_split_example::proofs::notes::circuit::value diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/constants.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/constants.hpp index 9a081fd32499..02dd07b98fcc 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/constants.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/constants.hpp @@ -3,7 +3,9 @@ #include "barretenberg/numeric/uint256/uint256.hpp" #include -namespace bb::join_split_example::proofs::notes { +namespace join_split_example { +namespace proofs { +namespace notes { constexpr size_t ASSET_ID_BIT_LENGTH = 30; constexpr size_t NONCE_BIT_LENGTH = 32; @@ -38,4 +40,6 @@ constexpr uint32_t DEFI_BRIDGE_OUTPUT_B_ASSET_ID_LEN = MAX_NUM_ASSETS_BIT_LENGTH constexpr uint32_t DEFI_BRIDGE_BITCONFIG_LEN = 32; constexpr uint32_t DEFI_BRIDGE_AUX_DATA = 64; -} // namespace bb::join_split_example::proofs::notes +} // namespace notes +} // namespace proofs +} // namespace join_split_example diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/account_note.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/account_note.cpp index 893602921a09..24f19552897e 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/account_note.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/account_note.cpp @@ -2,11 +2,11 @@ #include "../../constants.hpp" #include "barretenberg/crypto/pedersen_hash/pedersen.hpp" -namespace bb::join_split_example::proofs::notes::native::account { +namespace join_split_example::proofs::notes::native::account { grumpkin::fq generate_account_commitment(const bb::fr& alias_hash, const bb::fr& owner_x, const bb::fr& signing_x) { - return bb::crypto::pedersen_hash::hash({ alias_hash, owner_x, signing_x }, GeneratorIndex::ACCOUNT_NOTE_COMMITMENT); + return crypto::pedersen_hash::hash({ alias_hash, owner_x, signing_x }, GeneratorIndex::ACCOUNT_NOTE_COMMITMENT); } grumpkin::fq account_note::commit() const @@ -14,4 +14,4 @@ grumpkin::fq account_note::commit() const return generate_account_commitment(alias_hash, owner_key.x, signing_key.x); } -} // namespace bb::join_split_example::proofs::notes::native::account +} // namespace join_split_example::proofs::notes::native::account diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/account_note.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/account_note.hpp index b7970ab88418..25674ca4876d 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/account_note.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/account_note.hpp @@ -3,7 +3,11 @@ #include "barretenberg/crypto/pedersen_commitment/pedersen.hpp" #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" -namespace bb::join_split_example::proofs::notes::native::account { +namespace join_split_example { +namespace proofs { +namespace notes { +namespace native { +namespace account { grumpkin::fq generate_account_commitment(const bb::fr& alias_hash, const bb::fr& owner_x, const bb::fr& signing_x); @@ -15,4 +19,8 @@ struct account_note { grumpkin::fq commit() const; }; -} // namespace bb::join_split_example::proofs::notes::native::account +} // namespace account +} // namespace native +} // namespace notes +} // namespace proofs +} // namespace join_split_example diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/compute_account_alias_hash_nullifier.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/compute_account_alias_hash_nullifier.hpp index a5b6c805f6f7..0dbcdcfac8f9 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/compute_account_alias_hash_nullifier.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/compute_account_alias_hash_nullifier.hpp @@ -3,7 +3,7 @@ #include "account_note.hpp" #include "barretenberg/crypto/pedersen_hash/pedersen.hpp" -namespace bb::join_split_example::proofs::notes::native::account { +namespace join_split_example::proofs::notes::native::account { using fr = bb::fr; @@ -14,4 +14,4 @@ inline fr compute_account_alias_hash_nullifier(fr const& alias_hash) crypto::GeneratorContext(notes::GeneratorIndex::ACCOUNT_ALIAS_HASH_NULLIFIER)); } -} // namespace bb::join_split_example::proofs::notes::native::account +} // namespace join_split_example::proofs::notes::native::account diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/compute_account_public_key_nullifier.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/compute_account_public_key_nullifier.hpp index 83ee8a6d1e3b..d2bdc842f842 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/compute_account_public_key_nullifier.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/compute_account_public_key_nullifier.hpp @@ -3,7 +3,7 @@ #include "account_note.hpp" #include "barretenberg/crypto/pedersen_hash/pedersen.hpp" -namespace bb::join_split_example::proofs::notes::native::account { +namespace join_split_example::proofs::notes::native::account { using namespace bb; @@ -13,4 +13,4 @@ inline fr compute_account_public_key_nullifier(grumpkin::g1::affine_element cons notes::GeneratorIndex::ACCOUNT_PUBLIC_KEY_NULLIFIER); } -} // namespace bb::join_split_example::proofs::notes::native::account +} // namespace join_split_example::proofs::notes::native::account diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/asset_id.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/asset_id.cpp index 06b1387e7934..9749ad14cffe 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/asset_id.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/asset_id.cpp @@ -1,6 +1,6 @@ #include "../constants.hpp" -namespace bb::join_split_example::proofs::notes::native { +namespace join_split_example::proofs::notes::native { std::pair deflag_asset_id(uint32_t const& asset_id) { @@ -18,4 +18,4 @@ bool get_asset_id_flag(uint32_t const& asset_id) return is_virtual; } -} // namespace bb::join_split_example::proofs::notes::native \ No newline at end of file +} // namespace join_split_example::proofs::notes::native \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/asset_id.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/asset_id.hpp index 64046424d465..dd1b21d59cd5 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/asset_id.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/asset_id.hpp @@ -2,10 +2,10 @@ #include #include -namespace bb::join_split_example::proofs::notes::native { +namespace join_split_example::proofs::notes::native { std::pair deflag_asset_id(uint32_t const& asset_id); bool get_asset_id_flag(uint32_t const& asset_id); -} // namespace bb::join_split_example::proofs::notes::native \ No newline at end of file +} // namespace join_split_example::proofs::notes::native \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/bridge_call_data.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/bridge_call_data.hpp index b27953722b19..bfd852ba30dc 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/bridge_call_data.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/bridge_call_data.hpp @@ -5,7 +5,10 @@ #include "barretenberg/crypto/pedersen_commitment/pedersen.hpp" #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" -namespace bb::join_split_example::proofs::notes::native { +namespace join_split_example { +namespace proofs { +namespace notes { +namespace native { /** * The bridge_call_data structure (with bit-lengths) is defined as follows: @@ -176,4 +179,7 @@ inline std::ostream& operator<<(std::ostream& os, bridge_call_data const& bridge return os; } -} // namespace bb::join_split_example::proofs::notes::native +} // namespace native +} // namespace notes +} // namespace proofs +} // namespace join_split_example diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/claim_note.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/claim_note.hpp index b0574cad662c..e023e426262e 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/claim_note.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/claim_note.hpp @@ -6,7 +6,7 @@ #include "complete_partial_commitment.hpp" #include "create_partial_commitment.hpp" -namespace bb::join_split_example::proofs::notes::native::claim { +namespace join_split_example::proofs::notes::native::claim { struct claim_note { uint256_t deposit_value; @@ -64,4 +64,4 @@ inline std::ostream& operator<<(std::ostream& os, claim_note const& note) " }"); } -} // namespace bb::join_split_example::proofs::notes::native::claim +} // namespace join_split_example::proofs::notes::native::claim diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/claim_note_tx_data.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/claim_note_tx_data.hpp index ed3e72e58985..f15bc431e20d 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/claim_note_tx_data.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/claim_note_tx_data.hpp @@ -4,7 +4,11 @@ #include "barretenberg/crypto/pedersen_commitment/pedersen.hpp" #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" -namespace bb::join_split_example::proofs::notes::native::claim { +namespace join_split_example { +namespace proofs { +namespace notes { +namespace native { +namespace claim { struct partial_claim_note_data { uint256_t deposit_value; @@ -39,4 +43,8 @@ inline void write(std::vector& buf, partial_claim_note_data const& note write(buf, note.input_nullifier); } -} // namespace bb::join_split_example::proofs::notes::native::claim +} // namespace claim +} // namespace native +} // namespace notes +} // namespace proofs +} // namespace join_split_example diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/complete_partial_commitment.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/complete_partial_commitment.hpp index 28a859634689..99dfa52da161 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/complete_partial_commitment.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/complete_partial_commitment.hpp @@ -4,7 +4,7 @@ #include "barretenberg/crypto/pedersen_hash/pedersen.hpp" #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" -namespace bb::join_split_example::proofs::notes::native::claim { +namespace join_split_example::proofs::notes::native::claim { inline auto complete_partial_commitment(grumpkin::fq const& claim_note_partial_commitment, uint32_t interaction_nonce, @@ -14,4 +14,4 @@ inline auto complete_partial_commitment(grumpkin::fq const& claim_note_partial_c GeneratorIndex::CLAIM_NOTE_COMMITMENT); } -} // namespace bb::join_split_example::proofs::notes::native::claim +} // namespace join_split_example::proofs::notes::native::claim diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/compute_nullifier.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/compute_nullifier.hpp index 5273720b6d94..86fa9a76dfaa 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/compute_nullifier.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/compute_nullifier.hpp @@ -4,11 +4,11 @@ #include "barretenberg/crypto/pedersen_hash/pedersen.hpp" #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" -namespace bb::join_split_example::proofs::notes::native::claim { +namespace join_split_example::proofs::notes::native::claim { inline auto compute_nullifier(grumpkin::fq const& note_commitment) { return crypto::pedersen_hash::hash({ note_commitment }, GeneratorIndex::CLAIM_NOTE_NULLIFIER); } -} // namespace bb::join_split_example::proofs::notes::native::claim +} // namespace join_split_example::proofs::notes::native::claim diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/create_partial_commitment.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/create_partial_commitment.hpp index ef969a328057..ca0a5a549707 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/create_partial_commitment.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/create_partial_commitment.hpp @@ -3,7 +3,7 @@ #include "barretenberg/crypto/pedersen_hash/pedersen.hpp" #include "claim_note.hpp" -namespace bb::join_split_example::proofs::notes::native::claim { +namespace join_split_example::proofs::notes::native::claim { inline auto create_partial_commitment(uint256_t const& deposit_value, uint256_t const& bridge_call_data, @@ -15,4 +15,4 @@ inline auto create_partial_commitment(uint256_t const& deposit_value, GeneratorIndex::CLAIM_NOTE_PARTIAL_COMMITMENT); } -} // namespace bb::join_split_example::proofs::notes::native::claim +} // namespace join_split_example::proofs::notes::native::claim diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/complete_partial_commitment.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/complete_partial_commitment.hpp index 570ac1d21832..3efd99219e67 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/complete_partial_commitment.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/complete_partial_commitment.hpp @@ -2,15 +2,15 @@ #include "../../constants.hpp" #include "barretenberg/crypto/pedersen_hash/pedersen.hpp" -namespace bb::join_split_example::proofs::notes::native::value { +namespace join_split_example::proofs::notes::native::value { inline auto complete_partial_commitment(grumpkin::fq const& partial_commitment, uint256_t const& value, uint32_t asset_id, grumpkin::fq input_nullifier) { - return bb::crypto::pedersen_hash::hash({ partial_commitment, value, asset_id, input_nullifier }, - GeneratorIndex::VALUE_NOTE_COMMITMENT); + return crypto::pedersen_hash::hash({ partial_commitment, value, asset_id, input_nullifier }, + GeneratorIndex::VALUE_NOTE_COMMITMENT); }; -} // namespace bb::join_split_example::proofs::notes::native::value +} // namespace join_split_example::proofs::notes::native::value diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/compute_nullifier.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/compute_nullifier.cpp index 92b7843902fd..827690d6f6dc 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/compute_nullifier.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/compute_nullifier.cpp @@ -4,7 +4,7 @@ #include "barretenberg/crypto/pedersen_commitment/pedersen.hpp" #include "barretenberg/crypto/pedersen_hash/pedersen.hpp" -namespace bb::join_split_example::proofs::notes::native { +namespace join_split_example::proofs::notes::native { using namespace bb; @@ -26,9 +26,9 @@ fr compute_nullifier(grumpkin::fq const& note_commitment, }; auto hashed_inputs = crypto::pedersen_hash::hash(buf, GeneratorIndex::JOIN_SPLIT_NULLIFIER); - auto blake_result = bb::crypto::blake2s(to_buffer(hashed_inputs)); + auto blake_result = blake2::blake2s(to_buffer(hashed_inputs)); return from_buffer(blake_result); } -} // namespace bb::join_split_example::proofs::notes::native +} // namespace join_split_example::proofs::notes::native diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/compute_nullifier.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/compute_nullifier.hpp index 2f5c36eea5fe..66f913d263d9 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/compute_nullifier.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/compute_nullifier.hpp @@ -1,10 +1,16 @@ #pragma once #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" -namespace bb::join_split_example::proofs::notes::native { +namespace join_split_example { +namespace proofs { +namespace notes { +namespace native { bb::fr compute_nullifier(grumpkin::fq const& note_commitment, grumpkin::fr const& account_private_key, const bool is_note_in_use); -} // namespace bb::join_split_example::proofs::notes::native +} // namespace native +} // namespace notes +} // namespace proofs +} // namespace join_split_example diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/create_partial_commitment.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/create_partial_commitment.hpp index 3ffdeca198b7..56829f920061 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/create_partial_commitment.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/create_partial_commitment.hpp @@ -4,15 +4,15 @@ #include "barretenberg/crypto/pedersen_hash/pedersen.hpp" #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" -namespace bb::join_split_example::proofs::notes::native::value { +namespace join_split_example::proofs::notes::native::value { inline auto create_partial_commitment(bb::fr const& secret, grumpkin::g1::affine_element const& owner, bool account_required, bb::fr const& creator_pubkey) { - return bb::crypto::pedersen_hash::hash({ secret, owner.x, owner.y, account_required, creator_pubkey }, - GeneratorIndex::VALUE_NOTE_PARTIAL_COMMITMENT); + return crypto::pedersen_hash::hash({ secret, owner.x, owner.y, account_required, creator_pubkey }, + GeneratorIndex::VALUE_NOTE_PARTIAL_COMMITMENT); } -} // namespace bb::join_split_example::proofs::notes::native::value +} // namespace join_split_example::proofs::notes::native::value diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/value_note.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/value_note.hpp index 4912fa22cabb..4010f060f84b 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/value_note.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/value_note.hpp @@ -5,7 +5,11 @@ #include "complete_partial_commitment.hpp" #include "create_partial_commitment.hpp" -namespace bb::join_split_example::proofs::notes::native::value { +namespace join_split_example { +namespace proofs { +namespace notes { +namespace native { +namespace value { using namespace bb; @@ -59,4 +63,8 @@ inline void write(std::vector& buf, value_note const& note) write(buf, note.input_nullifier); } -} // namespace bb::join_split_example::proofs::notes::native::value +} // namespace value +} // namespace native +} // namespace notes +} // namespace proofs +} // namespace join_split_example diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/verify.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/verify.hpp index ba78fba3a5b5..9d48d13f06b2 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/verify.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/verify.hpp @@ -5,7 +5,8 @@ #include "barretenberg/stdlib/recursion/aggregation_state/aggregation_state.hpp" #include "barretenberg/stdlib/recursion/verifier/verifier.hpp" -namespace bb::join_split_example::proofs { +namespace join_split_example { +namespace proofs { template struct verify_result { verify_result() @@ -69,4 +70,5 @@ auto verify_logic_internal(Builder& builder, Tx& tx, CircuitData const& cd, char return result; } -} // namespace bb::join_split_example::proofs +} // namespace proofs +} // namespace join_split_example diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/types.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/types.hpp index 68b0e79363d7..7d419cef5d05 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/types.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/types.hpp @@ -15,7 +15,7 @@ #include "barretenberg/stdlib/primitives/uint/uint.hpp" #include "barretenberg/stdlib/primitives/witness/witness.hpp" -namespace bb::join_split_example { +namespace join_split_example { using Builder = bb::UltraCircuitBuilder; using Composer = plonk::UltraComposer; @@ -39,6 +39,8 @@ using bn254 = bb::stdlib::bn254; using hash_path_ct = bb::stdlib::merkle_tree::hash_path; -using schnorr_signature_bits = bb::stdlib::schnorr_signature_bits; +namespace schnorr { +using signature_bits = bb::stdlib::schnorr::signature_bits; +} // namespace schnorr -} // namespace bb::join_split_example +} // namespace join_split_example \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/numeric/bitop/count_leading_zeros.hpp b/barretenberg/cpp/src/barretenberg/numeric/bitop/count_leading_zeros.hpp index acf8179af94e..c41877610c14 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/bitop/count_leading_zeros.hpp +++ b/barretenberg/cpp/src/barretenberg/numeric/bitop/count_leading_zeros.hpp @@ -3,7 +3,7 @@ #include "../uint256/uint256.hpp" #include -namespace bb::numeric { +namespace numeric { /** * Returns the number of leading 0 bits for a given integer type. @@ -49,4 +49,4 @@ template <> constexpr inline size_t count_leading_zeros(uint256_t con return 256; } -} // namespace bb::numeric +} // namespace numeric diff --git a/barretenberg/cpp/src/barretenberg/numeric/bitop/count_leading_zeros.test.cpp b/barretenberg/cpp/src/barretenberg/numeric/bitop/count_leading_zeros.test.cpp index 0849a881d08e..c482c7d0a755 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/bitop/count_leading_zeros.test.cpp +++ b/barretenberg/cpp/src/barretenberg/numeric/bitop/count_leading_zeros.test.cpp @@ -1,8 +1,6 @@ #include "count_leading_zeros.hpp" #include -using namespace bb; - TEST(bitop, ClzUint3231) { uint32_t a = 0b00000000000000000000000000000001; diff --git a/barretenberg/cpp/src/barretenberg/numeric/bitop/get_msb.hpp b/barretenberg/cpp/src/barretenberg/numeric/bitop/get_msb.hpp index fc456a68a8e0..d3df553401b0 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/bitop/get_msb.hpp +++ b/barretenberg/cpp/src/barretenberg/numeric/bitop/get_msb.hpp @@ -2,7 +2,7 @@ #include #include #include -namespace bb::numeric { +namespace numeric { // from http://supertech.csail.mit.edu/papers/debruijn.pdf constexpr inline uint32_t get_msb32(const uint32_t in) @@ -43,4 +43,4 @@ template constexpr inline T get_msb(const T in) return (sizeof(T) <= 4) ? get_msb32(in) : get_msb64(in); } -} // namespace bb::numeric \ No newline at end of file +} // namespace numeric \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/numeric/bitop/get_msb.test.cpp b/barretenberg/cpp/src/barretenberg/numeric/bitop/get_msb.test.cpp index 3abdd73b155e..044fb3bbfd9a 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/bitop/get_msb.test.cpp +++ b/barretenberg/cpp/src/barretenberg/numeric/bitop/get_msb.test.cpp @@ -1,8 +1,6 @@ #include "get_msb.hpp" #include -using namespace bb; - TEST(bitop, GetMsbUint640Value) { uint64_t a = 0b00000000000000000000000000000000; diff --git a/barretenberg/cpp/src/barretenberg/numeric/bitop/keep_n_lsb.hpp b/barretenberg/cpp/src/barretenberg/numeric/bitop/keep_n_lsb.hpp index c03a3154e37f..ee9859eecb6a 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/bitop/keep_n_lsb.hpp +++ b/barretenberg/cpp/src/barretenberg/numeric/bitop/keep_n_lsb.hpp @@ -1,11 +1,11 @@ #pragma once #include -namespace bb::numeric { +namespace numeric { template inline T keep_n_lsb(T const& input, size_t num_bits) { return num_bits >= sizeof(T) * 8 ? input : input & ((T(1) << num_bits) - 1); } -} // namespace bb::numeric +} // namespace numeric diff --git a/barretenberg/cpp/src/barretenberg/numeric/bitop/pow.hpp b/barretenberg/cpp/src/barretenberg/numeric/bitop/pow.hpp index 2e67afffc9a1..295a5e5b4c7d 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/bitop/pow.hpp +++ b/barretenberg/cpp/src/barretenberg/numeric/bitop/pow.hpp @@ -3,7 +3,7 @@ #include "./get_msb.hpp" #include -namespace bb::numeric { +namespace numeric { constexpr uint64_t pow64(const uint64_t input, const uint64_t exponent) { if (input == 0) { @@ -31,4 +31,4 @@ constexpr bool is_power_of_two(uint64_t x) return (x != 0U) && ((x & (x - 1)) == 0U); } -} // namespace bb::numeric \ No newline at end of file +} // namespace numeric \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/numeric/bitop/rotate.hpp b/barretenberg/cpp/src/barretenberg/numeric/bitop/rotate.hpp index 5be15b96e385..1fc0cd1cfddf 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/bitop/rotate.hpp +++ b/barretenberg/cpp/src/barretenberg/numeric/bitop/rotate.hpp @@ -2,7 +2,7 @@ #include #include -namespace bb::numeric { +namespace numeric { constexpr inline uint64_t rotate64(const uint64_t value, const uint64_t rotation) { @@ -13,4 +13,4 @@ constexpr inline uint32_t rotate32(const uint32_t value, const uint32_t rotation { return rotation != 0U ? (value >> rotation) + (value << (32 - rotation)) : value; } -} // namespace bb::numeric \ No newline at end of file +} // namespace numeric \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/numeric/bitop/sparse_form.hpp b/barretenberg/cpp/src/barretenberg/numeric/bitop/sparse_form.hpp index c2a17193831e..dcc4a13315d3 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/bitop/sparse_form.hpp +++ b/barretenberg/cpp/src/barretenberg/numeric/bitop/sparse_form.hpp @@ -7,7 +7,7 @@ #include "../uint256/uint256.hpp" -namespace bb::numeric { +namespace numeric { inline std::vector slice_input(const uint256_t& input, const uint64_t base, const size_t num_slices) { @@ -154,4 +154,4 @@ template class sparse_int { uint64_t sparse_value; }; -} // namespace bb::numeric +} // namespace numeric diff --git a/barretenberg/cpp/src/barretenberg/numeric/random/engine.cpp b/barretenberg/cpp/src/barretenberg/numeric/random/engine.cpp index e8b5c4a940a8..ff31c6136d8f 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/random/engine.cpp +++ b/barretenberg/cpp/src/barretenberg/numeric/random/engine.cpp @@ -4,7 +4,7 @@ #include #include -namespace bb::numeric { +namespace numeric::random { namespace { auto generate_random_data() @@ -16,7 +16,7 @@ auto generate_random_data() } } // namespace -class RandomEngine : public RNG { +class RandomEngine : public Engine { public: uint8_t get_random_uint8() override { @@ -71,7 +71,7 @@ class RandomEngine : public RNG { } }; -class DebugEngine : public RNG { +class DebugEngine : public Engine { public: DebugEngine() // disable linting for this line: we want the DEBUG engine to produce predictable pseudorandom numbers! @@ -116,7 +116,7 @@ class DebugEngine : public RNG { /** * Used by tests to ensure consistent behavior. */ -RNG& get_debug_randomness(bool reset) +Engine& get_debug_engine(bool reset) { // static std::seed_seq seed({ 1, 2, 3, 4, 5 }); static DebugEngine debug_engine; @@ -129,11 +129,11 @@ RNG& get_debug_randomness(bool reset) /** * Default engine. If wanting consistent proof construction, uncomment the line to return the debug engine. */ -RNG& get_randomness() +Engine& get_engine() { - // return get_debug_randomness(); + // return get_debug_engine(); static RandomEngine engine; return engine; } -} // namespace bb::numeric +} // namespace numeric::random diff --git a/barretenberg/cpp/src/barretenberg/numeric/random/engine.hpp b/barretenberg/cpp/src/barretenberg/numeric/random/engine.hpp index aad7932bbbfb..9721f69886e1 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/random/engine.hpp +++ b/barretenberg/cpp/src/barretenberg/numeric/random/engine.hpp @@ -5,9 +5,9 @@ #include "unistd.h" #include -namespace bb::numeric { +namespace numeric::random { -class RNG { +class Engine { public: virtual uint8_t get_random_uint8() = 0; @@ -21,12 +21,12 @@ class RNG { virtual uint256_t get_random_uint256() = 0; - virtual ~RNG() = default; - RNG() noexcept = default; - RNG(const RNG& other) = default; - RNG(RNG&& other) = default; - RNG& operator=(const RNG& other) = default; - RNG& operator=(RNG&& other) = default; + virtual ~Engine() = default; + Engine() noexcept = default; + Engine(const Engine& other) = default; + Engine(Engine&& other) = default; + Engine& operator=(const Engine& other) = default; + Engine& operator=(Engine&& other) = default; uint512_t get_random_uint512() { @@ -45,7 +45,7 @@ class RNG { } }; -RNG& get_debug_randomness(bool reset = false); -RNG& get_randomness(); +Engine& get_debug_engine(bool reset = false); +Engine& get_engine(); -} // namespace bb::numeric +} // namespace numeric::random diff --git a/barretenberg/cpp/src/barretenberg/numeric/random/engine.test.cpp b/barretenberg/cpp/src/barretenberg/numeric/random/engine.test.cpp index 494246a07e80..83c9c47f099a 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/random/engine.test.cpp +++ b/barretenberg/cpp/src/barretenberg/numeric/random/engine.test.cpp @@ -3,11 +3,9 @@ #include "barretenberg/common/streams.hpp" #include -using namespace bb; - TEST(engine, GetRandomUint64) { - auto& engine = numeric::get_randomness(); + auto& engine = numeric::random::get_engine(); auto a = engine.get_random_uint64(); auto b = engine.get_random_uint64(); EXPECT_NE(a, 0U); @@ -17,25 +15,25 @@ TEST(engine, GetRandomUint64) TEST(engine, ResetDebugEngine) { - auto& debug_engine = numeric::get_debug_randomness(); + auto& debug_engine = numeric::random::get_debug_engine(); auto a = debug_engine.get_random_uint64(); auto b = debug_engine.get_random_uint64(); EXPECT_NE(a, b); - debug_engine = numeric::get_debug_randomness(true); + debug_engine = numeric::random::get_debug_engine(true); auto c = debug_engine.get_random_uint64(); auto d = debug_engine.get_random_uint64(); EXPECT_EQ(a, c); EXPECT_EQ(b, d); - auto e = numeric::get_randomness().get_random_uint64(); + auto e = numeric::random::get_engine().get_random_uint64(); EXPECT_NE(a, e); } TEST(engine, GetExpectedDebugValue) { - auto& debug_engine = numeric::get_debug_randomness(true); + auto& debug_engine = numeric::random::get_debug_engine(true); auto a = debug_engine.get_random_uint1024(); auto expected = from_buffer(std::vector{ 0x69, 0x1f, 0x71, 0xcb, 0xcd, 0xdb, 0x45, 0x74, 0xe5, 0x17, 0x17, 0xa7, 0x29, 0x02, 0x21, 0x4a, diff --git a/barretenberg/cpp/src/barretenberg/numeric/uint128/uint128.hpp b/barretenberg/cpp/src/barretenberg/numeric/uint128/uint128.hpp index 363ee4f9a1b9..e229f9b7d237 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/uint128/uint128.hpp +++ b/barretenberg/cpp/src/barretenberg/numeric/uint128/uint128.hpp @@ -7,7 +7,7 @@ #include "barretenberg/common/serialize.hpp" #include -namespace bb::numeric { +namespace numeric { class alignas(32) uint128_t { public: @@ -187,7 +187,7 @@ template inline void write(B& it, uint128_t const& value) write(it, value.data[0]); } -} // namespace bb::numeric +} // namespace numeric #include "./uint128_impl.hpp" diff --git a/barretenberg/cpp/src/barretenberg/numeric/uint128/uint128.test.cpp b/barretenberg/cpp/src/barretenberg/numeric/uint128/uint128.test.cpp index ecf457ad9756..14c4c843ce4b 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/uint128/uint128.test.cpp +++ b/barretenberg/cpp/src/barretenberg/numeric/uint128/uint128.test.cpp @@ -2,14 +2,12 @@ #include "../random/engine.hpp" #include #ifdef __i386__ - -using namespace bb; -using namespace bb::numeric; - namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } +using namespace numeric; + TEST(uint128, GetBit) { constexpr uint128_t a{ 0b0110011001110010011001100, diff --git a/barretenberg/cpp/src/barretenberg/numeric/uint128/uint128_impl.hpp b/barretenberg/cpp/src/barretenberg/numeric/uint128/uint128_impl.hpp index 5bc5f72c7586..8fa503c95e31 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/uint128/uint128_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/numeric/uint128/uint128_impl.hpp @@ -3,7 +3,7 @@ #include "../bitop/get_msb.hpp" #include "./uint128.hpp" #include "barretenberg/common/assert.hpp" -namespace bb::numeric { +namespace numeric { constexpr std::pair uint128_t::mul_wide(const uint32_t a, const uint32_t b) { @@ -410,5 +410,5 @@ constexpr uint128_t uint128_t::operator<<(const uint128_t& other) const return result; } -} // namespace bb::numeric +} // namespace numeric #endif diff --git a/barretenberg/cpp/src/barretenberg/numeric/uint256/uint256.hpp b/barretenberg/cpp/src/barretenberg/numeric/uint256/uint256.hpp index fe9e759adaaa..5ddaa9713aeb 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/uint256/uint256.hpp +++ b/barretenberg/cpp/src/barretenberg/numeric/uint256/uint256.hpp @@ -20,7 +20,7 @@ #include #include -namespace bb::numeric { +namespace numeric { class alignas(32) uint256_t { public: @@ -242,10 +242,10 @@ template inline void write(B& it, uint256_t const& value) write(it, value.data[0]); } -} // namespace bb::numeric +} // namespace numeric #include "./uint256_impl.hpp" // disable linter errors; we want to expose a global uint256_t type to mimic uint64_t, uint32_t etc // NOLINTNEXTLINE(tidymisc-unused-using-decls, google-global-names-in-headers, misc-unused-using-decls) -using bb::numeric::uint256_t; +using numeric::uint256_t; diff --git a/barretenberg/cpp/src/barretenberg/numeric/uint256/uint256.test.cpp b/barretenberg/cpp/src/barretenberg/numeric/uint256/uint256.test.cpp index ae72524449cd..28234d0c2796 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/uint256/uint256.test.cpp +++ b/barretenberg/cpp/src/barretenberg/numeric/uint256/uint256.test.cpp @@ -2,12 +2,12 @@ #include "../random/engine.hpp" #include -using namespace bb; -using namespace bb::numeric; namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } +using namespace numeric; + TEST(uint256, TestStringConstructors) { std::string input = "9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789"; diff --git a/barretenberg/cpp/src/barretenberg/numeric/uint256/uint256_impl.hpp b/barretenberg/cpp/src/barretenberg/numeric/uint256/uint256_impl.hpp index ee51adc763ad..9f4d4daa33df 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/uint256/uint256_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/numeric/uint256/uint256_impl.hpp @@ -2,7 +2,7 @@ #include "../bitop/get_msb.hpp" #include "./uint256.hpp" #include "barretenberg/common/assert.hpp" -namespace bb::numeric { +namespace numeric { constexpr std::pair uint256_t::mul_wide(const uint64_t a, const uint64_t b) { @@ -409,4 +409,4 @@ constexpr uint256_t uint256_t::operator<<(const uint256_t& other) const return result; } -} // namespace bb::numeric +} // namespace numeric diff --git a/barretenberg/cpp/src/barretenberg/numeric/uintx/uintx.hpp b/barretenberg/cpp/src/barretenberg/numeric/uintx/uintx.hpp index 2ac1b886604c..aa5fc07b097d 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/uintx/uintx.hpp +++ b/barretenberg/cpp/src/barretenberg/numeric/uintx/uintx.hpp @@ -18,7 +18,7 @@ #include #include -namespace bb::numeric { +namespace numeric { template class uintx { public: @@ -187,9 +187,9 @@ template inline std::ostream& operator<<(std::ostream& os, uin using uint512_t = uintx; using uint1024_t = uintx; -} // namespace bb::numeric +} // namespace numeric #include "./uintx_impl.hpp" -using bb::numeric::uint1024_t; // NOLINT -using bb::numeric::uint512_t; // NOLINT +using numeric::uint1024_t; // NOLINT +using numeric::uint512_t; // NOLINT diff --git a/barretenberg/cpp/src/barretenberg/numeric/uintx/uintx.test.cpp b/barretenberg/cpp/src/barretenberg/numeric/uintx/uintx.test.cpp index 036470ed975a..32e5cc6da5f8 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/uintx/uintx.test.cpp +++ b/barretenberg/cpp/src/barretenberg/numeric/uintx/uintx.test.cpp @@ -2,10 +2,8 @@ #include "../random/engine.hpp" #include -using namespace bb; - namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } // namespace TEST(uintx, GetBit) @@ -69,27 +67,27 @@ TEST(uintx, DivAndMod) TEST(uintx, DISABLEDMulmod) { /* - fq a = fq::random_element(); - fq b = fq::random_element(); - // fq a_converted = a.from_montgomery_form(); - // fq b_converted = b.from_montgomery_form(); + bb::fq a = bb::fq::random_element(); + bb::fq b = bb::fq::random_element(); + // bb::fq a_converted = a.from_montgomery_form(); + // bb::fq b_converted = b.from_montgomery_form(); uint256_t a_uint = uint256_t(a); // { a_converted.data[0], a_converted.data[1], a_converted.data[2], a_converted.data[3] }; uint256_t b_uint = uint256_t(b); // { b_converted.data[0], b_converted.data[1], b_converted.data[2], b_converted.data[3] }; uint256_t modulus_uint{ bb::Bn254FqParams::modulus_0, - Bn254FqParams::modulus_1, - Bn254FqParams::modulus_2, - Bn254FqParams::modulus_3 }; + bb::Bn254FqParams::modulus_1, + bb::Bn254FqParams::modulus_2, + bb::Bn254FqParams::modulus_3 }; uint1024_t a_uintx = uint1024_t(uint512_t(a_uint)); uint1024_t b_uintx = uint1024_t(uint512_t(b_uint)); uint1024_t modulus_uintx = uint1024_t(uint512_t(modulus_uint)); const auto [quotient, remainder] = (a_uintx * b_uintx).divmod(modulus_uintx); - // fq expected_a = a_converted.to_montgomery_form(); - // fq expected_b = b_converted.to_montgomery_form(); - fq expected = (a * b).from_montgomery_form(); + // bb::fq expected_a = a_converted.to_montgomery_form(); + // bb::fq expected_b = b_converted.to_montgomery_form(); + bb::fq expected = (a * b).from_montgomery_form(); EXPECT_EQ(remainder.lo.lo.data[0], expected.data[0]); EXPECT_EQ(remainder.lo.lo.data[1], expected.data[1]); diff --git a/barretenberg/cpp/src/barretenberg/numeric/uintx/uintx_impl.hpp b/barretenberg/cpp/src/barretenberg/numeric/uintx/uintx_impl.hpp index 91c6c9ea0702..314a754b6aef 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/uintx/uintx_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/numeric/uintx/uintx_impl.hpp @@ -2,7 +2,7 @@ #include "./uintx.hpp" #include "barretenberg/common/assert.hpp" -namespace bb::numeric { +namespace numeric { template constexpr std::pair, uintx> uintx::divmod(const uintx& b) const { @@ -336,4 +336,4 @@ template constexpr uintx uintx::operator } return result; } -} // namespace bb::numeric \ No newline at end of file +} // namespace numeric \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/plonk/composer/standard_composer.test.cpp b/barretenberg/cpp/src/barretenberg/plonk/composer/standard_composer.test.cpp index 952997d0e00c..e99f9a2144c6 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/composer/standard_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/composer/standard_composer.test.cpp @@ -5,11 +5,12 @@ #include "barretenberg/proof_system/circuit_builder/standard_circuit_builder.hpp" #include +using namespace bb; using namespace bb; using namespace bb::plonk; namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } class StandardPlonkComposer : public ::testing::Test { diff --git a/barretenberg/cpp/src/barretenberg/plonk/composer/ultra_composer.test.cpp b/barretenberg/cpp/src/barretenberg/plonk/composer/ultra_composer.test.cpp index 0fd5c17b8acd..0a5dea87edcb 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/composer/ultra_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/composer/ultra_composer.test.cpp @@ -9,11 +9,14 @@ #include "barretenberg/proof_system/plookup_tables/sha256.hpp" #include "barretenberg/stdlib/primitives/plookup/plookup.hpp" +using namespace bb; using namespace bb; using namespace bb::plonk; +namespace bb::plonk::test_ultra_plonk_composer { + namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } using plookup::ColumnIdx; @@ -63,10 +66,10 @@ TYPED_TEST_SUITE(ultra_plonk_composer, BooleanTypes); TYPED_TEST(ultra_plonk_composer, create_gates_from_plookup_accumulators) { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = bb::UltraCircuitBuilder(); auto composer = UltraComposer(); - fr input_value = fr::random_element(); + bb::fr input_value = fr::random_element(); const fr input_lo = static_cast(input_value).slice(0, plookup::fixed_base::table::BITS_PER_LO_SCALAR); const auto input_lo_index = circuit_builder.add_variable(input_lo); @@ -644,7 +647,7 @@ TYPED_TEST(ultra_plonk_composer, non_native_field_multiplication) const auto q_indices = get_limb_witness_indices(split_into_limbs(uint256_t(q))); const auto r_indices = get_limb_witness_indices(split_into_limbs(uint256_t(r))); - non_native_field_witnesses inputs{ + bb::non_native_field_witnesses inputs{ a_indices, b_indices, q_indices, r_indices, modulus_limbs, fr(uint256_t(modulus)), }; const auto [lo_1_idx, hi_1_idx] = builder.evaluate_non_native_field_multiplication(inputs); @@ -820,3 +823,5 @@ TEST(ultra_plonk_composer, range_constraint_small_variable) bool result = verifier.verify_proof(proof); EXPECT_EQ(result, true); } + +} // namespace bb::plonk::test_ultra_plonk_composer diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/commitment_scheme/commitment_scheme.test.cpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/commitment_scheme/commitment_scheme.test.cpp index 299b1f83e1be..bd446e47c10c 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/commitment_scheme/commitment_scheme.test.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/commitment_scheme/commitment_scheme.test.cpp @@ -35,7 +35,7 @@ TEST(commitment_scheme, kate_open) transcript::StandardTranscript inp_tx = transcript::StandardTranscript(transcript::Manifest()); plonk::KateCommitmentScheme newKate; - // std::shared_ptr> crs_factory = (new + // std::shared_ptr> crs_factory = (new // FileReferenceStringFactory("../srs_db/ignition")); auto file_crs = std::make_shared>("../srs_db/ignition"); auto crs = file_crs->get_prover_crs(n); diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/prover/prover.test.cpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/prover/prover.test.cpp index 0e9dbb679ce3..f7b92b5bdafe 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/prover/prover.test.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/prover/prover.test.cpp @@ -113,7 +113,8 @@ plonk::Prover generate_test_data(const size_t n) // even indices = mul gates, odd incides = add gates - auto reference_string = std::make_shared>(n + 1, "../srs_db/ignition"); + auto reference_string = + std::make_shared>(n + 1, "../srs_db/ignition"); std::shared_ptr key = std::make_shared(n, 0, reference_string, CircuitType::STANDARD); polynomial w_l(n); diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.test.cpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.test.cpp index 846d04951f19..9353566f712d 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.test.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.test.cpp @@ -11,6 +11,7 @@ #include #endif +using namespace bb; using namespace bb; using namespace bb::plonk; @@ -140,8 +141,8 @@ StandardComposer(); fr a = fr::one(); builder.add_public_variable(a); bool all_polys_are_equal{ true }; for (size_t i = 0; i < precomputed_poly_list.size(); ++i) { std::string poly_id = precomputed_poly_list[i]; - polynomial& input_poly = p_key.polynomial_store.get(poly_id); - polynomial& output_poly = pk_data.polynomial_store.get(poly_id); + bb::polynomial& input_poly = p_key.polynomial_store.get(poly_id); + bb::polynomial& output_poly = pk_data.polynomial_store.get(poly_id); all_polys_are_equal = all_polys_are_equal && (input_poly == output_poly); } diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/public_inputs/public_inputs.test.cpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/public_inputs/public_inputs.test.cpp index c9e7fdeb57ee..9e9923a02204 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/public_inputs/public_inputs.test.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/public_inputs/public_inputs.test.cpp @@ -138,7 +138,7 @@ TEST(test_public_inputs, compute_delta) for (size_t i = 0; i < num_public_inputs; ++i) { public_inputs.push_back(left[i]); } - fr target_delta = plonk::compute_public_input_delta(public_inputs, beta, gamma, domain.root); + fr target_delta = bb::plonk::compute_public_input_delta(public_inputs, beta, gamma, domain.root); EXPECT_EQ((modified_result == target_delta), true); } diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.test.cpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.test.cpp index caf2e4c49725..088d5142f56c 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.test.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.test.cpp @@ -3,12 +3,15 @@ #include "barretenberg/common/test.hpp" #include "barretenberg/numeric/random/engine.hpp" -using namespace bb; -using namespace bb::plonk; namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } // namespace +using namespace bb; +using namespace bb::plonk; + +namespace bb::plonk::test_verification_key { + /** * @brief generate a random vk data for use in tests * @@ -151,3 +154,4 @@ TEST(VerificationKey, HashEqualityDifferentRecursiveProofPublicInputIndices) vk1_data.recursive_proof_public_input_indices.push_back(42); expect_hashes_eq(vk0_data, vk1_data); } +} // namespace bb::plonk::test_verification_key diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.test.cpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.test.cpp index 10a50a38edb5..13e997110c0d 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.test.cpp @@ -28,7 +28,7 @@ plonk::Verifier generate_verifier(std::shared_ptr circuit_proving_k poly_coefficients[6] = circuit_proving_key->polynomial_store.get("sigma_2").data(); poly_coefficients[7] = circuit_proving_key->polynomial_store.get("sigma_3").data(); - std::vector commitments; + std::vector commitments; scalar_multiplication::pippenger_runtime_state state(circuit_proving_key->circuit_size); commitments.resize(8); diff --git a/barretenberg/cpp/src/barretenberg/plonk/transcript/transcript.cpp b/barretenberg/cpp/src/barretenberg/plonk/transcript/transcript.cpp index 168ad725affa..5447a0480a6f 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/transcript/transcript.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/transcript/transcript.cpp @@ -46,7 +46,7 @@ std::array Keccak256Hasher::hash(std std::array Blake3sHasher::hash(std::vector const& buffer) { grumpkin::fq input = grumpkin::fq::serialize_from_buffer(&buffer[0]); - grumpkin::fq hashed = bb::crypto::pedersen_hash::hash({ input }); + grumpkin::fq hashed = crypto::pedersen_hash::hash({ input }); std::vector res = to_buffer(hashed); std::array result; for (size_t i = 0; i < PRNG_OUTPUT_SIZE; ++i) { @@ -217,7 +217,7 @@ void Transcript::apply_fiat_shamir(const std::string& challenge_name /*, const b break; } case HashType::PedersenBlake3s: { - std::vector hashed_buffer = to_buffer(bb::crypto::pedersen_hash::hash_buffer(buffer)); + std::vector hashed_buffer = to_buffer(crypto::pedersen_hash::hash_buffer(buffer)); base_hash = Blake3sHasher::hash(hashed_buffer); break; } diff --git a/barretenberg/cpp/src/barretenberg/plonk/transcript/transcript.test.cpp b/barretenberg/cpp/src/barretenberg/plonk/transcript/transcript.test.cpp index 37ef74ff9a87..49f6bf9bee05 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/transcript/transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/transcript/transcript.test.cpp @@ -5,8 +5,6 @@ #include #include -using namespace bb; - namespace { transcript::Manifest create_manifest(const size_t num_public_inputs) { @@ -137,8 +135,8 @@ TEST(transcript, univariate_serialization) constexpr size_t num_public_inputs = 0; constexpr size_t LENGTH = 8; - using Fr = fr; - using Univariate = Univariate; + using Fr = bb::fr; + using Univariate = bb::Univariate; using Transcript = transcript::StandardTranscript; std::vector g1_vector(64); diff --git a/barretenberg/cpp/src/barretenberg/polynomials/barycentric.test.cpp b/barretenberg/cpp/src/barretenberg/polynomials/barycentric.test.cpp index a481f9fc64e1..10efc3916d76 100644 --- a/barretenberg/cpp/src/barretenberg/polynomials/barycentric.test.cpp +++ b/barretenberg/cpp/src/barretenberg/polynomials/barycentric.test.cpp @@ -2,7 +2,7 @@ #include "univariate.hpp" #include -using namespace bb; +namespace bb::test_barycentric { template class BarycentricDataTests : public testing::Test {}; @@ -86,3 +86,5 @@ TYPED_TEST(BarycentricDataTests, BarycentricData5to6) Univariate expected{ { 1, 3, 25, 109, 321, 751 } }; EXPECT_EQ(ext1, expected); } + +} // namespace bb::test_barycentric diff --git a/barretenberg/cpp/src/barretenberg/polynomials/polynomial.hpp b/barretenberg/cpp/src/barretenberg/polynomials/polynomial.hpp index d1b6112eef87..70e080bdfa4f 100644 --- a/barretenberg/cpp/src/barretenberg/polynomials/polynomial.hpp +++ b/barretenberg/cpp/src/barretenberg/polynomials/polynomial.hpp @@ -90,28 +90,34 @@ template class Polynomial { Fr evaluate(const Fr& z, size_t target_size) const; Fr evaluate(const Fr& z) const; - Fr compute_barycentric_evaluation(const Fr& z, const EvaluationDomain& domain) requires - polynomial_arithmetic::SupportsFFT; + Fr compute_barycentric_evaluation(const Fr& z, const EvaluationDomain& domain) + requires polynomial_arithmetic::SupportsFFT; Fr evaluate_from_fft(const EvaluationDomain& large_domain, const Fr& z, - const EvaluationDomain& small_domain) requires polynomial_arithmetic::SupportsFFT; - void fft(const EvaluationDomain& domain) requires polynomial_arithmetic::SupportsFFT; - void partial_fft(const EvaluationDomain& domain, - Fr constant = 1, - bool is_coset = false) requires polynomial_arithmetic::SupportsFFT; - void coset_fft(const EvaluationDomain& domain) requires polynomial_arithmetic::SupportsFFT; + const EvaluationDomain& small_domain) + requires polynomial_arithmetic::SupportsFFT; + void fft(const EvaluationDomain& domain) + requires polynomial_arithmetic::SupportsFFT; + void partial_fft(const EvaluationDomain& domain, Fr constant = 1, bool is_coset = false) + requires polynomial_arithmetic::SupportsFFT; + void coset_fft(const EvaluationDomain& domain) + requires polynomial_arithmetic::SupportsFFT; void coset_fft(const EvaluationDomain& domain, const EvaluationDomain& large_domain, - size_t domain_extension) requires polynomial_arithmetic::SupportsFFT; - void coset_fft_with_constant(const EvaluationDomain& domain, - const Fr& constant) requires polynomial_arithmetic::SupportsFFT; - void coset_fft_with_generator_shift(const EvaluationDomain& domain, - const Fr& constant) requires polynomial_arithmetic::SupportsFFT; - void ifft(const EvaluationDomain& domain) requires polynomial_arithmetic::SupportsFFT; - void ifft_with_constant(const EvaluationDomain& domain, - const Fr& constant) requires polynomial_arithmetic::SupportsFFT; - void coset_ifft(const EvaluationDomain& domain) requires polynomial_arithmetic::SupportsFFT; - Fr compute_kate_opening_coefficients(const Fr& z) requires polynomial_arithmetic::SupportsFFT; + size_t domain_extension) + requires polynomial_arithmetic::SupportsFFT; + void coset_fft_with_constant(const EvaluationDomain& domain, const Fr& constant) + requires polynomial_arithmetic::SupportsFFT; + void coset_fft_with_generator_shift(const EvaluationDomain& domain, const Fr& constant) + requires polynomial_arithmetic::SupportsFFT; + void ifft(const EvaluationDomain& domain) + requires polynomial_arithmetic::SupportsFFT; + void ifft_with_constant(const EvaluationDomain& domain, const Fr& constant) + requires polynomial_arithmetic::SupportsFFT; + void coset_ifft(const EvaluationDomain& domain) + requires polynomial_arithmetic::SupportsFFT; + Fr compute_kate_opening_coefficients(const Fr& z) + requires polynomial_arithmetic::SupportsFFT; bool is_empty() const { return size_ == 0; } @@ -225,13 +231,6 @@ template class Polynomial { std::size_t size() const { return size_; } std::size_t capacity() const { return size_ + MAXIMUM_COEFFICIENT_SHIFT; } - static Polynomial random(const size_t num_coeffs) - { - Polynomial p(num_coeffs); - std::generate_n(p.begin(), num_coeffs, []() { return Fr::random_element(); }); - return p; - } - private: // allocate a fresh memory pointer for backing memory // DOES NOT initialize memory diff --git a/barretenberg/cpp/src/barretenberg/polynomials/polynomial_arithmetic.test.cpp b/barretenberg/cpp/src/barretenberg/polynomials/polynomial_arithmetic.test.cpp index 16281c3a650e..6e2cc6aab796 100644 --- a/barretenberg/cpp/src/barretenberg/polynomials/polynomial_arithmetic.test.cpp +++ b/barretenberg/cpp/src/barretenberg/polynomials/polynomial_arithmetic.test.cpp @@ -1043,7 +1043,7 @@ TYPED_TEST(PolynomialTests, evaluate_mle) using FF = TypeParam; auto test_case = [](size_t N) { - auto& engine = numeric::get_debug_randomness(); + auto& engine = numeric::random::get_debug_engine(); const size_t m = numeric::get_msb(N); EXPECT_EQ(N, 1 << m); Polynomial poly(N); diff --git a/barretenberg/cpp/src/barretenberg/polynomials/pow.test.cpp b/barretenberg/cpp/src/barretenberg/polynomials/pow.test.cpp index a9da061ba733..b6aeff91265a 100644 --- a/barretenberg/cpp/src/barretenberg/polynomials/pow.test.cpp +++ b/barretenberg/cpp/src/barretenberg/polynomials/pow.test.cpp @@ -2,27 +2,29 @@ #include "barretenberg/ecc/curves/bn254/fr.hpp" #include -using namespace bb; +namespace bb::test_pow { + +using FF = bb::fr; TEST(PowPolynomial, FullPowConsistency) { constexpr size_t d = 5; - std::vector betas(d); + std::vector betas(d); for (auto& beta : betas) { - beta = fr::random_element(); + beta = FF::random_element(); } - PowPolynomial pow_polynomial(betas); - std::array variables{}; + PowPolynomial pow_polynomial(betas); + std::array variables{}; for (auto& u_i : variables) { - u_i = fr::random_element(); + u_i = FF::random_element(); pow_polynomial.partially_evaluate(u_i); } size_t beta_idx = 0; - fr expected_eval = 1; + FF expected_eval = 1; for (auto& u_i : variables) { - expected_eval *= fr(1) - u_i + u_i * pow_polynomial.betas[beta_idx]; + expected_eval *= FF(1) - u_i + u_i * pow_polynomial.betas[beta_idx]; beta_idx++; } @@ -31,9 +33,10 @@ TEST(PowPolynomial, FullPowConsistency) TEST(PowPolynomial, PowPolynomialsOnPowers) { - auto betas = std::vector{ 2, 4, 16 }; + auto betas = std::vector{ 2, 4, 16 }; auto pow = PowPolynomial(betas); pow.compute_values(); - auto expected_values = std::vector{ 1, 2, 4, 8, 16, 32, 64, 128 }; + auto expected_values = std::vector{ 1, 2, 4, 8, 16, 32, 64, 128 }; EXPECT_EQ(expected_values, pow.pow_betas); } +} // namespace bb::test_pow diff --git a/barretenberg/cpp/src/barretenberg/polynomials/univariate.test.cpp b/barretenberg/cpp/src/barretenberg/polynomials/univariate.test.cpp index 10bcd0abb07b..5b35de5e68a3 100644 --- a/barretenberg/cpp/src/barretenberg/polynomials/univariate.test.cpp +++ b/barretenberg/cpp/src/barretenberg/polynomials/univariate.test.cpp @@ -2,23 +2,30 @@ #include "barretenberg/ecc/curves/bn254/fr.hpp" #include -using namespace bb; +namespace bb::test_univariate { template class UnivariateTest : public testing::Test { public: template using UnivariateView = UnivariateView; }; -using FieldTypes = testing::Types; +using FieldTypes = testing::Types; TYPED_TEST_SUITE(UnivariateTest, FieldTypes); +#define UNIVARIATE_TESTS_ALIASES using FF = TypeParam; +// IMPROVEMENT: Can't make alias for Univariate for some reason. +// Might be convenient to solve boilerplate or repeated type aliasing +// using this or some other means. + TYPED_TEST(UnivariateTest, Constructors) { - fr a0 = fr::random_element(); - fr a1 = fr::random_element(); - fr a2 = fr::random_element(); + UNIVARIATE_TESTS_ALIASES + + FF a0 = FF::random_element(); + FF a1 = FF::random_element(); + FF a2 = FF::random_element(); - Univariate uni({ a0, a1, a2 }); + Univariate uni({ a0, a1, a2 }); EXPECT_EQ(uni.value_at(0), a0); EXPECT_EQ(uni.value_at(1), a1); @@ -27,111 +34,124 @@ TYPED_TEST(UnivariateTest, Constructors) TYPED_TEST(UnivariateTest, Addition) { - Univariate f1{ { 1, 2 } }; - Univariate f2{ { 3, 4 } }; + UNIVARIATE_TESTS_ALIASES + + Univariate f1{ { 1, 2 } }; + Univariate f2{ { 3, 4 } }; // output should be {4, 6} - Univariate expected_result{ { 4, 6 } }; + Univariate expected_result{ { 4, 6 } }; auto f1f2 = f1 + f2; EXPECT_EQ(f1f2, expected_result); } TYPED_TEST(UnivariateTest, Multiplication) { + UNIVARIATE_TESTS_ALIASES - Univariate f1 = Univariate{ { 1, 2 } }.template extend_to<3>(); - Univariate f2 = Univariate{ { 3, 4 } }.template extend_to<3>(); + Univariate f1 = Univariate{ { 1, 2 } }.template extend_to<3>(); + Univariate f2 = Univariate{ { 3, 4 } }.template extend_to<3>(); // output should be {3, 8, 15} - Univariate expected_result{ { 3, 8, 15 } }; - Univariate f1f2 = f1 * f2; + Univariate expected_result{ { 3, 8, 15 } }; + Univariate f1f2 = f1 * f2; EXPECT_EQ(f1f2, expected_result); } TYPED_TEST(UnivariateTest, ConstructUnivariateViewFromUnivariate) { + UNIVARIATE_TESTS_ALIASES - Univariate f{ { 1, 2, 3 } }; - UnivariateView g(f); + Univariate f{ { 1, 2, 3 } }; + UnivariateView g(f); EXPECT_EQ(g.value_at(0), f.value_at(0)); EXPECT_EQ(g.value_at(1), f.value_at(1)); } TYPED_TEST(UnivariateTest, ConstructUnivariateFromUnivariateView) { + UNIVARIATE_TESTS_ALIASES - Univariate f{ { 1, 2, 3 } }; - UnivariateView g(f); - Univariate h(g); + Univariate f{ { 1, 2, 3 } }; + UnivariateView g(f); + Univariate h(g); EXPECT_EQ(h.value_at(0), g.value_at(0)); EXPECT_EQ(h.value_at(1), g.value_at(1)); } TYPED_TEST(UnivariateTest, UnivariateViewAddition) { - Univariate f1{ { 1, 2, 3 } }; - Univariate f2{ { 3, 4, 3 } }; + UNIVARIATE_TESTS_ALIASES - UnivariateView g1(f1); - UnivariateView g2(f2); + Univariate f1{ { 1, 2, 3 } }; + Univariate f2{ { 3, 4, 3 } }; - Univariate expected_result{ { 4, 6 } }; - Univariate result = g1 + g2; + UnivariateView g1(f1); + UnivariateView g2(f2); + + Univariate expected_result{ { 4, 6 } }; + Univariate result = g1 + g2; EXPECT_EQ(result, expected_result); - Univariate result2 = result + g1; - Univariate expected_result2{ { 5, 8 } }; + Univariate result2 = result + g1; + Univariate expected_result2{ { 5, 8 } }; EXPECT_EQ(result2, expected_result2); } TYPED_TEST(UnivariateTest, UnivariateViewSubtraction) { - Univariate f1{ { 1, 2, 3 } }; - Univariate f2{ { 3, 4, 3 } }; + UNIVARIATE_TESTS_ALIASES + + Univariate f1{ { 1, 2, 3 } }; + Univariate f2{ { 3, 4, 3 } }; - UnivariateView g1(f1); - UnivariateView g2(f2); + UnivariateView g1(f1); + UnivariateView g2(f2); - Univariate expected_result{ { -2, -2 } }; - Univariate result = g1 - g2; + Univariate expected_result{ { -2, -2 } }; + Univariate result = g1 - g2; EXPECT_EQ(result, expected_result); - Univariate result2 = result - g1; - Univariate expected_result2{ { -3, -4 } }; + Univariate result2 = result - g1; + Univariate expected_result2{ { -3, -4 } }; EXPECT_EQ(result2, expected_result2); } TYPED_TEST(UnivariateTest, UnivariateViewMultiplication) { - Univariate f1{ { 1, 2, 3 } }; - Univariate f2{ { 3, 4, 3 } }; + UNIVARIATE_TESTS_ALIASES - UnivariateView g1(f1); - UnivariateView g2(f2); + Univariate f1{ { 1, 2, 3 } }; + Univariate f2{ { 3, 4, 3 } }; - Univariate expected_result{ { 3, 8 } }; - Univariate result = g1 * g2; + UnivariateView g1(f1); + UnivariateView g2(f2); + + Univariate expected_result{ { 3, 8 } }; + Univariate result = g1 * g2; EXPECT_EQ(result, expected_result); - Univariate result2 = result * g1; - Univariate expected_result2{ { 3, 16 } }; + Univariate result2 = result * g1; + Univariate expected_result2{ { 3, 16 } }; EXPECT_EQ(result2, expected_result2); } TYPED_TEST(UnivariateTest, Serialization) { + UNIVARIATE_TESTS_ALIASES + const size_t LENGTH = 4; - std::array evaluations; + std::array evaluations; for (size_t i = 0; i < LENGTH; ++i) { - evaluations[i] = fr::random_element(); + evaluations[i] = FF::random_element(); } // Instantiate a Univariate from the evaluations - auto univariate = Univariate(evaluations); + auto univariate = Univariate(evaluations); // Serialize univariate to buffer std::vector buffer = univariate.to_buffer(); // Deserialize - auto deserialized_univariate = Univariate::serialize_from_buffer(&buffer[0]); + auto deserialized_univariate = Univariate::serialize_from_buffer(&buffer[0]); for (size_t i = 0; i < LENGTH; ++i) { EXPECT_EQ(univariate.value_at(i), deserialized_univariate.value_at(i)); @@ -140,13 +160,17 @@ TYPED_TEST(UnivariateTest, Serialization) TYPED_TEST(UnivariateTest, EvaluationCustomDomain) { + UNIVARIATE_TESTS_ALIASES + []() { - auto poly = Univariate(std::array{ 1, 2 }); - EXPECT_EQ(poly.evaluate(fr(5)), fr(5)); + auto poly = Univariate(std::array{ 1, 2 }); + EXPECT_EQ(poly.evaluate(FF(5)), FF(5)); }(); []() { - auto poly = Univariate(std::array{ 1, 11, 111, 1111, 11111 }); - EXPECT_EQ(poly.evaluate(fr(2)), fr(294330751)); + auto poly = Univariate(std::array{ 1, 11, 111, 1111, 11111 }); + EXPECT_EQ(poly.evaluate(FF(2)), FF(294330751)); }(); } + +} // namespace bb::test_univariate diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_builder_types.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_builder_types.hpp index 99f7103afcfa..d01d92ce5d60 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_builder_types.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_builder_types.hpp @@ -2,7 +2,7 @@ #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" -namespace bb::eccvm { +namespace bb_eccvm { static constexpr size_t NUM_SCALAR_BITS = 128; static constexpr size_t WNAF_SLICE_BITS = 4; @@ -44,4 +44,4 @@ template struct ScalarMul { template using MSM = std::vector>; -} // namespace bb::eccvm \ No newline at end of file +} // namespace bb_eccvm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.hpp index 7569275796e1..b73b18897102 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.hpp @@ -24,21 +24,21 @@ template class ECCVMCircuitBuilder { using Element = typename CycleGroup::element; using AffineElement = typename CycleGroup::affine_element; - static constexpr size_t NUM_SCALAR_BITS = bb::eccvm::NUM_SCALAR_BITS; - static constexpr size_t WNAF_SLICE_BITS = bb::eccvm::WNAF_SLICE_BITS; - static constexpr size_t NUM_WNAF_SLICES = bb::eccvm::NUM_WNAF_SLICES; - static constexpr uint64_t WNAF_MASK = bb::eccvm::WNAF_MASK; - static constexpr size_t POINT_TABLE_SIZE = bb::eccvm::POINT_TABLE_SIZE; - static constexpr size_t WNAF_SLICES_PER_ROW = bb::eccvm::WNAF_SLICES_PER_ROW; - static constexpr size_t ADDITIONS_PER_ROW = bb::eccvm::ADDITIONS_PER_ROW; + static constexpr size_t NUM_SCALAR_BITS = bb_eccvm::NUM_SCALAR_BITS; + static constexpr size_t WNAF_SLICE_BITS = bb_eccvm::WNAF_SLICE_BITS; + static constexpr size_t NUM_WNAF_SLICES = bb_eccvm::NUM_WNAF_SLICES; + static constexpr uint64_t WNAF_MASK = bb_eccvm::WNAF_MASK; + static constexpr size_t POINT_TABLE_SIZE = bb_eccvm::POINT_TABLE_SIZE; + static constexpr size_t WNAF_SLICES_PER_ROW = bb_eccvm::WNAF_SLICES_PER_ROW; + static constexpr size_t ADDITIONS_PER_ROW = bb_eccvm::ADDITIONS_PER_ROW; static constexpr size_t NUM_POLYNOMIALS = Flavor::NUM_ALL_ENTITIES; static constexpr size_t NUM_WIRES = Flavor::NUM_WIRES; - using MSM = bb::eccvm::MSM; - using VMOperation = bb::eccvm::VMOperation; + using MSM = bb_eccvm::MSM; + using VMOperation = bb_eccvm::VMOperation; std::shared_ptr op_queue; - using ScalarMul = bb::eccvm::ScalarMul; + using ScalarMul = bb_eccvm::ScalarMul; using ProverPolynomials = typename Flavor::ProverPolynomials; ECCVMCircuitBuilder() diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.test.cpp index 18bacda13efc..013e9a3c0864 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.test.cpp @@ -6,9 +6,11 @@ using namespace bb; namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } +namespace eccvm_circuit_builder_tests { + template class ECCVMCircuitBuilderTests : public ::testing::Test {}; using FlavorTypes = ::testing::Types; @@ -19,7 +21,7 @@ TYPED_TEST(ECCVMCircuitBuilderTests, BaseCase) using Flavor = TypeParam; using G1 = typename Flavor::CycleGroup; using Fr = typename G1::Fr; - ECCVMCircuitBuilder circuit; + bb::ECCVMCircuitBuilder circuit; auto generators = G1::derive_generators("test generators", 3); typename G1::element a = generators[0]; typename G1::element b = generators[1]; @@ -53,7 +55,7 @@ TYPED_TEST(ECCVMCircuitBuilderTests, Add) { using Flavor = TypeParam; using G1 = typename Flavor::CycleGroup; - ECCVMCircuitBuilder circuit; + bb::ECCVMCircuitBuilder circuit; auto generators = G1::derive_generators("test generators", 3); typename G1::element a = generators[0]; @@ -69,7 +71,7 @@ TYPED_TEST(ECCVMCircuitBuilderTests, Mul) using Flavor = TypeParam; using G1 = typename Flavor::CycleGroup; using Fr = typename G1::Fr; - ECCVMCircuitBuilder circuit; + bb::ECCVMCircuitBuilder circuit; auto generators = G1::derive_generators("test generators", 3); typename G1::element a = generators[0]; Fr x = Fr::random_element(&engine); @@ -85,7 +87,7 @@ TYPED_TEST(ECCVMCircuitBuilderTests, ShortMul) using Flavor = TypeParam; using G1 = typename Flavor::CycleGroup; using Fr = typename G1::Fr; - ECCVMCircuitBuilder circuit; + bb::ECCVMCircuitBuilder circuit; auto generators = G1::derive_generators("test generators", 3); typename G1::element a = generators[0]; @@ -107,7 +109,7 @@ TYPED_TEST(ECCVMCircuitBuilderTests, EqFails) using Flavor = TypeParam; using G1 = typename Flavor::CycleGroup; using Fr = typename G1::Fr; - ECCVMCircuitBuilder circuit; + bb::ECCVMCircuitBuilder circuit; auto generators = G1::derive_generators("test generators", 3); typename G1::element a = generators[0]; @@ -122,7 +124,7 @@ TYPED_TEST(ECCVMCircuitBuilderTests, EqFails) TYPED_TEST(ECCVMCircuitBuilderTests, EmptyRow) { using Flavor = TypeParam; - ECCVMCircuitBuilder circuit; + bb::ECCVMCircuitBuilder circuit; circuit.empty_row(); @@ -135,7 +137,7 @@ TYPED_TEST(ECCVMCircuitBuilderTests, EmptyRowBetweenOps) using Flavor = TypeParam; using G1 = typename Flavor::CycleGroup; using Fr = typename G1::Fr; - ECCVMCircuitBuilder circuit; + bb::ECCVMCircuitBuilder circuit; auto generators = G1::derive_generators("test generators", 3); typename G1::element a = generators[0]; @@ -156,7 +158,7 @@ TYPED_TEST(ECCVMCircuitBuilderTests, EndWithEq) using Flavor = TypeParam; using G1 = typename Flavor::CycleGroup; using Fr = typename G1::Fr; - ECCVMCircuitBuilder circuit; + bb::ECCVMCircuitBuilder circuit; auto generators = G1::derive_generators("test generators", 3); typename G1::element a = generators[0]; @@ -176,7 +178,7 @@ TYPED_TEST(ECCVMCircuitBuilderTests, EndWithAdd) using Flavor = TypeParam; using G1 = typename Flavor::CycleGroup; using Fr = typename G1::Fr; - ECCVMCircuitBuilder circuit; + bb::ECCVMCircuitBuilder circuit; auto generators = G1::derive_generators("test generators", 3); typename G1::element a = generators[0]; @@ -197,7 +199,7 @@ TYPED_TEST(ECCVMCircuitBuilderTests, EndWithMul) using Flavor = TypeParam; using G1 = typename Flavor::CycleGroup; using Fr = typename G1::Fr; - ECCVMCircuitBuilder circuit; + bb::ECCVMCircuitBuilder circuit; auto generators = G1::derive_generators("test generators", 3); typename G1::element a = generators[0]; @@ -216,7 +218,7 @@ TYPED_TEST(ECCVMCircuitBuilderTests, EndWithNoop) using Flavor = TypeParam; using G1 = typename Flavor::CycleGroup; using Fr = typename G1::Fr; - ECCVMCircuitBuilder circuit; + bb::ECCVMCircuitBuilder circuit; auto generators = G1::derive_generators("test generators", 3); typename G1::element a = generators[0]; @@ -255,16 +257,17 @@ TYPED_TEST(ECCVMCircuitBuilderTests, MSM) // single msms for (size_t j = 1; j < max_num_msms; ++j) { using Flavor = TypeParam; - ECCVMCircuitBuilder circuit; + bb::ECCVMCircuitBuilder circuit; try_msms(j, circuit); bool result = circuit.check_circuit(); EXPECT_EQ(result, true); } // chain msms - ECCVMCircuitBuilder circuit; + bb::ECCVMCircuitBuilder circuit; for (size_t j = 1; j < 9; ++j) { try_msms(j, circuit); } bool result = circuit.check_circuit(); EXPECT_EQ(result, true); } +} // namespace eccvm_circuit_builder_tests \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/msm_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/msm_builder.hpp index 6f0c45e37441..c47f818ff304 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/msm_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/msm_builder.hpp @@ -13,9 +13,9 @@ template class ECCVMMSMMBuilder { using Element = typename CycleGroup::element; using AffineElement = typename CycleGroup::affine_element; - static constexpr size_t ADDITIONS_PER_ROW = bb::eccvm::ADDITIONS_PER_ROW; - static constexpr size_t NUM_SCALAR_BITS = bb::eccvm::NUM_SCALAR_BITS; - static constexpr size_t WNAF_SLICE_BITS = bb::eccvm::WNAF_SLICE_BITS; + static constexpr size_t ADDITIONS_PER_ROW = bb_eccvm::ADDITIONS_PER_ROW; + static constexpr size_t NUM_SCALAR_BITS = bb_eccvm::NUM_SCALAR_BITS; + static constexpr size_t WNAF_SLICE_BITS = bb_eccvm::WNAF_SLICE_BITS; struct MSMState { uint32_t pc = 0; @@ -53,7 +53,7 @@ template class ECCVMMSMMBuilder { * @param total_number_of_muls * @return std::vector */ - static std::vector compute_msm_state(const std::vector>& msms, + static std::vector compute_msm_state(const std::vector>& msms, std::array, 2>& point_table_read_counts, const uint32_t total_number_of_muls) { diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/precomputed_tables_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/precomputed_tables_builder.hpp index 1c7d2bb443e3..ca583c8de412 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/precomputed_tables_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/precomputed_tables_builder.hpp @@ -11,9 +11,9 @@ template class ECCVMPrecomputedTablesBuilder { using Element = typename CycleGroup::element; using AffineElement = typename CycleGroup::affine_element; - static constexpr size_t NUM_WNAF_SLICES = bb::eccvm::NUM_WNAF_SLICES; - static constexpr size_t WNAF_SLICES_PER_ROW = bb::eccvm::WNAF_SLICES_PER_ROW; - static constexpr size_t WNAF_SLICE_BITS = bb::eccvm::WNAF_SLICE_BITS; + static constexpr size_t NUM_WNAF_SLICES = bb_eccvm::NUM_WNAF_SLICES; + static constexpr size_t WNAF_SLICES_PER_ROW = bb_eccvm::WNAF_SLICES_PER_ROW; + static constexpr size_t WNAF_SLICE_BITS = bb_eccvm::WNAF_SLICE_BITS; struct PrecomputeState { int s1 = 0; @@ -34,7 +34,7 @@ template class ECCVMPrecomputedTablesBuilder { }; static std::vector compute_precompute_state( - const std::vector>& ecc_muls) + const std::vector>& ecc_muls) { std::vector precompute_state; @@ -101,7 +101,7 @@ template class ECCVMPrecomputedTablesBuilder { row.precompute_double = d2; // fill accumulator in reverse order i.e. first row = 15[P], then 13[P], ..., 1[P] - row.precompute_accumulator = entry.precomputed_table[bb::eccvm::POINT_TABLE_SIZE - 1 - i]; + row.precompute_accumulator = entry.precomputed_table[bb_eccvm::POINT_TABLE_SIZE - 1 - i]; precompute_state.emplace_back(row); } } diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/transcript_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/transcript_builder.hpp index 1ff3d8b4cbac..5d0c693eac69 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/transcript_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/transcript_builder.hpp @@ -58,7 +58,7 @@ template class ECCVMTranscriptBuilder { } }; static std::vector compute_transcript_state( - const std::vector>& vm_operations, const uint32_t total_number_of_muls) + const std::vector>& vm_operations, const uint32_t total_number_of_muls) { std::vector transcript_state; VMState state{ @@ -74,7 +74,7 @@ template class ECCVMTranscriptBuilder { transcript_state.emplace_back(TranscriptState{}); for (size_t i = 0; i < vm_operations.size(); ++i) { TranscriptState row; - const bb::eccvm::VMOperation& entry = vm_operations[i]; + const bb_eccvm::VMOperation& entry = vm_operations[i]; const bool is_mul = entry.mul; const bool z1_zero = (entry.mul) ? entry.z1 == 0 : true; diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/AvmMini_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/AvmMini_circuit_builder.hpp index baef5adc8560..de70d2c08579 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/AvmMini_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/AvmMini_circuit_builder.hpp @@ -12,7 +12,6 @@ #include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" #include "barretenberg/flavor/generated/AvmMini_flavor.hpp" -#include "barretenberg/relations/generated/AvmMini/alu_chip.hpp" #include "barretenberg/relations/generated/AvmMini/avm_mini.hpp" #include "barretenberg/relations/generated/AvmMini/mem_trace.hpp" @@ -34,32 +33,6 @@ template struct AvmMiniFullRow { FF memTrace_m_in_tag{}; FF memTrace_m_tag_err{}; FF memTrace_m_one_min_inv{}; - FF aluChip_alu_clk{}; - FF aluChip_alu_ia{}; - FF aluChip_alu_ib{}; - FF aluChip_alu_ic{}; - FF aluChip_alu_op_add{}; - FF aluChip_alu_op_sub{}; - FF aluChip_alu_op_mul{}; - FF aluChip_alu_op_div{}; - FF aluChip_alu_ff_tag{}; - FF aluChip_alu_u8_tag{}; - FF aluChip_alu_u16_tag{}; - FF aluChip_alu_u32_tag{}; - FF aluChip_alu_u64_tag{}; - FF aluChip_alu_u128_tag{}; - FF aluChip_alu_u8_r0{}; - FF aluChip_alu_u8_r1{}; - FF aluChip_alu_u16_r0{}; - FF aluChip_alu_u16_r1{}; - FF aluChip_alu_u16_r2{}; - FF aluChip_alu_u16_r3{}; - FF aluChip_alu_u16_r4{}; - FF aluChip_alu_u16_r5{}; - FF aluChip_alu_u16_r6{}; - FF aluChip_alu_u16_r7{}; - FF aluChip_alu_u64_r0{}; - FF aluChip_alu_cf{}; FF avmMini_pc{}; FF avmMini_internal_return_ptr{}; FF avmMini_sel_internal_call{}; @@ -87,20 +60,12 @@ template struct AvmMiniFullRow { FF avmMini_mem_idx_b{}; FF avmMini_mem_idx_c{}; FF avmMini_last{}; - FF aluChip_alu_u16_r1_shift{}; - FF aluChip_alu_u16_r0_shift{}; - FF aluChip_alu_u16_r4_shift{}; - FF aluChip_alu_u16_r7_shift{}; - FF aluChip_alu_u16_r5_shift{}; - FF aluChip_alu_u16_r2_shift{}; - FF aluChip_alu_u16_r6_shift{}; - FF aluChip_alu_u16_r3_shift{}; - FF avmMini_pc_shift{}; - FF avmMini_internal_return_ptr_shift{}; + FF memTrace_m_rw_shift{}; FF memTrace_m_tag_shift{}; FF memTrace_m_addr_shift{}; FF memTrace_m_val_shift{}; - FF memTrace_m_rw_shift{}; + FF avmMini_internal_return_ptr_shift{}; + FF avmMini_pc_shift{}; }; class AvmMiniCircuitBuilder { @@ -113,8 +78,8 @@ class AvmMiniCircuitBuilder { using Polynomial = Flavor::Polynomial; using ProverPolynomials = Flavor::ProverPolynomials; - static constexpr size_t num_fixed_columns = 80; - static constexpr size_t num_polys = 66; + static constexpr size_t num_fixed_columns = 46; + static constexpr size_t num_polys = 40; std::vector rows; void set_trace(std::vector&& trace) { rows = std::move(trace); } @@ -143,32 +108,6 @@ class AvmMiniCircuitBuilder { polys.memTrace_m_in_tag[i] = rows[i].memTrace_m_in_tag; polys.memTrace_m_tag_err[i] = rows[i].memTrace_m_tag_err; polys.memTrace_m_one_min_inv[i] = rows[i].memTrace_m_one_min_inv; - polys.aluChip_alu_clk[i] = rows[i].aluChip_alu_clk; - polys.aluChip_alu_ia[i] = rows[i].aluChip_alu_ia; - polys.aluChip_alu_ib[i] = rows[i].aluChip_alu_ib; - polys.aluChip_alu_ic[i] = rows[i].aluChip_alu_ic; - polys.aluChip_alu_op_add[i] = rows[i].aluChip_alu_op_add; - polys.aluChip_alu_op_sub[i] = rows[i].aluChip_alu_op_sub; - polys.aluChip_alu_op_mul[i] = rows[i].aluChip_alu_op_mul; - polys.aluChip_alu_op_div[i] = rows[i].aluChip_alu_op_div; - polys.aluChip_alu_ff_tag[i] = rows[i].aluChip_alu_ff_tag; - polys.aluChip_alu_u8_tag[i] = rows[i].aluChip_alu_u8_tag; - polys.aluChip_alu_u16_tag[i] = rows[i].aluChip_alu_u16_tag; - polys.aluChip_alu_u32_tag[i] = rows[i].aluChip_alu_u32_tag; - polys.aluChip_alu_u64_tag[i] = rows[i].aluChip_alu_u64_tag; - polys.aluChip_alu_u128_tag[i] = rows[i].aluChip_alu_u128_tag; - polys.aluChip_alu_u8_r0[i] = rows[i].aluChip_alu_u8_r0; - polys.aluChip_alu_u8_r1[i] = rows[i].aluChip_alu_u8_r1; - polys.aluChip_alu_u16_r0[i] = rows[i].aluChip_alu_u16_r0; - polys.aluChip_alu_u16_r1[i] = rows[i].aluChip_alu_u16_r1; - polys.aluChip_alu_u16_r2[i] = rows[i].aluChip_alu_u16_r2; - polys.aluChip_alu_u16_r3[i] = rows[i].aluChip_alu_u16_r3; - polys.aluChip_alu_u16_r4[i] = rows[i].aluChip_alu_u16_r4; - polys.aluChip_alu_u16_r5[i] = rows[i].aluChip_alu_u16_r5; - polys.aluChip_alu_u16_r6[i] = rows[i].aluChip_alu_u16_r6; - polys.aluChip_alu_u16_r7[i] = rows[i].aluChip_alu_u16_r7; - polys.aluChip_alu_u64_r0[i] = rows[i].aluChip_alu_u64_r0; - polys.aluChip_alu_cf[i] = rows[i].aluChip_alu_cf; polys.avmMini_pc[i] = rows[i].avmMini_pc; polys.avmMini_internal_return_ptr[i] = rows[i].avmMini_internal_return_ptr; polys.avmMini_sel_internal_call[i] = rows[i].avmMini_sel_internal_call; @@ -198,20 +137,12 @@ class AvmMiniCircuitBuilder { polys.avmMini_last[i] = rows[i].avmMini_last; } - polys.aluChip_alu_u16_r1_shift = Polynomial(polys.aluChip_alu_u16_r1.shifted()); - polys.aluChip_alu_u16_r0_shift = Polynomial(polys.aluChip_alu_u16_r0.shifted()); - polys.aluChip_alu_u16_r4_shift = Polynomial(polys.aluChip_alu_u16_r4.shifted()); - polys.aluChip_alu_u16_r7_shift = Polynomial(polys.aluChip_alu_u16_r7.shifted()); - polys.aluChip_alu_u16_r5_shift = Polynomial(polys.aluChip_alu_u16_r5.shifted()); - polys.aluChip_alu_u16_r2_shift = Polynomial(polys.aluChip_alu_u16_r2.shifted()); - polys.aluChip_alu_u16_r6_shift = Polynomial(polys.aluChip_alu_u16_r6.shifted()); - polys.aluChip_alu_u16_r3_shift = Polynomial(polys.aluChip_alu_u16_r3.shifted()); - polys.avmMini_pc_shift = Polynomial(polys.avmMini_pc.shifted()); - polys.avmMini_internal_return_ptr_shift = Polynomial(polys.avmMini_internal_return_ptr.shifted()); + polys.memTrace_m_rw_shift = Polynomial(polys.memTrace_m_rw.shifted()); polys.memTrace_m_tag_shift = Polynomial(polys.memTrace_m_tag.shifted()); polys.memTrace_m_addr_shift = Polynomial(polys.memTrace_m_addr.shifted()); polys.memTrace_m_val_shift = Polynomial(polys.memTrace_m_val.shifted()); - polys.memTrace_m_rw_shift = Polynomial(polys.memTrace_m_rw.shifted()); + polys.avmMini_internal_return_ptr_shift = Polynomial(polys.avmMini_internal_return_ptr.shifted()); + polys.avmMini_pc_shift = Polynomial(polys.avmMini_pc.shifted()); return polys; } @@ -249,18 +180,14 @@ class AvmMiniCircuitBuilder { return true; }; - if (!evaluate_relation.template operator()>("alu_chip", - AvmMini_vm::get_relation_label_alu_chip)) { + if (!evaluate_relation.template operator()>( + "mem_trace", AvmMini_vm::get_relation_label_mem_trace)) { return false; } if (!evaluate_relation.template operator()>("avm_mini", AvmMini_vm::get_relation_label_avm_mini)) { return false; } - if (!evaluate_relation.template operator()>( - "mem_trace", AvmMini_vm::get_relation_label_mem_trace)) { - return false; - } return true; } diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.test.cpp index e08938d19579..acfdad1c165f 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.test.cpp @@ -7,8 +7,10 @@ using namespace bb; namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } +namespace bb { + /** * @brief Check that a single accumulation gate is created correctly * @@ -76,9 +78,9 @@ TEST(GoblinTranslatorCircuitBuilder, CircuitBuilderBaseCase) */ TEST(GoblinTranslatorCircuitBuilder, SeveralOperationCorrectness) { - using point = g1::affine_element; - using scalar = fr; - using Fq = fq; + using point = bb::g1::affine_element; + using scalar = bb::fr; + using Fq = bb::fq; auto P1 = point::random_element(); auto P2 = point::random_element(); @@ -126,4 +128,5 @@ TEST(GoblinTranslatorCircuitBuilder, SeveralOperationCorrectness) EXPECT_TRUE(circuit_builder.check_circuit()); // Check the computation result is in line with what we've computed EXPECT_EQ(result, circuit_builder.get_computation_result()); -} \ No newline at end of file +} +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_translator_mini.fuzzer.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_translator_mini.fuzzer.cpp index f390dd0b8eff..ee34d21262b0 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_translator_mini.fuzzer.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_translator_mini.fuzzer.cpp @@ -1,10 +1,7 @@ #include "barretenberg/numeric/uint256/uint256.hpp" #include "goblin_translator_circuit_builder.hpp" - -using namespace bb; - -using Fr = curve::BN254::ScalarField; -using Fq = curve::BN254::BaseField; +using Fr = ::curve::BN254::ScalarField; +using Fq = ::curve::BN254::BaseField; extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data, size_t size) { diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.cpp index 428409bf73f0..84a6b0b5105c 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.cpp @@ -6,7 +6,7 @@ #include using namespace bb; -using namespace bb::crypto; +using namespace crypto; namespace bb { diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.test.cpp index 4e2b85667154..927f563626cf 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.test.cpp @@ -4,7 +4,7 @@ using namespace bb; namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } namespace bb { diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/standard_circuit_builder.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/standard_circuit_builder.test.cpp index aec2887e552b..9a05d8fea16a 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/standard_circuit_builder.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/standard_circuit_builder.test.cpp @@ -3,12 +3,15 @@ #include "barretenberg/crypto/pedersen_commitment/pedersen.hpp" #include +using namespace bb; using namespace bb; namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } +namespace standard_circuit_constructor_tests { + TEST(standard_circuit_constructor, base_case) { StandardCircuitBuilder circuit_constructor = StandardCircuitBuilder(); @@ -465,3 +468,5 @@ TEST(standard_circuit_constructor, test_check_circuit_broken) bool result = circuit_constructor.check_circuit(); EXPECT_EQ(result, false); } + +} // namespace standard_circuit_constructor_tests diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/toy_avm/toy_avm_circuit_builder.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/toy_avm/toy_avm_circuit_builder.test.cpp index 25e182c0a46a..2049cf001a3c 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/toy_avm/toy_avm_circuit_builder.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/toy_avm/toy_avm_circuit_builder.test.cpp @@ -8,9 +8,11 @@ using namespace bb; namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } +namespace toy_avm_circuit_builder_tests { + /** * @brief A test explaining the work of the permutations in Toy AVM * @@ -18,8 +20,8 @@ auto& engine = numeric::get_debug_randomness(); TEST(ToyAVMCircuitBuilder, BaseCase) { - using FF = honk::flavor::ToyFlavor::FF; - using Builder = ToyCircuitBuilder; + using FF = bb::honk::flavor::ToyFlavor::FF; + using Builder = bb::ToyCircuitBuilder; using Row = Builder::Row; Builder circuit_builder; @@ -116,3 +118,4 @@ TEST(ToyAVMCircuitBuilder, BaseCase) circuit_builder.rows[2].toy_xor_a = tmp; EXPECT_EQ(circuit_builder.check_circuit(), true); } +} // namespace toy_avm_circuit_builder_tests \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.test.cpp index 16e1252712af..8605db48b4ab 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.test.cpp @@ -5,7 +5,7 @@ using namespace bb; namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } namespace bb { using plookup::ColumnIdx; @@ -44,7 +44,7 @@ TEST(ultra_circuit_constructor, create_gates_from_plookup_accumulators) UltraCircuitBuilder circuit_builder = UltraCircuitBuilder(); - fr input_value = fr::random_element(); + bb::fr input_value = fr::random_element(); const fr input_lo = static_cast(input_value).slice(0, plookup::fixed_base::table::BITS_PER_LO_SCALAR); const auto input_lo_index = circuit_builder.add_variable(input_lo); @@ -648,7 +648,7 @@ TEST(ultra_circuit_constructor, non_native_field_multiplication) const auto q_indices = get_limb_witness_indices(split_into_limbs(uint256_t(q))); const auto r_indices = get_limb_witness_indices(split_into_limbs(uint256_t(r))); - non_native_field_witnesses inputs{ + bb::non_native_field_witnesses inputs{ a_indices, b_indices, q_indices, r_indices, modulus_limbs, fr(uint256_t(modulus)), }; const auto [lo_1_idx, hi_1_idx] = circuit_constructor.evaluate_non_native_field_multiplication(inputs); diff --git a/barretenberg/cpp/src/barretenberg/proof_system/composer/composer_lib.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/composer/composer_lib.test.cpp index aad304526642..1f2aac2b46f0 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/composer/composer_lib.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/composer/composer_lib.test.cpp @@ -6,7 +6,7 @@ #include #include -using namespace bb; +namespace bb::test_composer_lib { class ComposerLibTests : public ::testing::Test { protected: @@ -14,7 +14,7 @@ class ComposerLibTests : public ::testing::Test { using FF = typename Flavor::FF; Flavor::CircuitBuilder circuit_constructor; Flavor::ProvingKey proving_key = []() { - auto crs_factory = srs::factories::CrsFactory(); + auto crs_factory = bb::srs::factories::CrsFactory(); auto crs = crs_factory.get_prover_crs(4); return Flavor::ProvingKey(/*circuit_size=*/8, /*num_public_inputs=*/0); }(); @@ -59,3 +59,5 @@ TEST_F(ComposerLibTests, ConstructSelectors) EXPECT_EQ(proving_key.q_c[2 + offset], 19); EXPECT_EQ(proving_key.q_c[3 + offset], 20); } + +} // namespace bb::test_composer_lib diff --git a/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.test.cpp index 3fc4d2bcb3c6..0ebd08ea3821 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.test.cpp @@ -6,7 +6,7 @@ #include #include -using namespace bb; +namespace bb::test_composer_lib { class PermutationHelperTests : public ::testing::Test { protected: @@ -14,7 +14,7 @@ class PermutationHelperTests : public ::testing::Test { using FF = typename Flavor::FF; using ProvingKey = Flavor::ProvingKey; Flavor::CircuitBuilder circuit_constructor; - srs::factories::CrsFactory crs_factory = srs::factories::CrsFactory(); + bb::srs::factories::CrsFactory crs_factory = bb::srs::factories::CrsFactory(); std::shared_ptr proving_key; virtual void SetUp() @@ -89,3 +89,5 @@ TEST_F(PermutationHelperTests, ComputeStandardAuxPolynomials) // TODO(#425) Flesh out these tests compute_first_and_last_lagrange_polynomials(proving_key); } + +} // namespace bb::test_composer_lib diff --git a/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.test.cpp index 7e78b77e3cd7..e78684c82c7c 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.test.cpp @@ -6,8 +6,9 @@ #include "barretenberg/srs/factories/file_crs_factory.hpp" #include -using namespace bb; + using namespace bb::honk; +namespace grand_product_library_tests { template class GrandProductTests : public testing::Test { @@ -80,7 +81,7 @@ template class GrandProductTests : public testing::Test { auto beta = FF::random_element(); auto gamma = FF::random_element(); - RelationParameters params{ + bb::RelationParameters params{ .eta = 0, .beta = beta, .gamma = gamma, @@ -90,7 +91,8 @@ template class GrandProductTests : public testing::Test { typename Flavor::ProverPolynomials prover_polynomials; for (auto [prover_poly, key_poly] : zip_view(prover_polynomials.get_unshifted(), proving_key->get_all())) { - ASSERT(flavor_get_label(prover_polynomials, prover_poly) == flavor_get_label(*proving_key, key_poly)); + ASSERT(bb::flavor_get_label(prover_polynomials, prover_poly) == + bb::flavor_get_label(*proving_key, key_poly)); prover_poly = key_poly.share(); } @@ -230,7 +232,7 @@ template class GrandProductTests : public testing::Test { auto gamma = FF::random_element(); auto eta = FF::random_element(); - RelationParameters params{ + bb::RelationParameters params{ .eta = eta, .beta = beta, .gamma = gamma, @@ -240,13 +242,14 @@ template class GrandProductTests : public testing::Test { typename Flavor::ProverPolynomials prover_polynomials; for (auto [prover_poly, key_poly] : zip_view(prover_polynomials.get_unshifted(), proving_key->get_all())) { - ASSERT(flavor_get_label(prover_polynomials, prover_poly) == flavor_get_label(*proving_key, key_poly)); + ASSERT(bb::flavor_get_label(prover_polynomials, prover_poly) == + bb::flavor_get_label(*proving_key, key_poly)); prover_poly = key_poly.share(); } for (auto [prover_poly, key_poly] : zip_view(prover_polynomials.get_shifted(), proving_key->get_to_be_shifted())) { - ASSERT(flavor_get_label(prover_polynomials, prover_poly) == - flavor_get_label(*proving_key, key_poly) + "_shift"); + ASSERT(bb::flavor_get_label(prover_polynomials, prover_poly) == + bb::flavor_get_label(*proving_key, key_poly) + "_shift"); prover_poly = key_poly.shifted(); } // Test a few assignments @@ -257,7 +260,7 @@ template class GrandProductTests : public testing::Test { // Method 1: Compute z_lookup using the prover library method constexpr size_t LOOKUP_RELATION_INDEX = 1; using LHS = typename std::tuple_element::type; - using RHS = LookupRelation; + using RHS = bb::LookupRelation; static_assert(std::same_as); grand_product_library::compute_grand_product( proving_key->circuit_size, prover_polynomials, params); @@ -348,3 +351,5 @@ TYPED_TEST(GrandProductTests, GrandProductLookup) { TestFixture::test_lookup_grand_product_construction(); } + +} // namespace grand_product_library_tests diff --git a/barretenberg/cpp/src/barretenberg/proof_system/op_queue/ecc_op_queue.hpp b/barretenberg/cpp/src/barretenberg/proof_system/op_queue/ecc_op_queue.hpp index a4d5d3642ebc..1caa057f8584 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/op_queue/ecc_op_queue.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/op_queue/ecc_op_queue.hpp @@ -26,7 +26,7 @@ class ECCOpQueue { Point accumulator = point_at_infinity; public: - using ECCVMOperation = bb::eccvm::VMOperation; + using ECCVMOperation = bb_eccvm::VMOperation; std::vector raw_ops; std::array, 4> ultra_ops; // ops encoded in the width-4 Ultra format diff --git a/barretenberg/cpp/src/barretenberg/proof_system/op_queue/ecc_op_queue.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/op_queue/ecc_op_queue.test.cpp index 7b13cce43f3f..2df97e0e8100 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/op_queue/ecc_op_queue.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/op_queue/ecc_op_queue.test.cpp @@ -1,8 +1,7 @@ #include "barretenberg/proof_system/op_queue/ecc_op_queue.hpp" #include -using namespace bb; - +namespace bb::test_flavor { TEST(ECCOpQueueTest, Basic) { ECCOpQueue op_queue; @@ -14,8 +13,8 @@ TEST(ECCOpQueueTest, Basic) TEST(ECCOpQueueTest, InternalAccumulatorCorrectness) { - using point = g1::affine_element; - using scalar = fr; + using point = bb::g1::affine_element; + using scalar = bb::fr; // Compute a simple point accumulation natively auto P1 = point::random_element(); @@ -37,3 +36,5 @@ TEST(ECCOpQueueTest, InternalAccumulatorCorrectness) // Adding an equality op should reset the accumulator to zero (the point at infinity) EXPECT_TRUE(op_queue.get_accumulator().is_point_at_infinity()); } + +} // namespace bb::test_flavor diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/aes128.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/aes128.hpp index f3102bbfd18e..3306338e9b9b 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/aes128.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/aes128.hpp @@ -8,7 +8,8 @@ #include "sparse.hpp" #include "types.hpp" -namespace bb::plookup::aes128_tables { +namespace plookup { +namespace aes128_tables { static constexpr uint64_t AES_BASE = 9; static constexpr uint64_t aes_normalization_table[AES_BASE]{ 1, 0, 0, 0, 0, 0, 0, 0, 0, @@ -126,7 +127,7 @@ inline MultiTable get_aes_input_table(const MultiTableId id = AES_INPUT) inline std::array get_aes_sbox_values_from_key(const std::array key) { const auto byte = numeric::map_from_sparse_form(key[0]); - uint8_t sbox_value = crypto::aes128_sbox[(uint8_t)byte]; + uint8_t sbox_value = crypto::aes128::sbox[(uint8_t)byte]; uint8_t swizzled = ((uint8_t)(sbox_value << 1) ^ (uint8_t)(((sbox_value >> 7) & 1) * 0x1b)); return { bb::fr(numeric::map_into_sparse_form(sbox_value)), bb::fr(numeric::map_into_sparse_form((uint8_t)(sbox_value ^ swizzled))) }; @@ -141,7 +142,7 @@ inline BasicTable generate_aes_sbox_table(BasicTableId id, const size_t table_in table.use_twin_keys = false; for (uint64_t i = 0; i < table.size; ++i) { const auto first = numeric::map_into_sparse_form((uint8_t)i); - uint8_t sbox_value = crypto::aes128_sbox[(uint8_t)i]; + uint8_t sbox_value = crypto::aes128::sbox[(uint8_t)i]; uint8_t swizzled = ((uint8_t)(sbox_value << 1) ^ (uint8_t)(((sbox_value >> 7) & 1) * 0x1b)); const auto second = numeric::map_into_sparse_form(sbox_value); const auto third = numeric::map_into_sparse_form((uint8_t)(sbox_value ^ swizzled)); @@ -172,4 +173,5 @@ inline MultiTable get_aes_sbox_table(const MultiTableId id = AES_SBOX) } return table; } -} // namespace bb::plookup::aes128_tables +} // namespace aes128_tables +} // namespace plookup diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/blake2s.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/blake2s.hpp index 10a56396e6be..4cea760b45ec 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/blake2s.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/blake2s.hpp @@ -5,7 +5,8 @@ #include "sparse.hpp" #include "types.hpp" -namespace bb::plookup::blake2s_tables { +namespace plookup { +namespace blake2s_tables { static constexpr size_t BITS_IN_LAST_SLICE = 5UL; static constexpr size_t SIZE_OF_LAST_SLICE = (1UL << BITS_IN_LAST_SLICE); @@ -211,4 +212,5 @@ inline MultiTable get_blake2s_xor_rotate_7_table(const MultiTableId id = BLAKE_X return table; } -} // namespace bb::plookup::blake2s_tables +} // namespace blake2s_tables +} // namespace plookup diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/dummy.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/dummy.hpp index f49409c9bbc6..50ba5fa83f8e 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/dummy.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/dummy.hpp @@ -9,7 +9,8 @@ #include "types.hpp" -namespace bb::plookup::dummy_tables { +namespace plookup { +namespace dummy_tables { /** * @brief Lookup the value corresponding to a specific key @@ -92,4 +93,5 @@ inline MultiTable get_honk_dummy_multitable() table.get_table_values.emplace_back(&get_value_from_key); return table; } -} // namespace bb::plookup::dummy_tables \ No newline at end of file +} // namespace dummy_tables +} // namespace plookup \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/fixed_base/fixed_base.cpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/fixed_base/fixed_base.cpp index 6a470eb835c6..1309aafb5d56 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/fixed_base/fixed_base.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/fixed_base/fixed_base.cpp @@ -6,7 +6,7 @@ #include "barretenberg/numeric/bitop/pow.hpp" #include "barretenberg/numeric/bitop/rotate.hpp" #include "barretenberg/numeric/bitop/sparse_form.hpp" -namespace bb::plookup::fixed_base { +namespace plookup::fixed_base { /** * @brief Given a base_point [P] and an offset_generator [G], compute a lookup table of MAX_TABLE_SIZE that contains the @@ -287,4 +287,4 @@ const std::array table::generate_generator_offset(rhs_base_point_hi), }; -} // namespace bb::plookup::fixed_base \ No newline at end of file +} // namespace plookup::fixed_base \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/fixed_base/fixed_base.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/fixed_base/fixed_base.hpp index 11922a0433d4..d147b3e90746 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/fixed_base/fixed_base.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/fixed_base/fixed_base.hpp @@ -6,7 +6,7 @@ #include "barretenberg/crypto/pedersen_hash/pedersen.hpp" #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" -namespace bb::plookup::fixed_base { +namespace plookup::fixed_base { /** * @brief Generates plookup tables required to perform fixed-base scalar multiplication over a fixed number of points. @@ -84,4 +84,4 @@ class table : public FixedBaseParams { } }; -} // namespace bb::plookup::fixed_base +} // namespace plookup::fixed_base diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/fixed_base/fixed_base_params.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/fixed_base/fixed_base_params.hpp index 94f7a7d9414b..45570b50f23d 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/fixed_base/fixed_base_params.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/fixed_base/fixed_base_params.hpp @@ -6,7 +6,7 @@ #include #include -namespace bb::plookup { +namespace plookup { /** * @brief Parameters definitions for our fixed-base-scalar-multiplication lookup tables * @@ -73,4 +73,4 @@ struct FixedBaseParams { return MULTI_TABLE_BIT_LENGTHS[multitable_index]; } }; -} // namespace bb::plookup \ No newline at end of file +} // namespace plookup \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_chi.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_chi.hpp index 0e5b4a8a5c38..f1a75bd31504 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_chi.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_chi.hpp @@ -4,7 +4,8 @@ #include "barretenberg/common/constexpr_utils.hpp" #include "barretenberg/numeric/bitop/pow.hpp" -namespace bb::plookup::keccak_tables { +namespace plookup { +namespace keccak_tables { /** * @brief Generates plookup tables required for CHI round of Keccak hash function @@ -248,4 +249,5 @@ class Chi { return table; } }; -} // namespace bb::plookup::keccak_tables +} // namespace keccak_tables +} // namespace plookup diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_input.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_input.hpp index c3b6d20ae980..8fdc116f99fb 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_input.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_input.hpp @@ -5,7 +5,8 @@ #include "barretenberg/numeric/bitop/pow.hpp" #include "barretenberg/numeric/bitop/sparse_form.hpp" -namespace bb::plookup::keccak_tables { +namespace plookup { +namespace keccak_tables { /** * @brief Generates plookup tables used convert 64-bit integers into a sparse representation used for Keccak hash @@ -139,4 +140,5 @@ class KeccakInput { } }; -} // namespace bb::plookup::keccak_tables +} // namespace keccak_tables +} // namespace plookup diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_output.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_output.hpp index 53f2fc9a53f0..6c5d57429b88 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_output.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_output.hpp @@ -7,7 +7,8 @@ #include "../sparse.hpp" #include "../types.hpp" -namespace bb::plookup::keccak_tables { +namespace plookup { +namespace keccak_tables { /** * @brief Converts a base-11 sparse integer representation into a regular base-2 binary integer. @@ -170,4 +171,5 @@ class KeccakOutput { } }; -} // namespace bb::plookup::keccak_tables +} // namespace keccak_tables +} // namespace plookup diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_rho.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_rho.hpp index c16085aca8a0..96dd0f99ff68 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_rho.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_rho.hpp @@ -4,7 +4,8 @@ #include "barretenberg/common/constexpr_utils.hpp" #include "barretenberg/numeric/bitop/pow.hpp" -namespace bb::plookup::keccak_tables { +namespace plookup { +namespace keccak_tables { /** * @brief Generate the plookup tables used for the RHO round of the Keccak hash algorithm @@ -291,4 +292,5 @@ template class Rho { } }; -} // namespace bb::plookup::keccak_tables +} // namespace keccak_tables +} // namespace plookup diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_theta.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_theta.hpp index 9f05cf94267a..c9137f0b3dcc 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_theta.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_theta.hpp @@ -4,7 +4,8 @@ #include "barretenberg/common/constexpr_utils.hpp" #include "barretenberg/numeric/bitop/pow.hpp" -namespace bb::plookup::keccak_tables { +namespace plookup { +namespace keccak_tables { /** * @brief Generates plookup tables required for THETA round of Keccak hash function @@ -250,4 +251,5 @@ class Theta { return table; } }; -} // namespace bb::plookup::keccak_tables +} // namespace keccak_tables +} // namespace plookup diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/non_native_group_generator.cpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/non_native_group_generator.cpp index ed172573e24c..3e12005d314c 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/non_native_group_generator.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/non_native_group_generator.cpp @@ -1,6 +1,7 @@ #include "non_native_group_generator.hpp" -namespace bb::plookup::ecc_generator_tables { +namespace plookup { +namespace ecc_generator_tables { /** * Init 8-bit generator lookup tables @@ -487,4 +488,5 @@ MultiTable ecc_generator_table::get_xyprime_endo_table(const MultiTableId id template class ecc_generator_table; template class ecc_generator_table; -} // namespace bb::plookup::ecc_generator_tables \ No newline at end of file +} // namespace ecc_generator_tables +} // namespace plookup \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/non_native_group_generator.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/non_native_group_generator.hpp index b57e9247e651..16fd12a8686d 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/non_native_group_generator.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/non_native_group_generator.hpp @@ -6,7 +6,8 @@ #include "barretenberg/ecc/curves/secp256k1/secp256k1.hpp" #include -namespace bb::plookup::ecc_generator_tables { +namespace plookup { +namespace ecc_generator_tables { template class ecc_generator_table { public: @@ -55,4 +56,5 @@ template class ecc_generator_table { static MultiTable get_xyprime_endo_table(const MultiTableId id, const BasicTableId basic_id); }; -} // namespace bb::plookup::ecc_generator_tables +} // namespace ecc_generator_tables +} // namespace plookup diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/plookup_tables.cpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/plookup_tables.cpp index 6a2257bf1029..c8f1f83de007 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/plookup_tables.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/plookup_tables.cpp @@ -1,7 +1,7 @@ #include "plookup_tables.hpp" #include "barretenberg/common/constexpr_utils.hpp" -namespace bb::plookup { +namespace plookup { using namespace bb; @@ -201,4 +201,4 @@ ReadData get_lookup_accumulators(const MultiTableId id, return lookup; } -} // namespace bb::plookup +} // namespace plookup diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/plookup_tables.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/plookup_tables.hpp index 492793150d3b..b4fcaeac1a18 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/plookup_tables.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/plookup_tables.hpp @@ -16,7 +16,7 @@ #include "types.hpp" #include "uint.hpp" -namespace bb::plookup { +namespace plookup { const MultiTable& create_table(MultiTableId id); @@ -213,4 +213,4 @@ inline BasicTable create_basic_table(const BasicTableId id, const size_t index) } } } -} // namespace bb::plookup +} // namespace plookup diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/sha256.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/sha256.hpp index 02465bc15d83..31316ae56d73 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/sha256.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/sha256.hpp @@ -8,7 +8,8 @@ #include "sparse.hpp" #include "types.hpp" -namespace bb::plookup::sha256_tables { +namespace plookup { +namespace sha256_tables { static constexpr uint64_t choose_normalization_table[28]{ /* xor result = 0 */ @@ -389,4 +390,5 @@ inline MultiTable get_majority_input_table(const MultiTableId id = SHA256_MAJ_IN return table; } -} // namespace bb::plookup::sha256_tables +} // namespace sha256_tables +} // namespace plookup diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/sparse.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/sparse.hpp index 35c858e30a3d..5664c8cb4fa2 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/sparse.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/sparse.hpp @@ -7,7 +7,8 @@ #include "barretenberg/numeric/bitop/rotate.hpp" #include "barretenberg/numeric/bitop/sparse_form.hpp" -namespace bb::plookup::sparse_tables { +namespace plookup { +namespace sparse_tables { template inline std::array get_sparse_table_with_rotation_values(const std::array key) @@ -114,4 +115,5 @@ inline BasicTable generate_sparse_normalization_table(BasicTableId id, const siz table.column_3_step_size = bb::fr(0); return table; } -} // namespace bb::plookup::sparse_tables +} // namespace sparse_tables +} // namespace plookup diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/types.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/types.hpp index 489d9e600716..181844ea163e 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/types.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/types.hpp @@ -6,7 +6,7 @@ #include "./fixed_base/fixed_base_params.hpp" #include "barretenberg/ecc/curves/bn254/fr.hpp" -namespace bb::plookup { +namespace plookup { enum BasicTableId { XOR, @@ -325,4 +325,4 @@ template class ReadData { std::array, 3> columns; }; -} // namespace bb::plookup +} // namespace plookup diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/uint.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/uint.hpp index 1ccfecdd2a5b..dcf02fe79f7e 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/uint.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/uint.hpp @@ -4,7 +4,8 @@ #include "barretenberg/numeric/bitop/rotate.hpp" -namespace bb::plookup::uint_tables { +namespace plookup { +namespace uint_tables { template inline std::array get_xor_rotate_values_from_key(const std::array key) @@ -102,4 +103,5 @@ inline MultiTable get_uint32_and_table(const MultiTableId id = UINT32_AND) return table; } -} // namespace bb::plookup::uint_tables +} // namespace uint_tables +} // namespace plookup diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/combiner.test.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/combiner.test.cpp index 132ba6144987..c1367e624141 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/combiner.test.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/combiner.test.cpp @@ -6,12 +6,13 @@ #include "barretenberg/sumcheck/instance/instances.hpp" #include -using namespace bb; using namespace bb::honk; - -using Flavor = honk::flavor::Ultra; +namespace bb::test_protogalaxy_prover { +using Flavor = bb::honk::flavor::Ultra; using Polynomial = typename Flavor::Polynomial; using FF = typename Flavor::FF; +using RelationParameters = bb::RelationParameters; +using PowPolynomial = bb::PowPolynomial; // TODO(https://github.com/AztecProtocol/barretenberg/issues/780): Improve combiner tests to check more than the // arithmetic relation so we more than unit test folding relation parameters and alpha as well. @@ -42,7 +43,7 @@ TEST(Protogalaxy, CombinerOn2Instances) for (size_t idx = 0; idx < NUM_INSTANCES; idx++) { auto instance = std::make_shared(); - auto prover_polynomials = honk::get_sequential_prover_polynomials( + auto prover_polynomials = bb::honk::get_sequential_prover_polynomials( /*log_circuit_size=*/1, idx * 128); restrict_to_standard_arithmetic_relation(prover_polynomials); instance->prover_polynomials = std::move(prover_polynomials); @@ -51,22 +52,22 @@ TEST(Protogalaxy, CombinerOn2Instances) } ProverInstances instances{ instance_data }; - instances.alphas.fill(bb::Univariate(FF(0))); // focus on the arithmetic relation only + instances.alphas.fill(Univariate(FF(0))); // focus on the arithmetic relation only auto pow_polynomial = PowPolynomial(std::vector{ 2 }); auto result = prover.compute_combiner(instances, pow_polynomial); - auto expected_result = Univariate(std::array{ 87706, - 13644570, - 76451738, - 226257946, - static_cast(500811930), - static_cast(937862426), - static_cast(1575158170), - static_cast(2450447898), - static_cast(3601480346), - static_cast(5066004250), - static_cast(6881768346), - static_cast(9086521370), - static_cast(11718012058) }); + auto expected_result = bb::Univariate(std::array{ 87706, + 13644570, + 76451738, + 226257946, + static_cast(500811930), + static_cast(937862426), + static_cast(1575158170), + static_cast(2450447898), + static_cast(3601480346), + static_cast(5066004250), + static_cast(6881768346), + static_cast(9086521370), + static_cast(11718012058) }); EXPECT_EQ(result, expected_result); } else { std::vector> instance_data(NUM_INSTANCES); @@ -74,7 +75,7 @@ TEST(Protogalaxy, CombinerOn2Instances) for (size_t idx = 0; idx < NUM_INSTANCES; idx++) { auto instance = std::make_shared(); - auto prover_polynomials = honk::get_zero_prover_polynomials( + auto prover_polynomials = bb::honk::get_zero_prover_polynomials( /*log_circuit_size=*/1); restrict_to_standard_arithmetic_relation(prover_polynomials); instance->prover_polynomials = std::move(prover_polynomials); @@ -83,7 +84,7 @@ TEST(Protogalaxy, CombinerOn2Instances) } ProverInstances instances{ instance_data }; - instances.alphas.fill(bb::Univariate(FF(0))); // focus on the arithmetic relation only + instances.alphas.fill(Univariate(FF(0))); // focus on the arithmetic relation only const auto create_add_gate = [](auto& polys, const size_t idx, FF w_l, FF w_r) { polys.w_l[idx] = w_l; @@ -132,7 +133,7 @@ TEST(Protogalaxy, CombinerOn2Instances) auto pow_polynomial = PowPolynomial(std::vector{ 2 }); auto result = prover.compute_combiner(instances, pow_polynomial); auto expected_result = - Univariate(std::array{ 0, 0, 12, 36, 72, 120, 180, 252, 336, 432, 540, 660, 792 }); + bb::Univariate(std::array{ 0, 0, 12, 36, 72, 120, 180, 252, 336, 432, 540, 660, 792 }); EXPECT_EQ(result, expected_result); } @@ -165,7 +166,7 @@ TEST(Protogalaxy, CombinerOn4Instances) for (size_t idx = 0; idx < NUM_INSTANCES; idx++) { auto instance = std::make_shared(); - auto prover_polynomials = honk::get_zero_prover_polynomials( + auto prover_polynomials = bb::honk::get_zero_prover_polynomials( /*log_circuit_size=*/1); instance->prover_polynomials = std::move(prover_polynomials); instance->instance_size = 2; @@ -173,7 +174,7 @@ TEST(Protogalaxy, CombinerOn4Instances) } ProverInstances instances{ instance_data }; - instances.alphas.fill(bb::Univariate(FF(0))); // focus on the arithmetic relation only + instances.alphas.fill(Univariate(FF(0))); // focus on the arithmetic relation only zero_all_selectors(instances[0]->prover_polynomials); zero_all_selectors(instances[1]->prover_polynomials); @@ -184,8 +185,10 @@ TEST(Protogalaxy, CombinerOn4Instances) auto result = prover.compute_combiner(instances, pow_polynomial); std::array zeroes; std::fill(zeroes.begin(), zeroes.end(), 0); - auto expected_result = Univariate(zeroes); + auto expected_result = bb::Univariate(zeroes); EXPECT_EQ(result, expected_result); }; run_test(); }; + +} // namespace bb::test_protogalaxy_prover \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp index 6a138c51a516..ca78b8706045 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp @@ -269,10 +269,14 @@ std::shared_ptr ProtoGalaxyProver_ FoldingResult ProtoGalaxyProver_::fold_instances() { prepare_for_folding(); + + // TODO(#https://github.com/AztecProtocol/barretenberg/issues/740): Handle the case where we are folding for the + // first time and accumulator is 0 FF delta = transcript->get_challenge("delta"); auto accumulator = get_accumulator(); diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp index bf7d4c50117c..0e33b27cd77d 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp @@ -6,20 +6,17 @@ template void ProtoGalaxyVerifier_::receive_accumulator(const std::shared_ptr& inst, const std::string& domain_separator) { - // Get circuit parameters inst->instance_size = transcript->template receive_from_prover(domain_separator + "_instance_size"); inst->log_instance_size = static_cast(numeric::get_msb(inst->instance_size)); inst->public_input_size = transcript->template receive_from_prover(domain_separator + "_public_input_size"); - // Get folded public inputs for (size_t i = 0; i < inst->public_input_size; ++i) { auto public_input_i = transcript->template receive_from_prover(domain_separator + "_public_input_" + std::to_string(i)); inst->public_inputs.emplace_back(public_input_i); } - // Get folded relation parameters auto eta = transcript->template receive_from_prover(domain_separator + "_eta"); auto beta = transcript->template receive_from_prover(domain_separator + "_beta"); auto gamma = transcript->template receive_from_prover(domain_separator + "_gamma"); @@ -29,7 +26,6 @@ void ProtoGalaxyVerifier_::receive_accumulator(const std::sha inst->relation_parameters = RelationParameters{ eta, beta, gamma, public_input_delta, lookup_grand_product_delta }; - // Get the folded relation separator challenges \vec{α} for (size_t idx = 0; idx < NUM_SUBRELATIONS - 1; idx++) { inst->alphas[idx] = transcript->template receive_from_prover(domain_separator + "_alpha_" + std::to_string(idx)); @@ -37,14 +33,11 @@ void ProtoGalaxyVerifier_::receive_accumulator(const std::sha inst->target_sum = transcript->template receive_from_prover(domain_separator + "_target_sum"); - // Get the folded gate challenges, \vec{β} in the paper inst->gate_challenges = std::vector(inst->log_instance_size); for (size_t idx = 0; idx < inst->log_instance_size; idx++) { inst->gate_challenges[idx] = transcript->template receive_from_prover(domain_separator + "_gate_challenge_" + std::to_string(idx)); } - - // Get the folded commitments to all witness polynomials auto comm_view = inst->witness_commitments.get_all(); auto witness_labels = inst->commitment_labels.get_witness(); for (size_t idx = 0; idx < witness_labels.size(); idx++) { @@ -52,7 +45,6 @@ void ProtoGalaxyVerifier_::receive_accumulator(const std::sha transcript->template receive_from_prover(domain_separator + "_" + witness_labels[idx]); } - // Get the folded commitments to selector polynomials inst->verification_key = std::make_shared(inst->instance_size, inst->public_input_size); auto vk_view = inst->verification_key->get_all(); auto vk_labels = inst->commitment_labels.get_precomputed(); @@ -65,7 +57,6 @@ template void ProtoGalaxyVerifier_::receive_and_finalise_instance(const std::shared_ptr& inst, const std::string& domain_separator) { - // Get circuit parameters and the public inputs inst->instance_size = transcript->template receive_from_prover(domain_separator + "_instance_size"); inst->log_instance_size = static_cast(numeric::get_msb(inst->instance_size)); inst->public_input_size = @@ -80,39 +71,33 @@ void ProtoGalaxyVerifier_::receive_and_finalise_instance(cons inst->pub_inputs_offset = transcript->template receive_from_prover(domain_separator + "_pub_inputs_offset"); - // Get commitments to first three wire polynomials auto labels = inst->commitment_labels; auto& witness_commitments = inst->witness_commitments; witness_commitments.w_l = transcript->template receive_from_prover(domain_separator + "_" + labels.w_l); witness_commitments.w_r = transcript->template receive_from_prover(domain_separator + "_" + labels.w_r); witness_commitments.w_o = transcript->template receive_from_prover(domain_separator + "_" + labels.w_o); - // Get challenge for sorted list batching and wire four memory records commitment auto eta = transcript->get_challenge(domain_separator + "_eta"); witness_commitments.sorted_accum = transcript->template receive_from_prover(domain_separator + "_" + labels.sorted_accum); witness_commitments.w_4 = transcript->template receive_from_prover(domain_separator + "_" + labels.w_4); - // Get permutation challenges and commitment to permutation and lookup grand products auto [beta, gamma] = transcript->get_challenges(domain_separator + "_beta", domain_separator + "_gamma"); witness_commitments.z_perm = transcript->template receive_from_prover(domain_separator + "_" + labels.z_perm); witness_commitments.z_lookup = transcript->template receive_from_prover(domain_separator + "_" + labels.z_lookup); - // Compute correction terms for grand products const FF public_input_delta = compute_public_input_delta( inst->public_inputs, beta, gamma, inst->instance_size, inst->pub_inputs_offset); const FF lookup_grand_product_delta = compute_lookup_grand_product_delta(beta, gamma, inst->instance_size); inst->relation_parameters = RelationParameters{ eta, beta, gamma, public_input_delta, lookup_grand_product_delta }; - // Get the relation separation challenges for (size_t idx = 0; idx < NUM_SUBRELATIONS - 1; idx++) { inst->alphas[idx] = transcript->get_challenge(domain_separator + "_alpha_" + std::to_string(idx)); } - // Get the commitments to the selector polynomials for the given instance inst->verification_key = std::make_shared(inst->instance_size, inst->public_input_size); auto vk_view = inst->verification_key->get_all(); auto vk_labels = labels.get_precomputed(); diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/AvmMini/alu_chip.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/AvmMini/alu_chip.hpp deleted file mode 100644 index c1cd8a6e9703..000000000000 --- a/barretenberg/cpp/src/barretenberg/relations/generated/AvmMini/alu_chip.hpp +++ /dev/null @@ -1,280 +0,0 @@ - -#pragma once -#include "../../relation_parameters.hpp" -#include "../../relation_types.hpp" -#include "./declare_views.hpp" - -namespace bb::AvmMini_vm { - -template struct Alu_chipRow { - FF aluChip_alu_u16_r0{}; - FF aluChip_alu_u16_r3{}; - FF aluChip_alu_u16_r5{}; - FF aluChip_alu_u16_r1_shift{}; - FF aluChip_alu_u16_r0_shift{}; - FF aluChip_alu_op_add{}; - FF aluChip_alu_ia{}; - FF aluChip_alu_u16_r4_shift{}; - FF aluChip_alu_ib{}; - FF aluChip_alu_u16_r7{}; - FF aluChip_alu_u8_r0{}; - FF aluChip_alu_u16_r7_shift{}; - FF aluChip_alu_op_sub{}; - FF aluChip_alu_u16_r6{}; - FF aluChip_alu_u16_r5_shift{}; - FF aluChip_alu_op_mul{}; - FF aluChip_alu_u64_tag{}; - FF aluChip_alu_u16_r2_shift{}; - FF aluChip_alu_u64_r0{}; - FF aluChip_alu_ff_tag{}; - FF aluChip_alu_u32_tag{}; - FF aluChip_alu_u16_tag{}; - FF aluChip_alu_u16_r4{}; - FF aluChip_alu_u16_r6_shift{}; - FF aluChip_alu_u16_r2{}; - FF aluChip_alu_ic{}; - FF aluChip_alu_u8_tag{}; - FF aluChip_alu_cf{}; - FF aluChip_alu_u16_r3_shift{}; - FF aluChip_alu_u8_r1{}; - FF aluChip_alu_u16_r1{}; - FF aluChip_alu_u128_tag{}; -}; - -inline std::string get_relation_label_alu_chip(int index) -{ - switch (index) { - case 9: - return "ALU_MUL_COMMON_1"; - - case 8: - return "ALU_MULTIPLICATION_FF"; - - case 6: - return "ALU_ADD_SUB_1"; - - case 7: - return "ALU_ADD_SUB_2"; - - case 10: - return "ALU_MUL_COMMON_2"; - - case 13: - return "ALU_MULTIPLICATION_OUT_U128"; - } - return std::to_string(index); -} - -template class alu_chipImpl { - public: - using FF = FF_; - - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 3, 3, 3, 3, 3, 3, 4, 5, 5, 5, 5, 6, 6, 8, - }; - - template - void static accumulate(ContainerOverSubrelations& evals, - const AllEntities& new_term, - [[maybe_unused]] const RelationParameters&, - [[maybe_unused]] const FF& scaling_factor) - { - - // Contribution 0 - { - AvmMini_DECLARE_VIEWS(0); - - auto tmp = (aluChip_alu_ff_tag * (-aluChip_alu_ff_tag + FF(1))); - tmp *= scaling_factor; - std::get<0>(evals) += tmp; - } - // Contribution 1 - { - AvmMini_DECLARE_VIEWS(1); - - auto tmp = (aluChip_alu_u8_tag * (-aluChip_alu_u8_tag + FF(1))); - tmp *= scaling_factor; - std::get<1>(evals) += tmp; - } - // Contribution 2 - { - AvmMini_DECLARE_VIEWS(2); - - auto tmp = (aluChip_alu_u16_tag * (-aluChip_alu_u16_tag + FF(1))); - tmp *= scaling_factor; - std::get<2>(evals) += tmp; - } - // Contribution 3 - { - AvmMini_DECLARE_VIEWS(3); - - auto tmp = (aluChip_alu_u32_tag * (-aluChip_alu_u32_tag + FF(1))); - tmp *= scaling_factor; - std::get<3>(evals) += tmp; - } - // Contribution 4 - { - AvmMini_DECLARE_VIEWS(4); - - auto tmp = (aluChip_alu_u64_tag * (-aluChip_alu_u64_tag + FF(1))); - tmp *= scaling_factor; - std::get<4>(evals) += tmp; - } - // Contribution 5 - { - AvmMini_DECLARE_VIEWS(5); - - auto tmp = (aluChip_alu_u128_tag * (-aluChip_alu_u128_tag + FF(1))); - tmp *= scaling_factor; - std::get<5>(evals) += tmp; - } - // Contribution 6 - { - AvmMini_DECLARE_VIEWS(6); - - auto tmp = - (((aluChip_alu_op_add + aluChip_alu_op_sub) * - ((((((((((aluChip_alu_u8_r0 + (aluChip_alu_u8_r1 * FF(256))) + (aluChip_alu_u16_r0 * FF(65536))) + - (aluChip_alu_u16_r1 * FF(4294967296UL))) + - (aluChip_alu_u16_r2 * FF(281474976710656UL))) + - (aluChip_alu_u16_r3 * FF(uint256_t{ 0, 1, 0, 0 }))) + - (aluChip_alu_u16_r4 * FF(uint256_t{ 0, 65536, 0, 0 }))) + - (aluChip_alu_u16_r5 * FF(uint256_t{ 0, 4294967296, 0, 0 }))) + - (aluChip_alu_u16_r6 * FF(uint256_t{ 0, 281474976710656, 0, 0 }))) - - aluChip_alu_ia) + - (aluChip_alu_ff_tag * aluChip_alu_ic))) + - ((aluChip_alu_op_add - aluChip_alu_op_sub) * - ((aluChip_alu_cf * FF(uint256_t{ 0, 0, 1, 0 })) - aluChip_alu_ib))); - tmp *= scaling_factor; - std::get<6>(evals) += tmp; - } - // Contribution 7 - { - AvmMini_DECLARE_VIEWS(7); - - auto tmp = - (((aluChip_alu_op_add + aluChip_alu_op_sub) * - (((((((aluChip_alu_u8_tag * aluChip_alu_u8_r0) + - (aluChip_alu_u16_tag * (aluChip_alu_u8_r0 + (aluChip_alu_u8_r1 * FF(256))))) + - (aluChip_alu_u32_tag * - ((aluChip_alu_u8_r0 + (aluChip_alu_u8_r1 * FF(256))) + (aluChip_alu_u16_r0 * FF(65536))))) + - (aluChip_alu_u64_tag * - ((((aluChip_alu_u8_r0 + (aluChip_alu_u8_r1 * FF(256))) + (aluChip_alu_u16_r0 * FF(65536))) + - (aluChip_alu_u16_r1 * FF(4294967296UL))) + - (aluChip_alu_u16_r2 * FF(281474976710656UL))))) + - (aluChip_alu_u128_tag * - ((((((((aluChip_alu_u8_r0 + (aluChip_alu_u8_r1 * FF(256))) + (aluChip_alu_u16_r0 * FF(65536))) + - (aluChip_alu_u16_r1 * FF(4294967296UL))) + - (aluChip_alu_u16_r2 * FF(281474976710656UL))) + - (aluChip_alu_u16_r3 * FF(uint256_t{ 0, 1, 0, 0 }))) + - (aluChip_alu_u16_r4 * FF(uint256_t{ 0, 65536, 0, 0 }))) + - (aluChip_alu_u16_r5 * FF(uint256_t{ 0, 4294967296, 0, 0 }))) + - (aluChip_alu_u16_r6 * FF(uint256_t{ 0, 281474976710656, 0, 0 }))))) + - (aluChip_alu_ff_tag * aluChip_alu_ia)) - - aluChip_alu_ic)) + - ((aluChip_alu_ff_tag * (aluChip_alu_op_add - aluChip_alu_op_sub)) * aluChip_alu_ib)); - tmp *= scaling_factor; - std::get<7>(evals) += tmp; - } - // Contribution 8 - { - AvmMini_DECLARE_VIEWS(8); - - auto tmp = - ((aluChip_alu_ff_tag * aluChip_alu_op_mul) * ((aluChip_alu_ia * aluChip_alu_ib) - aluChip_alu_ic)); - tmp *= scaling_factor; - std::get<8>(evals) += tmp; - } - // Contribution 9 - { - AvmMini_DECLARE_VIEWS(9); - - auto tmp = - ((((-aluChip_alu_ff_tag + FF(1)) - aluChip_alu_u128_tag) * aluChip_alu_op_mul) * - (((((((((aluChip_alu_u8_r0 + (aluChip_alu_u8_r1 * FF(256))) + (aluChip_alu_u16_r0 * FF(65536))) + - (aluChip_alu_u16_r1 * FF(4294967296UL))) + - (aluChip_alu_u16_r2 * FF(281474976710656UL))) + - (aluChip_alu_u16_r3 * FF(uint256_t{ 0, 1, 0, 0 }))) + - (aluChip_alu_u16_r4 * FF(uint256_t{ 0, 65536, 0, 0 }))) + - (aluChip_alu_u16_r5 * FF(uint256_t{ 0, 4294967296, 0, 0 }))) + - (aluChip_alu_u16_r6 * FF(uint256_t{ 0, 281474976710656, 0, 0 }))) - - (aluChip_alu_ia * aluChip_alu_ib))); - tmp *= scaling_factor; - std::get<9>(evals) += tmp; - } - // Contribution 10 - { - AvmMini_DECLARE_VIEWS(10); - - auto tmp = (aluChip_alu_op_mul * - (((((aluChip_alu_u8_tag * aluChip_alu_u8_r0) + - (aluChip_alu_u16_tag * (aluChip_alu_u8_r0 + (aluChip_alu_u8_r1 * FF(256))))) + - (aluChip_alu_u32_tag * - ((aluChip_alu_u8_r0 + (aluChip_alu_u8_r1 * FF(256))) + (aluChip_alu_u16_r0 * FF(65536))))) + - (aluChip_alu_u64_tag * - ((((aluChip_alu_u8_r0 + (aluChip_alu_u8_r1 * FF(256))) + (aluChip_alu_u16_r0 * FF(65536))) + - (aluChip_alu_u16_r1 * FF(4294967296UL))) + - (aluChip_alu_u16_r2 * FF(281474976710656UL))))) - - (((-aluChip_alu_ff_tag + FF(1)) - aluChip_alu_u128_tag) * aluChip_alu_ic))); - tmp *= scaling_factor; - std::get<10>(evals) += tmp; - } - // Contribution 11 - { - AvmMini_DECLARE_VIEWS(11); - - auto tmp = ((aluChip_alu_u128_tag * aluChip_alu_op_mul) * - (((((aluChip_alu_u16_r0 + (aluChip_alu_u16_r1 * FF(65536))) + - (aluChip_alu_u16_r2 * FF(4294967296UL))) + - (aluChip_alu_u16_r3 * FF(281474976710656UL))) + - ((((aluChip_alu_u16_r4 + (aluChip_alu_u16_r5 * FF(65536))) + - (aluChip_alu_u16_r6 * FF(4294967296UL))) + - (aluChip_alu_u16_r7 * FF(281474976710656UL))) * - FF(uint256_t{ 0, 1, 0, 0 }))) - - aluChip_alu_ia)); - tmp *= scaling_factor; - std::get<11>(evals) += tmp; - } - // Contribution 12 - { - AvmMini_DECLARE_VIEWS(12); - - auto tmp = ((aluChip_alu_u128_tag * aluChip_alu_op_mul) * - (((((aluChip_alu_u16_r0_shift + (aluChip_alu_u16_r1_shift * FF(65536))) + - (aluChip_alu_u16_r2_shift * FF(4294967296UL))) + - (aluChip_alu_u16_r3_shift * FF(281474976710656UL))) + - ((((aluChip_alu_u16_r4_shift + (aluChip_alu_u16_r5_shift * FF(65536))) + - (aluChip_alu_u16_r6_shift * FF(4294967296UL))) + - (aluChip_alu_u16_r7_shift * FF(281474976710656UL))) * - FF(uint256_t{ 0, 1, 0, 0 }))) - - aluChip_alu_ib)); - tmp *= scaling_factor; - std::get<12>(evals) += tmp; - } - // Contribution 13 - { - AvmMini_DECLARE_VIEWS(13); - - auto tmp = ((aluChip_alu_u128_tag * aluChip_alu_op_mul) * - ((((aluChip_alu_ia * (((aluChip_alu_u16_r0_shift + (aluChip_alu_u16_r1_shift * FF(65536))) + - (aluChip_alu_u16_r2_shift * FF(4294967296UL))) + - (aluChip_alu_u16_r3_shift * FF(281474976710656UL)))) + - (((((aluChip_alu_u16_r0 + (aluChip_alu_u16_r1 * FF(65536))) + - (aluChip_alu_u16_r2 * FF(4294967296UL))) + - (aluChip_alu_u16_r3 * FF(281474976710656UL))) * - (((aluChip_alu_u16_r4_shift + (aluChip_alu_u16_r5_shift * FF(65536))) + - (aluChip_alu_u16_r6_shift * FF(4294967296UL))) + - (aluChip_alu_u16_r7_shift * FF(281474976710656UL)))) * - FF(uint256_t{ 0, 1, 0, 0 }))) - - (((aluChip_alu_cf * FF(uint256_t{ 0, 1, 0, 0 })) + aluChip_alu_u64_r0) * - FF(uint256_t{ 0, 0, 1, 0 }))) - - aluChip_alu_ic)); - tmp *= scaling_factor; - std::get<13>(evals) += tmp; - } - } -}; - -template using alu_chip = Relation>; - -} // namespace bb::AvmMini_vm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/AvmMini/avm_mini.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/AvmMini/avm_mini.hpp index 3347e38ff96d..d78c623933c9 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/AvmMini/avm_mini.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/AvmMini/avm_mini.hpp @@ -7,61 +7,70 @@ namespace bb::AvmMini_vm { template struct Avm_miniRow { - FF avmMini_sel_op_sub{}; - FF avmMini_inv{}; - FF avmMini_first{}; - FF avmMini_tag_err{}; - FF avmMini_pc_shift{}; + FF avmMini_rwa{}; FF avmMini_mem_op_a{}; - FF avmMini_rwb{}; + FF avmMini_sel_op_mul{}; FF avmMini_mem_op_c{}; FF avmMini_internal_return_ptr_shift{}; - FF avmMini_rwc{}; FF avmMini_sel_op_div{}; + FF avmMini_rwb{}; + FF avmMini_pc_shift{}; FF avmMini_internal_return_ptr{}; - FF avmMini_pc{}; + FF avmMini_sel_internal_call{}; FF avmMini_ia{}; - FF avmMini_sel_op_mul{}; + FF avmMini_mem_idx_a{}; + FF avmMini_sel_op_add{}; FF avmMini_mem_op_b{}; + FF avmMini_inv{}; + FF avmMini_tag_err{}; + FF avmMini_op_err{}; FF avmMini_ib{}; + FF avmMini_pc{}; + FF avmMini_sel_internal_return{}; FF avmMini_sel_jump{}; + FF avmMini_rwc{}; + FF avmMini_first{}; FF avmMini_sel_halt{}; - FF avmMini_sel_internal_return{}; - FF avmMini_op_err{}; - FF avmMini_mem_idx_a{}; - FF avmMini_mem_idx_b{}; - FF avmMini_sel_internal_call{}; - FF avmMini_sel_op_add{}; - FF avmMini_rwa{}; FF avmMini_ic{}; + FF avmMini_mem_idx_b{}; + FF avmMini_sel_op_sub{}; }; inline std::string get_relation_label_avm_mini(int index) { switch (index) { - case 20: - return "SUBOP_DIVISION_ZERO_ERR1"; + case 19: + return "SUBOP_ADDITION_FF"; - case 22: - return "SUBOP_ERROR_RELEVANT_OP"; + case 21: + return "SUBOP_MULTIPLICATION_FF"; - case 30: + case 33: return "RETURN_POINTER_DECREMENT"; - case 36: + case 39: return "INTERNAL_RETURN_POINTER_CONSISTENCY"; - case 21: - return "SUBOP_DIVISION_ZERO_ERR2"; - - case 35: - return "PC_INCREMENT"; + case 27: + return "RETURN_POINTER_INCREMENT"; case 24: - return "RETURN_POINTER_INCREMENT"; + return "SUBOP_DIVISION_ZERO_ERR2"; - case 19: + case 20: + return "SUBOP_SUBTRACTION_FF"; + + case 22: return "SUBOP_DIVISION_FF"; + + case 25: + return "SUBOP_ERROR_RELEVANT_OP"; + + case 23: + return "SUBOP_DIVISION_ZERO_ERR1"; + + case 38: + return "PC_INCREMENT"; } return std::to_string(index); } @@ -70,8 +79,9 @@ template class avm_miniImpl { public: using FF = FF_; - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 3, + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 4, 5, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 3, }; template @@ -237,7 +247,7 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(19); - auto tmp = ((avmMini_sel_op_div * (-avmMini_op_err + FF(1))) * ((avmMini_ic * avmMini_ib) - avmMini_ia)); + auto tmp = (avmMini_sel_op_add * ((avmMini_ia + avmMini_ib) - avmMini_ic)); tmp *= scaling_factor; std::get<19>(evals) += tmp; } @@ -245,7 +255,7 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(20); - auto tmp = (avmMini_sel_op_div * (((avmMini_ib * avmMini_inv) - FF(1)) + avmMini_op_err)); + auto tmp = (avmMini_sel_op_sub * ((avmMini_ia - avmMini_ib) - avmMini_ic)); tmp *= scaling_factor; std::get<20>(evals) += tmp; } @@ -253,7 +263,7 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(21); - auto tmp = ((avmMini_sel_op_div * avmMini_op_err) * (-avmMini_inv + FF(1))); + auto tmp = (avmMini_sel_op_mul * ((avmMini_ia * avmMini_ib) - avmMini_ic)); tmp *= scaling_factor; std::get<21>(evals) += tmp; } @@ -261,7 +271,7 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(22); - auto tmp = (avmMini_op_err * (avmMini_sel_op_div - FF(1))); + auto tmp = ((avmMini_sel_op_div * (-avmMini_op_err + FF(1))) * ((avmMini_ic * avmMini_ib) - avmMini_ia)); tmp *= scaling_factor; std::get<22>(evals) += tmp; } @@ -269,7 +279,7 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(23); - auto tmp = (avmMini_sel_jump * (avmMini_pc_shift - avmMini_ia)); + auto tmp = (avmMini_sel_op_div * (((avmMini_ib * avmMini_inv) - FF(1)) + avmMini_op_err)); tmp *= scaling_factor; std::get<23>(evals) += tmp; } @@ -277,8 +287,7 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(24); - auto tmp = (avmMini_sel_internal_call * - (avmMini_internal_return_ptr_shift - (avmMini_internal_return_ptr + FF(1)))); + auto tmp = ((avmMini_sel_op_div * avmMini_op_err) * (-avmMini_inv + FF(1))); tmp *= scaling_factor; std::get<24>(evals) += tmp; } @@ -286,7 +295,7 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(25); - auto tmp = (avmMini_sel_internal_call * (avmMini_internal_return_ptr - avmMini_mem_idx_b)); + auto tmp = (avmMini_op_err * (avmMini_sel_op_div - FF(1))); tmp *= scaling_factor; std::get<25>(evals) += tmp; } @@ -294,7 +303,7 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(26); - auto tmp = (avmMini_sel_internal_call * (avmMini_pc_shift - avmMini_ia)); + auto tmp = (avmMini_sel_jump * (avmMini_pc_shift - avmMini_ia)); tmp *= scaling_factor; std::get<26>(evals) += tmp; } @@ -302,7 +311,8 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(27); - auto tmp = (avmMini_sel_internal_call * ((avmMini_pc + FF(1)) - avmMini_ib)); + auto tmp = (avmMini_sel_internal_call * + (avmMini_internal_return_ptr_shift - (avmMini_internal_return_ptr + FF(1)))); tmp *= scaling_factor; std::get<27>(evals) += tmp; } @@ -310,7 +320,7 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(28); - auto tmp = (avmMini_sel_internal_call * (avmMini_rwb - FF(1))); + auto tmp = (avmMini_sel_internal_call * (avmMini_internal_return_ptr - avmMini_mem_idx_b)); tmp *= scaling_factor; std::get<28>(evals) += tmp; } @@ -318,7 +328,7 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(29); - auto tmp = (avmMini_sel_internal_call * (avmMini_mem_op_b - FF(1))); + auto tmp = (avmMini_sel_internal_call * (avmMini_pc_shift - avmMini_ia)); tmp *= scaling_factor; std::get<29>(evals) += tmp; } @@ -326,8 +336,7 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(30); - auto tmp = (avmMini_sel_internal_return * - (avmMini_internal_return_ptr_shift - (avmMini_internal_return_ptr - FF(1)))); + auto tmp = (avmMini_sel_internal_call * ((avmMini_pc + FF(1)) - avmMini_ib)); tmp *= scaling_factor; std::get<30>(evals) += tmp; } @@ -335,7 +344,7 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(31); - auto tmp = (avmMini_sel_internal_return * ((avmMini_internal_return_ptr - FF(1)) - avmMini_mem_idx_a)); + auto tmp = (avmMini_sel_internal_call * (avmMini_rwb - FF(1))); tmp *= scaling_factor; std::get<31>(evals) += tmp; } @@ -343,7 +352,7 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(32); - auto tmp = (avmMini_sel_internal_return * (avmMini_pc_shift - avmMini_ia)); + auto tmp = (avmMini_sel_internal_call * (avmMini_mem_op_b - FF(1))); tmp *= scaling_factor; std::get<32>(evals) += tmp; } @@ -351,7 +360,8 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(33); - auto tmp = (avmMini_sel_internal_return * avmMini_rwa); + auto tmp = (avmMini_sel_internal_return * + (avmMini_internal_return_ptr_shift - (avmMini_internal_return_ptr - FF(1)))); tmp *= scaling_factor; std::get<33>(evals) += tmp; } @@ -359,7 +369,7 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(34); - auto tmp = (avmMini_sel_internal_return * (avmMini_mem_op_a - FF(1))); + auto tmp = (avmMini_sel_internal_return * ((avmMini_internal_return_ptr - FF(1)) - avmMini_mem_idx_a)); tmp *= scaling_factor; std::get<34>(evals) += tmp; } @@ -367,9 +377,7 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(35); - auto tmp = ((((-avmMini_first + FF(1)) * (-avmMini_sel_halt + FF(1))) * - (((avmMini_sel_op_add + avmMini_sel_op_sub) + avmMini_sel_op_div) + avmMini_sel_op_mul)) * - (avmMini_pc_shift - (avmMini_pc + FF(1)))); + auto tmp = (avmMini_sel_internal_return * (avmMini_pc_shift - avmMini_ia)); tmp *= scaling_factor; std::get<35>(evals) += tmp; } @@ -377,12 +385,38 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(36); + auto tmp = (avmMini_sel_internal_return * avmMini_rwa); + tmp *= scaling_factor; + std::get<36>(evals) += tmp; + } + // Contribution 37 + { + AvmMini_DECLARE_VIEWS(37); + + auto tmp = (avmMini_sel_internal_return * (avmMini_mem_op_a - FF(1))); + tmp *= scaling_factor; + std::get<37>(evals) += tmp; + } + // Contribution 38 + { + AvmMini_DECLARE_VIEWS(38); + + auto tmp = ((((-avmMini_first + FF(1)) * (-avmMini_sel_halt + FF(1))) * + (((avmMini_sel_op_add + avmMini_sel_op_sub) + avmMini_sel_op_div) + avmMini_sel_op_mul)) * + (avmMini_pc_shift - (avmMini_pc + FF(1)))); + tmp *= scaling_factor; + std::get<38>(evals) += tmp; + } + // Contribution 39 + { + AvmMini_DECLARE_VIEWS(39); + auto tmp = ((-(((avmMini_first + avmMini_sel_internal_call) + avmMini_sel_internal_return) + avmMini_sel_halt) + FF(1)) * (avmMini_internal_return_ptr_shift - avmMini_internal_return_ptr)); tmp *= scaling_factor; - std::get<36>(evals) += tmp; + std::get<39>(evals) += tmp; } } }; diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/AvmMini/declare_views.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/AvmMini/declare_views.hpp index 1b036e259194..bf4df9cb83e5 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/AvmMini/declare_views.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/AvmMini/declare_views.hpp @@ -15,32 +15,6 @@ [[maybe_unused]] auto memTrace_m_in_tag = View(new_term.memTrace_m_in_tag); \ [[maybe_unused]] auto memTrace_m_tag_err = View(new_term.memTrace_m_tag_err); \ [[maybe_unused]] auto memTrace_m_one_min_inv = View(new_term.memTrace_m_one_min_inv); \ - [[maybe_unused]] auto aluChip_alu_clk = View(new_term.aluChip_alu_clk); \ - [[maybe_unused]] auto aluChip_alu_ia = View(new_term.aluChip_alu_ia); \ - [[maybe_unused]] auto aluChip_alu_ib = View(new_term.aluChip_alu_ib); \ - [[maybe_unused]] auto aluChip_alu_ic = View(new_term.aluChip_alu_ic); \ - [[maybe_unused]] auto aluChip_alu_op_add = View(new_term.aluChip_alu_op_add); \ - [[maybe_unused]] auto aluChip_alu_op_sub = View(new_term.aluChip_alu_op_sub); \ - [[maybe_unused]] auto aluChip_alu_op_mul = View(new_term.aluChip_alu_op_mul); \ - [[maybe_unused]] auto aluChip_alu_op_div = View(new_term.aluChip_alu_op_div); \ - [[maybe_unused]] auto aluChip_alu_ff_tag = View(new_term.aluChip_alu_ff_tag); \ - [[maybe_unused]] auto aluChip_alu_u8_tag = View(new_term.aluChip_alu_u8_tag); \ - [[maybe_unused]] auto aluChip_alu_u16_tag = View(new_term.aluChip_alu_u16_tag); \ - [[maybe_unused]] auto aluChip_alu_u32_tag = View(new_term.aluChip_alu_u32_tag); \ - [[maybe_unused]] auto aluChip_alu_u64_tag = View(new_term.aluChip_alu_u64_tag); \ - [[maybe_unused]] auto aluChip_alu_u128_tag = View(new_term.aluChip_alu_u128_tag); \ - [[maybe_unused]] auto aluChip_alu_u8_r0 = View(new_term.aluChip_alu_u8_r0); \ - [[maybe_unused]] auto aluChip_alu_u8_r1 = View(new_term.aluChip_alu_u8_r1); \ - [[maybe_unused]] auto aluChip_alu_u16_r0 = View(new_term.aluChip_alu_u16_r0); \ - [[maybe_unused]] auto aluChip_alu_u16_r1 = View(new_term.aluChip_alu_u16_r1); \ - [[maybe_unused]] auto aluChip_alu_u16_r2 = View(new_term.aluChip_alu_u16_r2); \ - [[maybe_unused]] auto aluChip_alu_u16_r3 = View(new_term.aluChip_alu_u16_r3); \ - [[maybe_unused]] auto aluChip_alu_u16_r4 = View(new_term.aluChip_alu_u16_r4); \ - [[maybe_unused]] auto aluChip_alu_u16_r5 = View(new_term.aluChip_alu_u16_r5); \ - [[maybe_unused]] auto aluChip_alu_u16_r6 = View(new_term.aluChip_alu_u16_r6); \ - [[maybe_unused]] auto aluChip_alu_u16_r7 = View(new_term.aluChip_alu_u16_r7); \ - [[maybe_unused]] auto aluChip_alu_u64_r0 = View(new_term.aluChip_alu_u64_r0); \ - [[maybe_unused]] auto aluChip_alu_cf = View(new_term.aluChip_alu_cf); \ [[maybe_unused]] auto avmMini_pc = View(new_term.avmMini_pc); \ [[maybe_unused]] auto avmMini_internal_return_ptr = View(new_term.avmMini_internal_return_ptr); \ [[maybe_unused]] auto avmMini_sel_internal_call = View(new_term.avmMini_sel_internal_call); \ @@ -68,17 +42,9 @@ [[maybe_unused]] auto avmMini_mem_idx_b = View(new_term.avmMini_mem_idx_b); \ [[maybe_unused]] auto avmMini_mem_idx_c = View(new_term.avmMini_mem_idx_c); \ [[maybe_unused]] auto avmMini_last = View(new_term.avmMini_last); \ - [[maybe_unused]] auto aluChip_alu_u16_r1_shift = View(new_term.aluChip_alu_u16_r1_shift); \ - [[maybe_unused]] auto aluChip_alu_u16_r0_shift = View(new_term.aluChip_alu_u16_r0_shift); \ - [[maybe_unused]] auto aluChip_alu_u16_r4_shift = View(new_term.aluChip_alu_u16_r4_shift); \ - [[maybe_unused]] auto aluChip_alu_u16_r7_shift = View(new_term.aluChip_alu_u16_r7_shift); \ - [[maybe_unused]] auto aluChip_alu_u16_r5_shift = View(new_term.aluChip_alu_u16_r5_shift); \ - [[maybe_unused]] auto aluChip_alu_u16_r2_shift = View(new_term.aluChip_alu_u16_r2_shift); \ - [[maybe_unused]] auto aluChip_alu_u16_r6_shift = View(new_term.aluChip_alu_u16_r6_shift); \ - [[maybe_unused]] auto aluChip_alu_u16_r3_shift = View(new_term.aluChip_alu_u16_r3_shift); \ - [[maybe_unused]] auto avmMini_pc_shift = View(new_term.avmMini_pc_shift); \ - [[maybe_unused]] auto avmMini_internal_return_ptr_shift = View(new_term.avmMini_internal_return_ptr_shift); \ + [[maybe_unused]] auto memTrace_m_rw_shift = View(new_term.memTrace_m_rw_shift); \ [[maybe_unused]] auto memTrace_m_tag_shift = View(new_term.memTrace_m_tag_shift); \ [[maybe_unused]] auto memTrace_m_addr_shift = View(new_term.memTrace_m_addr_shift); \ [[maybe_unused]] auto memTrace_m_val_shift = View(new_term.memTrace_m_val_shift); \ - [[maybe_unused]] auto memTrace_m_rw_shift = View(new_term.memTrace_m_rw_shift); + [[maybe_unused]] auto avmMini_internal_return_ptr_shift = View(new_term.avmMini_internal_return_ptr_shift); \ + [[maybe_unused]] auto avmMini_pc_shift = View(new_term.avmMini_pc_shift); diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/AvmMini/mem_trace.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/AvmMini/mem_trace.hpp index 49cc8062e820..abb9e8539782 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/AvmMini/mem_trace.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/AvmMini/mem_trace.hpp @@ -8,18 +8,18 @@ namespace bb::AvmMini_vm { template struct Mem_traceRow { FF memTrace_m_val{}; - FF memTrace_m_last{}; + FF memTrace_m_lastAccess{}; + FF memTrace_m_tag_err{}; + FF memTrace_m_rw_shift{}; FF memTrace_m_in_tag{}; - FF memTrace_m_tag{}; FF memTrace_m_rw{}; FF memTrace_m_tag_shift{}; + FF memTrace_m_last{}; FF memTrace_m_addr_shift{}; - FF memTrace_m_tag_err{}; + FF memTrace_m_tag{}; FF memTrace_m_one_min_inv{}; FF memTrace_m_val_shift{}; - FF memTrace_m_lastAccess{}; FF memTrace_m_addr{}; - FF memTrace_m_rw_shift{}; }; inline std::string get_relation_label_mem_trace(int index) @@ -28,8 +28,11 @@ inline std::string get_relation_label_mem_trace(int index) case 8: return "MEM_IN_TAG_CONSISTENCY_1"; - case 9: - return "MEM_IN_TAG_CONSISTENCY_2"; + case 7: + return "MEM_ZERO_INIT"; + + case 6: + return "MEM_READ_WRITE_TAG_CONSISTENCY"; case 5: return "MEM_READ_WRITE_VAL_CONSISTENCY"; @@ -37,11 +40,8 @@ inline std::string get_relation_label_mem_trace(int index) case 4: return "MEM_LAST_ACCESS_DELIMITER"; - case 6: - return "MEM_READ_WRITE_TAG_CONSISTENCY"; - - case 7: - return "MEM_ZERO_INIT"; + case 9: + return "MEM_IN_TAG_CONSISTENCY_2"; } return std::to_string(index); } diff --git a/barretenberg/cpp/src/barretenberg/relations/nested_containers.test.cpp b/barretenberg/cpp/src/barretenberg/relations/nested_containers.test.cpp index 730125f0bc9a..6a6e08d0ddff 100644 --- a/barretenberg/cpp/src/barretenberg/relations/nested_containers.test.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/nested_containers.test.cpp @@ -5,7 +5,9 @@ using namespace bb; -using FF = fr; +namespace bb::nested_contianers_tests { + +using FF = bb::fr; class NestedContainers : public testing::Test {}; @@ -13,10 +15,12 @@ TEST_F(NestedContainers, Univariate) { static constexpr std::array LENGTHS = { 0, 1, 2 }; static constexpr TupleOfUnivariates tuple; - static constexpr auto result0 = Univariate(); - static constexpr auto result1 = Univariate(); - static constexpr auto result2 = Univariate(); + static constexpr auto result0 = bb::Univariate(); + static constexpr auto result1 = bb::Univariate(); + static constexpr auto result2 = bb::Univariate(); EXPECT_EQ(std::get<0>(tuple), result0); EXPECT_EQ(std::get<1>(tuple), result1); EXPECT_EQ(std::get<2>(tuple), result2); } + +} // namespace bb::nested_contianers_tests diff --git a/barretenberg/cpp/src/barretenberg/relations/relation_manual.test.cpp b/barretenberg/cpp/src/barretenberg/relations/relation_manual.test.cpp index 099a7c3f25de..efe920903b92 100644 --- a/barretenberg/cpp/src/barretenberg/relations/relation_manual.test.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/relation_manual.test.cpp @@ -4,16 +4,16 @@ #include "barretenberg/relations/relation_parameters.hpp" #include -using namespace bb; +namespace bb::relation_manual_tests { -using FF = fr; +using FF = bb::fr; class RelationManual : public testing::Test {}; TEST_F(RelationManual, Poseidon2ExternalRelationZeros) { using Accumulator = std::array; - using Relation = bb::Poseidon2ExternalRelation; + using Relation = Poseidon2ExternalRelation; Accumulator acc{ 0, 0, 0, 0 }; struct AllPoseidonValues { @@ -44,7 +44,7 @@ TEST_F(RelationManual, Poseidon2ExternalRelationZeros) TEST_F(RelationManual, Poseidon2ExternalRelationRandom) { using Accumulator = std::array; - using Relation = bb::Poseidon2ExternalRelation; + using Relation = Poseidon2ExternalRelation; Accumulator acc{ 0, 0, 0, 0 }; struct AllPoseidonValues { @@ -90,7 +90,7 @@ TEST_F(RelationManual, Poseidon2ExternalRelationRandom) TEST_F(RelationManual, Poseidon2InternalRelationZeros) { using Accumulator = std::array; - using Relation = bb::Poseidon2InternalRelation; + using Relation = Poseidon2InternalRelation; Accumulator acc{ 0, 0, 0, 0 }; struct AllPoseidonValues { @@ -121,7 +121,7 @@ TEST_F(RelationManual, Poseidon2InternalRelationZeros) TEST_F(RelationManual, Poseidon2InternalRelationRandom) { using Accumulator = std::array; - using Relation = bb::Poseidon2InternalRelation; + using Relation = Poseidon2InternalRelation; Accumulator acc{ 0, 0, 0, 0 }; struct AllPoseidonValues { @@ -164,4 +164,5 @@ TEST_F(RelationManual, Poseidon2InternalRelationRandom) EXPECT_EQ(acc[1], 0); EXPECT_EQ(acc[2], 0); EXPECT_EQ(acc[3], 0); -} \ No newline at end of file +} +}; // namespace bb::relation_manual_tests \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp b/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp index 4f8093f9ad89..617a6b49e8c2 100644 --- a/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp @@ -16,6 +16,8 @@ using namespace bb; +namespace bb::ultra_relation_consistency_tests { + using Flavor = honk::flavor::GoblinTranslator; using FF = typename Flavor::FF; using InputElements = typename Flavor::AllValues; @@ -945,3 +947,5 @@ TEST_F(GoblinTranslatorRelationConsistency, NonNativeFieldRelation) run_test(/*random_inputs=*/false); run_test(/*random_inputs=*/true); }; + +} // namespace bb::ultra_relation_consistency_tests diff --git a/barretenberg/cpp/src/barretenberg/relations/ultra_relation_consistency.test.cpp b/barretenberg/cpp/src/barretenberg/relations/ultra_relation_consistency.test.cpp index 731725d6ee25..8af4e374f349 100644 --- a/barretenberg/cpp/src/barretenberg/relations/ultra_relation_consistency.test.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/ultra_relation_consistency.test.cpp @@ -26,7 +26,9 @@ using namespace bb; -using FF = fr; +namespace bb::ultra_relation_consistency_tests { + +using FF = bb::fr; struct InputElements { static constexpr size_t NUM_ELEMENTS = 45; std::array _data; @@ -678,3 +680,5 @@ TEST_F(UltraRelationConsistency, Poseidon2InternalRelation) run_test(/*random_inputs=*/false); run_test(/*random_inputs=*/true); }; + +} // namespace bb::ultra_relation_consistency_tests diff --git a/barretenberg/cpp/src/barretenberg/serialize/msgpack_schema.test.cpp b/barretenberg/cpp/src/barretenberg/serialize/msgpack_schema.test.cpp index 33a8454dac31..3979e8919be2 100644 --- a/barretenberg/cpp/src/barretenberg/serialize/msgpack_schema.test.cpp +++ b/barretenberg/cpp/src/barretenberg/serialize/msgpack_schema.test.cpp @@ -3,38 +3,37 @@ #include -using namespace bb; - // Sanity checking for msgpack +// TODO eventually move to barretenberg struct GoodExample { - fr a; - fr b; + bb::fr a; + bb::fr b; MSGPACK_FIELDS(a, b); } good_example; struct BadExampleOverlap { - fr a; - fr b; + bb::fr a; + bb::fr b; MSGPACK_FIELDS(a, a); } bad_example_overlap; struct BadExampleIncomplete { - fr a; - fr b; + bb::fr a; + bb::fr b; MSGPACK_FIELDS(a); } bad_example_incomplete; struct BadExampleCompileTimeError { std::vector a; - fr b; + bb::fr b; MSGPACK_FIELDS(b); // Type mismatch, expect 'a', will catch at compile-time } bad_example_compile_time_error; struct BadExampleOutOfObject { - fr a; - fr b; + bb::fr a; + bb::fr b; void msgpack(auto ar) { BadExampleOutOfObject other_object; @@ -67,9 +66,9 @@ TEST(msgpack_tests, msgpack_sanity_sanity) } struct ComplicatedSchema { - std::vector> array; + std::vector> array; std::optional good_or_not; - fr bare; + bb::fr bare; std::variant huh; MSGPACK_FIELDS(array, good_or_not, bare, huh); } complicated_schema; diff --git a/barretenberg/cpp/src/barretenberg/smt_verification/smt_bigfield.test.cpp b/barretenberg/cpp/src/barretenberg/smt_verification/smt_bigfield.test.cpp index 1f1abe570e2f..e40b9b0019ae 100644 --- a/barretenberg/cpp/src/barretenberg/smt_verification/smt_bigfield.test.cpp +++ b/barretenberg/cpp/src/barretenberg/smt_verification/smt_bigfield.test.cpp @@ -30,9 +30,9 @@ using namespace smt_circuit; using namespace bb; using namespace bb::plonk; -using field_ct = stdlib::field_t; -using witness_t = stdlib::witness_t; -using pub_witness_t = stdlib::public_witness_t; +using field_ct = bb::stdlib::field_t; +using witness_t = bb::stdlib::witness_t; +using pub_witness_t = bb::stdlib::public_witness_t; using bn254 = stdlib::bn254; diff --git a/barretenberg/cpp/src/barretenberg/smt_verification/smt_examples.test.cpp b/barretenberg/cpp/src/barretenberg/smt_verification/smt_examples.test.cpp index 81e31bec0f93..fd3b98ddd15b 100644 --- a/barretenberg/cpp/src/barretenberg/smt_verification/smt_examples.test.cpp +++ b/barretenberg/cpp/src/barretenberg/smt_verification/smt_examples.test.cpp @@ -8,15 +8,16 @@ #include "barretenberg/smt_verification/circuit/circuit.hpp" +using namespace bb; using namespace bb; namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } -using field_t = stdlib::field_t; -using witness_t = stdlib::witness_t; -using pub_witness_t = stdlib::public_witness_t; +using field_t = bb::stdlib::field_t; +using witness_t = bb::stdlib::witness_t; +using pub_witness_t = bb::stdlib::public_witness_t; TEST(circuit_verification, multiplication_true) { diff --git a/barretenberg/cpp/src/barretenberg/smt_verification/smt_polynomials.test.cpp b/barretenberg/cpp/src/barretenberg/smt_verification/smt_polynomials.test.cpp index 3e15583a71ae..61048a444698 100644 --- a/barretenberg/cpp/src/barretenberg/smt_verification/smt_polynomials.test.cpp +++ b/barretenberg/cpp/src/barretenberg/smt_verification/smt_polynomials.test.cpp @@ -13,16 +13,17 @@ #include "barretenberg/serialize/cbind.hpp" #include "barretenberg/smt_verification/circuit/circuit.hpp" +using namespace bb; using namespace bb; using namespace smt_circuit; -using field_ct = stdlib::field_t; -using witness_t = stdlib::witness_t; -using pub_witness_t = stdlib::public_witness_t; +using field_ct = bb::stdlib::field_t; +using witness_t = bb::stdlib::witness_t; +using pub_witness_t = bb::stdlib::public_witness_t; // TODO(alex): z1 = z2, s1=s2, but coefficients are not public namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } msgpack::sbuffer create_circuit(size_t n, bool pub_coeffs) diff --git a/barretenberg/cpp/src/barretenberg/solidity_helpers/circuits/ecdsa_circuit.hpp b/barretenberg/cpp/src/barretenberg/solidity_helpers/circuits/ecdsa_circuit.hpp index a20ab1c4bbe3..3b069e4a8a78 100644 --- a/barretenberg/cpp/src/barretenberg/solidity_helpers/circuits/ecdsa_circuit.hpp +++ b/barretenberg/cpp/src/barretenberg/solidity_helpers/circuits/ecdsa_circuit.hpp @@ -12,6 +12,10 @@ #include "barretenberg/stdlib/primitives/field/field.hpp" #include "barretenberg/stdlib/primitives/witness/witness.hpp" +using namespace bb::plonk; +using namespace stdlib; +using numeric::uint256_t; + template class EcdsaCircuit { public: using field_ct = stdlib::field_t; @@ -43,18 +47,18 @@ template class EcdsaCircuit { } // UNCONSTRAINED: create a random keypair to sign with - crypto::ecdsa_key_pair account; + crypto::ecdsa::key_pair account; account.private_key = curve::fr::random_element(); account.public_key = curve::g1::one * account.private_key; // UNCONSTRAINED: create a sig - crypto::ecdsa_signature signature = - crypto::ecdsa_construct_signature( + crypto::ecdsa::signature signature = crypto::ecdsa:: + construct_signature( message_string, account); // UNCONSTRAINED: verify the created signature bool dry_run = - crypto::ecdsa_verify_signature( + crypto::ecdsa::verify_signature( message_string, account.public_key, signature); if (!dry_run) { throw_or_abort("[non circuit]: Sig verification failed"); @@ -68,16 +72,16 @@ template class EcdsaCircuit { uint8_t vv = signature.v; // IN CIRCUIT: create a witness with the sig in our circuit - stdlib::ecdsa_signature sig{ typename curve::byte_array_ct(&builder, rr), - typename curve::byte_array_ct(&builder, ss), - stdlib::uint8(&builder, vv) }; + stdlib::ecdsa::signature sig{ typename curve::byte_array_ct(&builder, rr), + typename curve::byte_array_ct(&builder, ss), + stdlib::uint8(&builder, vv) }; // IN CIRCUIT: verify the signature - typename curve::bool_ct signature_result = stdlib::ecdsa_verify_signature( + typename curve::bool_ct signature_result = stdlib::ecdsa::verify_signature( // input_buffer, public_key, sig); input_buffer, public_key, diff --git a/barretenberg/cpp/src/barretenberg/solidity_helpers/proof_gen.cpp b/barretenberg/cpp/src/barretenberg/solidity_helpers/proof_gen.cpp index 10b54e88b7a9..97e82644e88a 100644 --- a/barretenberg/cpp/src/barretenberg/solidity_helpers/proof_gen.cpp +++ b/barretenberg/cpp/src/barretenberg/solidity_helpers/proof_gen.cpp @@ -11,7 +11,7 @@ #include "circuits/recursive_circuit.hpp" #include "utils/utils.hpp" -using namespace bb::numeric; +using namespace numeric; using numeric::uint256_t; template typename Circuit> void generate_proof(uint256_t inputs[]) diff --git a/barretenberg/cpp/src/barretenberg/srs/factories/mem_crs_factory.test.cpp b/barretenberg/cpp/src/barretenberg/srs/factories/mem_crs_factory.test.cpp index bfdab78e996e..46dfdecc57a4 100644 --- a/barretenberg/cpp/src/barretenberg/srs/factories/mem_crs_factory.test.cpp +++ b/barretenberg/cpp/src/barretenberg/srs/factories/mem_crs_factory.test.cpp @@ -9,7 +9,7 @@ using namespace bb; using namespace bb::srs::factories; -using namespace bb::curve; +using namespace curve; TEST(reference_string, mem_bn254_file_consistency) { @@ -41,7 +41,7 @@ TEST(reference_string, mem_bn254_file_consistency) EXPECT_EQ(memcmp(mem_verifier_crs->get_precomputed_g2_lines(), file_verifier_crs->get_precomputed_g2_lines(), - sizeof(pairing::miller_lines) * 2), + sizeof(bb::pairing::miller_lines) * 2), 0); } diff --git a/barretenberg/cpp/src/barretenberg/srs/factories/mem_grumpkin_crs_factory.cpp b/barretenberg/cpp/src/barretenberg/srs/factories/mem_grumpkin_crs_factory.cpp index 1001c9519a49..d9ab3b28f592 100644 --- a/barretenberg/cpp/src/barretenberg/srs/factories/mem_grumpkin_crs_factory.cpp +++ b/barretenberg/cpp/src/barretenberg/srs/factories/mem_grumpkin_crs_factory.cpp @@ -7,7 +7,7 @@ namespace { -using namespace bb::curve; +using namespace curve; using namespace bb; using namespace bb::srs::factories; diff --git a/barretenberg/cpp/src/barretenberg/srs/global_crs.cpp b/barretenberg/cpp/src/barretenberg/srs/global_crs.cpp index f6ac2e05c71d..6bf83a86b442 100644 --- a/barretenberg/cpp/src/barretenberg/srs/global_crs.cpp +++ b/barretenberg/cpp/src/barretenberg/srs/global_crs.cpp @@ -6,8 +6,8 @@ namespace { // TODO(#637): As a PoC we have two global variables for the two CRS but this could be improved to avoid duplication. -std::shared_ptr> crs_factory; -std::shared_ptr> grumpkin_crs_factory; +std::shared_ptr> crs_factory; +std::shared_ptr> grumpkin_crs_factory; } // namespace namespace bb::srs { @@ -21,11 +21,11 @@ void init_crs_factory(std::vector const& points, g2::affine_ // Initializes crs from a file path this we use in the entire codebase void init_crs_factory(std::string crs_path) { - crs_factory = std::make_shared>(crs_path); + crs_factory = std::make_shared>(crs_path); } // Initializes the crs using the memory buffers -void init_grumpkin_crs_factory(std::vector const& points) +void init_grumpkin_crs_factory(std::vector const& points) { grumpkin_crs_factory = std::make_shared(points); } diff --git a/barretenberg/cpp/src/barretenberg/srs/scalar_multiplication.test.cpp b/barretenberg/cpp/src/barretenberg/srs/scalar_multiplication.test.cpp index d5c257ada4ed..b9805c7c7d1c 100644 --- a/barretenberg/cpp/src/barretenberg/srs/scalar_multiplication.test.cpp +++ b/barretenberg/cpp/src/barretenberg/srs/scalar_multiplication.test.cpp @@ -20,12 +20,12 @@ #include #include -using namespace bb; - namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } +using namespace bb; + template class ScalarMultiplicationTests : public ::testing::Test { public: const std::string SRS_PATH = []() { @@ -36,7 +36,8 @@ template class ScalarMultiplicationTests : public ::testing::Te } }(); - static void read_transcript_g2(std::string const& srs_path) requires srs::HasG2 + static void read_transcript_g2(std::string const& srs_path) + requires srs::HasG2 { typename Curve::G2AffineElement g2_x; srs::IO::read_transcript_g2(g2_x, srs_path); @@ -230,14 +231,14 @@ TYPED_TEST(ScalarMultiplicationTests, ReduceBucketsSimple) std::array bucket_counts; std::array bit_offsets = { 0 }; - scalar_multiplication::affine_product_runtime_state product_state{ + bb::scalar_multiplication::affine_product_runtime_state product_state{ &monomials[0], &point_pairs[0], &output_buckets[0], &scratch_space[0], &bucket_counts[0], &bit_offsets[0], &point_schedule[0], num_points, 2, &bucket_empty_status[0] }; - AffineElement* output = scalar_multiplication::reduce_buckets(product_state, true); + AffineElement* output = bb::scalar_multiplication::reduce_buckets(product_state, true); for (size_t i = 0; i < product_state.num_buckets; ++i) { expected[i] = expected[i].normalize(); @@ -273,7 +274,7 @@ TYPED_TEST(ScalarMultiplicationTests, ReduceBuckets) TestFixture::read_transcript(monomials, num_initial_points, TestFixture::SRS_PATH); - scalar_multiplication::generate_pippenger_point_table(monomials, monomials, num_initial_points); + bb::scalar_multiplication::generate_pippenger_point_table(monomials, monomials, num_initial_points); Fr* scalars = (Fr*)(aligned_alloc(64, sizeof(Fr) * num_initial_points)); @@ -281,21 +282,21 @@ TYPED_TEST(ScalarMultiplicationTests, ReduceBuckets) scalars[i] = Fr::random_element(); } - scalar_multiplication::pippenger_runtime_state state(num_initial_points); + bb::scalar_multiplication::pippenger_runtime_state state(num_initial_points); std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now(); - scalar_multiplication::compute_wnaf_states( + bb::scalar_multiplication::compute_wnaf_states( state.point_schedule, state.skew_table, state.round_counts, scalars, num_initial_points); std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now(); std::chrono::milliseconds diff = std::chrono::duration_cast(end - start); std::cout << "wnaf time: " << diff.count() << "ms" << std::endl; start = std::chrono::steady_clock::now(); - scalar_multiplication::organize_buckets(state.point_schedule, num_points); + bb::scalar_multiplication::organize_buckets(state.point_schedule, num_points); end = std::chrono::steady_clock::now(); diff = std::chrono::duration_cast(end - start); std::cout << "organize bucket time: " << diff.count() << "ms" << std::endl; - const size_t max_num_buckets = scalar_multiplication::get_num_buckets(num_points * 2); + const size_t max_num_buckets = bb::scalar_multiplication::get_num_buckets(num_points * 2); uint32_t* bucket_counts = static_cast(aligned_alloc(64, max_num_buckets * 100 * sizeof(uint32_t))); memset((void*)bucket_counts, 0x00, max_num_buckets * sizeof(uint32_t)); @@ -311,19 +312,19 @@ TYPED_TEST(ScalarMultiplicationTests, ReduceBuckets) const size_t last_bucket = point_schedule_copy[num_points - 1] & 0x7fffffffULL; const size_t num_buckets = last_bucket - first_bucket + 1; - scalar_multiplication::affine_product_runtime_state product_state{ monomials, - point_pairs, - scratch_points, - scratch_field, - bucket_counts, - &bit_offsets[0], - &state.point_schedule[num_points], - num_points, - static_cast(num_buckets), - bucket_empty_status }; + bb::scalar_multiplication::affine_product_runtime_state product_state{ monomials, + point_pairs, + scratch_points, + scratch_field, + bucket_counts, + &bit_offsets[0], + &state.point_schedule[num_points], + num_points, + static_cast(num_buckets), + bucket_empty_status }; start = std::chrono::steady_clock::now(); - // scalar_multiplication::scalar_multiplication_internal(state, monomials); + // bb::scalar_multiplication::scalar_multiplication_internal(state, monomials); end = std::chrono::steady_clock::now(); diff = std::chrono::duration_cast(end - start); std::cout << "scalar mul: " << diff.count() << "ms" << std::endl; @@ -344,7 +345,7 @@ TYPED_TEST(ScalarMultiplicationTests, ReduceBuckets) size_t it = 0; - AffineElement* result_buckets = scalar_multiplication::reduce_buckets(product_state, true); + AffineElement* result_buckets = bb::scalar_multiplication::reduce_buckets(product_state, true); printf("num buckets = %zu \n", num_buckets); for (size_t i = 0; i < num_buckets; ++i) { @@ -400,22 +401,22 @@ TYPED_TEST(ScalarMultiplicationTests, DISABLED_ReduceBucketsBasic) Fr::__copy(source_scalar, scalars[i]); } - scalar_multiplication::pippenger_runtime_state state(num_initial_points); - scalar_multiplication::generate_pippenger_point_table(monomials, monomials, num_initial_points); + bb::scalar_multiplication::pippenger_runtime_state state(num_initial_points); + bb::scalar_multiplication::generate_pippenger_point_table(monomials, monomials, num_initial_points); std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now(); - scalar_multiplication::compute_wnaf_states( + bb::scalar_multiplication::compute_wnaf_states( state.point_schedule, state.skew_table, state.round_counts, scalars, num_initial_points); std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now(); std::chrono::milliseconds diff = std::chrono::duration_cast(end - start); std::cout << "wnaf time: " << diff.count() << "ms" << std::endl; start = std::chrono::steady_clock::now(); - scalar_multiplication::organize_buckets(state.point_schedule, num_points); + bb::scalar_multiplication::organize_buckets(state.point_schedule, num_points); end = std::chrono::steady_clock::now(); diff = std::chrono::duration_cast(end - start); std::cout << "organize bucket time: " << diff.count() << "ms" << std::endl; - const size_t max_num_buckets = scalar_multiplication::get_num_buckets(num_points * 2); + const size_t max_num_buckets = bb::scalar_multiplication::get_num_buckets(num_points * 2); uint32_t* bucket_counts = static_cast(aligned_alloc(64, max_num_buckets * sizeof(uint32_t))); memset((void*)bucket_counts, 0x00, max_num_buckets * sizeof(uint32_t)); @@ -424,20 +425,20 @@ TYPED_TEST(ScalarMultiplicationTests, DISABLED_ReduceBucketsBasic) const size_t last_bucket = state.point_schedule[num_points - 1] & 0x7fffffffULL; const size_t num_buckets = last_bucket - first_bucket + 1; - scalar_multiplication::affine_product_runtime_state product_state{ monomials, - point_pairs, - scratch_points, - scratch_field, - bucket_counts, - &bit_offsets[0], - state.point_schedule, - (uint32_t)state.round_counts[0], - static_cast(num_buckets), - bucket_empty_status }; + bb::scalar_multiplication::affine_product_runtime_state product_state{ monomials, + point_pairs, + scratch_points, + scratch_field, + bucket_counts, + &bit_offsets[0], + state.point_schedule, + (uint32_t)state.round_counts[0], + static_cast(num_buckets), + bucket_empty_status }; start = std::chrono::steady_clock::now(); - scalar_multiplication::reduce_buckets(product_state, true); - // scalar_multiplication::scalar_multiplication_internal(state, monomials); + bb::scalar_multiplication::reduce_buckets(product_state, true); + // bb::scalar_multiplication::scalar_multiplication_internal(state, monomials); end = std::chrono::steady_clock::now(); diff = std::chrono::duration_cast(end - start); std::cout << "scalar mul: " << diff.count() << "ms" << std::endl; @@ -477,7 +478,7 @@ TYPED_TEST(ScalarMultiplicationTests, AddAffinePoints) points_copy[count + 1] = points_copy[count + 1].normalize(); } - scalar_multiplication::add_affine_points(points, num_points, scratch_space); + bb::scalar_multiplication::add_affine_points(points, num_points, scratch_space); for (size_t i = num_points - 1; i > num_points - 1 - (num_points / 2); --i) { EXPECT_EQ((points[i].x == points_copy[i].x), true); EXPECT_EQ((points[i].y == points_copy[i].y), true); @@ -508,22 +509,22 @@ TYPED_TEST(ScalarMultiplicationTests, ConstructAdditionChains) Fr::__copy(source_scalar, scalars[i]); } - scalar_multiplication::pippenger_runtime_state state(num_initial_points); - scalar_multiplication::generate_pippenger_point_table(monomials, monomials, num_initial_points); + bb::scalar_multiplication::pippenger_runtime_state state(num_initial_points); + bb::scalar_multiplication::generate_pippenger_point_table(monomials, monomials, num_initial_points); std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now(); - scalar_multiplication::compute_wnaf_states( + bb::scalar_multiplication::compute_wnaf_states( state.point_schedule, state.skew_table, state.round_counts, scalars, num_initial_points); std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now(); std::chrono::milliseconds diff = std::chrono::duration_cast(end - start); std::cout << "wnaf time: " << diff.count() << "ms" << std::endl; start = std::chrono::steady_clock::now(); - scalar_multiplication::organize_buckets(state.point_schedule, num_points); + bb::scalar_multiplication::organize_buckets(state.point_schedule, num_points); end = std::chrono::steady_clock::now(); diff = std::chrono::duration_cast(end - start); std::cout << "organize bucket time: " << diff.count() << "ms" << std::endl; - const size_t max_num_buckets = scalar_multiplication::get_num_buckets(num_points * 2); + const size_t max_num_buckets = bb::scalar_multiplication::get_num_buckets(num_points * 2); bool* bucket_empty_status = static_cast(aligned_alloc(64, num_points * sizeof(bool))); uint32_t* bucket_counts = static_cast(aligned_alloc(64, max_num_buckets * sizeof(uint32_t))); memset((void*)bucket_counts, 0x00, max_num_buckets * sizeof(uint32_t)); @@ -532,20 +533,20 @@ TYPED_TEST(ScalarMultiplicationTests, ConstructAdditionChains) const size_t last_bucket = state.point_schedule[state.round_counts[0] - 1] & 0x7fffffffULL; const size_t num_buckets = last_bucket - first_bucket + 1; - scalar_multiplication::affine_product_runtime_state product_state{ monomials, - monomials, - monomials, - nullptr, - bucket_counts, - &bit_offsets[0], - state.point_schedule, - static_cast( - state.round_counts[0]), - static_cast(num_buckets), - bucket_empty_status }; + bb::scalar_multiplication::affine_product_runtime_state product_state{ monomials, + monomials, + monomials, + nullptr, + bucket_counts, + &bit_offsets[0], + state.point_schedule, + static_cast( + state.round_counts[0]), + static_cast(num_buckets), + bucket_empty_status }; start = std::chrono::steady_clock::now(); - scalar_multiplication::construct_addition_chains(product_state, true); + bb::scalar_multiplication::construct_addition_chains(product_state, true); end = std::chrono::steady_clock::now(); diff = std::chrono::duration_cast(end - start); info("construct addition chains: ", diff.count(), "ms"); @@ -607,7 +608,7 @@ TYPED_TEST(ScalarMultiplicationTests, RadixSort) // check that our radix sort correctly sorts! constexpr size_t target_degree = 1 << 8; - constexpr size_t num_rounds = scalar_multiplication::get_num_rounds(target_degree * 2); + constexpr size_t num_rounds = bb::scalar_multiplication::get_num_rounds(target_degree * 2); Fr* scalars = (Fr*)(aligned_alloc(64, sizeof(Fr) * target_degree)); Fr source_scalar = Fr::random_element(); @@ -616,14 +617,14 @@ TYPED_TEST(ScalarMultiplicationTests, RadixSort) Fr::__copy(source_scalar, scalars[i]); } - scalar_multiplication::pippenger_runtime_state state(target_degree); - scalar_multiplication::compute_wnaf_states( + bb::scalar_multiplication::pippenger_runtime_state state(target_degree); + bb::scalar_multiplication::compute_wnaf_states( state.point_schedule, state.skew_table, state.round_counts, scalars, target_degree); uint64_t* wnaf_copy = (uint64_t*)(aligned_alloc(64, sizeof(uint64_t) * target_degree * 2 * num_rounds)); memcpy((void*)wnaf_copy, (void*)state.point_schedule, sizeof(uint64_t) * target_degree * 2 * num_rounds); - scalar_multiplication::organize_buckets(state.point_schedule, target_degree * 2); + bb::scalar_multiplication::organize_buckets(state.point_schedule, target_degree * 2); for (size_t i = 0; i < num_rounds; ++i) { uint64_t* unsorted_wnaf = &wnaf_copy[i * target_degree * 2]; uint64_t* sorted_wnaf = &state.point_schedule[i * target_degree * 2]; @@ -667,7 +668,7 @@ TYPED_TEST(ScalarMultiplicationTests, OversizedInputs) memcpy((void*)(monomials + (2 * transcript_degree)), (void*)monomials, ((2 * target_degree - 2 * transcript_degree) * sizeof(AffineElement))); - scalar_multiplication::generate_pippenger_point_table(monomials, monomials, target_degree); + bb::scalar_multiplication::generate_pippenger_point_table(monomials, monomials, target_degree); Fr* scalars = (Fr*)(aligned_alloc(64, sizeof(Fr) * target_degree)); @@ -677,17 +678,17 @@ TYPED_TEST(ScalarMultiplicationTests, OversizedInputs) accumulator *= source_scalar; Fr::__copy(accumulator, scalars[i]); } - scalar_multiplication::pippenger_runtime_state state(target_degree); + bb::scalar_multiplication::pippenger_runtime_state state(target_degree); - Element first = scalar_multiplication::pippenger(scalars, monomials, target_degree, state); + Element first = bb::scalar_multiplication::pippenger(scalars, monomials, target_degree, state); first = first.normalize(); for (size_t i = 0; i < target_degree; ++i) { scalars[i].self_neg(); } - scalar_multiplication::pippenger_runtime_state state_2(target_degree); + bb::scalar_multiplication::pippenger_runtime_state state_2(target_degree); - Element second = scalar_multiplication::pippenger(scalars, monomials, target_degree, state_2); + Element second = bb::scalar_multiplication::pippenger(scalars, monomials, target_degree, state_2); second = second.normalize(); EXPECT_EQ((first.z == second.z), true); @@ -726,11 +727,11 @@ TYPED_TEST(ScalarMultiplicationTests, UndersizedInputs) expected += temp; } expected = expected.normalize(); - scalar_multiplication::generate_pippenger_point_table(points, points, num_points); + bb::scalar_multiplication::generate_pippenger_point_table(points, points, num_points); - scalar_multiplication::pippenger_runtime_state state(num_points); + bb::scalar_multiplication::pippenger_runtime_state state(num_points); - Element result = scalar_multiplication::pippenger(scalars, points, num_points, state); + Element result = bb::scalar_multiplication::pippenger(scalars, points, num_points, state); result = result.normalize(); aligned_free(scalars); @@ -764,10 +765,10 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerSmall) expected += temp; } expected = expected.normalize(); - scalar_multiplication::generate_pippenger_point_table(points, points, num_points); - scalar_multiplication::pippenger_runtime_state state(num_points); + bb::scalar_multiplication::generate_pippenger_point_table(points, points, num_points); + bb::scalar_multiplication::pippenger_runtime_state state(num_points); - Element result = scalar_multiplication::pippenger(scalars, points, num_points, state); + Element result = bb::scalar_multiplication::pippenger(scalars, points, num_points, state); result = result.normalize(); aligned_free(scalars); @@ -804,9 +805,9 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerEdgeCaseDbl) if (!expected.is_point_at_infinity()) { expected = expected.normalize(); } - scalar_multiplication::generate_pippenger_point_table(points, points, num_points); - scalar_multiplication::pippenger_runtime_state state(num_points); - Element result = scalar_multiplication::pippenger(scalars, points, num_points, state); + bb::scalar_multiplication::generate_pippenger_point_table(points, points, num_points); + bb::scalar_multiplication::pippenger_runtime_state state(num_points); + Element result = bb::scalar_multiplication::pippenger(scalars, points, num_points, state); result = result.normalize(); aligned_free(scalars); @@ -826,7 +827,7 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerShortInputs) Fr* scalars = (Fr*)aligned_alloc(32, sizeof(Fr) * num_points); - auto points = scalar_multiplication::point_table_alloc(num_points); + auto points = bb::scalar_multiplication::point_table_alloc(num_points); for (std::ptrdiff_t i = 0; i < (std::ptrdiff_t)num_points; ++i) { points[i] = AffineElement(Element::random_element()); @@ -861,10 +862,10 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerShortInputs) expected += temp; } expected = expected.normalize(); - scalar_multiplication::generate_pippenger_point_table(points.get(), points.get(), num_points); - scalar_multiplication::pippenger_runtime_state state(num_points); + bb::scalar_multiplication::generate_pippenger_point_table(points.get(), points.get(), num_points); + bb::scalar_multiplication::pippenger_runtime_state state(num_points); - Element result = scalar_multiplication::pippenger(scalars, points.get(), num_points, state); + Element result = bb::scalar_multiplication::pippenger(scalars, points.get(), num_points, state); result = result.normalize(); aligned_free(scalars); @@ -883,7 +884,7 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerUnsafe) Fr* scalars = (Fr*)aligned_alloc(32, sizeof(Fr) * num_points); - auto points = scalar_multiplication::point_table_alloc(num_points); + auto points = bb::scalar_multiplication::point_table_alloc(num_points); for (std::ptrdiff_t i = 0; i < (std::ptrdiff_t)num_points; ++i) { scalars[i] = Fr::random_element(); @@ -897,10 +898,10 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerUnsafe) expected += temp; } expected = expected.normalize(); - scalar_multiplication::generate_pippenger_point_table(points.get(), points.get(), num_points); + bb::scalar_multiplication::generate_pippenger_point_table(points.get(), points.get(), num_points); - scalar_multiplication::pippenger_runtime_state state(num_points); - Element result = scalar_multiplication::pippenger_unsafe(scalars, points.get(), num_points, state); + bb::scalar_multiplication::pippenger_runtime_state state(num_points); + Element result = bb::scalar_multiplication::pippenger_unsafe(scalars, points.get(), num_points, state); result = result.normalize(); aligned_free(scalars); @@ -954,10 +955,10 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerUnsafeShortInputs) expected += temp; } expected = expected.normalize(); - scalar_multiplication::generate_pippenger_point_table(points, points, num_points); - scalar_multiplication::pippenger_runtime_state state(num_points); + bb::scalar_multiplication::generate_pippenger_point_table(points, points, num_points); + bb::scalar_multiplication::pippenger_runtime_state state(num_points); - Element result = scalar_multiplication::pippenger_unsafe(scalars, points, num_points, state); + Element result = bb::scalar_multiplication::pippenger_unsafe(scalars, points, num_points, state); result = result.normalize(); aligned_free(scalars); @@ -991,10 +992,10 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerOne) expected += temp; } expected = expected.normalize(); - scalar_multiplication::generate_pippenger_point_table(points, points, num_points); - scalar_multiplication::pippenger_runtime_state state(num_points); + bb::scalar_multiplication::generate_pippenger_point_table(points, points, num_points); + bb::scalar_multiplication::pippenger_runtime_state state(num_points); - Element result = scalar_multiplication::pippenger(scalars, points, num_points, state); + Element result = bb::scalar_multiplication::pippenger(scalars, points, num_points, state); result = result.normalize(); aligned_free(scalars); @@ -1014,8 +1015,8 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerZeroPoints) AffineElement* points = (AffineElement*)aligned_alloc(32, sizeof(AffineElement) * (2 + 1)); - scalar_multiplication::pippenger_runtime_state state(0); - Element result = scalar_multiplication::pippenger(scalars, points, 0, state); + bb::scalar_multiplication::pippenger_runtime_state state(0); + Element result = bb::scalar_multiplication::pippenger(scalars, points, 0, state); aligned_free(scalars); aligned_free(points); @@ -1037,10 +1038,10 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerMulByZero) scalars[0] = Fr::zero(); points[0] = Group::affine_one; - scalar_multiplication::generate_pippenger_point_table(points, points, 1); + bb::scalar_multiplication::generate_pippenger_point_table(points, points, 1); - scalar_multiplication::pippenger_runtime_state state(1); - Element result = scalar_multiplication::pippenger(scalars, points, 1, state); + bb::scalar_multiplication::pippenger_runtime_state state(1); + Element result = bb::scalar_multiplication::pippenger(scalars, points, 1, state); aligned_free(scalars); aligned_free(points); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/commitment/pedersen/pedersen.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/commitment/pedersen/pedersen.test.cpp index bced7a462562..5e0f37f2dba6 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/commitment/pedersen/pedersen.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/commitment/pedersen/pedersen.test.cpp @@ -6,9 +6,10 @@ #include "barretenberg/stdlib/primitives/curves/bn254.hpp" #include "pedersen.hpp" +namespace test_StdlibPedersen { using namespace bb; namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } template class StdlibPedersen : public testing::Test { @@ -60,7 +61,7 @@ template class StdlibPedersen : public testing::Test { { Builder builder; - std::vector inputs; + std::vector inputs; std::vector> witness_inputs; for (size_t i = 0; i < 8; ++i) { @@ -93,3 +94,5 @@ TYPED_TEST(StdlibPedersen, HashConstants) { TestFixture::test_hash_constants(); }; + +} // namespace test_StdlibPedersen diff --git a/barretenberg/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.cpp b/barretenberg/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.cpp index 232e21c1cc3d..003ab78e3b2f 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.cpp @@ -7,11 +7,11 @@ #include "barretenberg/stdlib/primitives/circuit_builders/circuit_builders.hpp" #include "barretenberg/stdlib/primitives/plookup/plookup.hpp" -using namespace bb::crypto; +using namespace crypto::aes128; namespace bb::stdlib::aes128 { template using byte_pair = std::pair, field_t>; -using namespace bb::plookup; +using namespace plookup; constexpr uint32_t AES128_BASE = 9; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.test.cpp index 76b52fbc27e3..743a1eb80be8 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.test.cpp @@ -8,7 +8,7 @@ using namespace bb; TEST(stdlib_aes128, encrypt_64_bytes) { - typedef stdlib::field_t field_pt; + typedef stdlib::field_t field_pt; typedef stdlib::witness_t witness_pt; uint8_t key[16]{ 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c }; @@ -31,7 +31,7 @@ TEST(stdlib_aes128, encrypt_64_bytes) return converted; }; - auto builder = UltraCircuitBuilder(); + auto builder = bb::UltraCircuitBuilder(); std::vector in_field{ witness_pt(&builder, fr(convert_bytes(in))), diff --git a/barretenberg/cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa.hpp b/barretenberg/cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa.hpp index 1c2649ed1b38..ca4a212a8662 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa.hpp @@ -4,43 +4,42 @@ #include "../../primitives/circuit_builders/circuit_builders_fwd.hpp" #include "../../primitives/uint/uint.hpp" #include "barretenberg/crypto/ecdsa/ecdsa.hpp" -namespace bb::stdlib { +namespace bb::stdlib::ecdsa { -template struct ecdsa_signature { +template struct signature { stdlib::byte_array r; stdlib::byte_array s; stdlib::uint8 v; }; template -bool_t ecdsa_verify_signature(const stdlib::byte_array& message, - const G1& public_key, - const ecdsa_signature& sig); +bool_t verify_signature(const stdlib::byte_array& message, + const G1& public_key, + const signature& sig); template -bool_t ecdsa_verify_signature_noassert(const stdlib::byte_array& message, - const G1& public_key, - const ecdsa_signature& sig); +bool_t verify_signature_noassert(const stdlib::byte_array& message, + const G1& public_key, + const signature& sig); template -bool_t ecdsa_verify_signature_prehashed_message_noassert(const stdlib::byte_array& hashed_message, - const G1& public_key, - const ecdsa_signature& sig); +bool_t verify_signature_prehashed_message_noassert(const stdlib::byte_array& hashed_message, + const G1& public_key, + const signature& sig); -template -static ecdsa_signature ecdsa_from_witness(Builder* ctx, const crypto::ecdsa_signature& input) +template static signature from_witness(Builder* ctx, const crypto::ecdsa::signature& input) { std::vector r_vec(std::begin(input.r), std::end(input.r)); std::vector s_vec(std::begin(input.s), std::end(input.s)); stdlib::byte_array r(ctx, r_vec); stdlib::byte_array s(ctx, s_vec); stdlib::uint8 v(ctx, input.v); - ecdsa_signature out; + signature out; out.r = r; out.s = s; out.v = v; return out; } -} // namespace bb::stdlib +} // namespace bb::stdlib::ecdsa #include "./ecdsa_impl.hpp" \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa.test.cpp index 69aedf7e4351..ca55a8af5638 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa.test.cpp @@ -8,8 +8,9 @@ using namespace bb; -using Builder = UltraCircuitBuilder; -using curve_ = stdlib::secp256k1; +namespace test_stdlib_ecdsa { +using Builder = bb::UltraCircuitBuilder; +using curve = stdlib::secp256k1; using curveR1 = stdlib::secp256r1; TEST(stdlib_ecdsa, verify_signature) @@ -19,31 +20,31 @@ TEST(stdlib_ecdsa, verify_signature) // whaaablaghaaglerijgeriij std::string message_string = "Instructions unclear, ask again later."; - crypto::ecdsa_key_pair account; - account.private_key = curve_::fr::random_element(); - account.public_key = curve_::g1::one * account.private_key; + crypto::ecdsa::key_pair account; + account.private_key = curve::fr::random_element(); + account.public_key = curve::g1::one * account.private_key; - crypto::ecdsa_signature signature = - crypto::ecdsa_construct_signature(message_string, account); + crypto::ecdsa::signature signature = + crypto::ecdsa::construct_signature(message_string, account); - bool first_result = crypto::ecdsa_verify_signature( + bool first_result = crypto::ecdsa::verify_signature( message_string, account.public_key, signature); EXPECT_EQ(first_result, true); - curve_::g1_bigfr_ct public_key = curve_::g1_bigfr_ct::from_witness(&builder, account.public_key); + curve::g1_bigfr_ct public_key = curve::g1_bigfr_ct::from_witness(&builder, account.public_key); std::vector rr(signature.r.begin(), signature.r.end()); std::vector ss(signature.s.begin(), signature.s.end()); uint8_t vv = signature.v; - stdlib::ecdsa_signature sig{ curve_::byte_array_ct(&builder, rr), - curve_::byte_array_ct(&builder, ss), - stdlib::uint8(&builder, vv) }; + stdlib::ecdsa::signature sig{ curve::byte_array_ct(&builder, rr), + curve::byte_array_ct(&builder, ss), + stdlib::uint8(&builder, vv) }; - curve_::byte_array_ct message(&builder, message_string); + curve::byte_array_ct message(&builder, message_string); - curve_::bool_ct signature_result = - stdlib::ecdsa_verify_signature( + curve::bool_ct signature_result = + stdlib::ecdsa::verify_signature( message, public_key, sig); EXPECT_EQ(signature_result.get_value(), true); @@ -60,14 +61,15 @@ TEST(stdlib_ecdsa, verify_r1_signature) std::string message_string = "Instructions unclear, ask again later."; - crypto::ecdsa_key_pair account; + crypto::ecdsa::key_pair account; account.private_key = curveR1::fr::random_element(); account.public_key = curveR1::g1::one * account.private_key; - crypto::ecdsa_signature signature = - crypto::ecdsa_construct_signature(message_string, account); + crypto::ecdsa::signature signature = + crypto::ecdsa::construct_signature(message_string, + account); - bool first_result = crypto::ecdsa_verify_signature( + bool first_result = crypto::ecdsa::verify_signature( message_string, account.public_key, signature); EXPECT_EQ(first_result, true); @@ -77,14 +79,14 @@ TEST(stdlib_ecdsa, verify_r1_signature) std::vector ss(signature.s.begin(), signature.s.end()); uint8_t vv = signature.v; - stdlib::ecdsa_signature sig{ curveR1::byte_array_ct(&builder, rr), - curveR1::byte_array_ct(&builder, ss), - stdlib::uint8(&builder, vv) }; + stdlib::ecdsa::signature sig{ curveR1::byte_array_ct(&builder, rr), + curveR1::byte_array_ct(&builder, ss), + stdlib::uint8(&builder, vv) }; curveR1::byte_array_ct message(&builder, message_string); curveR1::bool_ct signature_result = - stdlib::ecdsa_verify_signature( + stdlib::ecdsa::verify_signature( message, public_key, sig); EXPECT_EQ(signature_result.get_value(), true); @@ -95,40 +97,40 @@ TEST(stdlib_ecdsa, verify_r1_signature) EXPECT_EQ(proof_result, true); } -TEST(stdlib_ecdsa, ecdsa_verify_signature_noassert_succeed) +TEST(stdlib_ecdsa, verify_signature_noassert_succeed) { Builder builder = Builder(); // whaaablaghaaglerijgeriij std::string message_string = "Instructions unclear, ask again later."; - crypto::ecdsa_key_pair account; - account.private_key = curve_::fr::random_element(); - account.public_key = curve_::g1::one * account.private_key; + crypto::ecdsa::key_pair account; + account.private_key = curve::fr::random_element(); + account.public_key = curve::g1::one * account.private_key; - crypto::ecdsa_signature signature = - crypto::ecdsa_construct_signature(message_string, account); + crypto::ecdsa::signature signature = + crypto::ecdsa::construct_signature(message_string, account); - bool first_result = crypto::ecdsa_verify_signature( + bool first_result = crypto::ecdsa::verify_signature( message_string, account.public_key, signature); EXPECT_EQ(first_result, true); - curve_::g1_bigfr_ct public_key = curve_::g1_bigfr_ct::from_witness(&builder, account.public_key); + curve::g1_bigfr_ct public_key = curve::g1_bigfr_ct::from_witness(&builder, account.public_key); std::vector rr(signature.r.begin(), signature.r.end()); std::vector ss(signature.s.begin(), signature.s.end()); uint8_t vv = signature.v; - stdlib::ecdsa_signature sig{ - curve_::byte_array_ct(&builder, rr), - curve_::byte_array_ct(&builder, ss), + stdlib::ecdsa::signature sig{ + curve::byte_array_ct(&builder, rr), + curve::byte_array_ct(&builder, ss), stdlib::uint8(&builder, vv), }; - curve_::byte_array_ct message(&builder, message_string); + curve::byte_array_ct message(&builder, message_string); - curve_::bool_ct signature_result = - stdlib::ecdsa_verify_signature_noassert( + curve::bool_ct signature_result = + stdlib::ecdsa::verify_signature_noassert( message, public_key, sig); EXPECT_EQ(signature_result.get_value(), true); @@ -139,40 +141,38 @@ TEST(stdlib_ecdsa, ecdsa_verify_signature_noassert_succeed) EXPECT_EQ(proof_result, true); } -TEST(stdlib_ecdsa, ecdsa_verify_signature_noassert_fail) +TEST(stdlib_ecdsa, verify_signature_noassert_fail) { Builder builder = Builder(); // whaaablaghaaglerijgeriij std::string message_string = "Instructions unclear, ask again later."; - crypto::ecdsa_key_pair account; - account.private_key = curve_::fr::random_element(); - account.public_key = curve_::g1::one * account.private_key; + crypto::ecdsa::key_pair account; + account.private_key = curve::fr::random_element(); + account.public_key = curve::g1::one * account.private_key; - crypto::ecdsa_signature signature = - crypto::ecdsa_construct_signature(message_string, account); + crypto::ecdsa::signature signature = + crypto::ecdsa::construct_signature(message_string, account); // tamper w. signature to make fail signature.r[0] += 1; - bool first_result = crypto::ecdsa_verify_signature( + bool first_result = crypto::ecdsa::verify_signature( message_string, account.public_key, signature); EXPECT_EQ(first_result, false); - curve_::g1_bigfr_ct public_key = curve_::g1_bigfr_ct::from_witness(&builder, account.public_key); + curve::g1_bigfr_ct public_key = curve::g1_bigfr_ct::from_witness(&builder, account.public_key); std::vector rr(signature.r.begin(), signature.r.end()); std::vector ss(signature.s.begin(), signature.s.end()); - stdlib::ecdsa_signature sig{ curve_::byte_array_ct(&builder, rr), - curve_::byte_array_ct(&builder, ss), - 27 }; + stdlib::ecdsa::signature sig{ curve::byte_array_ct(&builder, rr), curve::byte_array_ct(&builder, ss), 27 }; - curve_::byte_array_ct message(&builder, message_string); + curve::byte_array_ct message(&builder, message_string); - curve_::bool_ct signature_result = - stdlib::ecdsa_verify_signature_noassert( + curve::bool_ct signature_result = + stdlib::ecdsa::verify_signature_noassert( message, public_key, sig); EXPECT_EQ(signature_result.get_value(), false); @@ -182,3 +182,4 @@ TEST(stdlib_ecdsa, ecdsa_verify_signature_noassert_fail) bool proof_result = builder.check_circuit(); EXPECT_EQ(proof_result, true); } +} // namespace test_stdlib_ecdsa diff --git a/barretenberg/cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa_impl.hpp b/barretenberg/cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa_impl.hpp index fa67089fd4ee..5f7403fb2c1b 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa_impl.hpp @@ -4,7 +4,7 @@ #include "barretenberg/stdlib/hash/sha256/sha256.hpp" #include "barretenberg/stdlib/primitives//bit_array/bit_array.hpp" -namespace bb::stdlib { +namespace bb::stdlib::ecdsa { /** * @brief Verify ECDSA signature. Produces unsatisfiable constraints if signature fails @@ -20,9 +20,9 @@ namespace bb::stdlib { * @return bool_t */ template -bool_t ecdsa_verify_signature(const stdlib::byte_array& message, - const G1& public_key, - const ecdsa_signature& sig) +bool_t verify_signature(const stdlib::byte_array& message, + const G1& public_key, + const signature& sig) { Builder* ctx = message.get_context() ? message.get_context() : public_key.x.context; @@ -130,9 +130,9 @@ bool_t ecdsa_verify_signature(const stdlib::byte_array& messag * @return bool_t */ template -bool_t ecdsa_verify_signature_prehashed_message_noassert(const stdlib::byte_array& hashed_message, - const G1& public_key, - const ecdsa_signature& sig) +bool_t verify_signature_prehashed_message_noassert(const stdlib::byte_array& hashed_message, + const G1& public_key, + const signature& sig) { Builder* ctx = hashed_message.get_context() ? hashed_message.get_context() : public_key.x.context; @@ -210,15 +210,14 @@ bool_t ecdsa_verify_signature_prehashed_message_noassert(const stdlib:: * @return bool_t */ template -bool_t ecdsa_verify_signature_noassert(const stdlib::byte_array& message, - const G1& public_key, - const ecdsa_signature& sig) +bool_t verify_signature_noassert(const stdlib::byte_array& message, + const G1& public_key, + const signature& sig) { stdlib::byte_array hashed_message = static_cast>(stdlib::sha256(message)); - return ecdsa_verify_signature_prehashed_message_noassert( - hashed_message, public_key, sig); + return verify_signature_prehashed_message_noassert(hashed_message, public_key, sig); } -} // namespace bb::stdlib \ No newline at end of file +} // namespace bb::stdlib::ecdsa \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/encryption/schnorr/schnorr.cpp b/barretenberg/cpp/src/barretenberg/stdlib/encryption/schnorr/schnorr.cpp index 8c4c8e011c45..2f73d0646c39 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/encryption/schnorr/schnorr.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/encryption/schnorr/schnorr.cpp @@ -7,14 +7,13 @@ #include "barretenberg/stdlib/primitives/group/cycle_group.hpp" #include -namespace bb::stdlib { +namespace bb::stdlib::schnorr { /** * @brief Instantiate a witness containing the signature (s, e) as a quadruple of * field_t elements (s_lo, s_hi, e_lo, e_hi). */ -template -schnorr_signature_bits schnorr_convert_signature(C* context, const crypto::schnorr_signature& signature) +template signature_bits convert_signature(C* context, const crypto::schnorr::signature& signature) { using cycle_scalar = typename cycle_group::cycle_scalar; @@ -24,8 +23,8 @@ schnorr_signature_bits schnorr_convert_signature(C* context, const crypto::sc const uint8_t* e_ptr = &signature.e[0]; numeric::read(s_ptr, s_bigint); numeric::read(e_ptr, e_bigint); - schnorr_signature_bits sig{ .s = cycle_scalar::from_witness_bitstring(context, s_bigint, 256), - .e = cycle_scalar::from_witness_bitstring(context, e_bigint, 256) }; + signature_bits sig{ .s = cycle_scalar::from_witness_bitstring(context, s_bigint, 256), + .e = cycle_scalar::from_witness_bitstring(context, e_bigint, 256) }; return sig; } @@ -38,9 +37,9 @@ schnorr_signature_bits schnorr_convert_signature(C* context, const crypto::sc * (~1,169k for fixed/variable_base_mul, ~4k for blake2s) for a string of length = 34. */ template -std::array, 2> schnorr_verify_signature_internal(const byte_array& message, - const cycle_group& pub_key, - const schnorr_signature_bits& sig) +std::array, 2> verify_signature_internal(const byte_array& message, + const cycle_group& pub_key, + const signature_bits& sig) { cycle_group g1(grumpkin::g1::one); // compute g1 * sig.s + key * sig,e @@ -67,11 +66,9 @@ std::array, 2> schnorr_verify_signature_internal(const byte_array& * e' == e is true. */ template -void schnorr_verify_signature(const byte_array& message, - const cycle_group& pub_key, - const schnorr_signature_bits& sig) +void verify_signature(const byte_array& message, const cycle_group& pub_key, const signature_bits& sig) { - auto [output_lo, output_hi] = schnorr_verify_signature_internal(message, pub_key, sig); + auto [output_lo, output_hi] = verify_signature_internal(message, pub_key, sig); output_lo.assert_equal(sig.e.lo, "verify signature failed"); output_hi.assert_equal(sig.e.hi, "verify signature failed"); } @@ -82,42 +79,37 @@ void schnorr_verify_signature(const byte_array& message, * and return the boolean witness e' == e. */ template -bool_t schnorr_signature_verification_result(const byte_array& message, - const cycle_group& pub_key, - const schnorr_signature_bits& sig) +bool_t signature_verification_result(const byte_array& message, + const cycle_group& pub_key, + const signature_bits& sig) { - auto [output_lo, output_hi] = schnorr_verify_signature_internal(message, pub_key, sig); + auto [output_lo, output_hi] = verify_signature_internal(message, pub_key, sig); bool_t valid = (output_lo == sig.e.lo) && (output_hi == sig.e.hi); return valid; } #define VERIFY_SIGNATURE_INTERNAL(circuit_type) \ - template std::array, 2> schnorr_verify_signature_internal( \ - const byte_array&, \ - const cycle_group&, \ - const schnorr_signature_bits&) + template std::array, 2> verify_signature_internal( \ + const byte_array&, const cycle_group&, const signature_bits&) VERIFY_SIGNATURE_INTERNAL(bb::StandardCircuitBuilder); VERIFY_SIGNATURE_INTERNAL(bb::UltraCircuitBuilder); VERIFY_SIGNATURE_INTERNAL(bb::GoblinUltraCircuitBuilder); #define VERIFY_SIGNATURE(circuit_type) \ - template void schnorr_verify_signature(const byte_array&, \ - const cycle_group&, \ - const schnorr_signature_bits&) + template void verify_signature( \ + const byte_array&, const cycle_group&, const signature_bits&) VERIFY_SIGNATURE(bb::StandardCircuitBuilder); VERIFY_SIGNATURE(bb::UltraCircuitBuilder); VERIFY_SIGNATURE(bb::GoblinUltraCircuitBuilder); #define SIGNATURE_VERIFICATION_RESULT(circuit_type) \ - template bool_t schnorr_signature_verification_result( \ - const byte_array&, \ - const cycle_group&, \ - const schnorr_signature_bits&) + template bool_t signature_verification_result( \ + const byte_array&, const cycle_group&, const signature_bits&) SIGNATURE_VERIFICATION_RESULT(bb::StandardCircuitBuilder); SIGNATURE_VERIFICATION_RESULT(bb::UltraCircuitBuilder); SIGNATURE_VERIFICATION_RESULT(bb::GoblinUltraCircuitBuilder); #define CONVERT_SIGNATURE(circuit_type) \ - template schnorr_signature_bits schnorr_convert_signature( \ - circuit_type*, const crypto::schnorr_signature&) + template signature_bits convert_signature(circuit_type*, \ + const crypto::schnorr::signature&) CONVERT_SIGNATURE(bb::StandardCircuitBuilder); CONVERT_SIGNATURE(bb::UltraCircuitBuilder); CONVERT_SIGNATURE(bb::GoblinUltraCircuitBuilder); -} // namespace bb::stdlib +} // namespace bb::stdlib::schnorr diff --git a/barretenberg/cpp/src/barretenberg/stdlib/encryption/schnorr/schnorr.hpp b/barretenberg/cpp/src/barretenberg/stdlib/encryption/schnorr/schnorr.hpp index b9ea2e632a5d..26f2ef0784b5 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/encryption/schnorr/schnorr.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/encryption/schnorr/schnorr.hpp @@ -6,29 +6,26 @@ #include "../../primitives/witness/witness.hpp" #include "barretenberg/crypto/schnorr/schnorr.hpp" -namespace bb::stdlib { +namespace bb::stdlib::schnorr { -template struct schnorr_signature_bits { +template struct signature_bits { typename cycle_group::cycle_scalar s; typename cycle_group::cycle_scalar e; }; -template -schnorr_signature_bits schnorr_convert_signature(C* context, const crypto::schnorr_signature& sig); +template signature_bits convert_signature(C* context, const crypto::schnorr::signature& sig); template -std::array, 2> schnorr_verify_signature_internal(const byte_array& message, - const cycle_group& pub_key, - const schnorr_signature_bits& sig); +std::array, 2> verify_signature_internal(const byte_array& message, + const cycle_group& pub_key, + const signature_bits& sig); template -void schnorr_verify_signature(const byte_array& message, - const cycle_group& pub_key, - const schnorr_signature_bits& sig); +void verify_signature(const byte_array& message, const cycle_group& pub_key, const signature_bits& sig); template -bool_t schnorr_signature_verification_result(const byte_array& message, - const cycle_group& pub_key, - const schnorr_signature_bits& sig); +bool_t signature_verification_result(const byte_array& message, + const cycle_group& pub_key, + const signature_bits& sig); -} // namespace bb::stdlib +} // namespace bb::stdlib::schnorr diff --git a/barretenberg/cpp/src/barretenberg/stdlib/encryption/schnorr/schnorr.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/encryption/schnorr/schnorr.test.cpp index 6c5bfe9573f9..0ae462195d5b 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/encryption/schnorr/schnorr.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/encryption/schnorr/schnorr.test.cpp @@ -5,21 +5,24 @@ #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" #include "schnorr.hpp" +namespace bb::test_stdlib_schnorr { + using namespace bb; using namespace bb::stdlib; +using namespace bb::stdlib::schnorr; -using Builder = UltraCircuitBuilder; +using Builder = bb::UltraCircuitBuilder; using bool_ct = bool_t; using byte_array_ct = byte_array; using field_ct = field_t; using witness_ct = witness_t; /** - * @test Test circuit verifying a Schnorr signature generated by \see{crypto::schnorr_verify_signature}. + * @test Test circuit verifying a Schnorr signature generated by \see{crypto::schnorr::verify_signature}. * We only test: messages signed and verified using Grumpkin and the BLAKE2s hash function. We test strings of lengths * 0, 1, ..., 33. */ -TEST(stdlib_schnorr, schnorr_verify_signature) +TEST(stdlib_schnorr, verify_signature) { std::string longer_string = "This is a test string of length 34"; @@ -28,24 +31,24 @@ TEST(stdlib_schnorr, schnorr_verify_signature) Builder builder = Builder(); auto message_string = longer_string.substr(0, i); - crypto::schnorr_key_pair account; + crypto::schnorr::key_pair account; account.private_key = grumpkin::fr::random_element(); account.public_key = grumpkin::g1::one * account.private_key; - crypto::schnorr_signature signature = - crypto::schnorr_construct_signature(message_string, - account); + crypto::schnorr::signature signature = + crypto::schnorr::construct_signature( + message_string, account); - bool first_result = crypto::schnorr_verify_signature( + bool first_result = crypto::schnorr::verify_signature( message_string, account.public_key, signature); EXPECT_EQ(first_result, true); cycle_group pub_key{ witness_ct(&builder, account.public_key.x), witness_ct(&builder, account.public_key.y), false }; - schnorr_signature_bits sig = schnorr_convert_signature(&builder, signature); + signature_bits sig = convert_signature(&builder, signature); byte_array_ct message(&builder, message_string); - schnorr_verify_signature(message, pub_key, sig); + verify_signature(message, pub_key, sig); info("num gates = ", builder.get_num_gates()); bool result = builder.check_circuit(); @@ -63,22 +66,22 @@ TEST(stdlib_schnorr, verify_signature_failure) std::string message_string = "This is a test string of length 34"; // create key pair 1 - crypto::schnorr_key_pair account1; + crypto::schnorr::key_pair account1; account1.private_key = grumpkin::fr::random_element(); account1.public_key = grumpkin::g1::one * account1.private_key; // create key pair 2 - crypto::schnorr_key_pair account2; + crypto::schnorr::key_pair account2; account2.private_key = grumpkin::fr::random_element(); account2.public_key = grumpkin::g1::one * account2.private_key; // sign the message with account 1 private key - crypto::schnorr_signature signature = - crypto::schnorr_construct_signature(message_string, - account1); + crypto::schnorr::signature signature = + crypto::schnorr::construct_signature(message_string, + account1); // check native verification with account 2 public key fails - bool native_result = crypto::schnorr_verify_signature( + bool native_result = crypto::schnorr::verify_signature( message_string, account2.public_key, signature); EXPECT_EQ(native_result, false); @@ -86,9 +89,9 @@ TEST(stdlib_schnorr, verify_signature_failure) cycle_group pub_key2_ct{ witness_ct(&builder, account2.public_key.x), witness_ct(&builder, account2.public_key.y), false }; - schnorr_signature_bits sig = schnorr_convert_signature(&builder, signature); + signature_bits sig = convert_signature(&builder, signature); byte_array_ct message(&builder, message_string); - schnorr_verify_signature(message, pub_key2_ct, sig); + verify_signature(message, pub_key2_ct, sig); info("num gates = ", builder.get_num_gates()); @@ -97,33 +100,33 @@ TEST(stdlib_schnorr, verify_signature_failure) } /** - * @test Like stdlib_schnorr.schnorr_verify_signature, but we use the function signature_verification that produces a + * @test Like stdlib_schnorr.verify_signature, but we use the function signature_verification that produces a * boolean witness and does not require the prover to provide a valid signature. */ -TEST(stdlib_schnorr, schnorr_signature_verification_result) +TEST(stdlib_schnorr, signature_verification_result) { std::string longer_string = "This is a test string of length 34"; Builder builder = Builder(); - crypto::schnorr_key_pair account; + crypto::schnorr::key_pair account; account.private_key = grumpkin::fr::random_element(); account.public_key = grumpkin::g1::one * account.private_key; - crypto::schnorr_signature signature = - crypto::schnorr_construct_signature(longer_string, - account); + crypto::schnorr::signature signature = + crypto::schnorr::construct_signature(longer_string, + account); - bool first_result = crypto::schnorr_verify_signature( + bool first_result = crypto::schnorr::verify_signature( longer_string, account.public_key, signature); EXPECT_EQ(first_result, true); cycle_group pub_key{ witness_ct(&builder, account.public_key.x), witness_ct(&builder, account.public_key.y), false }; - schnorr_signature_bits sig = schnorr_convert_signature(&builder, signature); + signature_bits sig = convert_signature(&builder, signature); byte_array_ct message(&builder, longer_string); - bool_ct signature_result = schnorr_signature_verification_result(message, pub_key, sig); + bool_ct signature_result = signature_verification_result(message, pub_key, sig); EXPECT_EQ(signature_result.witness_bool, true); info("num gates = ", builder.get_num_gates()); @@ -142,22 +145,22 @@ TEST(stdlib_schnorr, signature_verification_result_failure) std::string message_string = "This is a test string of length 34"; // create key pair 1 - crypto::schnorr_key_pair account1; + crypto::schnorr::key_pair account1; account1.private_key = grumpkin::fr::random_element(); account1.public_key = grumpkin::g1::one * account1.private_key; // create key pair 2 - crypto::schnorr_key_pair account2; + crypto::schnorr::key_pair account2; account2.private_key = grumpkin::fr::random_element(); account2.public_key = grumpkin::g1::one * account2.private_key; // sign the message with account 1 private key - crypto::schnorr_signature signature = - crypto::schnorr_construct_signature(message_string, - account1); + crypto::schnorr::signature signature = + crypto::schnorr::construct_signature(message_string, + account1); // check native verification with account 2 public key fails - bool native_result = crypto::schnorr_verify_signature( + bool native_result = crypto::schnorr::verify_signature( message_string, account2.public_key, signature); EXPECT_EQ(native_result, false); @@ -165,9 +168,9 @@ TEST(stdlib_schnorr, signature_verification_result_failure) cycle_group pub_key2_ct{ witness_ct(&builder, account2.public_key.x), witness_ct(&builder, account2.public_key.y), false }; - schnorr_signature_bits sig = schnorr_convert_signature(&builder, signature); + signature_bits sig = convert_signature(&builder, signature); byte_array_ct message(&builder, message_string); - bool_ct signature_result = schnorr_signature_verification_result(message, pub_key2_ct, sig); + bool_ct signature_result = signature_verification_result(message, pub_key2_ct, sig); EXPECT_EQ(signature_result.witness_bool, false); info("num gates = ", builder.get_num_gates()); @@ -175,3 +178,5 @@ TEST(stdlib_schnorr, signature_verification_result_failure) bool verification_result = builder.check_circuit(); EXPECT_EQ(verification_result, true); } + +} // namespace bb::test_stdlib_schnorr diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/blake2s/blake2s.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/blake2s/blake2s.test.cpp index f5a8b37f24dc..bf8be6de42fc 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/blake2s/blake2s.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/blake2s/blake2s.test.cpp @@ -7,7 +7,7 @@ using namespace bb; using namespace bb::stdlib; -using Builder = UltraCircuitBuilder; +using Builder = bb::UltraCircuitBuilder; using field_ct = field_t; using witness_ct = witness_t; @@ -24,7 +24,7 @@ using public_witness_t = public_witness_t; // byte_array_ct input_arr(&builder, input_v); // byte_array_ct output = blake2s(input_arr); -// std::vector expected = crypto::blake2s(input_v); +// std::vector expected = blake2::blake2s(input_v); // EXPECT_EQ(output.get_value(), expected); @@ -43,7 +43,7 @@ TEST(stdlib_blake2s, test_single_block_plookup) byte_array_plookup input_arr(&builder, input_v); byte_array_plookup output = blake2s(input_arr); - auto expected = crypto::blake2s(input_v); + auto expected = blake2::blake2s(input_v); EXPECT_EQ(output.get_value(), std::vector(expected.begin(), expected.end())); @@ -62,7 +62,7 @@ TEST(stdlib_blake2s, test_single_block_plookup) // byte_array_ct input_arr(&builder, input_v); // byte_array_ct output = blake2s(input_arr); -// std::vector expected = crypto::blake2s(input_v); +// std::vector expected = blake2::blake2s(input_v); // EXPECT_EQ(output.get_value(), expected); @@ -81,7 +81,7 @@ TEST(stdlib_blake2s, test_double_block_plookup) byte_array_plookup input_arr(&builder, input_v); byte_array_plookup output = blake2s(input_arr); - auto expected = crypto::blake2s(input_v); + auto expected = blake2::blake2s(input_v); EXPECT_EQ(output.get_value(), std::vector(expected.begin(), expected.end())); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/blake2s/blake_util.hpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/blake2s/blake_util.hpp index 25a65a5abbcf..418f601e1466 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/blake2s/blake_util.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/blake2s/blake_util.hpp @@ -6,7 +6,7 @@ namespace bb::stdlib::blake_util { -using namespace bb::plookup; +using namespace plookup; // constants enum blake_constant { BLAKE3_STATE_SIZE = 16 }; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/blake3s/blake3s.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/blake3s/blake3s.test.cpp index 9e054605e3a0..69c5b7a79040 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/blake3s/blake3s.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/blake3s/blake3s.test.cpp @@ -10,8 +10,8 @@ using byte_array = stdlib::byte_array; using public_witness_t = stdlib::public_witness_t; using byte_array_plookup = stdlib::byte_array; using public_witness_t_plookup = stdlib::public_witness_t; -using StandardBuilder = StandardCircuitBuilder; -using UltraBuilder = UltraCircuitBuilder; +using StandardBuilder = bb::StandardCircuitBuilder; +using UltraBuilder = bb::UltraCircuitBuilder; TEST(stdlib_blake3s, test_single_block) { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/keccak/keccak.cpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/keccak/keccak.cpp index 2392853e3355..3f10f28b9c39 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/keccak/keccak.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/keccak/keccak.cpp @@ -5,7 +5,7 @@ #include "barretenberg/stdlib/primitives/uint/uint.hpp" namespace bb::stdlib { -using namespace bb::plookup; +using namespace plookup; /** * @brief Normalize a base-11 limb and left-rotate by keccak::ROTATIONS[lane_index] bits. diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/keccak/keccak.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/keccak/keccak.test.cpp index 49409098b2fc..3c414a26856d 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/keccak/keccak.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/keccak/keccak.test.cpp @@ -6,7 +6,7 @@ using namespace bb; -typedef UltraCircuitBuilder Builder; +typedef bb::UltraCircuitBuilder Builder; typedef stdlib::byte_array byte_array; typedef stdlib::public_witness_t public_witness_t; typedef stdlib::field_t field_ct; @@ -14,7 +14,7 @@ typedef stdlib::witness_t witness_ct; typedef stdlib::uint32 uint32_ct; namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } TEST(stdlib_keccak, keccak_format_input_table) @@ -67,7 +67,7 @@ TEST(stdlib_keccak, keccak_rho_output_table) { Builder builder = Builder(); - constexpr_for<0, 25, 1>([&] { + bb::constexpr_for<0, 25, 1>([&] { uint256_t extended_native = 0; uint256_t binary_native = 0; for (size_t j = 0; j < 64; ++j) { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.test.cpp index 71787e0a8de4..e81aeae6bf56 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.test.cpp @@ -5,9 +5,10 @@ #include "barretenberg/stdlib/primitives/curves/bn254.hpp" #include "pedersen.hpp" +namespace test_StdlibPedersen { using namespace bb; namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } template class StdlibPedersen : public testing::Test { @@ -154,41 +155,41 @@ template class StdlibPedersen : public testing::Test { Builder builder; for (size_t i = 0; i < 7; ++i) { - std::vector inputs; + std::vector inputs; inputs.push_back(bb::fr::random_element()); inputs.push_back(bb::fr::random_element()); inputs.push_back(bb::fr::random_element()); inputs.push_back(bb::fr::random_element()); if (i == 1) { - inputs[0] = fr(0); + inputs[0] = bb::fr(0); } if (i == 2) { - inputs[1] = fr(0); - inputs[2] = fr(0); + inputs[1] = bb::fr(0); + inputs[2] = bb::fr(0); } if (i == 3) { - inputs[3] = fr(0); + inputs[3] = bb::fr(0); } if (i == 4) { - inputs[0] = fr(0); - inputs[3] = fr(0); + inputs[0] = bb::fr(0); + inputs[3] = bb::fr(0); } if (i == 5) { - inputs[0] = fr(0); - inputs[1] = fr(0); - inputs[2] = fr(0); - inputs[3] = fr(0); + inputs[0] = bb::fr(0); + inputs[1] = bb::fr(0); + inputs[2] = bb::fr(0); + inputs[3] = bb::fr(0); } if (i == 6) { - inputs[1] = fr(1); + inputs[1] = bb::fr(1); } std::vector witnesses; for (auto input : inputs) { witnesses.push_back(witness_ct(&builder, input)); } - fr expected = crypto::pedersen_hash::hash(inputs); + bb::fr expected = crypto::pedersen_hash::hash(inputs); fr_ct result = pedersen_hash::hash(witnesses); EXPECT_EQ(result.get_value(), expected); @@ -224,7 +225,7 @@ template class StdlibPedersen : public testing::Test { { Builder builder; - std::vector inputs; + std::vector inputs; std::vector> witness_inputs; for (size_t i = 0; i < 8; ++i) { @@ -236,7 +237,7 @@ template class StdlibPedersen : public testing::Test { } } - fr expected = crypto::pedersen_hash::hash(inputs); + bb::fr expected = crypto::pedersen_hash::hash(inputs); auto result = pedersen_hash::hash(witness_inputs); EXPECT_EQ(result.get_value(), expected); @@ -308,3 +309,5 @@ TYPED_TEST(StdlibPedersen, HashConstants) { TestFixture::test_hash_constants(); }; + +} // namespace test_StdlibPedersen diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/poseidon2/poseidon2.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/poseidon2/poseidon2.test.cpp index 6d5e4bb1cdf3..428193f5c39b 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/poseidon2/poseidon2.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/poseidon2/poseidon2.test.cpp @@ -4,9 +4,10 @@ #include "barretenberg/numeric/random/engine.hpp" #include "barretenberg/stdlib/primitives/curves/bn254.hpp" +namespace test_StdlibPoseidon2 { using namespace bb; namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } template class StdlibPoseidon2 : public testing::Test { @@ -127,7 +128,7 @@ template class StdlibPoseidon2 : public testing::Test { { Builder builder; - std::vector inputs; + std::vector inputs; std::vector> witness_inputs; for (size_t i = 0; i < 8; ++i) { @@ -139,7 +140,7 @@ template class StdlibPoseidon2 : public testing::Test { } } - fr expected = native_poseidon2::hash(inputs); + bb::fr expected = native_poseidon2::hash(inputs); auto result = poseidon2::hash(builder, witness_inputs); EXPECT_EQ(result.get_value(), expected); @@ -184,3 +185,5 @@ TYPED_TEST(StdlibPoseidon2, TestHashConstants) { TestFixture::test_hash_constants(); }; + +} // namespace test_StdlibPoseidon2 diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/sha256/sha256.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/sha256/sha256.test.cpp index 9d7e3299b61a..618dc52ef93f 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/sha256/sha256.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/sha256/sha256.test.cpp @@ -9,13 +9,16 @@ #include "barretenberg/numeric/bitop/sparse_form.hpp" #include "barretenberg/numeric/random/engine.hpp" +namespace { +auto& engine = numeric::random::get_debug_engine(); +} + +namespace bb::test_stdlib_sha256 { + using namespace bb; using namespace bb::stdlib; -namespace { -auto& engine = numeric::get_debug_randomness(); -} -using Builder = UltraCircuitBuilder; +using Builder = bb::UltraCircuitBuilder; using byte_array_ct = byte_array; using packed_byte_array_ct = packed_byte_array; @@ -117,18 +120,18 @@ std::array inner_block(std::array& w) // auto builder = UltraPlonkBuilder(); // std::array w_inputs; -// std::array, 64> w_elements; +// std::array, 64> w_elements; // for (size_t i = 0; i < 64; ++i) { // w_inputs[i] = engine.get_random_uint32(); -// w_elements[i] = stdlib::witness_t(&builder, -// fr(w_inputs[i])); +// w_elements[i] = bb::stdlib::witness_t(&builder, +// bb::fr(w_inputs[i])); // } // const auto expected = inner_block(w_inputs); // const std::array, 8> result = -// stdlib::sha256_inner_block(w_elements); +// bb::stdlib::sha256_inner_block(w_elements); // for (size_t i = 0; i < 8; ++i) { // EXPECT_EQ(uint256_t(result[i].get_value()).data[0] & 0xffffffffUL, // uint256_t(expected[i]).data[0] & 0xffffffffUL); @@ -138,22 +141,22 @@ std::array inner_block(std::array& w) // auto prover = composer.create_prover(); // auto verifier = composer.create_verifier(); -// plonk::proof proof = prover.construct_proof(); +// bb::plonk::proof proof = prover.construct_proof(); // bool proof_result = builder.check_circuit(); // EXPECT_EQ(proof_result, true); // } TEST(stdlib_sha256, test_plookup_55_bytes) { - typedef stdlib::field_t field_pt; - typedef stdlib::packed_byte_array packed_byte_array_pt; + typedef bb::stdlib::field_t field_pt; + typedef bb::stdlib::packed_byte_array packed_byte_array_pt; // 55 bytes is the largest number of bytes that can be hashed in a single block, // accounting for the single padding bit, and the 64 size bits required by the SHA-256 standard. - auto builder = UltraCircuitBuilder(); + auto builder = bb::UltraCircuitBuilder(); packed_byte_array_pt input(&builder, "An 8 character password? Snow White and the 7 Dwarves.."); - packed_byte_array_pt output_bits = stdlib::sha256(input); + packed_byte_array_pt output_bits = bb::stdlib::sha256(input); std::vector output = output_bits.to_unverified_byte_slices(4); @@ -178,7 +181,7 @@ TEST(stdlib_sha256, test_55_bytes) auto builder = Builder(); packed_byte_array_ct input(&builder, "An 8 character password? Snow White and the 7 Dwarves.."); - packed_byte_array_ct output_bits = stdlib::sha256(input); + packed_byte_array_ct output_bits = bb::stdlib::sha256(input); std::vector output = output_bits.to_unverified_byte_slices(4); @@ -198,13 +201,13 @@ TEST(stdlib_sha256, test_55_bytes) TEST(stdlib_sha256, test_NIST_vector_one_packed_byte_array) { - typedef stdlib::field_t field_pt; - typedef stdlib::packed_byte_array packed_byte_array_pt; + typedef bb::stdlib::field_t field_pt; + typedef bb::stdlib::packed_byte_array packed_byte_array_pt; - auto builder = UltraCircuitBuilder(); + auto builder = bb::UltraCircuitBuilder(); packed_byte_array_pt input(&builder, "abc"); - packed_byte_array_pt output_bytes = stdlib::sha256(input); + packed_byte_array_pt output_bytes = bb::stdlib::sha256(input); std::vector output = output_bytes.to_unverified_byte_slices(4); EXPECT_EQ(uint256_t(output[0].get_value()).data[0], (uint64_t)0xBA7816BFU); EXPECT_EQ(uint256_t(output[1].get_value()).data[0], (uint64_t)0x8F01CFEAU); @@ -222,14 +225,14 @@ TEST(stdlib_sha256, test_NIST_vector_one_packed_byte_array) TEST(stdlib_sha256, test_NIST_vector_one) { - typedef stdlib::field_t field_pt; - typedef stdlib::packed_byte_array packed_byte_array_pt; + typedef bb::stdlib::field_t field_pt; + typedef bb::stdlib::packed_byte_array packed_byte_array_pt; - auto builder = UltraCircuitBuilder(); + auto builder = bb::UltraCircuitBuilder(); packed_byte_array_pt input(&builder, "abc"); - packed_byte_array_pt output_bits = stdlib::sha256(input); + packed_byte_array_pt output_bits = bb::stdlib::sha256(input); std::vector output = output_bits.to_unverified_byte_slices(4); @@ -253,7 +256,7 @@ TEST(stdlib_sha256, test_NIST_vector_two) byte_array_ct input(&builder, "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"); - byte_array_ct output_bits = stdlib::sha256(input); + byte_array_ct output_bits = bb::stdlib::sha256(input); std::vector output = packed_byte_array_ct(output_bits).to_unverified_byte_slices(4); @@ -278,7 +281,7 @@ TEST(stdlib_sha256, test_NIST_vector_three) // one byte, 0xbd byte_array_ct input(&builder, std::vector{ 0xbd }); - byte_array_ct output_bits = stdlib::sha256(input); + byte_array_ct output_bits = bb::stdlib::sha256(input); std::vector output = packed_byte_array_ct(output_bits).to_unverified_byte_slices(4); @@ -303,7 +306,7 @@ TEST(stdlib_sha256, test_NIST_vector_four) // 4 bytes, 0xc98c8e55 byte_array_ct input(&builder, std::vector{ 0xc9, 0x8c, 0x8e, 0x55 }); - byte_array_ct output_bits = stdlib::sha256(input); + byte_array_ct output_bits = bb::stdlib::sha256(input); std::vector output = packed_byte_array_ct(output_bits).to_unverified_byte_slices(4); @@ -324,10 +327,10 @@ TEST(stdlib_sha256, test_NIST_vector_four) HEAVY_TEST(stdlib_sha256, test_NIST_vector_five) { - typedef stdlib::field_t field_pt; - typedef stdlib::packed_byte_array packed_byte_array_pt; + typedef bb::stdlib::field_t field_pt; + typedef bb::stdlib::packed_byte_array packed_byte_array_pt; - auto builder = UltraCircuitBuilder(); + auto builder = bb::UltraCircuitBuilder(); packed_byte_array_pt input( &builder, @@ -342,7 +345,7 @@ HEAVY_TEST(stdlib_sha256, test_NIST_vector_five) "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" "AAAAAAAAAA"); - packed_byte_array_pt output_bits = stdlib::sha256(input); + packed_byte_array_pt output_bits = bb::stdlib::sha256(input); std::vector output = output_bits.to_unverified_byte_slices(4); @@ -371,7 +374,7 @@ TEST(stdlib_sha256, test_input_len_multiple) auto input_buf = std::vector(inp, 1); byte_array_ct input(&builder, input_buf); - byte_array_ct output_bits = stdlib::sha256(input); + byte_array_ct output_bits = bb::stdlib::sha256(input); auto circuit_output = output_bits.get_value(); @@ -415,7 +418,7 @@ TEST(stdlib_sha256, test_input_str_len_multiple) auto input_buf = std::vector(input_str.begin(), input_str.end()); byte_array_ct input(&builder, input_buf); - byte_array_ct output_bits = stdlib::sha256(input); + byte_array_ct output_bits = bb::stdlib::sha256(input); auto circuit_output = output_bits.get_value(); @@ -424,3 +427,5 @@ TEST(stdlib_sha256, test_input_str_len_multiple) EXPECT_EQ(circuit_output, expected); } } + +} // namespace bb::test_stdlib_sha256 diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/sha256/sha256_plookup.cpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/sha256/sha256_plookup.cpp index bffa757acd72..cb16d9f89ccc 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/sha256/sha256_plookup.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/sha256/sha256_plookup.cpp @@ -11,7 +11,7 @@ using namespace bb; namespace bb::stdlib::sha256_plookup { -using namespace bb::plookup; +using namespace plookup; namespace internal { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/hash.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/hash.test.cpp index 2e420fb15383..8daf6b0ef385 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/hash.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/hash.test.cpp @@ -5,10 +5,12 @@ #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" #include "barretenberg/stdlib/merkle_tree/membership.hpp" +namespace bb::stdlib_merkle_tree_hash_test { + using namespace bb; using namespace bb::stdlib; -using Builder = UltraCircuitBuilder; +using Builder = bb::UltraCircuitBuilder; using field_ct = field_t; using witness_ct = witness_t; @@ -62,3 +64,4 @@ TEST(stdlib_merkle_tree_hash, compute_tree_native) } EXPECT_EQ(tree_vector.back(), mem_tree.root()); } +} // namespace bb::stdlib_merkle_tree_hash_test \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/membership.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/membership.test.cpp index 1d8d06820e74..f559cf01085d 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/membership.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/membership.test.cpp @@ -7,15 +7,17 @@ #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" +namespace { +auto& engine = numeric::random::get_debug_engine(); +} + +namespace bb::stdlib_merkle_test { + using namespace bb; using namespace bb::stdlib::merkle_tree; using namespace bb::stdlib; -namespace { -auto& engine = numeric::get_debug_randomness(); -} - -using Builder = UltraCircuitBuilder; +using Builder = bb::UltraCircuitBuilder; using bool_ct = bool_t; using field_ct = field_t; @@ -245,3 +247,4 @@ TEST(stdlib_merkle_tree, test_update_memberships) bool result = builder.check_circuit(); EXPECT_EQ(result, true); } +} // namespace bb::stdlib_merkle_test \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/merkle_tree.bench.cpp b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/merkle_tree.bench.cpp index 49871e881e6f..94268b49bb17 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/merkle_tree.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/merkle_tree.bench.cpp @@ -8,7 +8,7 @@ using namespace benchmark; using namespace bb::stdlib::merkle_tree; namespace { -auto& engine = bb::numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } constexpr size_t DEPTH = 256; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/merkle_tree.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/merkle_tree.test.cpp index 55bd530c2161..ec80f169126f 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/merkle_tree.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/merkle_tree.test.cpp @@ -5,16 +5,18 @@ #include "memory_store.hpp" #include "memory_tree.hpp" +namespace bb::test_stdlib_merkle_tree { + using namespace bb::stdlib; using namespace bb::stdlib::merkle_tree; -using Builder = UltraCircuitBuilder; +using Builder = bb::UltraCircuitBuilder; using field_ct = field_t; using witness_ct = witness_t; namespace { -auto& engine = numeric::get_debug_randomness(); -auto& random_engine = numeric::get_randomness(); +auto& engine = numeric::random::get_debug_engine(); +auto& random_engine = numeric::random::get_engine(); } // namespace static std::vector VALUES = []() { @@ -182,3 +184,4 @@ TEST(stdlib_merkle_tree, test_get_sibling_path_layers) EXPECT_NE(before[2], after[2]); } } +} // namespace bb::test_stdlib_merkle_tree \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/nullifier_tree/nullifier_tree.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/nullifier_tree/nullifier_tree.test.cpp index 99a1eeeffdeb..de20b85ddbd4 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/nullifier_tree/nullifier_tree.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/nullifier_tree/nullifier_tree.test.cpp @@ -9,8 +9,8 @@ using namespace bb; using namespace bb::stdlib::merkle_tree; namespace { -auto& engine = numeric::get_debug_randomness(); -auto& random_engine = numeric::get_randomness(); +auto& engine = numeric::random::get_debug_engine(); +auto& random_engine = numeric::random::get_engine(); } // namespace static std::vector VALUES = []() { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield.test.cpp index cc03446d73f2..e47278837ec2 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield.test.cpp @@ -18,6 +18,7 @@ #include #include +namespace test_stdlib_bigfield { using namespace bb; /* A note regarding Plookup: @@ -29,7 +30,7 @@ using namespace bb; */ namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } template class stdlib_bigfield : public testing::Test { @@ -826,18 +827,18 @@ template class stdlib_bigfield : public testing::Test { static void test_conditional_select_regression() { auto builder = Builder(); - fq a(0); - fq b(1); + bb::fq a(0); + bb::fq b(1); fq_ct a_ct(&builder, a); fq_ct b_ct(&builder, b); fq_ct selected = a_ct.conditional_select(b_ct, typename bn254::bool_ct(&builder, true)); - EXPECT_EQ(fq((selected.get_value() % uint512_t(bb::fq::modulus)).lo), b); + EXPECT_EQ(bb::fq((selected.get_value() % uint512_t(bb::fq::modulus)).lo), b); } static void test_division_context() { auto builder = Builder(); - fq a(1); + bb::fq a(1); fq_ct a_ct(&builder, a); fq_ct ret = fq_ct::div_check_denominator_nonzero({}, a_ct); EXPECT_NE(ret.get_context(), nullptr); @@ -942,15 +943,15 @@ TYPED_TEST(stdlib_bigfield, division_context) // fq_ct::NUM_LIMB_BITS * 2))), // witness_ct( // &builder, -// fr(uint256_t(inputs[0]).slice(fq_ct::NUM_LIMB_BITS * 2, +// bb::fr(uint256_t(inputs[0]).slice(fq_ct::NUM_LIMB_BITS * 2, // fq_ct::NUM_LIMB_BITS * 4)))); // fq_ct b1(&builder, uint256_t(inputs[1])); // fq_ct b2(&builder, uint256_t(inputs[2])); // fq_ct c = a / (b1 - b2); // // uint256_t modulus{ bb::Bn254FqParams::modulus_0, -// // Bn254FqParams::modulus_1, -// // Bn254FqParams::modulus_2, -// // Bn254FqParams::modulus_3 }; +// // bb::Bn254FqParams::modulus_1, +// // bb::Bn254FqParams::modulus_2, +// // bb::Bn254FqParams::modulus_3 }; // fq expected = (inputs[0] / (inputs[1] - inputs[2])); // std::cerr << "denominator = " << inputs[1] - inputs[2] << std::endl; @@ -977,20 +978,20 @@ TYPED_TEST(stdlib_bigfield, division_context) // // PLOOKUP TESTS // TEST(stdlib_bigfield_plookup, test_mul) // { -// plonk::UltraPlonkBuilder builder = plonk::UltraPlonkBuilder(); +// plonk::UltraPlonkBuilder builder = bb::plonk::UltraPlonkBuilder(); // size_t num_repetitions = 1; // for (size_t i = 0; i < num_repetitions; ++i) { // fq inputs[3]{ fq::random_element(), fq::random_element(), fq::random_element() }; // fq_ct a( // witness_ct(&builder, bb::fr(uint256_t(inputs[0]).slice(0, // fq_ct::NUM_LIMB_BITS * 2))), witness_ct(&builder, -// fr( +// bb::fr( // uint256_t(inputs[0]).slice(fq_ct::NUM_LIMB_BITS * 2, fq_ct::NUM_LIMB_BITS * // 4)))); // fq_ct b( // witness_ct(&builder, bb::fr(uint256_t(inputs[1]).slice(0, // fq_ct::NUM_LIMB_BITS * 2))), witness_ct(&builder, -// fr( +// bb::fr( // uint256_t(inputs[1]).slice(fq_ct::NUM_LIMB_BITS * 2, fq_ct::NUM_LIMB_BITS * // 4)))); // std::cerr << "starting mul" << std::endl; @@ -1024,14 +1025,14 @@ TYPED_TEST(stdlib_bigfield, division_context) // TEST(stdlib_bigfield_plookup, test_sqr) // { -// plonk::UltraPlonkBuilder builder = plonk::UltraPlonkBuilder(); +// plonk::UltraPlonkBuilder builder = bb::plonk::UltraPlonkBuilder(); // size_t num_repetitions = 10; // for (size_t i = 0; i < num_repetitions; ++i) { // fq inputs[3]{ fq::random_element(), fq::random_element(), fq::random_element() }; // fq_ct a( // witness_ct(&builder, bb::fr(uint256_t(inputs[0]).slice(0, // fq_ct::NUM_LIMB_BITS * 2))), witness_ct(&builder, -// fr( +// bb::fr( // uint256_t(inputs[0]).slice(fq_ct::NUM_LIMB_BITS * 2, fq_ct::NUM_LIMB_BITS * // 4)))); // uint64_t before = builder.get_num_gates(); @@ -1061,3 +1062,4 @@ TYPED_TEST(stdlib_bigfield, division_context) // bool result = verifier.verify_proof(proof); // EXPECT_EQ(result, true); // } +} // namespace test_stdlib_bigfield diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup.test.cpp index 1dad1d6a38cc..6561525428f8 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup.test.cpp @@ -9,8 +9,9 @@ #include "barretenberg/stdlib/primitives/curves/secp256k1.hpp" #include "barretenberg/stdlib/primitives/curves/secp256r1.hpp" +namespace test_stdlib_biggroup { namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } using namespace bb; @@ -906,7 +907,7 @@ HEAVY_TYPED_TEST(stdlib_biggroup, multiple_montgomery_ladder) HEAVY_TYPED_TEST(stdlib_biggroup, compute_naf) { // ULTRATODO: make this work for secp curves - if constexpr (TypeParam::Curve::type == CurveType::BN254) { + if constexpr (TypeParam::Curve::type == bb::CurveType::BN254) { size_t num_repetitions = 1; for (size_t i = 0; i < num_repetitions; i++) { TestFixture::test_compute_naf(); @@ -979,7 +980,7 @@ HEAVY_TYPED_TEST(stdlib_biggroup, wnaf_batch_4) /* The following tests are specific to BN254 and don't work when Fr is a bigfield */ HEAVY_TYPED_TEST(stdlib_biggroup, bn254_endo_batch_mul) { - if constexpr (TypeParam::Curve::type == CurveType::BN254 && !TypeParam::use_bigfield) { + if constexpr (TypeParam::Curve::type == bb::CurveType::BN254 && !TypeParam::use_bigfield) { if constexpr (HasGoblinBuilder) { GTEST_SKIP() << "https://github.com/AztecProtocol/barretenberg/issues/707"; } else { @@ -991,7 +992,7 @@ HEAVY_TYPED_TEST(stdlib_biggroup, bn254_endo_batch_mul) } HEAVY_TYPED_TEST(stdlib_biggroup, mixed_mul_bn254_endo) { - if constexpr (TypeParam::Curve::type == CurveType::BN254 && !TypeParam::use_bigfield) { + if constexpr (TypeParam::Curve::type == bb::CurveType::BN254 && !TypeParam::use_bigfield) { if constexpr (HasGoblinBuilder) { GTEST_SKIP() << "https://github.com/AztecProtocol/barretenberg/issues/707"; } else { @@ -1005,7 +1006,7 @@ HEAVY_TYPED_TEST(stdlib_biggroup, mixed_mul_bn254_endo) /* The following tests are specific to SECP256k1 */ HEAVY_TYPED_TEST(stdlib_biggroup, wnaf_secp256k1) { - if constexpr (TypeParam::Curve::type == CurveType::SECP256K1) { + if constexpr (TypeParam::Curve::type == bb::CurveType::SECP256K1) { TestFixture::test_wnaf_secp256k1(); } else { GTEST_SKIP(); @@ -1013,7 +1014,7 @@ HEAVY_TYPED_TEST(stdlib_biggroup, wnaf_secp256k1) } HEAVY_TYPED_TEST(stdlib_biggroup, wnaf_8bit_secp256k1) { - if constexpr (TypeParam::Curve::type == CurveType::SECP256K1) { + if constexpr (TypeParam::Curve::type == bb::CurveType::SECP256K1) { TestFixture::test_wnaf_8bit_secp256k1(); } else { GTEST_SKIP(); @@ -1021,9 +1022,10 @@ HEAVY_TYPED_TEST(stdlib_biggroup, wnaf_8bit_secp256k1) } HEAVY_TYPED_TEST(stdlib_biggroup, ecdsa_mul_secp256k1) { - if constexpr (TypeParam::Curve::type == CurveType::SECP256K1) { + if constexpr (TypeParam::Curve::type == bb::CurveType::SECP256K1) { TestFixture::test_ecdsa_mul_secp256k1(); } else { GTEST_SKIP(); } } +} // namespace test_stdlib_biggroup diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_goblin.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_goblin.test.cpp index 1753d04de84f..2d6a147ea9db 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_goblin.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_goblin.test.cpp @@ -9,8 +9,9 @@ #include "barretenberg/numeric/random/engine.hpp" #include +namespace test_stdlib_biggroup_goblin { namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } using namespace bb; @@ -84,3 +85,4 @@ HEAVY_TYPED_TEST(stdlib_biggroup_goblin, batch_mul) { TestFixture::test_goblin_style_batch_mul(); } +} // namespace test_stdlib_biggroup_goblin diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bit_array/bit_array.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bit_array/bit_array.test.cpp index 7f002085da0c..8db4db895f2e 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bit_array/bit_array.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bit_array/bit_array.test.cpp @@ -17,10 +17,12 @@ using bit_array_ct = stdlib::bit_array; \ using bool_ct = stdlib::bool_t; +namespace test_stdlib_bit_array { + using namespace bb; namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } template class BitArrayTest : public ::testing::Test {}; @@ -127,3 +129,4 @@ TYPED_TEST(BitArrayTest, test_uint32_vector_constructor) static_cast(test_bit_array_2).get_value(); } +} // namespace test_stdlib_bit_array diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bool/bool.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bool/bool.test.cpp index d9f87cd59ab4..e3d4dfc7159b 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bool/bool.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bool/bool.test.cpp @@ -8,10 +8,11 @@ using witness_ct = stdlib::witness_t; \ using bool_ct = stdlib::bool_t; +namespace test_stdlib_bool { using namespace bb; namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } template class BoolTest : public ::testing::Test {}; @@ -527,3 +528,4 @@ TYPED_TEST(BoolTest, Normalize) bool result = builder.check_circuit(); EXPECT_EQ(result, true); } +} // namespace test_stdlib_bool \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/byte_array/byte_array.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/byte_array/byte_array.test.cpp index 0985b61aad51..3f1ec92fb3ac 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/byte_array/byte_array.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/byte_array/byte_array.test.cpp @@ -7,6 +7,7 @@ #pragma GCC diagnostic ignored "-Wunused-local-typedefs" +namespace test_stdlib_byte_array { using namespace bb; using namespace bb::stdlib; @@ -137,3 +138,5 @@ TYPED_TEST(ByteArrayTest, set_bit) bool proof_result = builder.check_circuit(); EXPECT_EQ(proof_result, true); } + +} // namespace test_stdlib_byte_array diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/circuit_builders/circuit_builders_fwd.hpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/circuit_builders/circuit_builders_fwd.hpp index ca1e082d04df..b1427d772764 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/circuit_builders/circuit_builders_fwd.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/circuit_builders/circuit_builders_fwd.hpp @@ -9,10 +9,12 @@ construction in stdlib and contains macros for explicit instantiation. #pragma once #include -namespace bb::honk::flavor { +namespace bb::honk { +namespace flavor { class Standard; class Ultra; -} // namespace bb::honk::flavor +} // namespace flavor +} // namespace bb::honk namespace bb { class Bn254FrParams; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/curves/bn254.hpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/curves/bn254.hpp index d437cee50441..594ac29d75de 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/curves/bn254.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/curves/bn254.hpp @@ -17,8 +17,6 @@ template struct bn254 { using ScalarFieldNative = curve::BN254::ScalarField; using BaseFieldNative = curve::BN254::BaseField; using GroupNative = curve::BN254::Group; - using ElementNative = GroupNative::element; - using AffineElementNative = GroupNative::affine_element; // Stdlib types corresponding to those defined in the native description of the curve. // Note: its useful to have these type names match the native analog exactly so that components that digest a Curve diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/curves/secp256k1.hpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/curves/secp256k1.hpp index 9ab05338b66f..c771f3e1f7f5 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/curves/secp256k1.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/curves/secp256k1.hpp @@ -11,21 +11,21 @@ namespace bb::stdlib { template struct secp256k1 { static constexpr bb::CurveType type = bb::CurveType::SECP256K1; - using fq = ::secp256k1::fq; - using fr = ::secp256k1::fr; - using g1 = ::secp256k1::g1; + typedef ::secp256k1::fq fq; + typedef ::secp256k1::fr fr; + typedef ::secp256k1::g1 g1; - using Builder = CircuitType; - using witness_ct = witness_t; - using public_witness_ct = public_witness_t; - using fr_ct = field_t; - using byte_array_ct = byte_array; - using bool_ct = bool_t; - using uint32_ct = stdlib::uint32; + typedef CircuitType Builder; + typedef witness_t witness_ct; + typedef public_witness_t public_witness_ct; + typedef field_t fr_ct; + typedef byte_array byte_array_ct; + typedef bool_t bool_ct; + typedef stdlib::uint32 uint32_ct; - using fq_ct = bigfield; - using bigfr_ct = bigfield; - using g1_ct = element; - using g1_bigfr_ct = element; + typedef bigfield fq_ct; + typedef bigfield bigfr_ct; + typedef element g1_ct; + typedef element g1_bigfr_ct; }; } // namespace bb::stdlib diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/array.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/array.test.cpp index 70b7e8fee188..bb4602e33b6c 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/array.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/array.test.cpp @@ -6,14 +6,16 @@ #include #include -using namespace bb; +namespace test_stdlib_array { namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } template void ignore_unused(T&) {} // use to ignore unused variables in lambdas +using namespace bb; + template class stdlib_array : public testing::Test { typedef stdlib::bool_t bool_ct; typedef stdlib::field_t field_ct; @@ -693,3 +695,4 @@ TYPED_TEST(stdlib_array, test_pata_nonzero_after_zero_target_fails_2) { TestFixture::test_pata_nonzero_after_zero_target_fails_2(); } +} // namespace test_stdlib_array \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field.test.cpp index 6977453e34a1..444364e4b3fb 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field.test.cpp @@ -10,8 +10,10 @@ using namespace bb; +namespace test_stdlib_field { + namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } template void ignore_unused(T&) {} // use to ignore unused variables in lambdas @@ -191,12 +193,12 @@ template class stdlib_field : public testing::Test { Builder builder = Builder(); field_ct a = witness_ct(&builder, bb::fr::random_element()); - a *= fr::random_element(); - a += fr::random_element(); + a *= bb::fr::random_element(); + a += bb::fr::random_element(); field_ct b = witness_ct(&builder, bb::fr::random_element()); - b *= fr::random_element(); - b += fr::random_element(); + b *= bb::fr::random_element(); + b += bb::fr::random_element(); // numerator constant field_ct out = field_ct(&builder, b.get_value()) / a; @@ -616,11 +618,11 @@ template class stdlib_field : public testing::Test { constexpr uint256_t modulus_minus_one = fr::modulus - 1; const fr p_lo = modulus_minus_one.slice(0, 130); - std::vector test_elements = { bb::fr::random_element(), - 0, - -1, - fr(static_cast(engine.get_random_uint8())), - fr((static_cast(1) << 130) + 1 + p_lo) }; + std::vector test_elements = { bb::fr::random_element(), + 0, + -1, + bb::fr(static_cast(engine.get_random_uint8())), + bb::fr((static_cast(1) << 130) + 1 + p_lo) }; for (auto a_expected : test_elements) { field_ct a = witness_ct(&builder, a_expected); @@ -711,13 +713,13 @@ template class stdlib_field : public testing::Test { { Builder builder = Builder(); - fr base_val(engine.get_random_uint256()); + bb::fr base_val(engine.get_random_uint256()); uint32_t exponent_val = engine.get_random_uint32(); field_ct base = witness_ct(&builder, base_val); field_ct exponent = witness_ct(&builder, exponent_val); field_ct result = base.pow(exponent); - fr expected = base_val.pow(exponent_val); + bb::fr expected = base_val.pow(exponent_val); EXPECT_EQ(result.get_value(), expected); @@ -730,7 +732,7 @@ template class stdlib_field : public testing::Test { { Builder builder = Builder(); - fr base_val(engine.get_random_uint256()); + bb::fr base_val(engine.get_random_uint256()); uint32_t exponent_val = 0; field_ct base = witness_ct(&builder, base_val); @@ -748,7 +750,7 @@ template class stdlib_field : public testing::Test { { Builder builder = Builder(); - fr base_val(engine.get_random_uint256()); + bb::fr base_val(engine.get_random_uint256()); uint32_t exponent_val = 1; field_ct base = witness_ct(&builder, base_val); @@ -768,13 +770,13 @@ template class stdlib_field : public testing::Test { const size_t num_gates_start = builder.num_gates; - fr base_val(engine.get_random_uint256()); + bb::fr base_val(engine.get_random_uint256()); uint32_t exponent_val = engine.get_random_uint32(); field_ct base(&builder, base_val); field_ct exponent(&builder, exponent_val); field_ct result = base.pow(exponent); - fr expected = base_val.pow(exponent_val); + bb::fr expected = base_val.pow(exponent_val); EXPECT_EQ(result.get_value(), expected); @@ -786,13 +788,13 @@ template class stdlib_field : public testing::Test { { Builder builder = Builder(); - fr base_val(engine.get_random_uint256()); + bb::fr base_val(engine.get_random_uint256()); uint32_t exponent_val = engine.get_random_uint32(); field_ct base(&builder, base_val); field_ct exponent = witness_ct(&builder, exponent_val); field_ct result = base.pow(exponent); - fr expected = base_val.pow(exponent_val); + bb::fr expected = base_val.pow(exponent_val); EXPECT_EQ(result.get_value(), expected); @@ -805,13 +807,13 @@ template class stdlib_field : public testing::Test { { Builder builder = Builder(); - fr base_val(engine.get_random_uint256()); + bb::fr base_val(engine.get_random_uint256()); uint32_t exponent_val = engine.get_random_uint32(); field_ct base = witness_ct(&builder, base_val); field_ct exponent(&builder, exponent_val); field_ct result = base.pow(exponent); - fr expected = base_val.pow(exponent_val); + bb::fr expected = base_val.pow(exponent_val); EXPECT_EQ(result.get_value(), expected); info("num gates = ", builder.get_num_gates()); @@ -824,14 +826,14 @@ template class stdlib_field : public testing::Test { { Builder builder = Builder(); - fr base_val(engine.get_random_uint256()); + bb::fr base_val(engine.get_random_uint256()); uint64_t exponent_val = engine.get_random_uint32(); exponent_val += (uint64_t(1) << 32); field_ct base = witness_ct(&builder, base_val); field_ct exponent = witness_ct(&builder, exponent_val); field_ct result = base.pow(exponent); - fr expected = base_val.pow(exponent_val); + bb::fr expected = base_val.pow(exponent_val); EXPECT_NE(result.get_value(), expected); EXPECT_EQ(builder.failed(), true); @@ -842,7 +844,7 @@ template class stdlib_field : public testing::Test { { Builder builder = Builder(); - fr value(engine.get_random_uint256()); + bb::fr value(engine.get_random_uint256()); field_ct value_ct = witness_ct(&builder, value); field_ct first_copy = witness_ct(&builder, value_ct.get_value()); @@ -1033,3 +1035,5 @@ TYPED_TEST(stdlib_field, test_ranged_less_than) { TestFixture::test_ranged_less_than(); } + +} // namespace test_stdlib_field diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/group/cycle_group.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/group/cycle_group.test.cpp index 9a4fcd32c854..c321120d4c5a 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/group/cycle_group.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/group/cycle_group.test.cpp @@ -17,10 +17,11 @@ using bool_ct = stdlib::bool_t; \ using witness_ct = stdlib::witness_t; +namespace stdlib_cycle_group_tests { using namespace bb; namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-local-typedefs" @@ -566,3 +567,5 @@ TYPED_TEST(CycleGroupTest, TestMul) EXPECT_EQ(proof_result, true); } #pragma GCC diagnostic pop + +} // namespace stdlib_cycle_group_tests diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/logic/logic.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/logic/logic.test.cpp index d0ac7d4f1b2f..a8d88e0f9be4 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/logic/logic.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/logic/logic.test.cpp @@ -15,14 +15,17 @@ using field_ct = stdlib::field_t; \ using bool_ct = stdlib::bool_t; \ using public_witness_ct = stdlib::public_witness_t; -using namespace bb; + +namespace test_stdlib_logic { namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } template void ignore_unused(T&) {} // use to ignore unused variables in lambdas +using namespace bb; + template class LogicTest : public testing::Test {}; using CircuitTypes = ::testing::Types; @@ -144,3 +147,5 @@ TYPED_TEST(LogicTest, DifferentWitnessSameResult) EXPECT_EQ(result, false); } } + +} // namespace test_stdlib_logic \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/dynamic_array.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/dynamic_array.test.cpp index ff419207d4f4..07525e2cd174 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/dynamic_array.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/dynamic_array.test.cpp @@ -7,14 +7,15 @@ #include "../bool/bool.hpp" #include "../circuit_builders/circuit_builders.hpp" +namespace test_stdlib_dynamic_array { using namespace bb; namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } // Defining ultra-specific types for local testing. -using Builder = UltraCircuitBuilder; +using Builder = bb::UltraCircuitBuilder; using bool_ct = stdlib::bool_t; using field_ct = stdlib::field_t; using witness_ct = stdlib::witness_t; @@ -62,3 +63,5 @@ TEST(DynamicArray, DynamicArrayReadWriteConsistency) bool verified = builder.check_circuit(); EXPECT_EQ(verified, true); } + +} // namespace test_stdlib_dynamic_array \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/ram_table.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/ram_table.test.cpp index 4c58de3300b1..0f471c3a4ca7 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/ram_table.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/ram_table.test.cpp @@ -4,15 +4,17 @@ #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" #include "ram_table.hpp" +namespace test_stdlib_ram_table { + using namespace bb; // Defining ultra-specific types for local testing. -using Builder = UltraCircuitBuilder; +using Builder = bb::UltraCircuitBuilder; using field_ct = stdlib::field_t; using witness_ct = stdlib::witness_t; using ram_table_ct = stdlib::ram_table; namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } TEST(ram_table, ram_table_init_read_consistency) @@ -28,7 +30,7 @@ TEST(ram_table, ram_table_init_read_consistency) ram_table_ct table(table_values); field_ct result(0); - fr expected(0); + bb::fr expected(0); for (size_t i = 0; i < 10; ++i) { field_ct index(witness_ct(&builder, (uint64_t)i)); @@ -54,7 +56,7 @@ TEST(ram_table, ram_table_read_write_consistency) Builder builder; const size_t table_size = 10; - std::vector table_values(table_size); + std::vector table_values(table_size); ram_table_ct table(&builder, table_size); @@ -62,12 +64,12 @@ TEST(ram_table, ram_table_read_write_consistency) table.write(i, 0); } field_ct result(0); - fr expected(0); + bb::fr expected(0); const auto update = [&]() { for (size_t i = 0; i < table_size / 2; ++i) { - table_values[2 * i] = fr::random_element(); - table_values[2 * i + 1] = fr::random_element(); + table_values[2 * i] = bb::fr::random_element(); + table_values[2 * i + 1] = bb::fr::random_element(); // init with both constant and variable values table.write(2 * i, table_values[2 * i]); @@ -98,3 +100,4 @@ TEST(ram_table, ram_table_read_write_consistency) bool verified = builder.check_circuit(); EXPECT_EQ(verified, true); } +} // namespace test_stdlib_ram_table \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/rom_table.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/rom_table.test.cpp index dbbb9b099375..9fdd7ffe021c 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/rom_table.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/rom_table.test.cpp @@ -5,16 +5,17 @@ #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" #include "rom_table.hpp" +namespace test_stdlib_rom_array { using namespace bb; // Defining ultra-specific types for local testing. -using Builder = UltraCircuitBuilder; +using Builder = bb::UltraCircuitBuilder; using field_ct = stdlib::field_t; using witness_ct = stdlib::witness_t; using rom_table_ct = stdlib::rom_table; namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } TEST(rom_table, rom_table_read_write_consistency) @@ -30,7 +31,7 @@ TEST(rom_table, rom_table_read_write_consistency) rom_table_ct table(table_values); field_ct result(0); - fr expected(0); + bb::fr expected(0); for (size_t i = 0; i < 10; ++i) { field_ct index(witness_ct(&builder, (uint64_t)i)); @@ -61,3 +62,5 @@ TEST(rom_table, rom_table_read_write_consistency) bool verified = builder.check_circuit(); EXPECT_EQ(verified, true); } + +} // namespace test_stdlib_rom_array diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.test.cpp index 81552258c9b8..2eca3f8ff12b 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.test.cpp @@ -7,10 +7,11 @@ #pragma GCC diagnostic ignored "-Wunused-local-typedefs" +namespace test_stdlib_packed_byte_array { using namespace bb; namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } #define STDLIB_TYPE_ALIASES \ using Builder = TypeParam; \ @@ -193,3 +194,5 @@ TYPED_TEST(PackedByteArrayTest, TestAppendUint32) EXPECT_TRUE(builder.check_circuit()); } + +} // namespace test_stdlib_packed_byte_array diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.test.cpp index 00d2b6846eed..2620e827c473 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.test.cpp @@ -9,16 +9,17 @@ #include "barretenberg/stdlib/primitives/uint/uint.hpp" #include +namespace test_stdlib_plookups { using namespace bb; -using namespace bb::plookup; +using namespace plookup; // Defining ultra-specific types for local testing. -using Builder = UltraCircuitBuilder; +using Builder = bb::UltraCircuitBuilder; using field_ct = stdlib::field_t; using witness_ct = stdlib::witness_t; -using plookup_read = stdlib::plookup_read; +using plookup_read = bb::stdlib::plookup_read; namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } // TODO FIX FIX @@ -26,15 +27,15 @@ auto& engine = numeric::get_debug_randomness(); // { // Builder builder = Builder(); -// fr input_value = fr::random_element(); +// bb::fr input_value = fr::random_element(); // field_ct input_hi = witness_ct(&builder, uint256_t(input_value).slice(126, 256)); // field_ct input_lo = witness_ct(&builder, uint256_t(input_value).slice(0, 126)); // const auto lookup_hi = plookup_read::get_lookup_accumulators(MultiTableId::PEDERSEN_LEFT_HI, input_hi); // const auto lookup_lo = plookup_read::get_lookup_accumulators(MultiTableId::PEDERSEN_LEFT_LO, input_lo); -// std::vector expected_x; -// std::vector expected_y; +// std::vector expected_x; +// std::vector expected_y; // const size_t num_lookups_hi = // (128 + crypto::pedersen_hash::lookup::BITS_PER_TABLE) / crypto::pedersen_hash::lookup::BITS_PER_TABLE; @@ -44,7 +45,7 @@ auto& engine = numeric::get_debug_randomness(); // EXPECT_EQ(num_lookups_lo, lookup_lo[ColumnIdx::C1].size()); // const size_t num_lookups = num_lookups_hi + num_lookups_lo; -// std::vector expected_scalars; +// std::vector expected_scalars; // expected_x.resize(num_lookups); // expected_y.resize(num_lookups); // expected_scalars.resize(num_lookups); @@ -103,15 +104,15 @@ auto& engine = numeric::get_debug_randomness(); // { // Builder builder = Builder(); -// fr input_value = fr::random_element(); +// bb::fr input_value = fr::random_element(); // field_ct input_hi = witness_ct(&builder, uint256_t(input_value).slice(126, 256)); // field_ct input_lo = witness_ct(&builder, uint256_t(input_value).slice(0, 126)); // const auto lookup_hi = plookup_read::get_lookup_accumulators(MultiTableId::PEDERSEN_RIGHT_HI, input_hi); // const auto lookup_lo = plookup_read::get_lookup_accumulators(MultiTableId::PEDERSEN_RIGHT_LO, input_lo); -// std::vector expected_x; -// std::vector expected_y; +// std::vector expected_x; +// std::vector expected_y; // const size_t num_lookups_hi = // (128 + crypto::pedersen_hash::lookup::BITS_PER_TABLE) / crypto::pedersen_hash::lookup::BITS_PER_TABLE; @@ -121,7 +122,7 @@ auto& engine = numeric::get_debug_randomness(); // EXPECT_EQ(num_lookups_lo, lookup_lo[ColumnIdx::C1].size()); // const size_t num_lookups = num_lookups_hi + num_lookups_lo; -// std::vector expected_scalars; +// std::vector expected_scalars; // expected_x.resize(num_lookups); // expected_y.resize(num_lookups); // expected_scalars.resize(num_lookups); @@ -237,9 +238,9 @@ TEST(stdlib_plookup, blake2s_xor_rotate_16) const auto left_slices = numeric::slice_input(left_value, 1 << 6, num_lookups); const auto right_slices = numeric::slice_input(right_value, 1 << 6, num_lookups); - std::vector out_expected(num_lookups); - std::vector left_expected(num_lookups); - std::vector right_expected(num_lookups); + std::vector out_expected(num_lookups); + std::vector left_expected(num_lookups); + std::vector right_expected(num_lookups); for (size_t i = 0; i < left_slices.size(); ++i) { if (i == 2) { @@ -260,7 +261,7 @@ TEST(stdlib_plookup, blake2s_xor_rotate_16) * out_coefficients must be (a5/a4, a4/a3, a3/a2, a2/a1, a1/a0). Note that these are stored in reverse orde * for simplicity. */ - std::vector out_coefficients{ (1 << 6), (bb::fr(1) / bb::fr(1 << 22)), (1 << 2), (1 << 6), (1 << 6) }; + std::vector out_coefficients{ (1 << 6), (bb::fr(1) / bb::fr(1 << 22)), (1 << 2), (1 << 6), (1 << 6) }; for (size_t i = num_lookups - 2; i < num_lookups; --i) { out_expected[i] += out_expected[i + 1] * out_coefficients[i]; @@ -279,10 +280,10 @@ TEST(stdlib_plookup, blake2s_xor_rotate_16) * while defining the table we had set the coefficient of s0 to 1, so to correct that, we need to multiply by a * constant. */ - auto mul_constant = fr(1 << 16); - fr lookup_output = lookup[ColumnIdx::C3][0].get_value() * mul_constant; + auto mul_constant = bb::fr(1 << 16); + bb::fr lookup_output = lookup[ColumnIdx::C3][0].get_value() * mul_constant; uint32_t xor_rotate_output = numeric::rotate32(uint32_t(left_value) ^ uint32_t(right_value), 16); - EXPECT_EQ(fr(uint256_t(xor_rotate_output)), lookup_output); + EXPECT_EQ(bb::fr(uint256_t(xor_rotate_output)), lookup_output); bool result = builder.check_circuit(); @@ -306,9 +307,9 @@ TEST(stdlib_plookup, blake2s_xor_rotate_8) const auto left_slices = numeric::slice_input(left_value, 1 << 6, num_lookups); const auto right_slices = numeric::slice_input(right_value, 1 << 6, num_lookups); - std::vector out_expected(num_lookups); - std::vector left_expected(num_lookups); - std::vector right_expected(num_lookups); + std::vector out_expected(num_lookups); + std::vector left_expected(num_lookups); + std::vector right_expected(num_lookups); for (size_t i = 0; i < left_slices.size(); ++i) { if (i == 1) { @@ -323,8 +324,8 @@ TEST(stdlib_plookup, blake2s_xor_rotate_8) right_expected[i] = right_slices[i]; } - auto mul_constant = fr(1 << 24); - std::vector out_coefficients{ (bb::fr(1) / mul_constant), (1 << 4), (1 << 6), (1 << 6), (1 << 6) }; + auto mul_constant = bb::fr(1 << 24); + std::vector out_coefficients{ (bb::fr(1) / mul_constant), (1 << 4), (1 << 6), (1 << 6), (1 << 6) }; for (size_t i = num_lookups - 2; i < num_lookups; --i) { out_expected[i] += out_expected[i + 1] * out_coefficients[i]; @@ -338,9 +339,9 @@ TEST(stdlib_plookup, blake2s_xor_rotate_8) EXPECT_EQ(lookup[ColumnIdx::C3][i].get_value(), out_expected[i]); } - fr lookup_output = lookup[ColumnIdx::C3][0].get_value() * mul_constant; + bb::fr lookup_output = lookup[ColumnIdx::C3][0].get_value() * mul_constant; uint32_t xor_rotate_output = numeric::rotate32(uint32_t(left_value) ^ uint32_t(right_value), 8); - EXPECT_EQ(fr(uint256_t(xor_rotate_output)), lookup_output); + EXPECT_EQ(bb::fr(uint256_t(xor_rotate_output)), lookup_output); bool result = builder.check_circuit(); @@ -364,9 +365,9 @@ TEST(stdlib_plookup, blake2s_xor_rotate_7) const auto left_slices = numeric::slice_input(left_value, 1 << 6, num_lookups); const auto right_slices = numeric::slice_input(right_value, 1 << 6, num_lookups); - std::vector out_expected(num_lookups); - std::vector left_expected(num_lookups); - std::vector right_expected(num_lookups); + std::vector out_expected(num_lookups); + std::vector left_expected(num_lookups); + std::vector right_expected(num_lookups); for (size_t i = 0; i < left_slices.size(); ++i) { if (i == 1) { @@ -381,8 +382,8 @@ TEST(stdlib_plookup, blake2s_xor_rotate_7) right_expected[i] = right_slices[i]; } - auto mul_constant = fr(1 << 25); - std::vector out_coefficients{ (bb::fr(1) / mul_constant), (1 << 5), (1 << 6), (1 << 6), (1 << 6) }; + auto mul_constant = bb::fr(1 << 25); + std::vector out_coefficients{ (bb::fr(1) / mul_constant), (1 << 5), (1 << 6), (1 << 6), (1 << 6) }; for (size_t i = num_lookups - 2; i < num_lookups; --i) { out_expected[i] += out_expected[i + 1] * out_coefficients[i]; @@ -396,9 +397,9 @@ TEST(stdlib_plookup, blake2s_xor_rotate_7) EXPECT_EQ(lookup[ColumnIdx::C3][i].get_value(), out_expected[i]); } - fr lookup_output = lookup[ColumnIdx::C3][0].get_value() * mul_constant; + bb::fr lookup_output = lookup[ColumnIdx::C3][0].get_value() * mul_constant; uint32_t xor_rotate_output = numeric::rotate32(uint32_t(left_value) ^ uint32_t(right_value), 7); - EXPECT_EQ(fr(uint256_t(xor_rotate_output)), lookup_output); + EXPECT_EQ(bb::fr(uint256_t(xor_rotate_output)), lookup_output); bool result = builder.check_circuit(); @@ -441,9 +442,9 @@ TEST(stdlib_plookup, blake2s_xor) // t5 = a5 // // output = (t0 - 2^12 t2) * 2^{32 - 12} + t2 - fr lookup_output = lookup[ColumnIdx::C3][2].get_value(); - fr t2_term = fr(1 << 12) * lookup[ColumnIdx::C3][2].get_value(); - lookup_output += fr(1 << 20) * (lookup[ColumnIdx::C3][0].get_value() - t2_term); + bb::fr lookup_output = lookup[ColumnIdx::C3][2].get_value(); + bb::fr t2_term = bb::fr(1 << 12) * lookup[ColumnIdx::C3][2].get_value(); + lookup_output += bb::fr(1 << 20) * (lookup[ColumnIdx::C3][0].get_value() - t2_term); for (size_t i = num_lookups - 2; i < num_lookups; --i) { out_expected[i] += out_expected[i + 1] * (1 << 6); @@ -455,7 +456,7 @@ TEST(stdlib_plookup, blake2s_xor) // The following checks if the xor output rotated by 12 can be computed correctly from basic blake2s_xor. // auto xor_rotate_output = numeric::rotate32(uint32_t(left_value) ^ uint32_t(right_value), 12); - EXPECT_EQ(fr(uint256_t(xor_rotate_output)), lookup_output); + EXPECT_EQ(bb::fr(uint256_t(xor_rotate_output)), lookup_output); for (size_t i = 0; i < num_lookups; ++i) { EXPECT_EQ(lookup[ColumnIdx::C1][i].get_value(), bb::fr(left_expected[i])); @@ -519,7 +520,7 @@ TEST(stdlib_plookup, secp256k1_generator) uint64_t wnaf_entries[18] = { 0 }; bool skew = false; - wnaf::fixed_wnaf<129, 1, 8>(&input_value.data[0], &wnaf_entries[0], skew, 0); + bb::wnaf::fixed_wnaf<129, 1, 8>(&input_value.data[0], &wnaf_entries[0], skew, 0); std::vector naf_values; for (size_t i = 0; i < 17; ++i) { @@ -604,3 +605,5 @@ TEST(stdlib_plookup, secp256k1_generator) bool proof_result = builder.check_circuit(); EXPECT_EQ(proof_result, true); } + +} // namespace test_stdlib_plookups diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint.test.cpp index 93c167cbde62..7afc1b71f1b3 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint.test.cpp @@ -7,8 +7,6 @@ #include #include -using namespace bb; - #pragma GCC diagnostic ignored "-Wunused-local-typedefs" #define STDLIB_TYPE_ALIASES \ @@ -21,9 +19,10 @@ using namespace bb; using public_witness_ct = stdlib::public_witness_t; namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } +namespace test_stdlib_safe_uint { using namespace bb; template void ignore_unused(T&) {} // use to ignore unused variables in lambdas @@ -707,3 +706,4 @@ TYPED_TEST(SafeUintTest, TestByteArrayConversion) arr.write(static_cast(safe)); EXPECT_EQ(arr.get_string(), expected); } +} // namespace test_stdlib_safe_uint diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/plookup/logic.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/plookup/logic.cpp index e9e2960b7756..bd42fd7b40b9 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/plookup/logic.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/plookup/logic.cpp @@ -5,7 +5,7 @@ using namespace bb; namespace bb::stdlib { -using namespace bb::plookup; +using namespace plookup; template uint_plookup uint_plookup::operator&(const uint_plookup& other) const diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/uint.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/uint.test.cpp index 73a4ac6c6dda..a075df2e662b 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/uint.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/uint.test.cpp @@ -3,10 +3,11 @@ #include #include +using namespace bb; using namespace bb; namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } // NOTE: We only test width 32, but widths 8, 16, 32 and 64 can all be tested. @@ -15,7 +16,7 @@ auto& engine = numeric::get_debug_randomness(); // test_xor_special, test_xor_more_constants, test_and_constants, test_and_special, test_or_special, // test_ror_special, test_hash_rounds, test_and, test_xor, test_or. // They fail with 'C++ exception with description"Last key slice greater than 64" thrown in the test body."' - +namespace test_stdlib_uint { typedef uint32_t uint_native; size_t uint_native_width = 8 * sizeof(uint_native); uint_native uint_native_max = static_cast((static_cast(1) << uint_native_width) - 1); @@ -1914,10 +1915,10 @@ TYPED_TEST(stdlib_uint, test_at) // There was one plookup-specific test in the ./plookup/uint_plookup.test.cpp TEST(stdlib_uint32, test_accumulators_plookup_uint32) { - using uint32_ct = stdlib::uint32; - using witness_ct = stdlib::witness_t; + using uint32_ct = bb::stdlib::uint32; + using witness_ct = bb::stdlib::witness_t; - UltraCircuitBuilder builder; + bb::UltraCircuitBuilder builder; uint32_t a_val = engine.get_random_uint32(); uint32_t b_val = engine.get_random_uint32(); @@ -1939,3 +1940,4 @@ TEST(stdlib_uint32, test_accumulators_plookup_uint32) bool proof_result = builder.check_circuit(); EXPECT_EQ(proof_result, true); } +} // namespace test_stdlib_uint diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.test.cpp index 307e388e368a..4d8386ada5cf 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.test.cpp @@ -13,7 +13,7 @@ namespace bb::stdlib::recursion::honk { using Builder = UltraCircuitBuilder; using UltraFlavor = ::bb::honk::flavor::Ultra; using UltraRecursiveFlavor = ::bb::honk::flavor::UltraRecursive_; -using FF = fr; +using FF = bb::fr; using BaseTranscript = ::bb::honk::BaseTranscript; /** @@ -124,8 +124,8 @@ TEST(RecursiveHonkTranscript, InterfacesMatch) */ TEST(RecursiveHonkTranscript, ReturnValuesMatch) { - using FF = fr; - using Commitment = g1::affine_element; + using FF = bb::fr; + using Commitment = bb::g1::affine_element; using field_ct = field_t; using fq_ct = bigfield; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp deleted file mode 100644 index 6578f48cc992..000000000000 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp +++ /dev/null @@ -1,96 +0,0 @@ -#include "barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.hpp" -#include "barretenberg/commitment_schemes/zeromorph/zeromorph.hpp" -#include "barretenberg/numeric/bitop/get_msb.hpp" -#include "barretenberg/sumcheck/instance/verifier_instance.hpp" -#include "barretenberg/transcript/transcript.hpp" - -namespace bb::stdlib::recursion::honk { - -template -DeciderRecursiveVerifier_::DeciderRecursiveVerifier_(Builder* builder) - : builder(builder) -{} - -/** - * @brief This function verifies an Ultra Honk proof for a given Flavor, produced for a relaxed instance (ϕ, \vec{β*}, - * e*). - * - */ -template -std::array DeciderRecursiveVerifier_::verify_proof( - const bb::plonk::proof& proof) -{ - using Sumcheck = ::bb::honk::sumcheck::SumcheckVerifier; - using Curve = typename Flavor::Curve; - using ZeroMorph = ::bb::honk::pcs::zeromorph::ZeroMorphVerifier_; - using VerifierCommitments = typename Flavor::VerifierCommitments; - using Transcript = typename Flavor::Transcript; - using Instance = typename ::bb::honk::VerifierInstance_; - - static constexpr size_t NUM_SUBRELATIONS = Flavor::NUM_SUBRELATIONS; - transcript = std::make_shared(builder, proof.proof_data); - auto inst = std::make_unique(); - - const auto instance_size = transcript->template receive_from_prover("instance_size"); - const auto public_input_size = transcript->template receive_from_prover("public_input_size"); - const auto log_instance_size = static_cast(numeric::get_msb(uint32_t(instance_size.get_value()))); - - for (size_t i = 0; i < uint32_t(public_input_size.get_value()); ++i) { - auto public_input_i = transcript->template receive_from_prover("public_input_" + std::to_string(i)); - inst->public_inputs.emplace_back(public_input_i); - } - - auto eta = transcript->template receive_from_prover("eta"); - auto beta = transcript->template receive_from_prover("beta"); - auto gamma = transcript->template receive_from_prover("gamma"); - auto public_input_delta = transcript->template receive_from_prover("public_input_delta"); - auto lookup_grand_product_delta = transcript->template receive_from_prover("lookup_grand_product_delta"); - inst->relation_parameters = - RelationParameters{ eta, beta, gamma, public_input_delta, lookup_grand_product_delta }; - - for (size_t idx = 0; idx < NUM_SUBRELATIONS - 1; idx++) { - inst->alphas[idx] = transcript->template receive_from_prover("alpha" + std::to_string(idx)); - } - - inst->target_sum = transcript->template receive_from_prover("target_sum"); - - inst->gate_challenges = std::vector(log_instance_size); - for (size_t idx = 0; idx < log_instance_size; idx++) { - inst->gate_challenges[idx] = - transcript->template receive_from_prover("gate_challenge_" + std::to_string(idx)); - } - auto comm_view = inst->witness_commitments.get_all(); - auto witness_labels = inst->commitment_labels.get_witness(); - for (size_t idx = 0; idx < witness_labels.size(); idx++) { - comm_view[idx] = transcript->template receive_from_prover(witness_labels[idx]); - } - - inst->verification_key = std::make_shared(inst->instance_size, inst->public_input_size); - auto vk_view = inst->verification_key->get_all(); - auto vk_labels = inst->commitment_labels.get_precomputed(); - for (size_t idx = 0; idx < vk_labels.size(); idx++) { - vk_view[idx] = transcript->template receive_from_prover(vk_labels[idx]); - } - - VerifierCommitments commitments{ inst->verification_key, inst->witness_commitments }; - - auto sumcheck = Sumcheck(log_instance_size, transcript, inst->target_sum); - - auto [multivariate_challenge, claimed_evaluations, sumcheck_verified] = - sumcheck.verify(inst->relation_parameters, inst->alphas, inst->gate_challenges); - - // Execute ZeroMorph rounds. See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description of the - // unrolled protocol. - auto pairing_points = ZeroMorph::verify(commitments.get_unshifted(), - commitments.get_to_be_shifted(), - claimed_evaluations.get_unshifted(), - claimed_evaluations.get_shifted(), - multivariate_challenge, - transcript); - - return pairing_points; -} - -template class DeciderRecursiveVerifier_>; -template class DeciderRecursiveVerifier_>; -} // namespace bb::stdlib::recursion::honk diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.hpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.hpp deleted file mode 100644 index 18e6b75fa0bc..000000000000 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once -#include "barretenberg/flavor/goblin_ultra_recursive.hpp" -#include "barretenberg/flavor/ultra_recursive.hpp" -#include "barretenberg/plonk/proof_system/types/proof.hpp" -#include "barretenberg/stdlib/recursion/honk/transcript/transcript.hpp" -#include "barretenberg/sumcheck/sumcheck.hpp" - -namespace bb::stdlib::recursion::honk { -template class DeciderRecursiveVerifier_ { - using FF = typename Flavor::FF; - using Commitment = typename Flavor::Commitment; - using GroupElement = typename Flavor::GroupElement; - using VerificationKey = typename Flavor::VerificationKey; - using VerifierCommitmentKey = typename Flavor::VerifierCommitmentKey; - using Builder = typename Flavor::CircuitBuilder; - using RelationSeparator = typename Flavor::RelationSeparator; - using PairingPoints = std::array; - - public: - explicit DeciderRecursiveVerifier_(Builder* builder); - - PairingPoints verify_proof(const bb::plonk::proof& proof); - - std::map commitments; - std::shared_ptr pcs_verification_key; - Builder* builder; - std::shared_ptr> transcript; -}; - -} // namespace bb::stdlib::recursion::honk \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp deleted file mode 100644 index 68c366de5b94..000000000000 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp +++ /dev/null @@ -1,320 +0,0 @@ -#include "protogalaxy_recursive_verifier.hpp" -#include "barretenberg/polynomials/polynomial.hpp" -#include "barretenberg/proof_system/library/grand_product_delta.hpp" -namespace bb::stdlib::recursion::honk { - -template -void ProtoGalaxyRecursiveVerifier_::receive_accumulator(const std::shared_ptr& inst, - const std::string& domain_separator) -{ - // Get circuit parameters - const auto instance_size = transcript->template receive_from_prover(domain_separator + "_instance_size"); - const auto public_input_size = - transcript->template receive_from_prover(domain_separator + "_public_input_size"); - inst->instance_size = uint32_t(instance_size.get_value()); - inst->log_instance_size = uint32_t(numeric::get_msb(inst->instance_size)); - inst->public_input_size = uint32_t(public_input_size.get_value()); - - // Get folded public inputs - for (size_t i = 0; i < inst->public_input_size; ++i) { - auto public_input_i = - transcript->template receive_from_prover(domain_separator + "_public_input_" + std::to_string(i)); - inst->public_inputs.emplace_back(public_input_i); - } - - // Get folded relation parameters - auto eta = transcript->template receive_from_prover(domain_separator + "_eta"); - auto beta = transcript->template receive_from_prover(domain_separator + "_beta"); - auto gamma = transcript->template receive_from_prover(domain_separator + "_gamma"); - auto public_input_delta = transcript->template receive_from_prover(domain_separator + "_public_input_delta"); - auto lookup_grand_product_delta = - transcript->template receive_from_prover(domain_separator + "_lookup_grand_product_delta"); - inst->relation_parameters = - RelationParameters{ eta, beta, gamma, public_input_delta, lookup_grand_product_delta }; - - // Get the folded relation separator challenges \vec{α} - for (size_t idx = 0; idx < NUM_SUBRELATIONS - 1; idx++) { - inst->alphas[idx] = - transcript->template receive_from_prover(domain_separator + "_alpha_" + std::to_string(idx)); - } - - inst->target_sum = transcript->template receive_from_prover(domain_separator + "_target_sum"); - - // Get the folded gate challenges, \vec{β} in the paper - inst->gate_challenges = std::vector(inst->log_instance_size); - for (size_t idx = 0; idx < inst->log_instance_size; idx++) { - inst->gate_challenges[idx] = - transcript->template receive_from_prover(domain_separator + "_gate_challenge_" + std::to_string(idx)); - } - - // Get the folded commitments to all witness polynomials - auto comm_view = inst->witness_commitments.get_all(); - auto witness_labels = inst->commitment_labels.get_witness(); - for (size_t idx = 0; idx < witness_labels.size(); idx++) { - comm_view[idx] = - transcript->template receive_from_prover(domain_separator + "_" + witness_labels[idx]); - } - - // Get the folded commitments to selector polynomials - inst->verification_key = std::make_shared(inst->instance_size, inst->public_input_size); - auto vk_view = inst->verification_key->get_all(); - auto vk_labels = inst->commitment_labels.get_precomputed(); - for (size_t idx = 0; idx < vk_labels.size(); idx++) { - vk_view[idx] = transcript->template receive_from_prover(domain_separator + "_" + vk_labels[idx]); - } -} - -template -void ProtoGalaxyRecursiveVerifier_::receive_and_finalise_instance( - const std::shared_ptr& inst, const std::string& domain_separator) -{ - // Get circuit parameters and the public inputs - const auto instance_size = transcript->template receive_from_prover(domain_separator + "_instance_size"); - const auto public_input_size = - transcript->template receive_from_prover(domain_separator + "_public_input_size"); - inst->instance_size = uint32_t(instance_size.get_value()); - inst->log_instance_size = static_cast(numeric::get_msb(inst->instance_size)); - inst->public_input_size = uint32_t(public_input_size.get_value()); - - for (size_t i = 0; i < inst->public_input_size; ++i) { - auto public_input_i = - transcript->template receive_from_prover(domain_separator + "_public_input_" + std::to_string(i)); - inst->public_inputs.emplace_back(public_input_i); - } - - const auto pub_inputs_offset = - transcript->template receive_from_prover(domain_separator + "_pub_inputs_offset"); - - inst->pub_inputs_offset = uint32_t(pub_inputs_offset.get_value()); - - // Get commitments to first three wire polynomials - auto labels = inst->commitment_labels; - auto& witness_commitments = inst->witness_commitments; - witness_commitments.w_l = transcript->template receive_from_prover(domain_separator + "_" + labels.w_l); - witness_commitments.w_r = transcript->template receive_from_prover(domain_separator + "_" + labels.w_r); - witness_commitments.w_o = transcript->template receive_from_prover(domain_separator + "_" + labels.w_o); - - // Get challenge for sorted list batching and wire four memory records commitment - auto eta = transcript->get_challenge(domain_separator + "_eta"); - witness_commitments.sorted_accum = - transcript->template receive_from_prover(domain_separator + "_" + labels.sorted_accum); - witness_commitments.w_4 = transcript->template receive_from_prover(domain_separator + "_" + labels.w_4); - - // Get permutation challenges and commitment to permutation and lookup grand products - auto [beta, gamma] = transcript->get_challenges(domain_separator + "_beta", domain_separator + "_gamma"); - witness_commitments.z_perm = - transcript->template receive_from_prover(domain_separator + "_" + labels.z_perm); - witness_commitments.z_lookup = - transcript->template receive_from_prover(domain_separator + "_" + labels.z_lookup); - - // Compute correction terms for grand products - const FF public_input_delta = bb::honk::compute_public_input_delta( - inst->public_inputs, beta, gamma, inst->instance_size, inst->pub_inputs_offset); - const FF lookup_grand_product_delta = - bb::honk::compute_lookup_grand_product_delta(beta, gamma, inst->instance_size); - inst->relation_parameters = - RelationParameters{ eta, beta, gamma, public_input_delta, lookup_grand_product_delta }; - - // Get the relation separation challenges - for (size_t idx = 0; idx < NUM_SUBRELATIONS - 1; idx++) { - inst->alphas[idx] = transcript->get_challenge(domain_separator + "_alpha_" + std::to_string(idx)); - } - - // Get the commitments to the selector polynomials for the given instance - inst->verification_key = std::make_shared(inst->instance_size, inst->public_input_size); - auto vk_view = inst->verification_key->get_all(); - auto vk_labels = labels.get_precomputed(); - for (size_t idx = 0; idx < vk_labels.size(); idx++) { - vk_view[idx] = transcript->template receive_from_prover(domain_separator + "_" + vk_labels[idx]); - } -} - -// TODO(https://github.com/AztecProtocol/barretenberg/issues/795): The rounds prior to actual verifying are common -// between decider and folding verifier and could be somehow shared so we do not duplicate code so much. -template void ProtoGalaxyRecursiveVerifier_::prepare_for_folding() -{ - auto index = 0; - auto inst = instances[0]; - auto domain_separator = std::to_string(index); - const auto is_accumulator = transcript->template receive_from_prover(domain_separator + "is_accumulator"); - inst->is_accumulator = static_cast(is_accumulator.get_value()); - if (inst->is_accumulator) { - receive_accumulator(inst, domain_separator); - } else { - // This is the first round of folding and we need to generate some gate challenges. - // TODO(https://github.com/AztecProtocol/barretenberg/issues/740): implement option 2 to make this more - // efficient by avoiding the computation of the perturbator - receive_and_finalise_instance(inst, domain_separator); - inst->target_sum = 0; - auto beta = transcript->get_challenge(domain_separator + "_initial_gate_challenge"); - std::vector gate_challenges(inst->log_instance_size); - gate_challenges[0] = beta; - for (size_t i = 1; i < inst->log_instance_size; i++) { - gate_challenges[i] = gate_challenges[i - 1].sqr(); - } - inst->gate_challenges = gate_challenges; - } - index++; - - for (auto it = instances.begin() + 1; it != instances.end(); it++, index++) { - auto inst = *it; - auto domain_separator = std::to_string(index); - receive_and_finalise_instance(inst, domain_separator); - } -} - -template -void ProtoGalaxyRecursiveVerifier_::verify_folding_proof(std::vector proof) -{ - using Transcript = typename Flavor::Transcript; - using ElementNative = typename Flavor::Curve::ElementNative; - using AffineElementNative = typename Flavor::Curve::AffineElementNative; - using ScalarNative = typename Flavor::Curve::ScalarFieldNative; - - transcript = std::make_shared(builder, proof); - prepare_for_folding(); - - auto delta = transcript->get_challenge("delta"); - auto accumulator = get_accumulator(); - auto deltas = compute_round_challenge_pows(accumulator->log_instance_size, delta); - - std::vector perturbator_coeffs(accumulator->log_instance_size + 1); - for (size_t idx = 0; idx <= accumulator->log_instance_size; idx++) { - perturbator_coeffs[idx] = transcript->template receive_from_prover("perturbator_" + std::to_string(idx)); - } - - // TODO(https://github.com/AztecProtocol/barretenberg/issues/833): As currently the stdlib transcript is not - // creating proper constraints linked to Fiat-Shamir we add an additonal gate to ensure assert_equal is correct. - // This comparison to 0 can be removed here and below once we have merged the transcript. - auto zero = FF::from_witness(builder, ScalarNative(0)); - zero.assert_equal(accumulator->target_sum - perturbator_coeffs[0], "F(0) != e"); - - FF perturbator_challenge = transcript->get_challenge("perturbator_challenge"); - - auto perturbator_at_challenge = evaluate_perturbator(perturbator_coeffs, perturbator_challenge); - // The degree of K(X) is dk - k - 1 = k(d - 1) - 1. Hence we need k(d - 1) evaluations to represent it. - std::array combiner_quotient_evals; - for (size_t idx = 0; idx < VerifierInstances::BATCHED_EXTENDED_LENGTH - VerifierInstances::NUM; idx++) { - combiner_quotient_evals[idx] = transcript->template receive_from_prover( - "combiner_quotient_" + std::to_string(idx + VerifierInstances::NUM)); - } - Univariate combiner_quotient( - combiner_quotient_evals); - FF combiner_challenge = transcript->get_challenge("combiner_quotient_challenge"); - auto combiner_quotient_at_challenge = combiner_quotient.evaluate(combiner_challenge); // fine recursive i think - - auto vanishing_polynomial_at_challenge = combiner_challenge * (combiner_challenge - FF(1)); - auto lagranges = std::vector{ FF(1) - combiner_challenge, combiner_challenge }; - - // Compute next folding parameters and verify against the ones received from the prover - auto expected_next_target_sum = - perturbator_at_challenge * lagranges[0] + vanishing_polynomial_at_challenge * combiner_quotient_at_challenge; - auto next_target_sum = transcript->template receive_from_prover("next_target_sum"); - zero.assert_equal(expected_next_target_sum - next_target_sum, "next target sum mismatch"); - - auto expected_betas_star = update_gate_challenges(perturbator_challenge, accumulator->gate_challenges, deltas); - for (size_t idx = 0; idx < accumulator->log_instance_size; idx++) { - auto beta_star = transcript->template receive_from_prover("next_gate_challenge_" + std::to_string(idx)); - zero.assert_equal(beta_star - expected_betas_star[idx], - " next gate challenge mismatch at: " + std::to_string(idx)); - } - - // Compute ϕ and verify against the data received from the prover - WitnessCommitments acc_witness_commitments; - auto witness_labels = commitment_labels.get_witness(); - size_t comm_idx = 0; - auto random_generator = Commitment::from_witness(builder, AffineElementNative(ElementNative::random_element())); - for (auto& expected_comm : acc_witness_commitments.get_all()) { - expected_comm = random_generator; - size_t inst = 0; - for (auto& instance : instances) { - expected_comm = expected_comm + instance->witness_commitments.get_all()[comm_idx] * lagranges[inst]; - inst++; - } - auto comm = transcript->template receive_from_prover("next_" + witness_labels[comm_idx]); - auto res = expected_comm - comm; - random_generator.x.assert_equal(res.x); - random_generator.y.assert_equal(res.y); - comm_idx++; - } - - std::vector folded_public_inputs(instances[0]->public_inputs.size(), 0); - size_t public_input_idx = 0; - for (auto& expected_public_input : folded_public_inputs) { - size_t inst = 0; - for (auto& instance : instances) { - expected_public_input += instance->public_inputs[public_input_idx] * lagranges[inst]; - inst++; - } - auto next_public_input = - transcript->template receive_from_prover("next_public_input" + std::to_string(public_input_idx)); - zero.assert_equal(expected_public_input - next_public_input, - "folded public input mismatch at: " + std::to_string(public_input_idx)); - public_input_idx++; - } - - for (size_t alpha_idx = 0; alpha_idx < NUM_SUBRELATIONS - 1; alpha_idx++) { - FF expected_alpha(0); - size_t instance_idx = 0; - for (auto& instance : instances) { - expected_alpha += instance->alphas[alpha_idx] * lagranges[instance_idx]; - instance_idx++; - } - auto next_alpha = transcript->template receive_from_prover("next_alpha_" + std::to_string(alpha_idx)); - zero.assert_equal(expected_alpha - next_alpha, - "folded relation separator mismatch at: " + std::to_string(alpha_idx)); - } - - auto expected_parameters = bb::RelationParameters{}; - for (size_t inst_idx = 0; inst_idx < VerifierInstances::NUM; inst_idx++) { - auto instance = instances[inst_idx]; - expected_parameters.eta += instance->relation_parameters.eta * lagranges[inst_idx]; - expected_parameters.beta += instance->relation_parameters.beta * lagranges[inst_idx]; - expected_parameters.gamma += instance->relation_parameters.gamma * lagranges[inst_idx]; - expected_parameters.public_input_delta += - instance->relation_parameters.public_input_delta * lagranges[inst_idx]; - expected_parameters.lookup_grand_product_delta += - instance->relation_parameters.lookup_grand_product_delta * lagranges[inst_idx]; - } - - auto next_eta = transcript->template receive_from_prover("next_eta"); - zero.assert_equal(expected_parameters.eta - next_eta, "relation parameter eta mismatch"); - - auto next_beta = transcript->template receive_from_prover("next_beta"); - zero.assert_equal(expected_parameters.beta - next_beta, "relation parameter beta mismatch"); - - auto next_gamma = transcript->template receive_from_prover("next_gamma"); - zero.assert_equal(expected_parameters.gamma - next_gamma, "relation parameter gamma mismatch"); - - auto next_public_input_delta = transcript->template receive_from_prover("next_public_input_delta"); - zero.assert_equal(expected_parameters.public_input_delta - next_public_input_delta, - "relation parameter public input delta mismatch"); - - auto next_lookup_grand_product_delta = - transcript->template receive_from_prover("next_lookup_grand_product_delta"); - zero.assert_equal(expected_parameters.lookup_grand_product_delta - next_lookup_grand_product_delta, - "relation parameter lookup grand product delta mismatch"); - - auto acc_vk = std::make_shared(instances[0]->instance_size, instances[0]->public_input_size); - auto vk_labels = commitment_labels.get_precomputed(); - size_t vk_idx = 0; - for (auto& expected_vk : acc_vk->get_all()) { - size_t inst = 0; - expected_vk = random_generator; - for (auto& instance : instances) { - expected_vk = expected_vk + instance->verification_key->get_all()[vk_idx] * lagranges[inst]; - inst++; - } - auto vk = transcript->template receive_from_prover("next_" + vk_labels[vk_idx]); - auto res = expected_vk - vk; - random_generator.x.assert_equal(res.x); - random_generator.y.assert_equal(res.y); - vk_idx++; - } -} - -template class ProtoGalaxyRecursiveVerifier_< - bb::honk::VerifierInstances_, 2>>; -template class ProtoGalaxyRecursiveVerifier_< - bb::honk::VerifierInstances_, 2>>; -} // namespace bb::stdlib::recursion::honk \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.hpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.hpp deleted file mode 100644 index 64b757195428..000000000000 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.hpp +++ /dev/null @@ -1,118 +0,0 @@ -#pragma once -#include "barretenberg/flavor/flavor.hpp" -#include "barretenberg/flavor/goblin_ultra_recursive.hpp" -#include "barretenberg/flavor/ultra_recursive.hpp" -#include "barretenberg/plonk/proof_system/types/proof.hpp" -#include "barretenberg/protogalaxy/folding_result.hpp" -#include "barretenberg/stdlib/recursion/honk/transcript/transcript.hpp" -#include "barretenberg/sumcheck/instance/instances.hpp" - -namespace bb::stdlib::recursion::honk { -template class ProtoGalaxyRecursiveVerifier_ { - public: - using Flavor = typename VerifierInstances::Flavor; - using FF = typename Flavor::FF; - using Commitment = typename Flavor::Commitment; - using GroupElement = typename Flavor::GroupElement; - using Instance = typename VerifierInstances::Instance; - using VerificationKey = typename Flavor::VerificationKey; - using WitnessCommitments = typename Flavor::WitnessCommitments; - using CommitmentLabels = typename Flavor::CommitmentLabels; - using Builder = typename Flavor::CircuitBuilder; - using RelationSeparator = typename Flavor::RelationSeparator; - using PairingPoints = std::array; - - static constexpr size_t NUM_SUBRELATIONS = Flavor::NUM_SUBRELATIONS; - - VerifierInstances instances; - - CommitmentLabels commitment_labels; - - Builder* builder; - std::shared_ptr> transcript; - - explicit ProtoGalaxyRecursiveVerifier_(Builder* builder) - : instances(VerifierInstances()) - , builder(builder){}; - /** - * @brief Given a new round challenge δ for each iteration of the full ProtoGalaxy protocol, compute the vector - * [δ, δ^2,..., δ^t] where t = logn and n is the size of the instance. - */ - static std::vector compute_round_challenge_pows(size_t log_instance_size, FF round_challenge) - { - std::vector pows(log_instance_size); - pows[0] = round_challenge; - for (size_t i = 1; i < log_instance_size; i++) { - pows[i] = pows[i - 1].sqr(); - } - return pows; - } - - static std::vector update_gate_challenges(const FF perturbator_challenge, - const std::vector& gate_challenges, - const std::vector& round_challenges) - { - auto log_instance_size = gate_challenges.size(); - std::vector next_gate_challenges(log_instance_size); - - for (size_t idx = 0; idx < log_instance_size; idx++) { - next_gate_challenges[idx] = gate_challenges[idx] + perturbator_challenge * round_challenges[idx]; - } - return next_gate_challenges; - } - - std::shared_ptr get_accumulator() { return instances[0]; } - - /** - * @brief Instatiate the instances and the transcript. - * - * @param fold_data The data transmitted via the transcript by the prover. - */ - void prepare_for_folding(); - - /** - * @brief Instantiate the accumulator (i.e. the relaxed instance) from the transcript. - * - */ - void receive_accumulator(const std::shared_ptr&, const std::string&); - - /** - * @brief Process the public data ϕ for the Instances to be folded. - * - */ - void receive_and_finalise_instance(const std::shared_ptr&, const std::string&); - - /** - * @brief Run the folding protocol on the verifier side to establish whether the public data ϕ of the new - * accumulator, received from the prover is the same as that produced by the verifier. - * - * @details In the recursive setting this function doesn't return anything because the equality checks performed by - * the recursive verifier, ensuring the folded ϕ*, e* and β* on the verifier side correspond to what has been sent - * by the prover, are expressed as constraints. - - */ - void verify_folding_proof(std::vector proof); - - /** - * @brief Evaluates the perturbator at a given scalar, in a sequential manner for the recursive setting. - * - * @details This method is equivalent to the one in the Polynomial class for evaluating a polynomial, represented by - * coefficients in monomial basis, at a given point. The Polynomial class is used in the native verifier for - * constructing and computing the perturbator. We implement this separate functionality here in the recursive - * folding verifier to avoid instantiating the entire Polynomial class on stdlib::bn254. Furthermore, the evaluation - * needs to be done sequentially as we don't support a parallel_for in circuits. - * - */ - static FF evaluate_perturbator(std::vector coeffs, FF point) - { - FF point_acc = FF(1); - FF result = FF(0); - for (size_t i = 0; i < coeffs.size(); i++) { - result += coeffs[i] * point_acc; - point_acc *= point; - } - return result; - }; -}; - -} // namespace bb::stdlib::recursion::honk \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.test.cpp deleted file mode 100644 index 61dee74084fa..000000000000 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.test.cpp +++ /dev/null @@ -1,350 +0,0 @@ -#include "barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.hpp" -#include "barretenberg/common/test.hpp" -#include "barretenberg/flavor/ultra_recursive.hpp" -#include "barretenberg/stdlib/hash/blake3s/blake3s.hpp" -#include "barretenberg/stdlib/hash/pedersen/pedersen.hpp" -#include "barretenberg/stdlib/primitives/curves/bn254.hpp" -#include "barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.hpp" -#include "barretenberg/ultra_honk/ultra_composer.hpp" - -namespace bb::stdlib::recursion::honk { -class ProtogalaxyRecursiveTest : public testing::Test { - public: - // Define types relevant for testing - using UltraFlavor = ::bb::honk::flavor::Ultra; - using GoblinUltraFlavor = ::bb::honk::flavor::GoblinUltra; - using UltraComposer = ::bb::honk::UltraComposer_; - using GoblinUltraComposer = ::bb::honk::UltraComposer_; - - using InnerFlavor = UltraFlavor; - using InnerComposer = UltraComposer; - using Instance = ::bb::honk::ProverInstance_; - using InnerBuilder = typename InnerComposer::CircuitBuilder; - using InnerCurve = bn254; - using Commitment = InnerFlavor::Commitment; - using FF = InnerFlavor::FF; - - // Types for recursive verifier circuit - // cannot do on Goblin - using OuterBuilder = GoblinUltraCircuitBuilder; - using RecursiveFlavor = ::bb::honk::flavor::UltraRecursive_; - using RecursiveVerifierInstances = ::bb::honk::VerifierInstances_; - using FoldingRecursiveVerifier = ProtoGalaxyRecursiveVerifier_; - using DeciderRecursiveVerifier = DeciderRecursiveVerifier_; - using DeciderVerifier = ::bb::honk::DeciderVerifier_; - using NativeVerifierInstances = ::bb::honk::VerifierInstances_; - using NativeFoldingVerifier = bb::honk::ProtoGalaxyVerifier_; - - // Helper for getting composer for prover/verifier of recursive (outer) circuit - template static auto get_outer_composer() - { - if constexpr (IsGoblinBuilder) { - return GoblinUltraComposer(); - } else { - return UltraComposer(); - } - } - - /** - * @brief Create a non-trivial arbitrary inner circuit, the proof of which will be recursively verified - * - * @param builder - * @param public_inputs - * @param log_num_gates - * - * TODO(https://github.com/AztecProtocol/barretenberg/issues/744): make testing utility with functionality shared - * amongst test files - */ - static void create_inner_circuit(InnerBuilder& builder, size_t log_num_gates = 10) - { - using fr_ct = InnerCurve::ScalarField; - using fq_ct = InnerCurve::BaseField; - using public_witness_ct = InnerCurve::public_witness_ct; - using witness_ct = InnerCurve::witness_ct; - using byte_array_ct = InnerCurve::byte_array_ct; - using fr = typename InnerCurve::ScalarFieldNative; - - // Create 2^log_n many add gates based on input log num gates - const size_t num_gates = 1 << log_num_gates; - for (size_t i = 0; i < num_gates; ++i) { - fr a = fr::random_element(); - uint32_t a_idx = builder.add_variable(a); - - fr b = fr::random_element(); - fr c = fr::random_element(); - fr d = a + b + c; - uint32_t b_idx = builder.add_variable(b); - uint32_t c_idx = builder.add_variable(c); - uint32_t d_idx = builder.add_variable(d); - - builder.create_big_add_gate({ a_idx, b_idx, c_idx, d_idx, fr(1), fr(1), fr(1), fr(-1), fr(0) }); - } - - // Define some additional non-trivial but arbitrary circuit logic - fr_ct a(public_witness_ct(&builder, fr::random_element())); - fr_ct b(public_witness_ct(&builder, fr::random_element())); - fr_ct c(public_witness_ct(&builder, fr::random_element())); - - for (size_t i = 0; i < 32; ++i) { - a = (a * b) + b + a; - a = a.madd(b, c); - } - pedersen_hash::hash({ a, b }); - byte_array_ct to_hash(&builder, "nonsense test data"); - blake3s(to_hash); - - fr bigfield_data = fr::random_element(); - fr bigfield_data_a{ bigfield_data.data[0], bigfield_data.data[1], 0, 0 }; - fr bigfield_data_b{ bigfield_data.data[2], bigfield_data.data[3], 0, 0 }; - - fq_ct big_a(fr_ct(witness_ct(&builder, bigfield_data_a.to_montgomery_form())), fr_ct(witness_ct(&builder, 0))); - fq_ct big_b(fr_ct(witness_ct(&builder, bigfield_data_b.to_montgomery_form())), fr_ct(witness_ct(&builder, 0))); - - big_a* big_b; - }; - - public: - static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } - - static std::shared_ptr fold_and_verify(const std::vector>& instances, - InnerComposer& inner_composer) - { - // Generate a folding proof - auto inner_folding_prover = inner_composer.create_folding_prover(instances); - auto inner_folding_proof = inner_folding_prover.fold_instances(); - - // Create a recursive folding verifier circuit for the folding proof of the two instances - OuterBuilder outer_folding_circuit; - FoldingRecursiveVerifier verifier{ &outer_folding_circuit }; - verifier.verify_folding_proof(inner_folding_proof.folding_data); - info("Recursive Verifier with Ultra instances: num gates = ", outer_folding_circuit.num_gates); - - // Perform native folding verification and ensure it returns the same result (either true or false) as calling - // check_circuit on the recursive folding verifier - auto native_folding_verifier = inner_composer.create_folding_verifier(); - auto native_folding_result = native_folding_verifier.verify_folding_proof(inner_folding_proof.folding_data); - EXPECT_EQ(native_folding_result, outer_folding_circuit.check_circuit()); - - // Ensure that the underlying native and recursive folding verification algorithms agree by ensuring - // the manifests produced by each agree. - auto recursive_folding_manifest = verifier.transcript->get_manifest(); - auto native_folding_manifest = native_folding_verifier.transcript->get_manifest(); - - for (size_t i = 0; i < recursive_folding_manifest.size(); ++i) { - EXPECT_EQ(recursive_folding_manifest[i], native_folding_manifest[i]); - } - - // Check for a failure flag in the recursive verifier circuit - EXPECT_EQ(outer_folding_circuit.failed(), false) << outer_folding_circuit.err(); - - return inner_folding_proof.accumulator; - } -}; -/** - * @brief Create inner circuit and call check_circuit on it - * - */ -TEST_F(ProtogalaxyRecursiveTest, InnerCircuit) -{ - InnerBuilder builder; - - create_inner_circuit(builder); - - bool result = builder.check_circuit(); - EXPECT_EQ(result, true); -} - -/** - * @brief Ensure that evaluating the perturbator in the recursive folding verifier returns the same result as - * evaluating in Polynomial class. - * - */ -TEST_F(ProtogalaxyRecursiveTest, NewEvaluate) -{ - OuterBuilder builder; - using fr_ct = bn254::ScalarField; - using fr = bn254::ScalarFieldNative; - - std::vector coeffs; - std::vector coeffs_ct; - for (size_t idx = 0; idx < 8; idx++) { - auto el = fr::random_element(); - coeffs.emplace_back(el); - coeffs_ct.emplace_back(fr_ct(&builder, el)); - } - Polynomial poly(coeffs); - fr point = fr::random_element(); - fr_ct point_ct(fr_ct(&builder, point)); - auto res1 = poly.evaluate(point); - - auto res2 = FoldingRecursiveVerifier::evaluate_perturbator(coeffs_ct, point_ct); - EXPECT_EQ(res1, res2.get_value()); -} - -/** - * @brief Tests a simple recursive fold that is valid works as expected. - * - */ -TEST_F(ProtogalaxyRecursiveTest, RecursiveFoldingTest) -{ - // Create two arbitrary circuits for the first round of folding - InnerBuilder builder1; - - create_inner_circuit(builder1); - InnerBuilder builder2; - builder2.add_public_variable(FF(1)); - create_inner_circuit(builder2); - - InnerComposer inner_composer = InnerComposer(); - auto instance1 = inner_composer.create_instance(builder1); - auto instance2 = inner_composer.create_instance(builder2); - auto instances = std::vector>{ instance1, instance2 }; - - fold_and_verify(instances, inner_composer); -} - -/** - * @brief Recursively verify two rounds of folding valid circuits and then recursive verify the final decider proof, - * make sure the verifer circuits pass check_circuit(). Ensure that the algorithm of the recursive and native verifiers - * are identical by checking the manifests - - */ -TEST_F(ProtogalaxyRecursiveTest, FullProtogalaxyRecursiveTest) -{ - - // Create two arbitrary circuits for the first round of folding - InnerBuilder builder1; - - create_inner_circuit(builder1); - InnerBuilder builder2; - builder2.add_public_variable(FF(1)); - create_inner_circuit(builder2); - - InnerComposer inner_composer = InnerComposer(); - auto instance1 = inner_composer.create_instance(builder1); - auto instance2 = inner_composer.create_instance(builder2); - auto instances = std::vector>{ instance1, instance2 }; - - auto accumulator = fold_and_verify(instances, inner_composer); - - // Create another circuit to do a second round of folding - InnerBuilder builder3; - create_inner_circuit(builder3); - auto instance3 = inner_composer.create_instance(builder3); - instances = std::vector>{ accumulator, instance3 }; - - accumulator = fold_and_verify(instances, inner_composer); - - // Create a decider proof for the relaxed instance obtained through folding - auto inner_decider_prover = inner_composer.create_decider_prover(accumulator); - auto inner_decider_proof = inner_decider_prover.construct_proof(); - - // Create a decider verifier circuit for recursively verifying the decider proof - OuterBuilder outer_decider_circuit; - DeciderRecursiveVerifier decider_verifier{ &outer_decider_circuit }; - auto pairing_points = decider_verifier.verify_proof(inner_decider_proof); - info("Decider Recursive Verifier: num gates = ", outer_decider_circuit.num_gates); - // Check for a failure flag in the recursive verifier circuit - EXPECT_EQ(outer_decider_circuit.failed(), false) << outer_decider_circuit.err(); - - // Perform native verification then perform the pairing on the outputs of the recursive - // decider verifier and check that the result agrees. - DeciderVerifier native_decider_verifier = inner_composer.create_decider_verifier(accumulator); - auto native_result = native_decider_verifier.verify_proof(inner_decider_proof); - auto recursive_result = native_decider_verifier.pcs_verification_key->pairing_check(pairing_points[0].get_value(), - pairing_points[1].get_value()); - EXPECT_EQ(native_result, recursive_result); - - // Ensure that the underlying native and recursive decider verification algorithms agree by ensuring - // the manifests produced are the same. - auto recursive_decider_manifest = decider_verifier.transcript->get_manifest(); - auto native_decider_manifest = native_decider_verifier.transcript->get_manifest(); - for (size_t i = 0; i < recursive_decider_manifest.size(); ++i) { - EXPECT_EQ(recursive_decider_manifest[i], native_decider_manifest[i]); - } - - // Construct and verify a proof of the recursive decider verifier circuit - { - auto composer = get_outer_composer(); - auto instance = composer.create_instance(outer_decider_circuit); - auto prover = composer.create_prover(instance); - auto verifier = composer.create_verifier(instance); - auto proof = prover.construct_proof(); - bool verified = verifier.verify_proof(proof); - - ASSERT(verified); - } -} - -TEST_F(ProtogalaxyRecursiveTest, TamperedDeciderProof) -{ - // Create two arbitrary circuits for the first round of folding - InnerBuilder builder1; - - create_inner_circuit(builder1); - InnerBuilder builder2; - builder2.add_public_variable(FF(1)); - create_inner_circuit(builder2); - - InnerComposer inner_composer = InnerComposer(); - auto instance1 = inner_composer.create_instance(builder1); - auto instance2 = inner_composer.create_instance(builder2); - auto instances = std::vector>{ instance1, instance2 }; - - auto accumulator = fold_and_verify(instances, inner_composer); - - // Tamper with the accumulator by changing the target sum - accumulator->target_sum = FF::random_element(); - - // Create a decider proof for the relaxed instance obtained through folding - auto inner_decider_prover = inner_composer.create_decider_prover(accumulator); - auto inner_decider_proof = inner_decider_prover.construct_proof(); - - // Create a decider verifier circuit for recursively verifying the decider proof - OuterBuilder outer_decider_circuit; - DeciderRecursiveVerifier decider_verifier{ &outer_decider_circuit }; - decider_verifier.verify_proof(inner_decider_proof); - info("Decider Recursive Verifier: num gates = ", outer_decider_circuit.num_gates); - - // We expect the decider circuit check to fail due to the bad proof - EXPECT_FALSE(outer_decider_circuit.check_circuit()); -} - -TEST_F(ProtogalaxyRecursiveTest, TamperedAccumulator) -{ - // Create two arbitrary circuits for the first round of folding - InnerBuilder builder1; - - create_inner_circuit(builder1); - InnerBuilder builder2; - builder2.add_public_variable(FF(1)); - create_inner_circuit(builder2); - - InnerComposer inner_composer = InnerComposer(); - auto instance1 = inner_composer.create_instance(builder1); - auto instance2 = inner_composer.create_instance(builder2); - auto instances = std::vector>{ instance1, instance2 }; - - auto accumulator = fold_and_verify(instances, inner_composer); - - // Create another circuit to do a second round of folding - InnerBuilder builder3; - create_inner_circuit(builder3); - auto instance3 = inner_composer.create_instance(builder3); - - // Tamper with the accumulator - instances = std::vector>{ accumulator, instance3 }; - accumulator->prover_polynomials.w_l[1] = FF::random_element(); - - // Generate a folding proof - auto inner_folding_prover = inner_composer.create_folding_prover(instances); - auto inner_folding_proof = inner_folding_prover.fold_instances(); - - // Create a recursive folding verifier circuit for the folding proof of the two instances - OuterBuilder outer_folding_circuit; - FoldingRecursiveVerifier verifier{ &outer_folding_circuit }; - verifier.verify_folding_proof(inner_folding_proof.folding_data); - EXPECT_EQ(outer_folding_circuit.check_circuit(), false); -} - -} // namespace bb::stdlib::recursion::honk \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.hpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.hpp index 5712966f0016..f26b44d11167 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.hpp @@ -20,6 +20,11 @@ template class UltraRecursiveVerifier_ { explicit UltraRecursiveVerifier_(Builder* builder, const std::shared_ptr& native_verifier_key); + UltraRecursiveVerifier_(UltraRecursiveVerifier_&& other) = delete; + UltraRecursiveVerifier_(const UltraRecursiveVerifier_& other) = delete; + UltraRecursiveVerifier_& operator=(const UltraRecursiveVerifier_& other) = delete; + UltraRecursiveVerifier_& operator=(UltraRecursiveVerifier_&& other) = delete; + ~UltraRecursiveVerifier_() = default; // TODO(luke): Eventually this will return something like aggregation_state but I'm simplifying for now until we // determine the exact interface. Simply returns the two pairing points. diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/transcript/transcript.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/transcript/transcript.test.cpp index 7f6b856a253d..6d370e4cbd57 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/transcript/transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/transcript/transcript.test.cpp @@ -56,9 +56,9 @@ transcript::Manifest create_manifest(const size_t num_public_inputs) } // namespace struct TestData { - std::vector g1_elements; - std::vector fr_elements; - std::vector public_input_elements; + std::vector g1_elements; + std::vector fr_elements; + std::vector public_input_elements; size_t num_public_inputs; }; @@ -69,8 +69,8 @@ TestData get_test_data() data.g1_elements.push_back(bb::g1::affine_element(bb::g1::element::random_element())); data.fr_elements.push_back(bb::fr::random_element()); } - data.fr_elements[2] = fr(0); - data.fr_elements[3] = fr(0); + data.fr_elements[2] = bb::fr(0); + data.fr_elements[3] = bb::fr(0); data.num_public_inputs = 13; for (size_t i = 0; i < data.num_public_inputs; ++i) { data.public_input_elements.push_back(bb::fr::random_element()); @@ -191,7 +191,8 @@ TEST(stdlib_transcript, validate_transcript) const auto check_challenge = [&normal_transcript, &recursive_transcript](const std::string& challenge_name, const size_t challenge_idx = 0) { field_t result = recursive_transcript.get_challenge_field_element(challenge_name, challenge_idx); - fr expected = fr::serialize_from_buffer(&normal_transcript.get_challenge(challenge_name, challenge_idx)[0]); + bb::fr expected = + bb::fr::serialize_from_buffer(&normal_transcript.get_challenge(challenge_name, challenge_idx)[0]); EXPECT_EQ(result.get_value(), expected); }; @@ -208,21 +209,21 @@ TEST(stdlib_transcript, validate_transcript) const auto check_field_element = [&normal_transcript, &recursive_transcript](const std::string& element_name) { field_t result = recursive_transcript.get_field_element(element_name); - fr expected = fr::serialize_from_buffer(&normal_transcript.get_element(element_name)[0]); + bb::fr expected = bb::fr::serialize_from_buffer(&normal_transcript.get_element(element_name)[0]); EXPECT_EQ(result.get_value(), expected); }; const auto check_group_element = [&normal_transcript, &recursive_transcript](const std::string& element_name) { group_t recursive_value = recursive_transcript.get_circuit_group_element(element_name); - g1::affine_element expected = - g1::affine_element::serialize_from_buffer(&normal_transcript.get_element(element_name)[0]); - g1::affine_element result{ recursive_value.x.get_value().lo, recursive_value.y.get_value().lo }; + bb::g1::affine_element expected = + bb::g1::affine_element::serialize_from_buffer(&normal_transcript.get_element(element_name)[0]); + bb::g1::affine_element result{ recursive_value.x.get_value().lo, recursive_value.y.get_value().lo }; EXPECT_EQ(result, expected); }; const auto check_public_inputs = [&normal_transcript, &recursive_transcript]() { std::vector result = recursive_transcript.get_field_element_vector("public_inputs"); - std::vector expected = many_from_buffer(normal_transcript.get_element("public_inputs")); + std::vector expected = many_from_buffer(normal_transcript.get_element("public_inputs")); EXPECT_EQ(result.size(), expected.size()); for (size_t i = 0; i < result.size(); ++i) { EXPECT_EQ(result[i].get_value(), expected[i]); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/verification_key/verification_key.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/verification_key/verification_key.test.cpp index b579681391c1..a6e60ec4e740 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/verification_key/verification_key.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/verification_key/verification_key.test.cpp @@ -7,7 +7,7 @@ #include "barretenberg/srs/factories/file_crs_factory.hpp" namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } // namespace using namespace bb::plonk; @@ -20,8 +20,8 @@ using namespace bb::plonk; */ template class VerificationKeyFixture : public testing::Test { public: - using Curve = stdlib::bn254; - using RecursVk = stdlib::recursion::verification_key; + using Curve = bb::stdlib::bn254; + using RecursVk = bb::stdlib::recursion::verification_key; static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/verifier/verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/verifier/verifier.test.cpp index b3d9cadc6ce1..97a2933c32d1 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/verifier/verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/verifier/verifier.test.cpp @@ -16,7 +16,7 @@ namespace bb::stdlib { template class stdlib_verifier : public testing::Test { - using InnerComposer = plonk::UltraComposer; + using InnerComposer = bb::plonk::UltraComposer; using InnerBuilder = typename InnerComposer::CircuitBuilder; using OuterBuilder = typename OuterComposer::CircuitBuilder; @@ -36,7 +36,7 @@ template class stdlib_verifier : public testing::Test { using inner_scalar_field = typename inner_curve::ScalarFieldNative; using outer_scalar_field = typename outer_curve::BaseFieldNative; - using pairing_target_field = fq12; + using pairing_target_field = bb::fq12; // These constexpr definitions are to allow for the following: An Ultra Pedersen hash evaluates to a // different value from the Standard version of the Pedersen hash. Therefore, the fiat-shamir @@ -212,7 +212,7 @@ template class stdlib_verifier : public testing::Test { plonk::proof proof_to_recursively_verify_b = prover.construct_proof(); - auto output = stdlib::recursion::verify_proof( + auto output = bb::stdlib::recursion::verify_proof( &outer_circuit, verification_key_b, recursive_manifest, proof_to_recursively_verify_b, previous_output); verification_key_b->hash(); @@ -265,8 +265,8 @@ template class stdlib_verifier : public testing::Test { transcript::Manifest recursive_manifest = InnerComposer::create_manifest(prover_a.key->num_public_inputs); - stdlib::recursion::aggregation_state output = - stdlib::recursion::verify_proof( + bb::stdlib::recursion::aggregation_state output = + bb::stdlib::recursion::verify_proof( &outer_circuit, verification_key, recursive_manifest, recursive_proof); return { output, verification_key }; @@ -320,7 +320,7 @@ template class stdlib_verifier : public testing::Test { { x1, y1 }, }; - pairing_target_field result = pairing::reduced_ate_pairing_batch_precomputed(P_affine, lines, 2); + pairing_target_field result = bb::pairing::reduced_ate_pairing_batch_precomputed(P_affine, lines, 2); return (result == pairing_target_field::one()); } @@ -332,13 +332,13 @@ template class stdlib_verifier : public testing::Test { static void check_pairing(const circuit_outputs& circuit_output) { - auto g2_lines = srs::get_crs_factory()->get_verifier_crs()->get_precomputed_g2_lines(); + auto g2_lines = bb::srs::get_crs_factory()->get_verifier_crs()->get_precomputed_g2_lines(); g1::affine_element P[2]; P[0].x = outer_scalar_field(circuit_output.aggregation_state.P0.x.get_value().lo); P[0].y = outer_scalar_field(circuit_output.aggregation_state.P0.y.get_value().lo); P[1].x = outer_scalar_field(circuit_output.aggregation_state.P1.x.get_value().lo); P[1].y = outer_scalar_field(circuit_output.aggregation_state.P1.y.get_value().lo); - pairing_target_field inner_proof_result = pairing::reduced_ate_pairing_batch_precomputed(P, g2_lines, 2); + pairing_target_field inner_proof_result = bb::pairing::reduced_ate_pairing_batch_precomputed(P, g2_lines, 2); EXPECT_EQ(inner_proof_result, pairing_target_field::one()); } @@ -347,7 +347,7 @@ template class stdlib_verifier : public testing::Test { info("number of gates in recursive verification circuit = ", outer_circuit.get_num_gates()); bool result = outer_circuit.check_circuit(); EXPECT_EQ(result, expected_result); - auto g2_lines = srs::get_crs_factory()->get_verifier_crs()->get_precomputed_g2_lines(); + auto g2_lines = bb::srs::get_crs_factory()->get_verifier_crs()->get_precomputed_g2_lines(); EXPECT_EQ(check_recursive_proof_public_inputs(outer_circuit, g2_lines), true); } diff --git a/barretenberg/cpp/src/barretenberg/stdlib/types/ultra.hpp b/barretenberg/cpp/src/barretenberg/stdlib/types/ultra.hpp index 96bf0d2b2033..555d3f2975eb 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/types/ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/types/ultra.hpp @@ -57,7 +57,9 @@ using namespace stdlib::merkle_tree; using hash_path = stdlib::merkle_tree::hash_path; } // namespace merkle_tree -using schnorr_signature_bits = stdlib::schnorr_signature_bits; +namespace schnorr { +using signature_bits = stdlib::schnorr::signature_bits; +} // namespace schnorr // Ultra-composer specific types using rom_table_ct = stdlib::rom_table; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/utility/utility.hpp b/barretenberg/cpp/src/barretenberg/stdlib/utility/utility.hpp index 1759f5fc4121..bec32c7a78c1 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/utility/utility.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/utility/utility.hpp @@ -117,10 +117,6 @@ template class StdlibTypesUtility { using type = uint32_t; }; - template struct NativeType { - using type = bool; - }; - template struct NativeType { using type = FF; }; diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.test.cpp b/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.test.cpp index 86c51e5ed1c3..9de85a376045 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.test.cpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.test.cpp @@ -5,8 +5,9 @@ #include "barretenberg/proof_system/library/grand_product_library.hpp" #include "barretenberg/srs/factories/file_crs_factory.hpp" #include -using namespace bb; + using namespace bb::honk; +namespace instance_tests { template class InstanceTests : public testing::Test { using FF = typename Flavor::FF; @@ -88,3 +89,5 @@ TYPED_TEST(InstanceTests, SortedListAccumulator) { TestFixture::test_sorted_list_accumulator_construction(); } + +} // namespace instance_tests \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/partial_evaluation.test.cpp b/barretenberg/cpp/src/barretenberg/sumcheck/partial_evaluation.test.cpp index 83c5084988a0..c0df47b4861e 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/partial_evaluation.test.cpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/partial_evaluation.test.cpp @@ -4,6 +4,7 @@ #include using namespace bb::honk::sumcheck; +namespace test_sumcheck_polynomials { template class PartialEvaluationTests : public testing::Test {}; @@ -316,3 +317,5 @@ TYPED_TEST(PartialEvaluationTests, ThreeRoundsGenericMultiplePolys) EXPECT_EQ((polynomial_get_all[i])[0], expected_val[i]); } } + +} // namespace test_sumcheck_polynomials diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.test.cpp b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.test.cpp index 81a58a3f1692..7d385c5947e2 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.test.cpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.test.cpp @@ -11,16 +11,18 @@ #include "barretenberg/ultra_honk/ultra_composer.hpp" #include -using namespace bb; + using namespace bb::honk; using namespace bb::honk::sumcheck; -using Flavor = honk::flavor::Ultra; +using Flavor = bb::honk::flavor::Ultra; using FF = typename Flavor::FF; using ProverPolynomials = typename Flavor::ProverPolynomials; using RelationSeparator = Flavor::RelationSeparator; const size_t NUM_POLYNOMIALS = Flavor::NUM_ALL_ENTITIES; -Polynomial random_poly(size_t size) +namespace test_sumcheck_round { + +bb::Polynomial random_poly(size_t size) { auto poly = bb::Polynomial(size); for (auto& coeff : poly) { @@ -51,7 +53,7 @@ TEST_F(SumcheckTests, PolynomialNormalization) // Randomly construct the prover polynomials that are input to Sumcheck. // Note: ProverPolynomials are defined as spans so the polynomials they point to need to exist in memory. - std::array, NUM_POLYNOMIALS> random_polynomials; + std::array, NUM_POLYNOMIALS> random_polynomials; for (auto& poly : random_polynomials) { poly = random_poly(multivariate_n); } @@ -114,7 +116,7 @@ TEST_F(SumcheckTests, PolynomialNormalization) // full polynomials at challenge u via the evaluate_mle() function std::vector u_challenge = { u_0, u_1, u_2 }; for (auto [full_poly, claimed_eval] : zip_view(full_polynomials.get_all(), output.claimed_evaluations.get_all())) { - Polynomial poly(full_poly); + bb::Polynomial poly(full_poly); auto v_expected = poly.evaluate_mle(u_challenge); EXPECT_EQ(v_expected, claimed_eval); } @@ -127,7 +129,7 @@ TEST_F(SumcheckTests, Prover) // Randomly construct the prover polynomials that are input to Sumcheck. // Note: ProverPolynomials are defined as spans so the polynomials they point to need to exist in memory. - std::array, NUM_POLYNOMIALS> random_polynomials; + std::array, NUM_POLYNOMIALS> random_polynomials; for (auto& poly : random_polynomials) { poly = random_poly(multivariate_n); } @@ -174,9 +176,9 @@ TEST_F(SumcheckTests, ProverAndVerifierSimple) // Construct prover polynomials where each is the zero polynomial. // Note: ProverPolynomials are defined as spans so the polynomials they point to need to exist in memory. - std::array, NUM_POLYNOMIALS> zero_polynomials; + std::array, NUM_POLYNOMIALS> zero_polynomials; for (auto& poly : zero_polynomials) { - poly = Polynomial(multivariate_n); + poly = bb::Polynomial(multivariate_n); } auto full_polynomials = construct_ultra_full_polynomials(zero_polynomials); @@ -211,7 +213,7 @@ TEST_F(SumcheckTests, ProverAndVerifierSimple) full_polynomials.q_arith = q_arith; // Set aribitrary random relation parameters - RelationParameters relation_parameters{ + bb::RelationParameters relation_parameters{ .beta = FF::random_element(), .gamma = FF::random_element(), .public_input_delta = FF::one(), @@ -253,3 +255,5 @@ TEST_F(SumcheckTests, ProverAndVerifierSimple) run_test(/* expect_verified=*/true); run_test(/* expect_verified=*/false); } + +} // namespace test_sumcheck_round diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.test.cpp b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.test.cpp index 5091717988e7..bb33dc4ef7f6 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.test.cpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.test.cpp @@ -3,7 +3,7 @@ #include "barretenberg/relations/utils.hpp" #include -using namespace bb; + using namespace bb::honk; using namespace bb::honk::sumcheck; @@ -12,7 +12,9 @@ using bb::Univariate; using Flavor = flavor::Ultra; using FF = typename Flavor::FF; -using Utils = RelationUtils; +using Utils = bb::RelationUtils; + +namespace test_sumcheck_round { /** * @brief Test SumcheckRound functions for operations on tuples (and tuples of tuples) of Univariates @@ -20,7 +22,7 @@ using Utils = RelationUtils; */ TEST(SumcheckRound, SumcheckTupleOfTuplesOfUnivariates) { - using Flavor = honk::flavor::Ultra; + using Flavor = bb::honk::flavor::Ultra; using FF = typename Flavor::FF; using RelationSeparator = typename Flavor::RelationSeparator; @@ -41,7 +43,7 @@ TEST(SumcheckRound, SumcheckTupleOfTuplesOfUnivariates) Utils::scale_univariates(tuple_of_tuples, challenge, running_challenge); // Use extend_and_batch_univariates to extend to MAX_LENGTH then accumulate - PowPolynomial pow_polynomial({ 1 }); + bb::PowPolynomial pow_polynomial({ 1 }); auto result = Univariate(); SumcheckProverRound::extend_and_batch_univariates(tuple_of_tuples, result, pow_polynomial); @@ -71,8 +73,8 @@ TEST(SumcheckRound, SumcheckTupleOfTuplesOfUnivariates) */ TEST(SumcheckRound, TuplesOfEvaluationArrays) { - using Flavor = honk::flavor::Ultra; - using Utils = RelationUtils; + using Flavor = bb::honk::flavor::Ultra; + using Utils = bb::RelationUtils; using FF = typename Flavor::FF; using RelationSeparator = typename Flavor::RelationSeparator; @@ -111,7 +113,7 @@ TEST(SumcheckRound, TuplesOfEvaluationArrays) */ TEST(SumcheckRound, AddTuplesOfTuplesOfUnivariates) { - using Flavor = honk::flavor::Ultra; + using Flavor = bb::honk::flavor::Ultra; using FF = typename Flavor::FF; // Define some arbitrary univariates @@ -139,3 +141,5 @@ TEST(SumcheckRound, AddTuplesOfTuplesOfUnivariates) EXPECT_EQ(std::get<0>(std::get<1>(tuple_of_tuples_1)), expected_sum_2); EXPECT_EQ(std::get<1>(std::get<1>(tuple_of_tuples_1)), expected_sum_3); } + +} // namespace test_sumcheck_round diff --git a/barretenberg/cpp/src/barretenberg/transcript/transcript.test.cpp b/barretenberg/cpp/src/barretenberg/transcript/transcript.test.cpp index f9698f1a6c8c..b62cc960a2a4 100644 --- a/barretenberg/cpp/src/barretenberg/transcript/transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/transcript/transcript.test.cpp @@ -1,12 +1,12 @@ #include "barretenberg/transcript/transcript.hpp" #include -using namespace bb; +namespace bb::honk_transcript_tests { -using FF = fr; -using Fr = fr; -using Fq = fq; -using Transcript = honk::BaseTranscript; +using FF = bb::fr; +using Fr = bb::fr; +using Fq = bb::fq; +using Transcript = bb::honk::BaseTranscript; /** * @brief Test sending, receiving, and exporting proofs @@ -47,3 +47,5 @@ TEST(BaseTranscript, TwoProversTwoFields) EXPECT_STATE(verifier_transcript, 0, 64, 64); EXPECT_EQ(received_b, elt_b); } + +} // namespace bb::honk_transcript_tests diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.test.cpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.test.cpp index 7221bab8ff53..f6bcffd50bd5 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.test.cpp @@ -7,14 +7,16 @@ #include "barretenberg/translator_vm/goblin_translator_prover.hpp" #include -using namespace bb; + using namespace bb::honk; using CircuitBuilder = flavor::GoblinTranslator::CircuitBuilder; using Transcript = flavor::GoblinTranslator::Transcript; -using OpQueue = ECCOpQueue; +using OpQueue = bb::ECCOpQueue; + +namespace test_goblin_translator_composer { namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } std::vector add_variables(auto& circuit_constructor, std::vector variables) @@ -46,9 +48,9 @@ class GoblinTranslatorComposerTests : public ::testing::Test { */ TEST_F(GoblinTranslatorComposerTests, Basic) { - using G1 = g1::affine_element; - using Fr = fr; - using Fq = fq; + using G1 = bb::g1::affine_element; + using Fr = bb::fr; + using Fq = bb::fq; auto P1 = G1::random_element(); auto P2 = G1::random_element(); @@ -79,3 +81,5 @@ TEST_F(GoblinTranslatorComposerTests, Basic) bool verified = verifier.verify_proof(proof); EXPECT_TRUE(verified); } + +} // namespace test_goblin_translator_composer diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp index 6dcc73e1f7f3..654834bd1516 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp @@ -9,11 +9,13 @@ #include "barretenberg/proof_system/instance_inspector.hpp" #include "barretenberg/ultra_honk/ultra_composer.hpp" #include "barretenberg/ultra_honk/ultra_prover.hpp" -using namespace bb; + using namespace bb::honk; +namespace test_ultra_honk_composer { + namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } class DataBusComposerTests : public ::testing::Test { @@ -52,7 +54,7 @@ TEST_F(DataBusComposerTests, CallDataRead) // Add mock data to op queue to simulate interaction with a previous circuit op_queue->populate_with_mock_initital_data(); - auto builder = GoblinUltraCircuitBuilder{ op_queue }; + auto builder = bb::GoblinUltraCircuitBuilder{ op_queue }; // Create a general test circuit generate_test_circuit(builder); @@ -93,3 +95,5 @@ TEST_F(DataBusComposerTests, CallDataRead) bool verified = verifier.verify_proof(proof); EXPECT_TRUE(verified); } + +} // namespace test_ultra_honk_composer diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp index ff5d21488c3f..96512d75f106 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp @@ -7,11 +7,13 @@ #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" #include "barretenberg/ultra_honk/ultra_composer.hpp" #include "barretenberg/ultra_honk/ultra_prover.hpp" -using namespace bb; + using namespace bb::honk; +namespace test_ultra_honk_composer { + namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } class GoblinUltraHonkComposerTests : public ::testing::Test { @@ -97,7 +99,7 @@ TEST_F(GoblinUltraHonkComposerTests, SingleCircuit) // Add mock data to op queue to simulate interaction with a previous circuit op_queue->populate_with_mock_initital_data(); - auto builder = GoblinUltraCircuitBuilder{ op_queue }; + auto builder = bb::GoblinUltraCircuitBuilder{ op_queue }; generate_test_circuit(builder); @@ -128,7 +130,7 @@ TEST_F(GoblinUltraHonkComposerTests, MultipleCircuitsMergeOnly) // Construct multiple test circuits that share an ECC op queue. Generate and verify a proof for each. size_t NUM_CIRCUITS = 3; for (size_t i = 0; i < NUM_CIRCUITS; ++i) { - auto builder = GoblinUltraCircuitBuilder{ op_queue }; + auto builder = bb::GoblinUltraCircuitBuilder{ op_queue }; generate_test_circuit(builder); @@ -156,7 +158,7 @@ TEST_F(GoblinUltraHonkComposerTests, MultipleCircuitsHonkOnly) // Construct multiple test circuits that share an ECC op queue. Generate and verify a proof for each. size_t NUM_CIRCUITS = 3; for (size_t i = 0; i < NUM_CIRCUITS; ++i) { - auto builder = GoblinUltraCircuitBuilder{ op_queue }; + auto builder = bb::GoblinUltraCircuitBuilder{ op_queue }; generate_test_circuit(builder); @@ -184,7 +186,7 @@ TEST_F(GoblinUltraHonkComposerTests, MultipleCircuitsHonkAndMerge) // Construct multiple test circuits that share an ECC op queue. Generate and verify a proof for each. size_t NUM_CIRCUITS = 3; for (size_t i = 0; i < NUM_CIRCUITS; ++i) { - auto builder = GoblinUltraCircuitBuilder{ op_queue }; + auto builder = bb::GoblinUltraCircuitBuilder{ op_queue }; generate_test_circuit(builder); @@ -210,3 +212,5 @@ TEST_F(GoblinUltraHonkComposerTests, MultipleCircuitsHonkAndMerge) EXPECT_EQ(result, expected); } } + +} // namespace test_ultra_honk_composer diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp index 0865eff99bb2..3eceba80cf37 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp @@ -6,14 +6,13 @@ #include "barretenberg/ultra_honk/ultra_composer.hpp" #include -using namespace bb; using namespace bb::honk; class GoblinUltraTranscriptTests : public ::testing::Test { public: static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } - using Flavor = honk::flavor::GoblinUltra; + using Flavor = bb::honk::flavor::GoblinUltra; using FF = Flavor::FF; /** diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp index 1f41c5325abf..87ece52bb3fc 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp @@ -2,7 +2,7 @@ #include "barretenberg/protogalaxy/protogalaxy_prover.hpp" #include "barretenberg/ultra_honk/ultra_composer.hpp" #include -using namespace bb; + using namespace bb::honk; using Flavor = flavor::Ultra; @@ -14,18 +14,22 @@ using FF = Flavor::FF; using Affine = Flavor::Commitment; using Projective = Flavor::GroupElement; using Builder = Flavor::CircuitBuilder; +using Polynomial = typename Flavor::Polynomial; using ProverPolynomials = Flavor::ProverPolynomials; +using RelationParameters = bb::RelationParameters; using WitnessCommitments = typename Flavor::WitnessCommitments; using CommitmentKey = Flavor::CommitmentKey; +using PowPolynomial = bb::PowPolynomial; const size_t NUM_POLYNOMIALS = Flavor::NUM_ALL_ENTITIES; +namespace bb::protogalaxy_tests { namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } // TODO(https://github.com/AztecProtocol/barretenberg/issues/744): make testing utility with functionality shared // amongst test files in the proof system -Polynomial get_random_polynomial(size_t size) +bb::Polynomial get_random_polynomial(size_t size) { auto poly = bb::Polynomial(size); for (auto& coeff : poly) { @@ -47,7 +51,7 @@ std::shared_ptr fold_and_verify(const std::vector& accumulator, } void decide_and_verify(std::shared_ptr& accumulator, UltraComposer& composer, bool expected_result) { - auto decider_prover = composer.create_decider_prover(accumulator); + auto decider_prover = composer.create_decider_prover(accumulator, composer.commitment_key); auto decider_verifier = composer.create_decider_verifier(accumulator); auto decision = decider_prover.construct_proof(); auto verified = decider_verifier.verify_proof(decision); @@ -140,12 +144,12 @@ TEST_F(ProtoGalaxyTests, PerturbatorPolynomial) const size_t log_instance_size(3); const size_t instance_size(1 << log_instance_size); - std::array, NUM_POLYNOMIALS> random_polynomials; + std::array, NUM_POLYNOMIALS> random_polynomials; for (auto& poly : random_polynomials) { poly = get_random_polynomial(instance_size); } auto full_polynomials = construct_ultra_full_polynomials(random_polynomials); - auto relation_parameters = RelationParameters::get_random(); + auto relation_parameters = bb::RelationParameters::get_random(); RelationSeparator alphas; for (auto& alpha : alphas) { alpha = FF::random_element(); @@ -159,7 +163,7 @@ TEST_F(ProtoGalaxyTests, PerturbatorPolynomial) } // Construct pow(\vec{betas}) as in the paper - auto pow_beta = bb::PowPolynomial(betas); + auto pow_beta = PowPolynomial(betas); pow_beta.compute_values(); // Compute the corresponding target sum and create a dummy accumulator @@ -185,12 +189,12 @@ TEST_F(ProtoGalaxyTests, PerturbatorPolynomial) TEST_F(ProtoGalaxyTests, CombinerQuotient) { auto compressed_perturbator = FF(2); // F(\alpha) in the paper - auto combiner = Univariate(std::array{ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32 }); + auto combiner = bb::Univariate(std::array{ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32 }); auto combiner_quotient = ProtoGalaxyProver::compute_combiner_quotient(compressed_perturbator, combiner); // K(i) = (G(i) - ( L_0(i) * F(\alpha)) / Z(i), i = {2,.., 13} for ProverInstances::NUM = 2 // K(i) = (G(i) - (1 - i) * F(\alpha)) / i * (i - 1) - auto expected_evals = Univariate(std::array{ + auto expected_evals = bb::Univariate(std::array{ (FF(22) - (FF(1) - FF(2)) * compressed_perturbator) / (FF(2) * FF(2 - 1)), (FF(23) - (FF(1) - FF(3)) * compressed_perturbator) / (FF(3) * FF(3 - 1)), (FF(24) - (FF(1) - FF(4)) * compressed_perturbator) / (FF(4) * FF(4 - 1)), @@ -342,4 +346,6 @@ TEST_F(ProtoGalaxyTests, TamperedAccumulatorPolynomial) auto second_accumulator = fold_and_verify(instances, composer, false); decide_and_verify(second_accumulator, composer, false); -} \ No newline at end of file +} + +} // namespace bb::protogalaxy_tests \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp index bbecb252bf66..7b86527e5883 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp @@ -11,9 +11,11 @@ #include "barretenberg/relations/ultra_arithmetic_relation.hpp" #include "barretenberg/ultra_honk/ultra_composer.hpp" #include -using namespace bb; + using namespace bb::honk; +namespace test_honk_relations { + void ensure_non_zero(auto& polynomial) { bool has_non_zero_coefficient = false; @@ -129,14 +131,12 @@ template void create_some_lookup_gates(auto& circuit_builder) uint256_t(pedersen_input_value) .slice(plookup::fixed_base::table::BITS_PER_LO_SCALAR, plookup::fixed_base::table::BITS_PER_LO_SCALAR + plookup::fixed_base::table::BITS_PER_HI_SCALAR); - const auto input_lo = uint256_t(pedersen_input_value).slice(0, bb::plookup::fixed_base::table::BITS_PER_LO_SCALAR); + const auto input_lo = uint256_t(pedersen_input_value).slice(0, plookup::fixed_base::table::BITS_PER_LO_SCALAR); const auto input_hi_index = circuit_builder.add_variable(input_hi); const auto input_lo_index = circuit_builder.add_variable(input_lo); - const auto sequence_data_hi = - plookup::get_lookup_accumulators(bb::plookup::MultiTableId::FIXED_BASE_LEFT_HI, input_hi); - const auto sequence_data_lo = - plookup::get_lookup_accumulators(bb::plookup::MultiTableId::FIXED_BASE_LEFT_LO, input_lo); + const auto sequence_data_hi = plookup::get_lookup_accumulators(plookup::MultiTableId::FIXED_BASE_LEFT_HI, input_hi); + const auto sequence_data_lo = plookup::get_lookup_accumulators(plookup::MultiTableId::FIXED_BASE_LEFT_LO, input_lo); circuit_builder.create_gates_from_plookup_accumulators( plookup::MultiTableId::FIXED_BASE_LEFT_HI, sequence_data_hi, input_hi_index); @@ -226,7 +226,7 @@ template void create_some_ecc_op_queue_gates(auto& circuit_bui { using G1 = typename Flavor::Curve::Group; using FF = typename Flavor::FF; - static_assert(IsGoblinFlavor); + static_assert(bb::IsGoblinFlavor); const size_t num_ecc_operations = 10; // arbitrary for (size_t i = 0; i < num_ecc_operations; ++i) { auto point = G1::affine_one * FF::random_element(); @@ -258,7 +258,7 @@ TEST_F(RelationCorrectnessTests, UltraRelationCorrectness) // Create a composer and then add an assortment of gates designed to ensure that the constraint(s) represented // by each relation are non-trivially exercised. - auto builder = UltraCircuitBuilder(); + auto builder = bb::UltraCircuitBuilder(); // Create an assortment of representative gates create_some_add_gates(builder); @@ -310,7 +310,7 @@ TEST_F(RelationCorrectnessTests, GoblinUltraRelationCorrectness) // Create a composer and then add an assortment of gates designed to ensure that the constraint(s) represented // by each relation are non-trivially exercised. - auto builder = GoblinUltraCircuitBuilder(); + auto builder = bb::GoblinUltraCircuitBuilder(); // Create an assortment of representative gates create_some_add_gates(builder); @@ -378,14 +378,14 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorPermutationRelationCorrectness) using ProverPolynomials = typename Flavor::ProverPolynomials; using Polynomial = bb::Polynomial; using namespace bb::honk::permutation_library; - auto& engine = numeric::get_debug_randomness(); + auto& engine = numeric::random::get_debug_engine(); auto circuit_size = Flavor::MINI_CIRCUIT_SIZE * Flavor::CONCATENATION_INDEX; // We only need gamma, because permutationr elation only uses gamma FF gamma = FF::random_element(); // Fill relation parameters - RelationParameters params; + bb::RelationParameters params; params.gamma = gamma; // Create storage for polynomials @@ -495,14 +495,14 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorGenPermSortRelationCorrectness) using FF = typename Flavor::FF; using ProverPolynomials = typename Flavor::ProverPolynomials; using Polynomial = bb::Polynomial; - auto& engine = numeric::get_debug_randomness(); + auto& engine = numeric::random::get_debug_engine(); const auto circuit_size = Flavor::FULL_CIRCUIT_SIZE; const auto sort_step = Flavor::SORT_STEP; const auto max_value = (1 << Flavor::MICRO_LIMB_BITS) - 1; // No relation parameters are used in this relation - RelationParameters params; + bb::RelationParameters params; ProverPolynomials prover_polynomials; // Allocate polynomials @@ -577,13 +577,13 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorExtraRelationsCorrectness) using ProverPolynomialIds = typename Flavor::ProverPolynomialIds; using Polynomial = bb::Polynomial; - auto& engine = numeric::get_debug_randomness(); + auto& engine = numeric::random::get_debug_engine(); auto circuit_size = Flavor::FULL_CIRCUIT_SIZE; auto mini_circuit_size = Flavor::MINI_CIRCUIT_SIZE; // We only use accumulated_result from relation parameters in this relation - RelationParameters params; + bb::RelationParameters params; params.accumulated_result = { FF::random_element(), FF::random_element(), FF::random_element(), FF::random_element() }; @@ -679,12 +679,12 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorDecompositionRelationCorrectnes using ProverPolynomials = typename Flavor::ProverPolynomials; using ProverPolynomialIds = typename Flavor::ProverPolynomialIds; using Polynomial = bb::Polynomial; - auto& engine = numeric::get_debug_randomness(); + auto& engine = numeric::random::get_debug_engine(); auto circuit_size = Flavor::FULL_CIRCUIT_SIZE; // Decomposition relation doesn't use any relation parameters - RelationParameters params; + bb::RelationParameters params; // Create storage for polynomials ProverPolynomials prover_polynomials; @@ -1058,7 +1058,7 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorNonNativeRelationCorrectness) constexpr auto circuit_size = Flavor::FULL_CIRCUIT_SIZE; constexpr auto mini_circuit_size = Flavor::MINI_CIRCUIT_SIZE; - auto& engine = numeric::get_debug_randomness(); + auto& engine = numeric::random::get_debug_engine(); auto op_queue = std::make_shared(); @@ -1083,10 +1083,10 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorNonNativeRelationCorrectness) const auto evaluation_input_x = BF::random_element(&engine); // Generating all the values is pretty tedious, so just use CircuitBuilder - auto circuit_builder = GoblinTranslatorCircuitBuilder(batching_challenge_v, evaluation_input_x, op_queue); + auto circuit_builder = bb::GoblinTranslatorCircuitBuilder(batching_challenge_v, evaluation_input_x, op_queue); // The non-native field relation uses limbs of evaluation_input_x and powers of batching_challenge_v as inputs - RelationParameters params; + bb::RelationParameters params; auto v_power = BF::one(); for (size_t i = 0; i < 4 /*Number of powers of v that we need {1,2,3,4}*/; i++) { v_power *= batching_challenge_v; @@ -1180,3 +1180,5 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorNonNativeRelationCorrectness) // Check that Non-Native Field relation is satisfied across each row of the prover polynomials check_relation>(circuit_size, prover_polynomials, params); } + +} // namespace test_honk_relations diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp index fe0fede946c9..ab2cb1141cb2 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp @@ -14,13 +14,14 @@ #include -using namespace bb; using namespace bb::honk; using namespace bb::honk::sumcheck; -using Flavor = honk::flavor::Ultra; +using Flavor = bb::honk::flavor::Ultra; using FF = typename Flavor::FF; +namespace test_sumcheck_round { + class SumcheckTestsRealCircuit : public ::testing::Test { protected: static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } @@ -38,7 +39,7 @@ TEST_F(SumcheckTestsRealCircuit, Ultra) using RelationSeparator = typename Flavor::RelationSeparator; // Create a composer and a dummy circuit with a few gates - auto builder = UltraCircuitBuilder(); + auto builder = bb::UltraCircuitBuilder(); FF a = FF::one(); // Add some basic add gates, with a public input for good measure @@ -68,14 +69,12 @@ TEST_F(SumcheckTestsRealCircuit, Ultra) uint256_t(pedersen_input_value) .slice(plookup::fixed_base::table::BITS_PER_LO_SCALAR, plookup::fixed_base::table::BITS_PER_LO_SCALAR + plookup::fixed_base::table::BITS_PER_HI_SCALAR); - const FF input_lo = uint256_t(pedersen_input_value).slice(0, bb::plookup::fixed_base::table::BITS_PER_LO_SCALAR); + const FF input_lo = uint256_t(pedersen_input_value).slice(0, plookup::fixed_base::table::BITS_PER_LO_SCALAR); const auto input_hi_index = builder.add_variable(input_hi); const auto input_lo_index = builder.add_variable(input_lo); - const auto sequence_data_hi = - plookup::get_lookup_accumulators(bb::plookup::MultiTableId::FIXED_BASE_LEFT_HI, input_hi); - const auto sequence_data_lo = - plookup::get_lookup_accumulators(bb::plookup::MultiTableId::FIXED_BASE_LEFT_LO, input_lo); + const auto sequence_data_hi = plookup::get_lookup_accumulators(plookup::MultiTableId::FIXED_BASE_LEFT_HI, input_hi); + const auto sequence_data_lo = plookup::get_lookup_accumulators(plookup::MultiTableId::FIXED_BASE_LEFT_LO, input_lo); builder.create_gates_from_plookup_accumulators( plookup::MultiTableId::FIXED_BASE_LEFT_HI, sequence_data_hi, input_hi_index); @@ -201,3 +200,5 @@ TEST_F(SumcheckTestsRealCircuit, Ultra) ASSERT_TRUE(verified); } + +} // namespace test_sumcheck_round diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp index 5d2a6a71ea26..b81d6a421785 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp @@ -110,7 +110,8 @@ template class UltraComposer_ { */ MergeVerifier_ create_merge_verifier() { return MergeVerifier_(); } - ProtoGalaxyProver_ create_folding_prover(const std::vector>& instances) + ProtoGalaxyProver_ create_folding_prover(const std::vector>& instances, + const std::shared_ptr& commitment_key) { ProtoGalaxyProver_ output_state(instances, commitment_key); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp index 09a1bdb72f3b..3ab5595dcddb 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp @@ -16,11 +16,12 @@ #include #include -using namespace bb; using namespace bb::honk; +namespace test_ultra_honk_composer { + namespace { -auto& engine = numeric::get_debug_randomness(); +auto& engine = numeric::random::get_debug_engine(); } std::vector add_variables(auto& circuit_builder, std::vector variables) @@ -52,6 +53,9 @@ void ensure_non_zero(auto& polynomial) } class UltraHonkComposerTests : public ::testing::Test { + public: + using fr = bb::fr; + protected: static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } }; @@ -65,7 +69,7 @@ class UltraHonkComposerTests : public ::testing::Test { */ TEST_F(UltraHonkComposerTests, ANonZeroPolynomialIsAGoodPolynomial) { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = bb::UltraCircuitBuilder(); auto composer = UltraComposer(); auto instance = composer.create_instance(circuit_builder); @@ -92,7 +96,7 @@ TEST_F(UltraHonkComposerTests, ANonZeroPolynomialIsAGoodPolynomial) */ TEST_F(UltraHonkComposerTests, PublicInputs) { - auto builder = UltraCircuitBuilder(); + auto builder = bb::UltraCircuitBuilder(); size_t num_gates = 10; // Add some arbitrary arithmetic gates that utilize public inputs @@ -116,7 +120,7 @@ TEST_F(UltraHonkComposerTests, PublicInputs) TEST_F(UltraHonkComposerTests, XorConstraint) { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = bb::UltraCircuitBuilder(); uint32_t left_value = engine.get_random_uint32(); uint32_t right_value = engine.get_random_uint32(); @@ -144,9 +148,9 @@ TEST_F(UltraHonkComposerTests, XorConstraint) TEST_F(UltraHonkComposerTests, create_gates_from_plookup_accumulators) { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = bb::UltraCircuitBuilder(); - fr input_value = fr::random_element(); + bb::fr input_value = fr::random_element(); const fr input_lo = static_cast(input_value).slice(0, plookup::fixed_base::table::BITS_PER_LO_SCALAR); const auto input_lo_index = circuit_builder.add_variable(input_lo); @@ -211,7 +215,7 @@ TEST_F(UltraHonkComposerTests, create_gates_from_plookup_accumulators) TEST_F(UltraHonkComposerTests, test_no_lookup_proof) { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = bb::UltraCircuitBuilder(); for (size_t i = 0; i < 16; ++i) { for (size_t j = 0; j < 16; ++j) { @@ -236,7 +240,7 @@ TEST_F(UltraHonkComposerTests, test_elliptic_gate) { typedef grumpkin::g1::affine_element affine_element; typedef grumpkin::g1::element element; - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = bb::UltraCircuitBuilder(); affine_element p1 = affine_element::random_element(); affine_element p2 = affine_element::random_element(); @@ -268,7 +272,7 @@ TEST_F(UltraHonkComposerTests, test_elliptic_gate) TEST_F(UltraHonkComposerTests, non_trivial_tag_permutation) { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = bb::UltraCircuitBuilder(); fr a = fr::random_element(); fr b = -a; @@ -296,7 +300,7 @@ TEST_F(UltraHonkComposerTests, non_trivial_tag_permutation) TEST_F(UltraHonkComposerTests, non_trivial_tag_permutation_and_cycles) { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = bb::UltraCircuitBuilder(); fr a = fr::random_element(); fr c = -a; @@ -335,7 +339,7 @@ TEST_F(UltraHonkComposerTests, non_trivial_tag_permutation_and_cycles) TEST_F(UltraHonkComposerTests, bad_tag_permutation) { { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = bb::UltraCircuitBuilder(); fr a = fr::random_element(); fr b = -a; @@ -360,7 +364,7 @@ TEST_F(UltraHonkComposerTests, bad_tag_permutation) } // Same as above but without tag creation to check reason of failure is really tag mismatch { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = bb::UltraCircuitBuilder(); fr a = fr::random_element(); fr b = -a; @@ -380,7 +384,7 @@ TEST_F(UltraHonkComposerTests, bad_tag_permutation) TEST_F(UltraHonkComposerTests, sort_widget) { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = bb::UltraCircuitBuilder(); fr a = fr::one(); fr b = fr(2); fr c = fr(3); @@ -408,7 +412,7 @@ TEST_F(UltraHonkComposerTests, sort_with_edges_gate) fr h = fr(8); { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = bb::UltraCircuitBuilder(); auto a_idx = circuit_builder.add_variable(a); auto b_idx = circuit_builder.add_variable(b); auto c_idx = circuit_builder.add_variable(c); @@ -425,7 +429,7 @@ TEST_F(UltraHonkComposerTests, sort_with_edges_gate) } { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = bb::UltraCircuitBuilder(); auto a_idx = circuit_builder.add_variable(a); auto b_idx = circuit_builder.add_variable(b); auto c_idx = circuit_builder.add_variable(c); @@ -441,7 +445,7 @@ TEST_F(UltraHonkComposerTests, sort_with_edges_gate) prove_and_verify(circuit_builder, composer, /*expected_result=*/false); } { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = bb::UltraCircuitBuilder(); auto a_idx = circuit_builder.add_variable(a); auto b_idx = circuit_builder.add_variable(b); auto c_idx = circuit_builder.add_variable(c); @@ -457,7 +461,7 @@ TEST_F(UltraHonkComposerTests, sort_with_edges_gate) prove_and_verify(circuit_builder, composer, /*expected_result=*/false); } { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = bb::UltraCircuitBuilder(); auto a_idx = circuit_builder.add_variable(a); auto c_idx = circuit_builder.add_variable(c); auto d_idx = circuit_builder.add_variable(d); @@ -473,7 +477,7 @@ TEST_F(UltraHonkComposerTests, sort_with_edges_gate) prove_and_verify(circuit_builder, composer, /*expected_result=*/false); } { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = bb::UltraCircuitBuilder(); auto idx = add_variables(circuit_builder, { 1, 2, 5, 6, 7, 10, 11, 13, 16, 17, 20, 22, 22, 25, 26, 29, 29, 32, 32, 33, 35, 38, 39, 39, 42, 42, 43, 45 }); circuit_builder.create_sort_constraint_with_edges(idx, 1, 45); @@ -482,7 +486,7 @@ TEST_F(UltraHonkComposerTests, sort_with_edges_gate) prove_and_verify(circuit_builder, composer, /*expected_result=*/true); } { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = bb::UltraCircuitBuilder(); auto idx = add_variables(circuit_builder, { 1, 2, 5, 6, 7, 10, 11, 13, 16, 17, 20, 22, 22, 25, 26, 29, 29, 32, 32, 33, 35, 38, 39, 39, 42, 42, 43, 45 }); circuit_builder.create_sort_constraint_with_edges(idx, 1, 29); @@ -495,7 +499,7 @@ TEST_F(UltraHonkComposerTests, sort_with_edges_gate) TEST_F(UltraHonkComposerTests, range_constraint) { { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = bb::UltraCircuitBuilder(); auto indices = add_variables(circuit_builder, { 1, 2, 3, 4, 5, 6, 7, 8 }); for (size_t i = 0; i < indices.size(); i++) { circuit_builder.create_new_range_constraint(indices[i], 8); @@ -507,7 +511,7 @@ TEST_F(UltraHonkComposerTests, range_constraint) prove_and_verify(circuit_builder, composer, /*expected_result=*/true); } { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = bb::UltraCircuitBuilder(); auto indices = add_variables(circuit_builder, { 3 }); for (size_t i = 0; i < indices.size(); i++) { circuit_builder.create_new_range_constraint(indices[i], 3); @@ -519,7 +523,7 @@ TEST_F(UltraHonkComposerTests, range_constraint) prove_and_verify(circuit_builder, composer, /*expected_result=*/true); } { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = bb::UltraCircuitBuilder(); auto indices = add_variables(circuit_builder, { 1, 2, 3, 4, 5, 6, 8, 25 }); for (size_t i = 0; i < indices.size(); i++) { circuit_builder.create_new_range_constraint(indices[i], 8); @@ -530,7 +534,7 @@ TEST_F(UltraHonkComposerTests, range_constraint) prove_and_verify(circuit_builder, composer, /*expected_result=*/false); } { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = bb::UltraCircuitBuilder(); auto indices = add_variables(circuit_builder, { 1, 2, 3, 4, 5, 6, 10, 8, 15, 11, 32, 21, 42, 79, 16, 10, 3, 26, 19, 51 }); for (size_t i = 0; i < indices.size(); i++) { @@ -542,7 +546,7 @@ TEST_F(UltraHonkComposerTests, range_constraint) prove_and_verify(circuit_builder, composer, /*expected_result=*/true); } { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = bb::UltraCircuitBuilder(); auto indices = add_variables(circuit_builder, { 1, 2, 3, 80, 5, 6, 29, 8, 15, 11, 32, 21, 42, 79, 16, 10, 3, 26, 13, 14 }); for (size_t i = 0; i < indices.size(); i++) { @@ -554,7 +558,7 @@ TEST_F(UltraHonkComposerTests, range_constraint) prove_and_verify(circuit_builder, composer, /*expected_result=*/false); } { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = bb::UltraCircuitBuilder(); auto indices = add_variables(circuit_builder, { 1, 0, 3, 80, 5, 6, 29, 8, 15, 11, 32, 21, 42, 79, 16, 10, 3, 26, 13, 14 }); for (size_t i = 0; i < indices.size(); i++) { @@ -569,7 +573,7 @@ TEST_F(UltraHonkComposerTests, range_constraint) TEST_F(UltraHonkComposerTests, range_with_gates) { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = bb::UltraCircuitBuilder(); auto idx = add_variables(circuit_builder, { 1, 2, 3, 4, 5, 6, 7, 8 }); for (size_t i = 0; i < idx.size(); i++) { circuit_builder.create_new_range_constraint(idx[i], 8); @@ -588,7 +592,7 @@ TEST_F(UltraHonkComposerTests, range_with_gates) TEST_F(UltraHonkComposerTests, range_with_gates_where_range_is_not_a_power_of_two) { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = bb::UltraCircuitBuilder(); auto idx = add_variables(circuit_builder, { 1, 2, 3, 4, 5, 6, 7, 8 }); for (size_t i = 0; i < idx.size(); i++) { circuit_builder.create_new_range_constraint(idx[i], 12); @@ -609,7 +613,7 @@ TEST_F(UltraHonkComposerTests, sort_widget_complex) { { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = bb::UltraCircuitBuilder(); std::vector a = { 1, 3, 4, 7, 7, 8, 11, 14, 15, 15, 18, 19, 21, 21, 24, 25, 26, 27, 30, 32 }; std::vector ind; for (size_t i = 0; i < a.size(); i++) @@ -621,7 +625,7 @@ TEST_F(UltraHonkComposerTests, sort_widget_complex) } { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = bb::UltraCircuitBuilder(); std::vector a = { 1, 3, 4, 7, 7, 8, 16, 14, 15, 15, 18, 19, 21, 21, 24, 25, 26, 27, 30, 32 }; std::vector ind; for (size_t i = 0; i < a.size(); i++) @@ -635,7 +639,7 @@ TEST_F(UltraHonkComposerTests, sort_widget_complex) TEST_F(UltraHonkComposerTests, sort_widget_neg) { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = bb::UltraCircuitBuilder(); fr a = fr::one(); fr b = fr(2); fr c = fr(3); @@ -653,7 +657,7 @@ TEST_F(UltraHonkComposerTests, sort_widget_neg) TEST_F(UltraHonkComposerTests, composed_range_constraint) { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = bb::UltraCircuitBuilder(); auto c = fr::random_element(); auto d = uint256_t(c).slice(0, 133); auto e = fr(d); @@ -667,8 +671,8 @@ TEST_F(UltraHonkComposerTests, composed_range_constraint) TEST_F(UltraHonkComposerTests, non_native_field_multiplication) { - using fq = fq; - auto circuit_builder = UltraCircuitBuilder(); + using fq = bb::fq; + auto circuit_builder = bb::UltraCircuitBuilder(); fq a = fq::random_element(); fq b = fq::random_element(); @@ -712,7 +716,7 @@ TEST_F(UltraHonkComposerTests, non_native_field_multiplication) const auto q_indices = get_limb_witness_indices(split_into_limbs(uint256_t(q))); const auto r_indices = get_limb_witness_indices(split_into_limbs(uint256_t(r))); - non_native_field_witnesses inputs{ + bb::non_native_field_witnesses inputs{ a_indices, b_indices, q_indices, r_indices, modulus_limbs, fr(uint256_t(modulus)), }; const auto [lo_1_idx, hi_1_idx] = circuit_builder.evaluate_non_native_field_multiplication(inputs); @@ -724,7 +728,7 @@ TEST_F(UltraHonkComposerTests, non_native_field_multiplication) TEST_F(UltraHonkComposerTests, rom) { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = bb::UltraCircuitBuilder(); uint32_t rom_values[8]{ circuit_builder.add_variable(fr::random_element()), circuit_builder.add_variable(fr::random_element()), @@ -766,7 +770,7 @@ TEST_F(UltraHonkComposerTests, rom) TEST_F(UltraHonkComposerTests, ram) { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = bb::UltraCircuitBuilder(); uint32_t ram_values[8]{ circuit_builder.add_variable(fr::random_element()), circuit_builder.add_variable(fr::random_element()), @@ -830,7 +834,7 @@ TEST_F(UltraHonkComposerTests, ram) TEST_F(UltraHonkComposerTests, range_checks_on_duplicates) { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = bb::UltraCircuitBuilder(); uint32_t a = circuit_builder.add_variable(100); uint32_t b = circuit_builder.add_variable(100); @@ -870,7 +874,7 @@ TEST_F(UltraHonkComposerTests, range_checks_on_duplicates) // before range constraints are applied to it. TEST_F(UltraHonkComposerTests, range_constraint_small_variable) { - auto circuit_builder = UltraCircuitBuilder(); + auto circuit_builder = bb::UltraCircuitBuilder(); uint16_t mask = (1 << 8) - 1; int a = engine.get_random_uint16() & mask; @@ -886,4 +890,6 @@ TEST_F(UltraHonkComposerTests, range_constraint_small_variable) auto composer = UltraComposer(); prove_and_verify(circuit_builder, composer, /*expected_result=*/true); -} \ No newline at end of file +} + +} // namespace test_ultra_honk_composer \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp index 9fe521be717d..2c5c6ccb1dce 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp @@ -6,14 +6,13 @@ #include "barretenberg/ultra_honk/ultra_composer.hpp" #include -using namespace bb; using namespace bb::honk; class UltraTranscriptTests : public ::testing::Test { public: static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } - using Flavor = honk::flavor::Ultra; + using Flavor = bb::honk::flavor::Ultra; using FF = Flavor::FF; /** diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_alu_trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_alu_trace.cpp deleted file mode 100644 index 7da44d916bd4..000000000000 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_alu_trace.cpp +++ /dev/null @@ -1,347 +0,0 @@ -#include "AvmMini_alu_trace.hpp" - -namespace avm_trace { - -/** - * @brief Constructor of Alu trace builder of AVM. Only serves to set the capacity of the - * underlying trace. - */ -AvmMiniAluTraceBuilder::AvmMiniAluTraceBuilder() -{ - alu_trace.reserve(AVM_TRACE_SIZE); -} - -/** - * @brief Resetting the internal state so that a new Alu trace can be rebuilt using the same object. - * - */ -void AvmMiniAluTraceBuilder::reset() -{ - alu_trace.clear(); -} - -/** - * @brief Prepare the Alu trace to be incorporated into the main trace. - * - * @return The Alu trace (which is moved). - */ -std::vector AvmMiniAluTraceBuilder::finalize() -{ - return std::move(alu_trace); -} - -/** - * @brief Build Alu trace and compute the result of an addition of type defined by in_tag. - * Besides the addition calculation, for the types u8, u16, u32, u64, and u128, we - * have to store the result of the addition modulo 2^128 decomposed into 8-bit and - * 16-bit registers, i.e., - * a+b mod. 2^128 = alu_u8_r0 + alu_u8_r1 * 2^8 + alu_u16_r0 * 2^16 ... + alu_u16_r6 * 2^112 - * - * @param a Left operand of the addition - * @param b Right operand of the addition - * @param in_tag Instruction tag defining the number of bits on which the addition applies. - * It is assumed that the caller never uses the type u0. - * @param clk Clock referring to the operation in the main trace. - * - * @return FF The result of the addition casted in a finite field element - */ -FF AvmMiniAluTraceBuilder::add(FF const& a, FF const& b, AvmMemoryTag in_tag, uint32_t const clk) -{ - FF c{}; - bool carry = false; - uint8_t alu_u8_r0{}; - uint8_t alu_u8_r1{}; - std::array alu_u16_reg{}; - - uint128_t a_u128{ a }; - uint128_t b_u128{ b }; - uint128_t c_u128 = a_u128 + b_u128; - - switch (in_tag) { - case AvmMemoryTag::FF: - c = a + b; - break; - case AvmMemoryTag::U8: - c = FF{ static_cast(c_u128) }; - break; - case AvmMemoryTag::U16: - c = FF{ static_cast(c_u128) }; - break; - case AvmMemoryTag::U32: - c = FF{ static_cast(c_u128) }; - break; - case AvmMemoryTag::U64: - c = FF{ static_cast(c_u128) }; - break; - case AvmMemoryTag::U128: - c = FF{ uint256_t::from_uint128(c_u128) }; - break; - case AvmMemoryTag::U0: // Unsupported as instruction tag - return FF{ 0 }; - } - - if (in_tag != AvmMemoryTag::FF) { - // a_u128 + b_u128 >= 2^128 <==> c_u128 < a_u128 - if (c_u128 < a_u128) { - carry = true; - } - - uint128_t c_trunc_128 = c_u128; - alu_u8_r0 = static_cast(c_trunc_128); - c_trunc_128 >>= 8; - alu_u8_r1 = static_cast(c_trunc_128); - c_trunc_128 >>= 8; - - for (size_t i = 0; i < 7; i++) { - alu_u16_reg.at(i) = static_cast(c_trunc_128); - c_trunc_128 >>= 16; - } - } - - alu_trace.push_back(AvmMiniAluTraceBuilder::AluTraceEntry{ - .alu_clk = clk, - .alu_op_add = true, - .alu_ff_tag = in_tag == AvmMemoryTag::FF, - .alu_u8_tag = in_tag == AvmMemoryTag::U8, - .alu_u16_tag = in_tag == AvmMemoryTag::U16, - .alu_u32_tag = in_tag == AvmMemoryTag::U32, - .alu_u64_tag = in_tag == AvmMemoryTag::U64, - .alu_u128_tag = in_tag == AvmMemoryTag::U128, - .alu_ia = a, - .alu_ib = b, - .alu_ic = c, - .alu_cf = carry, - .alu_u8_r0 = alu_u8_r0, - .alu_u8_r1 = alu_u8_r1, - .alu_u16_reg = alu_u16_reg, - }); - - return c; -} - -/** - * @brief Build Alu trace and compute the result of a subtraction of type defined by in_tag. - * Besides the subtraction calculation, for the types u8, u16, u32, u64, and u128, we - * have to store the result of the subtraction modulo 2^128 decomposed into 8-bit and - * 16-bit registers, i.e., - * a-b mod. 2^128 = alu_u8_r0 + alu_u8_r1 * 2^8 + alu_u16_r0 * 2^16 ... + alu_u16_r6 * 2^112 - * - * @param a Left operand of the subtraction - * @param b Right operand of the subtraction - * @param in_tag Instruction tag defining the number of bits on which the subtracttion applies. - * It is assumed that the caller never uses the type u0. - * @param clk Clock referring to the operation in the main trace. - * - * @return FF The result of the subtraction casted in a finite field element - */ -FF AvmMiniAluTraceBuilder::sub(FF const& a, FF const& b, AvmMemoryTag in_tag, uint32_t const clk) -{ - FF c{}; - bool carry = false; - uint8_t alu_u8_r0{}; - uint8_t alu_u8_r1{}; - std::array alu_u16_reg{}; - uint128_t a_u128{ a }; - uint128_t b_u128{ b }; - uint128_t c_u128 = a_u128 - b_u128; - - switch (in_tag) { - case AvmMemoryTag::FF: - c = a - b; - break; - case AvmMemoryTag::U8: - c = FF{ static_cast(c_u128) }; - break; - case AvmMemoryTag::U16: - c = FF{ static_cast(c_u128) }; - break; - case AvmMemoryTag::U32: - c = FF{ static_cast(c_u128) }; - break; - case AvmMemoryTag::U64: - c = FF{ static_cast(c_u128) }; - break; - case AvmMemoryTag::U128: - c = FF{ uint256_t::from_uint128(c_u128) }; - break; - case AvmMemoryTag::U0: // Unsupported as instruction tag - return FF{ 0 }; - } - - if (in_tag != AvmMemoryTag::FF) { - // Underflow when a_u128 < b_u128 - if (a_u128 < b_u128) { - carry = true; - } - - uint128_t c_trunc_128 = c_u128; - alu_u8_r0 = static_cast(c_trunc_128); - c_trunc_128 >>= 8; - alu_u8_r1 = static_cast(c_trunc_128); - c_trunc_128 >>= 8; - - for (size_t i = 0; i < 7; i++) { - alu_u16_reg.at(i) = static_cast(c_trunc_128); - c_trunc_128 >>= 16; - } - } - - alu_trace.push_back(AvmMiniAluTraceBuilder::AluTraceEntry{ - .alu_clk = clk, - .alu_op_sub = true, - .alu_ff_tag = in_tag == AvmMemoryTag::FF, - .alu_u8_tag = in_tag == AvmMemoryTag::U8, - .alu_u16_tag = in_tag == AvmMemoryTag::U16, - .alu_u32_tag = in_tag == AvmMemoryTag::U32, - .alu_u64_tag = in_tag == AvmMemoryTag::U64, - .alu_u128_tag = in_tag == AvmMemoryTag::U128, - .alu_ia = a, - .alu_ib = b, - .alu_ic = c, - .alu_cf = carry, - .alu_u8_r0 = alu_u8_r0, - .alu_u8_r1 = alu_u8_r1, - .alu_u16_reg = alu_u16_reg, - }); - - return c; -} - -/** - * @brief Build Alu trace and compute the result of an multiplication of type defined by in_tag. - * - * @param a Left operand of the multiplication - * @param b Right operand of the multiplication - * @param in_tag Instruction tag defining the number of bits on which the multiplication applies. - * It is assumed that the caller never uses the type u0. - * @param clk Clock referring to the operation in the main trace. - * - * @return FF The result of the multiplication casted in a finite field element - */ -FF AvmMiniAluTraceBuilder::mul(FF const& a, FF const& b, AvmMemoryTag in_tag, uint32_t const clk) -{ - FF c{}; - bool carry = false; - uint8_t alu_u8_r0{}; - uint8_t alu_u8_r1{}; - - std::array alu_u16_reg{}; - - uint128_t a_u128{ a }; - uint128_t b_u128{ b }; - uint128_t c_u128 = a_u128 * b_u128; // Multiplication over the integers (not mod. 2^64) - - switch (in_tag) { - case AvmMemoryTag::FF: - c = a * b; - break; - case AvmMemoryTag::U8: - c = FF{ static_cast(c_u128) }; - break; - case AvmMemoryTag::U16: - c = FF{ static_cast(c_u128) }; - break; - case AvmMemoryTag::U32: - c = FF{ static_cast(c_u128) }; - break; - case AvmMemoryTag::U64: - c = FF{ static_cast(c_u128) }; - break; - case AvmMemoryTag::U128: { - uint256_t a_u256{ a }; - uint256_t b_u256{ b }; - uint256_t c_u256 = a_u256 * b_u256; // Multiplication over the integers (not mod. 2^128) - - uint128_t a_u128{ a_u256 }; - uint128_t b_u128{ b_u256 }; - - uint128_t c_u128 = a_u128 * b_u128; - - // Decompose a_u128 and b_u128 over 8 16-bit registers. - std::array alu_u16_reg_a{}; - std::array alu_u16_reg_b{}; - uint128_t a_trunc_128 = a_u128; - uint128_t b_trunc_128 = b_u128; - - for (size_t i = 0; i < 8; i++) { - alu_u16_reg_a.at(i) = static_cast(a_trunc_128); - alu_u16_reg_b.at(i) = static_cast(b_trunc_128); - a_trunc_128 >>= 16; - b_trunc_128 >>= 16; - } - - // Represent a, b with 64-bit limbs: a = a_l + 2^64 * a_h, b = b_l + 2^64 * b_h, - // c_high := 2^128 * a_h * b_h - uint256_t c_high = ((a_u256 >> 64) * (b_u256 >> 64)) << 128; - - // From PIL relation in alu_chip.pil, we need to determine the bit CF and 64-bit value R' in - // a * b_l + a_l * b_h * 2^64 = (CF * 2^64 + R') * 2^128 + c - // LHS is c_u256 - c_high - - // CF bit - carry = ((c_u256 - c_high) >> 192) > 0; - // R' value - uint64_t alu_u64_r0 = static_cast(((c_u256 - c_high) >> 128) & uint256_t(UINT64_MAX)); - - c = FF{ uint256_t::from_uint128(c_u128) }; - - alu_trace.push_back(AvmMiniAluTraceBuilder::AluTraceEntry{ - .alu_clk = clk, - .alu_op_mul = true, - .alu_u128_tag = in_tag == AvmMemoryTag::U128, - .alu_ia = a, - .alu_ib = b, - .alu_ic = c, - .alu_cf = carry, - .alu_u16_reg = alu_u16_reg_a, - .alu_u64_r0 = alu_u64_r0, - }); - - alu_trace.push_back(AvmMiniAluTraceBuilder::AluTraceEntry{ - .alu_u16_reg = alu_u16_reg_b, - }); - - return c; - } - case AvmMemoryTag::U0: // Unsupported as instruction tag - return FF{ 0 }; - } - - // Following code executed for: u8, u16, u32, u64 (u128 returned handled specifically) - if (in_tag != AvmMemoryTag::FF) { - // Decomposition of c_u128 into 8-bit and 16-bit registers as follows: - // alu_u8_r0 + alu_u8_r1 * 2^8 + alu_u16_r0 * 2^16 ... + alu_u16_r6 * 2^112 - uint128_t c_trunc_128 = c_u128; - alu_u8_r0 = static_cast(c_trunc_128); - c_trunc_128 >>= 8; - alu_u8_r1 = static_cast(c_trunc_128); - c_trunc_128 >>= 8; - - for (size_t i = 0; i < 7; i++) { - alu_u16_reg.at(i) = static_cast(c_trunc_128); - c_trunc_128 >>= 16; - } - } - - // Following code executed for: ff, u8, u16, u32, u64 (u128 returned handled specifically) - alu_trace.push_back(AvmMiniAluTraceBuilder::AluTraceEntry{ - .alu_clk = clk, - .alu_op_mul = true, - .alu_ff_tag = in_tag == AvmMemoryTag::FF, - .alu_u8_tag = in_tag == AvmMemoryTag::U8, - .alu_u16_tag = in_tag == AvmMemoryTag::U16, - .alu_u32_tag = in_tag == AvmMemoryTag::U32, - .alu_u64_tag = in_tag == AvmMemoryTag::U64, - .alu_ia = a, - .alu_ib = b, - .alu_ic = c, - .alu_cf = carry, - .alu_u8_r0 = alu_u8_r0, - .alu_u8_r1 = alu_u8_r1, - .alu_u16_reg = alu_u16_reg, - }); - - return c; -} - -} // namespace avm_trace diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_alu_trace.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_alu_trace.hpp deleted file mode 100644 index cda0263cb8da..000000000000 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_alu_trace.hpp +++ /dev/null @@ -1,49 +0,0 @@ -#pragma once - -#include "AvmMini_common.hpp" - -namespace avm_trace { - -class AvmMiniAluTraceBuilder { - - public: - struct AluTraceEntry { - uint32_t alu_clk{}; - - bool alu_op_add = false; - bool alu_op_sub = false; - bool alu_op_mul = false; - - bool alu_ff_tag = false; - bool alu_u8_tag = false; - bool alu_u16_tag = false; - bool alu_u32_tag = false; - bool alu_u64_tag = false; - bool alu_u128_tag = false; - - FF alu_ia{}; - FF alu_ib{}; - FF alu_ic{}; - - bool alu_cf = false; - - uint8_t alu_u8_r0{}; - uint8_t alu_u8_r1{}; - - std::array alu_u16_reg{}; - - uint64_t alu_u64_r0{}; - }; - - AvmMiniAluTraceBuilder(); - void reset(); - std::vector finalize(); - - FF add(FF const& a, FF const& b, AvmMemoryTag in_tag, uint32_t clk); - FF sub(FF const& a, FF const& b, AvmMemoryTag in_tag, uint32_t clk); - FF mul(FF const& a, FF const& b, AvmMemoryTag in_tag, uint32_t clk); - - private: - std::vector alu_trace; -}; -} // namespace avm_trace \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_common.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_common.hpp index 10b3c3473304..8588b632b87c 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_common.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_common.hpp @@ -11,7 +11,7 @@ namespace avm_trace { // Number of rows static const size_t AVM_TRACE_SIZE = 256; -enum class IntermRegister : uint32_t { IA = 0, IB = 1, IC = 2 }; -enum class AvmMemoryTag : uint32_t { U0 = 0, U8 = 1, U16 = 2, U32 = 3, U64 = 4, U128 = 5, FF = 6 }; +enum class IntermRegister : uint32_t { ia = 0, ib = 1, ic = 2 }; +enum class AvmMemoryTag : uint32_t { u0 = 0, u8 = 1, u16 = 2, u32 = 3, u64 = 4, u128 = 5, ff = 6 }; } // namespace avm_trace \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_helper.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_helper.cpp index 9e1fd096c895..207485ac63d6 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_helper.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_helper.cpp @@ -39,12 +39,6 @@ void log_avmMini_trace(std::vector const& trace, size_t beg, size_t end) info("internal_return: ", trace.at(i).avmMini_sel_internal_return); info("internal_return_ptr:", trace.at(i).avmMini_internal_return_ptr); - info("=======ALU TRACE====================================================================="); - info("alu_clk ", trace.at(i).aluChip_alu_clk); - info("alu_ia ", trace.at(i).aluChip_alu_ia); - info("alu_ib ", trace.at(i).aluChip_alu_ib); - info("alu_ic ", trace.at(i).aluChip_alu_ic); - info("=======MAIN TRACE===================================================================="); info("ia: ", trace.at(i).avmMini_ia); info("ib: ", trace.at(i).avmMini_ib); diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_mem_trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_mem_trace.cpp index 557244116b15..f55d7e9d8b6f 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_mem_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_mem_trace.cpp @@ -21,6 +21,38 @@ void AvmMiniMemTraceBuilder::reset() memory.fill(FF(0)); } +/** + * @brief A comparator on MemoryTraceEntry to be used by sorting algorithm. We sort first by + * ascending address (m_addr), then by clock (m_clk) and finally sub-clock (m_sub_clk). + * + * @param left The left hand side memory trace entry + * @param right The right hand side memory trace entry + * + * @return A boolean indicating whether left member is smaller than right member. + */ +bool AvmMiniMemTraceBuilder::compare_mem_entries(const MemoryTraceEntry& left, const MemoryTraceEntry& right) +{ + if (left.m_addr < right.m_addr) { + return true; + } + + if (left.m_addr > right.m_addr) { + return false; + } + + if (left.m_clk < right.m_clk) { + return true; + } + + if (left.m_clk > right.m_clk) { + return false; + } + + // No safeguard in case they are equal. The caller should ensure this property. + // Otherwise, relation will not be satisfied. + return left.m_sub_clk < right.m_sub_clk; +} + /** * @brief Prepare the memory trace to be incorporated into the main trace. * @@ -29,7 +61,7 @@ void AvmMiniMemTraceBuilder::reset() std::vector AvmMiniMemTraceBuilder::finalize() { // Sort memTrace - std::sort(mem_trace.begin(), mem_trace.end()); + std::sort(mem_trace.begin(), mem_trace.end(), compare_mem_entries); return std::move(mem_trace); } @@ -112,19 +144,19 @@ bool AvmMiniMemTraceBuilder::load_in_mem_trace( { uint32_t sub_clk = 0; switch (interm_reg) { - case IntermRegister::IA: + case IntermRegister::ia: sub_clk = SUB_CLK_LOAD_A; break; - case IntermRegister::IB: + case IntermRegister::ib: sub_clk = SUB_CLK_LOAD_B; break; - case IntermRegister::IC: + case IntermRegister::ic: sub_clk = SUB_CLK_LOAD_C; break; } auto m_tag = memory_tag.at(addr); - if (m_tag == AvmMemoryTag::U0 || m_tag == m_in_tag) { + if (m_tag == AvmMemoryTag::u0 || m_tag == m_in_tag) { insert_in_mem_trace(clk, sub_clk, addr, val, m_in_tag, false); return true; } @@ -149,13 +181,13 @@ void AvmMiniMemTraceBuilder::store_in_mem_trace( { uint32_t sub_clk = 0; switch (interm_reg) { - case IntermRegister::IA: + case IntermRegister::ia: sub_clk = SUB_CLK_STORE_A; break; - case IntermRegister::IB: + case IntermRegister::ib: sub_clk = SUB_CLK_STORE_B; break; - case IntermRegister::IC: + case IntermRegister::ic: sub_clk = SUB_CLK_STORE_C; break; } diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_mem_trace.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_mem_trace.hpp index 0cf1bcaca48a..6a06dcee1fb1 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_mem_trace.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_mem_trace.hpp @@ -16,48 +16,21 @@ class AvmMiniMemTraceBuilder { static const uint32_t SUB_CLK_STORE_C = 5; struct MemoryTraceEntry { - uint32_t m_clk{}; - uint32_t m_sub_clk{}; - uint32_t m_addr{}; + uint32_t m_clk; + uint32_t m_sub_clk; + uint32_t m_addr; FF m_val{}; - AvmMemoryTag m_tag{}; - AvmMemoryTag m_in_tag{}; + AvmMemoryTag m_tag; + AvmMemoryTag m_in_tag; bool m_rw = false; bool m_tag_err = false; FF m_one_min_inv{}; - - /** - * @brief A comparator on MemoryTraceEntry to be used by sorting algorithm. We sort first by - * ascending address (m_addr), then by clock (m_clk) and finally sub-clock (m_sub_clk). - */ - bool operator<(const MemoryTraceEntry& other) const - { - if (m_addr < other.m_addr) { - return true; - } - - if (m_addr > other.m_addr) { - return false; - } - - if (m_clk < other.m_clk) { - return true; - } - - if (m_clk > other.m_clk) { - return false; - } - - // No safeguard in case they are equal. The caller should ensure this property. - // Otherwise, relation will not be satisfied. - return m_sub_clk < other.m_sub_clk; - } }; // Structure to return value and tag matching boolean after a memory read. struct MemRead { - bool tag_match = false; - FF val{}; + bool tag_match; + FF val; }; AvmMiniMemTraceBuilder(); @@ -76,6 +49,8 @@ class AvmMiniMemTraceBuilder { std::array memory_tag{}; // The tag of the corresponding memory // entry (aligned with the memory array). + static bool compare_mem_entries(const MemoryTraceEntry& left, const MemoryTraceEntry& right); + void insert_in_mem_trace( uint32_t m_clk, uint32_t m_sub_clk, uint32_t m_addr, FF const& m_val, AvmMemoryTag m_in_tag, bool m_rw); void load_mismatch_tag_in_mem_trace(uint32_t m_clk, diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_trace.cpp index 771a1590ea1f..c38a615560fa 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_trace.cpp @@ -29,10 +29,9 @@ void AvmMiniTraceBuilder::reset() { main_trace.clear(); mem_trace_builder.reset(); - alu_trace_builder.reset(); } -/** +/** TODO: Implement for non finite field types * @brief Addition with direct memory access. * * @param a_offset An index in memory pointing to the first operand of the addition. @@ -45,17 +44,17 @@ void AvmMiniTraceBuilder::add(uint32_t a_offset, uint32_t b_offset, uint32_t dst auto clk = static_cast(main_trace.size()); // Reading from memory and loading into ia resp. ib. - auto read_a = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::IA, a_offset, in_tag); - auto read_b = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::IB, b_offset, in_tag); + auto read_a = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::ia, a_offset, in_tag); + auto read_b = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::ib, b_offset, in_tag); bool tag_match = read_a.tag_match && read_b.tag_match; // a + b = c - FF a = tag_match ? read_a.val : FF(0); - FF b = tag_match ? read_b.val : FF(0); - FF c = alu_trace_builder.add(a, b, in_tag, clk); + FF a = read_a.val; + FF b = read_b.val; + FF c = a + b; // Write into memory value c from intermediate register ic. - mem_trace_builder.write_into_memory(clk, IntermRegister::IC, dst_offset, c, in_tag); + mem_trace_builder.write_into_memory(clk, IntermRegister::ic, dst_offset, c, in_tag); main_trace.push_back(Row{ .avmMini_clk = clk, @@ -64,9 +63,9 @@ void AvmMiniTraceBuilder::add(uint32_t a_offset, uint32_t b_offset, uint32_t dst .avmMini_sel_op_add = FF(1), .avmMini_in_tag = FF(static_cast(in_tag)), .avmMini_tag_err = FF(static_cast(!tag_match)), - .avmMini_ia = a, - .avmMini_ib = b, - .avmMini_ic = c, + .avmMini_ia = tag_match ? a : FF(0), + .avmMini_ib = tag_match ? b : FF(0), + .avmMini_ic = tag_match ? c : FF(0), .avmMini_mem_op_a = FF(1), .avmMini_mem_op_b = FF(1), .avmMini_mem_op_c = FF(1), @@ -77,7 +76,7 @@ void AvmMiniTraceBuilder::add(uint32_t a_offset, uint32_t b_offset, uint32_t dst }); }; -/** +/** TODO: Implement for non finite field types * @brief Subtraction with direct memory access. * * @param a_offset An index in memory pointing to the first operand of the subtraction. @@ -90,17 +89,17 @@ void AvmMiniTraceBuilder::sub(uint32_t a_offset, uint32_t b_offset, uint32_t dst auto clk = static_cast(main_trace.size()); // Reading from memory and loading into ia resp. ib. - auto read_a = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::IA, a_offset, in_tag); - auto read_b = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::IB, b_offset, in_tag); + auto read_a = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::ia, a_offset, in_tag); + auto read_b = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::ib, b_offset, in_tag); bool tag_match = read_a.tag_match && read_b.tag_match; // a - b = c - FF a = tag_match ? read_a.val : FF(0); - FF b = tag_match ? read_b.val : FF(0); - FF c = alu_trace_builder.sub(a, b, in_tag, clk); + FF a = read_a.val; + FF b = read_b.val; + FF c = a - b; // Write into memory value c from intermediate register ic. - mem_trace_builder.write_into_memory(clk, IntermRegister::IC, dst_offset, c, in_tag); + mem_trace_builder.write_into_memory(clk, IntermRegister::ic, dst_offset, c, in_tag); main_trace.push_back(Row{ .avmMini_clk = clk, @@ -109,9 +108,9 @@ void AvmMiniTraceBuilder::sub(uint32_t a_offset, uint32_t b_offset, uint32_t dst .avmMini_sel_op_sub = FF(1), .avmMini_in_tag = FF(static_cast(in_tag)), .avmMini_tag_err = FF(static_cast(!tag_match)), - .avmMini_ia = a, - .avmMini_ib = b, - .avmMini_ic = c, + .avmMini_ia = tag_match ? a : FF(0), + .avmMini_ib = tag_match ? b : FF(0), + .avmMini_ic = tag_match ? c : FF(0), .avmMini_mem_op_a = FF(1), .avmMini_mem_op_b = FF(1), .avmMini_mem_op_c = FF(1), @@ -122,7 +121,7 @@ void AvmMiniTraceBuilder::sub(uint32_t a_offset, uint32_t b_offset, uint32_t dst }); }; -/** +/** TODO: Implement for non finite field types * @brief Multiplication with direct memory access. * * @param a_offset An index in memory pointing to the first operand of the multiplication. @@ -135,17 +134,17 @@ void AvmMiniTraceBuilder::mul(uint32_t a_offset, uint32_t b_offset, uint32_t dst auto clk = static_cast(main_trace.size()); // Reading from memory and loading into ia resp. ib. - auto read_a = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::IA, a_offset, in_tag); - auto read_b = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::IB, b_offset, in_tag); + auto read_a = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::ia, a_offset, in_tag); + auto read_b = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::ib, b_offset, in_tag); bool tag_match = read_a.tag_match && read_b.tag_match; // a * b = c - FF a = tag_match ? read_a.val : FF(0); - FF b = tag_match ? read_b.val : FF(0); - FF c = alu_trace_builder.mul(a, b, in_tag, clk); + FF a = read_a.val; + FF b = read_b.val; + FF c = a * b; // Write into memory value c from intermediate register ic. - mem_trace_builder.write_into_memory(clk, IntermRegister::IC, dst_offset, c, in_tag); + mem_trace_builder.write_into_memory(clk, IntermRegister::ic, dst_offset, c, in_tag); main_trace.push_back(Row{ .avmMini_clk = clk, @@ -154,9 +153,9 @@ void AvmMiniTraceBuilder::mul(uint32_t a_offset, uint32_t b_offset, uint32_t dst .avmMini_sel_op_mul = FF(1), .avmMini_in_tag = FF(static_cast(in_tag)), .avmMini_tag_err = FF(static_cast(!tag_match)), - .avmMini_ia = a, - .avmMini_ib = b, - .avmMini_ic = c, + .avmMini_ia = tag_match ? a : FF(0), + .avmMini_ib = tag_match ? b : FF(0), + .avmMini_ic = tag_match ? c : FF(0), .avmMini_mem_op_a = FF(1), .avmMini_mem_op_b = FF(1), .avmMini_mem_op_c = FF(1), @@ -180,8 +179,8 @@ void AvmMiniTraceBuilder::div(uint32_t a_offset, uint32_t b_offset, uint32_t dst auto clk = static_cast(main_trace.size()); // Reading from memory and loading into ia resp. ib. - auto read_a = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::IA, a_offset, in_tag); - auto read_b = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::IB, b_offset, in_tag); + auto read_a = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::ia, a_offset, in_tag); + auto read_b = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::ib, b_offset, in_tag); bool tag_match = read_a.tag_match && read_b.tag_match; // a * b^(-1) = c @@ -203,7 +202,7 @@ void AvmMiniTraceBuilder::div(uint32_t a_offset, uint32_t b_offset, uint32_t dst } // Write into memory value c from intermediate register ic. - mem_trace_builder.write_into_memory(clk, IntermRegister::IC, dst_offset, c, in_tag); + mem_trace_builder.write_into_memory(clk, IntermRegister::ic, dst_offset, c, in_tag); main_trace.push_back(Row{ .avmMini_clk = clk, @@ -227,38 +226,6 @@ void AvmMiniTraceBuilder::div(uint32_t a_offset, uint32_t b_offset, uint32_t dst }); } -// TODO: Finish SET opcode implementation. This is a partial implementation -// facilitating testing of arithmetic operations over non finite field types. -// We add an entry in the memory trace and a simplified one in the main trace -// without operation selector. -// TODO: PIL relations for the SET opcode need to be implemented. -// No check is performed that val pertains to type defined by in_tag. -/** - * @brief Set a constant from bytecode with direct memory access. - * - * @param val The constant to be written upcasted to u128 - * @param dst_offset Memory destination offset where val is written to - * @param in_tag The instruction memory tag - */ -void AvmMiniTraceBuilder::set(uint128_t val, uint32_t dst_offset, AvmMemoryTag in_tag) -{ - auto clk = static_cast(main_trace.size()); - auto val_ff = FF{ uint256_t::from_uint128(val) }; - - mem_trace_builder.write_into_memory(clk, IntermRegister::IC, dst_offset, val_ff, in_tag); - - main_trace.push_back(Row{ - .avmMini_clk = clk, - .avmMini_pc = FF(pc++), - .avmMini_internal_return_ptr = FF(internal_return_ptr), - .avmMini_in_tag = FF(static_cast(in_tag)), - .avmMini_ic = val_ff, - .avmMini_mem_op_c = FF(1), - .avmMini_rwc = FF(1), - .avmMini_mem_idx_c = FF(dst_offset), - }); -} - /** * @brief CALLDATACOPY opcode with direct memory access, i.e., * M[dst_offset:dst_offset+copy_size] = calldata[cd_offset:cd_offset+copy_size] @@ -270,9 +237,6 @@ void AvmMiniTraceBuilder::set(uint128_t val, uint32_t dst_offset, AvmMemoryTag i * TODO: Implement the indirect memory version (maybe not required) * TODO: taking care of intermediate register values consistency and propagating their * values to the next row when not overwritten. - * TODO: error handling if dst_offset + copy_size > 2^32 which would lead to - * out-of-bound memory write. Similarly, if cd_offset + copy_size is larger - * than call_data_mem.size() * * @param cd_offset The starting index of the region in calldata to be copied. * @param copy_size The number of finite field elements to be copied into memory. @@ -310,7 +274,7 @@ void AvmMiniTraceBuilder::call_data_copy(uint32_t cd_offset, uint32_t rwa = 1; // Storing from Ia - mem_trace_builder.write_into_memory(clk, IntermRegister::IA, mem_idx_a, ia, AvmMemoryTag::FF); + mem_trace_builder.write_into_memory(clk, IntermRegister::ia, mem_idx_a, ia, AvmMemoryTag::ff); if (copy_size - pos > 1) { ib = call_data_mem.at(cd_offset + pos + 1); @@ -319,7 +283,7 @@ void AvmMiniTraceBuilder::call_data_copy(uint32_t cd_offset, rwb = 1; // Storing from Ib - mem_trace_builder.write_into_memory(clk, IntermRegister::IB, mem_idx_b, ib, AvmMemoryTag::FF); + mem_trace_builder.write_into_memory(clk, IntermRegister::ib, mem_idx_b, ib, AvmMemoryTag::ff); } if (copy_size - pos > 2) { @@ -329,14 +293,14 @@ void AvmMiniTraceBuilder::call_data_copy(uint32_t cd_offset, rwc = 1; // Storing from Ic - mem_trace_builder.write_into_memory(clk, IntermRegister::IC, mem_idx_c, ic, AvmMemoryTag::FF); + mem_trace_builder.write_into_memory(clk, IntermRegister::ic, mem_idx_c, ic, AvmMemoryTag::ff); } main_trace.push_back(Row{ .avmMini_clk = clk, .avmMini_pc = FF(pc++), .avmMini_internal_return_ptr = FF(internal_return_ptr), - .avmMini_in_tag = FF(static_cast(AvmMemoryTag::FF)), + .avmMini_in_tag = FF(static_cast(AvmMemoryTag::ff)), .avmMini_ia = ia, .avmMini_ib = ib, .avmMini_ic = ic, @@ -366,13 +330,12 @@ void AvmMiniTraceBuilder::call_data_copy(uint32_t cd_offset, * intermediate registers and then values are copied to the returned vector. * TODO: Implement the indirect memory version (maybe not required) * TODO: taking care of flagging this row as the last one? Special STOP flag? - * TODO: error handling if ret_offset + ret_size > 2^32 which would lead to - * out-of-bound memory read. * * @param ret_offset The starting index of the memory region to be returned. * @param ret_size The number of elements to be returned. * @return The returned memory region as a std::vector. */ + std::vector AvmMiniTraceBuilder::return_op(uint32_t ret_offset, uint32_t ret_size) { // We parallelize loading memory operations in chunk of 3, i.e., 1 per intermediate register. @@ -398,7 +361,7 @@ std::vector AvmMiniTraceBuilder::return_op(uint32_t ret_offset, uint32_t ret uint32_t mem_idx_a = ret_offset + pos; // Reading and loading to Ia - auto read_a = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::IA, mem_idx_a, AvmMemoryTag::FF); + auto read_a = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::ia, mem_idx_a, AvmMemoryTag::ff); FF ia = read_a.val; returnMem.push_back(ia); @@ -408,7 +371,7 @@ std::vector AvmMiniTraceBuilder::return_op(uint32_t ret_offset, uint32_t ret // Reading and loading to Ib auto read_b = - mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::IB, mem_idx_b, AvmMemoryTag::FF); + mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::ib, mem_idx_b, AvmMemoryTag::ff); FF ib = read_b.val; returnMem.push_back(ib); } @@ -419,7 +382,7 @@ std::vector AvmMiniTraceBuilder::return_op(uint32_t ret_offset, uint32_t ret // Reading and loading to Ic auto read_c = - mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::IC, mem_idx_c, AvmMemoryTag::FF); + mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::ic, mem_idx_c, AvmMemoryTag::ff); FF ic = read_c.val; returnMem.push_back(ic); } @@ -429,7 +392,7 @@ std::vector AvmMiniTraceBuilder::return_op(uint32_t ret_offset, uint32_t ret .avmMini_pc = FF(pc), .avmMini_internal_return_ptr = FF(internal_return_ptr), .avmMini_sel_halt = FF(1), - .avmMini_in_tag = FF(static_cast(AvmMemoryTag::FF)), + .avmMini_in_tag = FF(static_cast(AvmMemoryTag::ff)), .avmMini_ia = ia, .avmMini_ib = ib, .avmMini_ic = ic, @@ -454,7 +417,7 @@ std::vector AvmMiniTraceBuilder::return_op(uint32_t ret_offset, uint32_t ret * @brief HALT opcode * This opcode effectively stops program execution, and is used in the relation that * ensures the program counter increments on each opcode. - * i.e. the program counter should freeze and the halt flag is set to 1. + * i.e.ythe program counter should freeze and the halt flag is set to 1. */ void AvmMiniTraceBuilder::halt() { @@ -514,7 +477,7 @@ void AvmMiniTraceBuilder::internal_call(uint32_t jmp_dest) internal_call_stack.push(stored_pc); // Add the return location to the memory trace - mem_trace_builder.write_into_memory(clk, IntermRegister::IB, internal_return_ptr, FF(stored_pc), AvmMemoryTag::FF); + mem_trace_builder.write_into_memory(clk, IntermRegister::ib, internal_return_ptr, FF(stored_pc), AvmMemoryTag::ff); main_trace.push_back(Row{ .avmMini_clk = clk, @@ -550,7 +513,7 @@ void AvmMiniTraceBuilder::internal_return() // Internal return pointer is decremented // We want to load the value pointed by the internal pointer auto read_a = - mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::IA, internal_return_ptr - 1, AvmMemoryTag::FF); + mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::ia, internal_return_ptr - 1, AvmMemoryTag::ff); main_trace.push_back(Row{ .avmMini_clk = clk, @@ -581,17 +544,14 @@ void AvmMiniTraceBuilder::internal_return() std::vector AvmMiniTraceBuilder::finalize() { auto mem_trace = mem_trace_builder.finalize(); - auto alu_trace = alu_trace_builder.finalize(); size_t mem_trace_size = mem_trace.size(); size_t main_trace_size = main_trace.size(); - size_t alu_trace_size = alu_trace.size(); // TODO: We will have to handle this through error handling and not an assertion // Smaller than N because we have to add an extra initial row to support shifted // elements assert(mem_trace_size < AVM_TRACE_SIZE); assert(main_trace_size < AVM_TRACE_SIZE); - assert(alu_trace_size < AVM_TRACE_SIZE); // Fill the rest with zeros. size_t zero_rows_num = AVM_TRACE_SIZE - main_trace_size - 1; @@ -601,7 +561,6 @@ std::vector AvmMiniTraceBuilder::finalize() main_trace.at(main_trace_size - 1).avmMini_last = FF(1); - // Memory trace inclusion for (size_t i = 0; i < mem_trace_size; i++) { auto const& src = mem_trace.at(i); auto& dest = main_trace.at(i); @@ -625,45 +584,6 @@ std::vector AvmMiniTraceBuilder::finalize() } } - // Alu trace inclusion - for (size_t i = 0; i < alu_trace_size; i++) { - auto const& src = alu_trace.at(i); - auto& dest = main_trace.at(i); - - dest.aluChip_alu_clk = FF(static_cast(src.alu_clk)); - - dest.aluChip_alu_op_add = FF(static_cast(src.alu_op_add)); - dest.aluChip_alu_op_sub = FF(static_cast(src.alu_op_sub)); - dest.aluChip_alu_op_mul = FF(static_cast(src.alu_op_mul)); - - dest.aluChip_alu_ff_tag = FF(static_cast(src.alu_ff_tag)); - dest.aluChip_alu_u8_tag = FF(static_cast(src.alu_u8_tag)); - dest.aluChip_alu_u16_tag = FF(static_cast(src.alu_u16_tag)); - dest.aluChip_alu_u32_tag = FF(static_cast(src.alu_u32_tag)); - dest.aluChip_alu_u64_tag = FF(static_cast(src.alu_u64_tag)); - dest.aluChip_alu_u128_tag = FF(static_cast(src.alu_u128_tag)); - - dest.aluChip_alu_ia = src.alu_ia; - dest.aluChip_alu_ib = src.alu_ib; - dest.aluChip_alu_ic = src.alu_ic; - - dest.aluChip_alu_cf = FF(static_cast(src.alu_cf)); - - dest.aluChip_alu_u8_r0 = FF(src.alu_u8_r0); - dest.aluChip_alu_u8_r1 = FF(src.alu_u8_r1); - - dest.aluChip_alu_u16_r0 = FF(src.alu_u16_reg.at(0)); - dest.aluChip_alu_u16_r1 = FF(src.alu_u16_reg.at(1)); - dest.aluChip_alu_u16_r2 = FF(src.alu_u16_reg.at(2)); - dest.aluChip_alu_u16_r3 = FF(src.alu_u16_reg.at(3)); - dest.aluChip_alu_u16_r4 = FF(src.alu_u16_reg.at(4)); - dest.aluChip_alu_u16_r5 = FF(src.alu_u16_reg.at(5)); - dest.aluChip_alu_u16_r6 = FF(src.alu_u16_reg.at(6)); - dest.aluChip_alu_u16_r7 = FF(src.alu_u16_reg.at(7)); - - dest.aluChip_alu_u64_r0 = FF(src.alu_u64_r0); - } - // Adding extra row for the shifted values at the top of the execution trace. Row first_row = Row{ .avmMini_first = FF(1), .memTrace_m_lastAccess = FF(1) }; main_trace.insert(main_trace.begin(), first_row); diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_trace.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_trace.hpp index af09f2e4d142..ef8e51b65bf3 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_trace.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_trace.hpp @@ -2,7 +2,6 @@ #include -#include "AvmMini_alu_trace.hpp" #include "AvmMini_common.hpp" #include "AvmMini_mem_trace.hpp" #include "barretenberg/common/throw_or_abort.hpp" @@ -37,9 +36,6 @@ class AvmMiniTraceBuilder { // Division with direct memory access. void div(uint32_t a_offset, uint32_t b_offset, uint32_t dst_offset, AvmMemoryTag in_tag); - // Set a constant from bytecode with direct memory access. - void set(uint128_t val, uint32_t dst_offset, AvmMemoryTag in_tag); - // Jump to a given program counter. void jump(uint32_t jmp_dest); @@ -67,7 +63,6 @@ class AvmMiniTraceBuilder { private: std::vector main_trace; AvmMiniMemTraceBuilder mem_trace_builder; - AvmMiniAluTraceBuilder alu_trace_builder; uint32_t pc = 0; uint32_t internal_return_ptr = CALLSTACK_OFFSET; diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.cpp index 552582558c44..aec530be7578 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.cpp @@ -72,10 +72,8 @@ void AvmMiniProver::execute_relation_check_rounds() using Sumcheck = sumcheck::SumcheckProver; auto sumcheck = Sumcheck(key->circuit_size, transcript); - FF alpha = transcript->get_challenge("Sumcheck:alpha"); std::vector gate_challenges(numeric::get_msb(key->circuit_size)); - for (size_t idx = 0; idx < gate_challenges.size(); idx++) { gate_challenges[idx] = transcript->get_challenge("Sumcheck:gate_challenge_" + std::to_string(idx)); } diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp index 09beb8a866e3..2da2112a9b38 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp @@ -72,54 +72,6 @@ bool AvmMiniVerifier::verify_proof(const plonk::proof& proof) transcript->template receive_from_prover(commitment_labels.memTrace_m_tag_err); commitments.memTrace_m_one_min_inv = transcript->template receive_from_prover(commitment_labels.memTrace_m_one_min_inv); - commitments.aluChip_alu_clk = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_clk); - commitments.aluChip_alu_ia = transcript->template receive_from_prover(commitment_labels.aluChip_alu_ia); - commitments.aluChip_alu_ib = transcript->template receive_from_prover(commitment_labels.aluChip_alu_ib); - commitments.aluChip_alu_ic = transcript->template receive_from_prover(commitment_labels.aluChip_alu_ic); - commitments.aluChip_alu_op_add = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_op_add); - commitments.aluChip_alu_op_sub = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_op_sub); - commitments.aluChip_alu_op_mul = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_op_mul); - commitments.aluChip_alu_op_div = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_op_div); - commitments.aluChip_alu_ff_tag = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_ff_tag); - commitments.aluChip_alu_u8_tag = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u8_tag); - commitments.aluChip_alu_u16_tag = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_tag); - commitments.aluChip_alu_u32_tag = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u32_tag); - commitments.aluChip_alu_u64_tag = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u64_tag); - commitments.aluChip_alu_u128_tag = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u128_tag); - commitments.aluChip_alu_u8_r0 = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u8_r0); - commitments.aluChip_alu_u8_r1 = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u8_r1); - commitments.aluChip_alu_u16_r0 = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r0); - commitments.aluChip_alu_u16_r1 = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r1); - commitments.aluChip_alu_u16_r2 = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r2); - commitments.aluChip_alu_u16_r3 = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r3); - commitments.aluChip_alu_u16_r4 = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r4); - commitments.aluChip_alu_u16_r5 = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r5); - commitments.aluChip_alu_u16_r6 = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r6); - commitments.aluChip_alu_u16_r7 = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r7); - commitments.aluChip_alu_u64_r0 = - transcript->template receive_from_prover(commitment_labels.aluChip_alu_u64_r0); - commitments.aluChip_alu_cf = transcript->template receive_from_prover(commitment_labels.aluChip_alu_cf); commitments.avmMini_pc = transcript->template receive_from_prover(commitment_labels.avmMini_pc); commitments.avmMini_internal_return_ptr = transcript->template receive_from_prover(commitment_labels.avmMini_internal_return_ptr); @@ -167,14 +119,11 @@ bool AvmMiniVerifier::verify_proof(const plonk::proof& proof) // Execute Sumcheck Verifier const size_t log_circuit_size = numeric::get_msb(circuit_size); auto sumcheck = SumcheckVerifier(log_circuit_size, transcript); - FF alpha = transcript->get_challenge("Sumcheck:alpha"); - auto gate_challenges = std::vector(log_circuit_size); for (size_t idx = 0; idx < log_circuit_size; idx++) { gate_challenges[idx] = transcript->get_challenge("Sumcheck:gate_challenge_" + std::to_string(idx)); } - auto [multivariate_challenge, claimed_evaluations, sumcheck_verified] = sumcheck.verify(relation_parameters, alpha, gate_challenges); diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_arithmetic.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_arithmetic.test.cpp index 15f4e0a37eee..46ed56f37f36 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_arithmetic.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_arithmetic.test.cpp @@ -1,190 +1,18 @@ -#include "AvmMini_common.test.hpp" - -#include "barretenberg/numeric/uint128/uint128.hpp" - -using namespace numeric; -using namespace tests_avm; -namespace { - -void common_validate_arithmetic_op(Row const& main_row, - Row const& alu_row, - FF const& a, - FF const& b, - FF const& c, - FF const& addr_a, - FF const& addr_b, - FF const& addr_c, - avm_trace::AvmMemoryTag const tag) -{ - // Check that the correct result is stored at the expected memory location. - EXPECT_EQ(main_row.avmMini_ic, c); - EXPECT_EQ(main_row.avmMini_mem_idx_c, addr_c); - EXPECT_EQ(main_row.avmMini_mem_op_c, FF(1)); - EXPECT_EQ(main_row.avmMini_rwc, FF(1)); - - // Check that ia and ib registers are correctly set with memory load operations. - EXPECT_EQ(main_row.avmMini_ia, a); - EXPECT_EQ(main_row.avmMini_mem_idx_a, addr_a); - EXPECT_EQ(main_row.avmMini_mem_op_a, FF(1)); - EXPECT_EQ(main_row.avmMini_rwa, FF(0)); - EXPECT_EQ(main_row.avmMini_ib, b); - EXPECT_EQ(main_row.avmMini_mem_idx_b, addr_b); - EXPECT_EQ(main_row.avmMini_mem_op_b, FF(1)); - EXPECT_EQ(main_row.avmMini_rwb, FF(0)); - - // Check the instruction tag - EXPECT_EQ(main_row.avmMini_in_tag, FF(static_cast(tag))); - - // Check that intermediate rgiesters are correctly copied in Alu trace - EXPECT_EQ(alu_row.aluChip_alu_ia, a); - EXPECT_EQ(alu_row.aluChip_alu_ib, b); - EXPECT_EQ(alu_row.aluChip_alu_ic, c); -} - -Row common_validate_add(std::vector const& trace, - FF const& a, - FF const& b, - FF const& c, - FF const& addr_a, - FF const& addr_b, - FF const& addr_c, - avm_trace::AvmMemoryTag const tag) -{ - // Find the first row enabling the addition selector - auto row = std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avmMini_sel_op_add == FF(1); }); - - // Find the corresponding Alu trace row - auto clk = row->avmMini_clk; - auto alu_row = std::ranges::find_if(trace.begin(), trace.end(), [clk](Row r) { return r.aluChip_alu_clk == clk; }); - - // Check that both rows were found - EXPECT_TRUE(row != trace.end()); - EXPECT_TRUE(alu_row != trace.end()); - - common_validate_arithmetic_op(*row, *alu_row, a, b, c, addr_a, addr_b, addr_c, tag); - - // Check that addition selector is set. - EXPECT_EQ(row->avmMini_sel_op_add, FF(1)); - EXPECT_EQ(alu_row->aluChip_alu_op_add, FF(1)); - - return *alu_row; -} - -Row common_validate_sub(std::vector const& trace, - FF const& a, - FF const& b, - FF const& c, - FF const& addr_a, - FF const& addr_b, - FF const& addr_c, - avm_trace::AvmMemoryTag const tag) -{ - // Find the first row enabling the subtraction selector - auto row = std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avmMini_sel_op_sub == FF(1); }); - - // Find the corresponding Alu trace row - auto clk = row->avmMini_clk; - auto alu_row = std::ranges::find_if(trace.begin(), trace.end(), [clk](Row r) { return r.aluChip_alu_clk == clk; }); - - // Check that both rows were found - EXPECT_TRUE(row != trace.end()); - EXPECT_TRUE(alu_row != trace.end()); - - common_validate_arithmetic_op(*row, *alu_row, a, b, c, addr_a, addr_b, addr_c, tag); - - // Check that subtraction selector is set. - EXPECT_EQ(row->avmMini_sel_op_sub, FF(1)); - EXPECT_EQ(alu_row->aluChip_alu_op_sub, FF(1)); - - return *alu_row; -} - -size_t common_validate_mul(std::vector const& trace, - FF const& a, - FF const& b, - FF const& c, - FF const& addr_a, - FF const& addr_b, - FF const& addr_c, - avm_trace::AvmMemoryTag const tag) -{ - // Find the first row enabling the multiplication selector - auto row = std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avmMini_sel_op_mul == FF(1); }); - - // Find the corresponding Alu trace row - auto clk = row->avmMini_clk; - auto alu_row = std::ranges::find_if(trace.begin(), trace.end(), [clk](Row r) { return r.aluChip_alu_clk == clk; }); - - // Check that both rows were found - EXPECT_TRUE(row != trace.end()); - EXPECT_TRUE(alu_row != trace.end()); - - common_validate_arithmetic_op(*row, *alu_row, a, b, c, addr_a, addr_b, addr_c, tag); - - // Check that multiplication selector is set. - EXPECT_EQ(row->avmMini_sel_op_mul, FF(1)); - EXPECT_EQ(alu_row->aluChip_alu_op_mul, FF(1)); - - return static_cast(alu_row - trace.begin()); -} - -// This function generates a mutated trace of an addition where a and b are the passed inputs. -// a and b are stored in memory indices 0 and 1. c_mutated is the wrong result of the addition -// and the memory and alu trace are created consistently with the wrong value c_mutated. -std::vector gen_mutated_trace_add(FF const& a, FF const& b, FF const& c_mutated, avm_trace::AvmMemoryTag tag) -{ - auto trace_builder = avm_trace::AvmMiniTraceBuilder(); - trace_builder.set(uint128_t{ a }, 0, tag); - trace_builder.set(uint128_t{ b }, 1, tag); - trace_builder.add(0, 1, 2, tag); - trace_builder.halt(); - auto trace = trace_builder.finalize(); - - auto select_row = [](Row r) { return r.avmMini_sel_op_add == FF(1); }; - mutate_ic_in_trace(trace, select_row, c_mutated, true); - - return trace; -} - -// This function generates a mutated trace of a subtraction where a and b are the passed inputs. -// a and b are stored in memory indices 0 and 1. c_mutated is the wrong result of the subtraction -// and the memory and alu trace are created consistently with the wrong value c_mutated. -std::vector gen_mutated_trace_sub(FF const& a, FF const& b, FF const& c_mutated, avm_trace::AvmMemoryTag tag) -{ - auto trace_builder = avm_trace::AvmMiniTraceBuilder(); - trace_builder.set(uint128_t{ a }, 0, tag); - trace_builder.set(uint128_t{ b }, 1, tag); - trace_builder.sub(0, 1, 2, tag); - trace_builder.halt(); - auto trace = trace_builder.finalize(); - - auto select_row = [](Row r) { return r.avmMini_sel_op_sub == FF(1); }; - mutate_ic_in_trace(trace, select_row, c_mutated, true); - - return trace; -} - -// This function generates a mutated trace of a multiplication where a and b are the passed inputs. -// a and b are stored in memory indices 0 and 1. c_mutated is the wrong result of the multiplication -// and the memory and alu trace are created consistently with the wrong value c_mutated. -std::vector gen_mutated_trace_mul(FF const& a, FF const& b, FF const& c_mutated, avm_trace::AvmMemoryTag tag) -{ - auto trace_builder = avm_trace::AvmMiniTraceBuilder(); - trace_builder.set(uint128_t{ a }, 0, tag); - trace_builder.set(uint128_t{ b }, 1, tag); - trace_builder.mul(0, 1, 2, tag); - trace_builder.halt(); - auto trace = trace_builder.finalize(); - - auto select_row = [](Row r) { return r.avmMini_sel_op_mul == FF(1); }; - mutate_ic_in_trace(trace, select_row, c_mutated, true); - - return trace; -} - -} // anonymous namespace - +#include "barretenberg/vm/avm_trace/AvmMini_helper.hpp" +#include "barretenberg/vm/generated/AvmMini_composer.hpp" +#include "barretenberg/vm/generated/AvmMini_prover.hpp" +#include "barretenberg/vm/generated/AvmMini_verifier.hpp" +#include "helpers.test.hpp" + +#include +#include +#include +#include +#include + +namespace tests_avm { using namespace avm_trace; + class AvmMiniArithmeticTests : public ::testing::Test { public: AvmMiniTraceBuilder trace_builder; @@ -193,28 +21,16 @@ class AvmMiniArithmeticTests : public ::testing::Test { // TODO(640): The Standard Honk on Grumpkin test suite fails unless the SRS is initialised for every test. void SetUp() override { - srs::init_crs_factory("../srs_db/ignition"); + bb::srs::init_crs_factory("../srs_db/ignition"); trace_builder = AvmMiniTraceBuilder(); // Clean instance for every run. }; }; -class AvmMiniArithmeticTestsFF : public AvmMiniArithmeticTests {}; -class AvmMiniArithmeticTestsU8 : public AvmMiniArithmeticTests {}; -class AvmMiniArithmeticTestsU16 : public AvmMiniArithmeticTests {}; -class AvmMiniArithmeticTestsU32 : public AvmMiniArithmeticTests {}; -class AvmMiniArithmeticTestsU64 : public AvmMiniArithmeticTests {}; -class AvmMiniArithmeticTestsU128 : public AvmMiniArithmeticTests {}; - -class AvmMiniArithmeticNegativeTestsFF : public AvmMiniArithmeticTests {}; -class AvmMiniArithmeticNegativeTestsU8 : public AvmMiniArithmeticTests {}; -class AvmMiniArithmeticNegativeTestsU16 : public AvmMiniArithmeticTests {}; -class AvmMiniArithmeticNegativeTestsU32 : public AvmMiniArithmeticTests {}; -class AvmMiniArithmeticNegativeTestsU64 : public AvmMiniArithmeticTests {}; -class AvmMiniArithmeticNegativeTestsU128 : public AvmMiniArithmeticTests {}; +class AvmMiniArithmeticNegativeTests : public AvmMiniArithmeticTests {}; /****************************************************************************** * - * POSITIVE TESTS + * POSITIVE TESTS - Finite Field Type * ****************************************************************************** * The positive tests aim at testing that a genuinely generated execution trace @@ -236,96 +52,106 @@ class AvmMiniArithmeticNegativeTestsU128 : public AvmMiniArithmeticTests {}; * will still correctly work along the development of the AVM. ******************************************************************************/ -/****************************************************************************** - * Positive Tests - FF - ******************************************************************************/ - // Test on basic addition over finite field type. -TEST_F(AvmMiniArithmeticTestsFF, addition) +TEST_F(AvmMiniArithmeticTests, additionFF) { // trace_builder trace_builder.call_data_copy(0, 3, 0, std::vector{ 37, 4, 11 }); // Memory layout: [37,4,11,0,0,0,....] - trace_builder.add(0, 1, 4, AvmMemoryTag::FF); // [37,4,11,0,41,0,....] + trace_builder.add(0, 1, 4, AvmMemoryTag::ff); // [37,4,11,0,41,0,....] trace_builder.return_op(0, 5); auto trace = trace_builder.finalize(); - auto alu_row = common_validate_add(trace, FF(37), FF(4), FF(41), FF(0), FF(1), FF(4), AvmMemoryTag::FF); + // Find the first row enabling the addition selector + auto row = std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avmMini_sel_op_add == FF(1); }); - EXPECT_EQ(alu_row.aluChip_alu_ff_tag, FF(1)); - EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0)); + // Check that the correct result is stored at the expected memory location. + EXPECT_TRUE(row != trace.end()); + EXPECT_EQ(row->avmMini_ic, FF(41)); + EXPECT_EQ(row->avmMini_mem_idx_c, FF(4)); + EXPECT_EQ(row->avmMini_mem_op_c, FF(1)); + EXPECT_EQ(row->avmMini_rwc, FF(1)); validate_trace_proof(std::move(trace)); } // Test on basic subtraction over finite field type. -TEST_F(AvmMiniArithmeticTestsFF, subtraction) +TEST_F(AvmMiniArithmeticTests, subtractionFF) { trace_builder.call_data_copy(0, 3, 0, std::vector{ 8, 4, 17 }); // Memory layout: [8,4,17,0,0,0,....] - trace_builder.sub(2, 0, 1, AvmMemoryTag::FF); // [8,9,17,0,0,0....] + trace_builder.sub(2, 0, 1, AvmMemoryTag::ff); // [8,9,17,0,0,0....] trace_builder.return_op(0, 3); auto trace = trace_builder.finalize(); - auto alu_row = common_validate_sub(trace, FF(17), FF(8), FF(9), FF(2), FF(0), FF(1), AvmMemoryTag::FF); + // Find the first row enabling the subtraction selector + auto row = std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avmMini_sel_op_sub == FF(1); }); - EXPECT_EQ(alu_row.aluChip_alu_ff_tag, FF(1)); - EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0)); + // Check that the correct result is stored at the expected memory location. + EXPECT_TRUE(row != trace.end()); + EXPECT_EQ(row->avmMini_ic, FF(9)); + EXPECT_EQ(row->avmMini_mem_idx_c, FF(1)); + EXPECT_EQ(row->avmMini_mem_op_c, FF(1)); + EXPECT_EQ(row->avmMini_rwc, FF(1)); validate_trace_proof(std::move(trace)); } // Test on basic multiplication over finite field type. -TEST_F(AvmMiniArithmeticTestsFF, multiplication) +TEST_F(AvmMiniArithmeticTests, multiplicationFF) { trace_builder.call_data_copy(0, 3, 0, std::vector{ 5, 0, 20 }); // Memory layout: [5,0,20,0,0,0,....] - trace_builder.mul(2, 0, 1, AvmMemoryTag::FF); // [5,100,20,0,0,0....] + trace_builder.mul(2, 0, 1, AvmMemoryTag::ff); // [5,100,20,0,0,0....] trace_builder.return_op(0, 3); auto trace = trace_builder.finalize(); - auto alu_row_index = common_validate_mul(trace, FF(20), FF(5), FF(100), FF(2), FF(0), FF(1), AvmMemoryTag::FF); - auto alu_row = trace.at(alu_row_index); + // Find the first row enabling the multiplication selector + auto row = std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avmMini_sel_op_mul == FF(1); }); - EXPECT_EQ(alu_row.aluChip_alu_ff_tag, FF(1)); - EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0)); + // Check that the correct result is stored at the expected memory location. + EXPECT_TRUE(row != trace.end()); + EXPECT_EQ(row->avmMini_ic, FF(100)); + EXPECT_EQ(row->avmMini_mem_idx_c, FF(1)); + EXPECT_EQ(row->avmMini_mem_op_c, FF(1)); + EXPECT_EQ(row->avmMini_rwc, FF(1)); validate_trace_proof(std::move(trace)); } // Test on multiplication by zero over finite field type. -TEST_F(AvmMiniArithmeticTestsFF, multiplicationByZero) +TEST_F(AvmMiniArithmeticTests, multiplicationByZeroFF) { trace_builder.call_data_copy(0, 1, 0, std::vector{ 127 }); // Memory layout: [127,0,0,0,0,0,....] - trace_builder.mul(0, 1, 2, AvmMemoryTag::FF); // [127,0,0,0,0,0....] + trace_builder.mul(0, 1, 2, AvmMemoryTag::ff); // [127,0,0,0,0,0....] trace_builder.return_op(0, 3); auto trace = trace_builder.finalize(); - auto alu_row_index = common_validate_mul(trace, FF(127), FF(0), FF(0), FF(0), FF(1), FF(2), AvmMemoryTag::FF); - auto alu_row = trace.at(alu_row_index); + // Find the first row enabling the multiplication selector + auto row = std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avmMini_sel_op_mul == FF(1); }); - EXPECT_EQ(alu_row.aluChip_alu_ff_tag, FF(1)); - EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0)); + // Check that the correct result is stored at the expected memory location. + EXPECT_TRUE(row != trace.end()); + EXPECT_EQ(row->avmMini_ic, FF(0)); + EXPECT_EQ(row->avmMini_mem_idx_c, FF(2)); + EXPECT_EQ(row->avmMini_mem_op_c, FF(1)); + EXPECT_EQ(row->avmMini_rwc, FF(1)); validate_trace_proof(std::move(trace)); } // Test on basic division over finite field type. -TEST_F(AvmMiniArithmeticTestsFF, division) +TEST_F(AvmMiniArithmeticTests, divisionFF) { trace_builder.call_data_copy(0, 2, 0, std::vector{ 15, 315 }); // Memory layout: [15,315,0,0,0,0,....] - trace_builder.div(1, 0, 2, AvmMemoryTag::FF); // [15,315,21,0,0,0....] + trace_builder.div(1, 0, 2, AvmMemoryTag::ff); // [15,315,21,0,0,0....] trace_builder.return_op(0, 3); auto trace = trace_builder.finalize(); @@ -343,12 +169,12 @@ TEST_F(AvmMiniArithmeticTestsFF, division) } // Test on division with zero numerator over finite field type. -TEST_F(AvmMiniArithmeticTestsFF, divisionNumeratorZero) +TEST_F(AvmMiniArithmeticTests, divisionNumeratorZeroFF) { trace_builder.call_data_copy(0, 1, 0, std::vector{ 15 }); // Memory layout: [15,0,0,0,0,0,....] - trace_builder.div(1, 0, 0, AvmMemoryTag::FF); // [0,0,0,0,0,0....] + trace_builder.div(1, 0, 0, AvmMemoryTag::ff); // [0,0,0,0,0,0....] trace_builder.return_op(0, 3); auto trace = trace_builder.finalize(); @@ -367,12 +193,12 @@ TEST_F(AvmMiniArithmeticTestsFF, divisionNumeratorZero) // Test on division by zero over finite field type. // We check that the operator error flag is raised. -TEST_F(AvmMiniArithmeticTestsFF, divisionByZeroError) +TEST_F(AvmMiniArithmeticTests, divisionByZeroErrorFF) { trace_builder.call_data_copy(0, 1, 0, std::vector{ 15 }); // Memory layout: [15,0,0,0,0,0,....] - trace_builder.div(0, 1, 2, AvmMemoryTag::FF); // [15,0,0,0,0,0....] + trace_builder.div(0, 1, 2, AvmMemoryTag::ff); // [15,0,0,0,0,0....] trace_builder.halt(); auto trace = trace_builder.finalize(); @@ -392,10 +218,10 @@ TEST_F(AvmMiniArithmeticTestsFF, divisionByZeroError) // Test on division of zero by zero over finite field type. // We check that the operator error flag is raised. -TEST_F(AvmMiniArithmeticTestsFF, divisionZeroByZeroError) +TEST_F(AvmMiniArithmeticTests, divisionZeroByZeroErrorFF) { // Memory layout: [0,0,0,0,0,0,....] - trace_builder.div(0, 1, 2, AvmMemoryTag::FF); // [0,0,0,0,0,0....] + trace_builder.div(0, 1, 2, AvmMemoryTag::ff); // [0,0,0,0,0,0....] trace_builder.halt(); auto trace = trace_builder.finalize(); @@ -417,937 +243,27 @@ TEST_F(AvmMiniArithmeticTestsFF, divisionZeroByZeroError) // and finishing with a division by zero. The chosen combination is arbitrary. // We only test that the proof can be correctly generated and verified. // No check on the evaluation is performed here. -TEST_F(AvmMiniArithmeticTestsFF, mixedOperationsWithError) +TEST_F(AvmMiniArithmeticTests, arithmeticFFWithError) { trace_builder.call_data_copy(0, 3, 2, std::vector{ 45, 23, 12 }); // Memory layout: [0,0,45,23,12,0,0,0,....] - trace_builder.add(2, 3, 4, AvmMemoryTag::FF); // [0,0,45,23,68,0,0,0,....] - trace_builder.add(4, 5, 5, AvmMemoryTag::FF); // [0,0,45,23,68,68,0,0,....] - trace_builder.add(5, 5, 5, AvmMemoryTag::FF); // [0,0,45,23,68,136,0,0,....] - trace_builder.add(5, 6, 7, AvmMemoryTag::FF); // [0,0,45,23,68,136,0,136,0....] - trace_builder.sub(7, 6, 8, AvmMemoryTag::FF); // [0,0,45,23,68,136,0,136,136,0....] - trace_builder.mul(8, 8, 8, AvmMemoryTag::FF); // [0,0,45,23,68,136,0,136,136^2,0....] - trace_builder.div(3, 5, 1, AvmMemoryTag::FF); // [0,23*136^(-1),45,23,68,136,0,136,136^2,0....] - trace_builder.div(1, 1, 9, AvmMemoryTag::FF); // [0,23*136^(-1),45,23,68,136,0,136,136^2,1,0....] + trace_builder.add(2, 3, 4, AvmMemoryTag::ff); // [0,0,45,23,68,0,0,0,....] + trace_builder.add(4, 5, 5, AvmMemoryTag::ff); // [0,0,45,23,68,68,0,0,....] + trace_builder.add(5, 5, 5, AvmMemoryTag::ff); // [0,0,45,23,68,136,0,0,....] + trace_builder.add(5, 6, 7, AvmMemoryTag::ff); // [0,0,45,23,68,136,0,136,0....] + trace_builder.sub(7, 6, 8, AvmMemoryTag::ff); // [0,0,45,23,68,136,0,136,136,0....] + trace_builder.mul(8, 8, 8, AvmMemoryTag::ff); // [0,0,45,23,68,136,0,136,136^2,0....] + trace_builder.div(3, 5, 1, AvmMemoryTag::ff); // [0,23*136^(-1),45,23,68,136,0,136,136^2,0....] + trace_builder.div(1, 1, 9, AvmMemoryTag::ff); // [0,23*136^(-1),45,23,68,136,0,136,136^2,1,0....] trace_builder.div( - 9, 0, 4, AvmMemoryTag::FF); // [0,23*136^(-1),45,23,1/0,136,0,136,136^2,1,0....] Error: division by 0 + 9, 0, 4, AvmMemoryTag::ff); // [0,23*136^(-1),45,23,1/0,136,0,136,136^2,1,0....] Error: division by 0 trace_builder.halt(); auto trace = trace_builder.finalize(); validate_trace_proof(std::move(trace)); } -/****************************************************************************** - * Positive Tests - U8 - ******************************************************************************/ - -// Test on basic addition over u8 type. -TEST_F(AvmMiniArithmeticTestsU8, addition) -{ - // trace_builder - trace_builder.set(62, 0, AvmMemoryTag::U8); - trace_builder.set(29, 1, AvmMemoryTag::U8); - - // Memory layout: [62,29,0,0,0,....] - trace_builder.add(0, 1, 2, AvmMemoryTag::U8); // [62,29,91,0,0,....] - trace_builder.return_op(2, 1); - auto trace = trace_builder.finalize(); - - auto alu_row = common_validate_add(trace, FF(62), FF(29), FF(91), FF(0), FF(1), FF(2), AvmMemoryTag::U8); - - EXPECT_EQ(alu_row.aluChip_alu_u8_tag, FF(1)); - EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(91)); - validate_trace_proof(std::move(trace)); -} - -// Test on basic addition over u8 type with carry. -TEST_F(AvmMiniArithmeticTestsU8, additionCarry) -{ - // trace_builder - trace_builder.set(159, 0, AvmMemoryTag::U8); - trace_builder.set(100, 1, AvmMemoryTag::U8); - - // Memory layout: [159,100,0,0,0,....] - trace_builder.add(0, 1, 2, AvmMemoryTag::U8); // [159,100,3,0,0,....] - trace_builder.return_op(2, 1); - auto trace = trace_builder.finalize(); - - auto alu_row = common_validate_add(trace, FF(159), FF(100), FF(3), FF(0), FF(1), FF(2), AvmMemoryTag::U8); - - EXPECT_EQ(alu_row.aluChip_alu_u8_tag, FF(1)); - EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(3)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(1)); - - validate_trace_proof(std::move(trace)); -} - -// Test on basic subtraction over u8 type. -TEST_F(AvmMiniArithmeticTestsU8, subtraction) -{ - // trace_builder - trace_builder.set(162, 0, AvmMemoryTag::U8); - trace_builder.set(29, 1, AvmMemoryTag::U8); - - // Memory layout: [162,29,0,0,0,....] - trace_builder.sub(0, 1, 2, AvmMemoryTag::U8); // [162,29,133,0,0,....] - trace_builder.return_op(2, 1); - auto trace = trace_builder.finalize(); - - auto alu_row = common_validate_sub(trace, FF(162), FF(29), FF(133), FF(0), FF(1), FF(2), AvmMemoryTag::U8); - - EXPECT_EQ(alu_row.aluChip_alu_u8_tag, FF(1)); - EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(133)); - - validate_trace_proof(std::move(trace)); -} - -// Test on subtraction over u8 type with carry. -// For a subtraction a - b = c, there is a carry flag iff a < b (equivalent to a < c) -TEST_F(AvmMiniArithmeticTestsU8, subtractionCarry) -{ - // trace_builder - trace_builder.set(5, 0, AvmMemoryTag::U8); - trace_builder.set(29, 1, AvmMemoryTag::U8); - - // Memory layout: [5,29,0,0,0,....] - trace_builder.sub(0, 1, 2, AvmMemoryTag::U8); // [5,29,232,0,0,....] - trace_builder.return_op(2, 1); - auto trace = trace_builder.finalize(); - - auto alu_row = common_validate_sub(trace, FF(5), FF(29), FF(232), FF(0), FF(1), FF(2), AvmMemoryTag::U8); - - EXPECT_EQ(alu_row.aluChip_alu_u8_tag, FF(1)); - EXPECT_EQ(alu_row.aluChip_alu_cf, FF(1)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(232)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(UINT8_MAX)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(UINT16_MAX)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r1, FF(UINT16_MAX)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r2, FF(UINT16_MAX)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r3, FF(UINT16_MAX)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r4, FF(UINT16_MAX)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r5, FF(UINT16_MAX)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r6, FF(UINT16_MAX)); - - validate_trace_proof(std::move(trace)); -} - -// Test on basic multiplication over u8 type. -TEST_F(AvmMiniArithmeticTestsU8, multiplication) -{ - // trace_builder - trace_builder.set(13, 0, AvmMemoryTag::U8); - trace_builder.set(15, 1, AvmMemoryTag::U8); - - trace_builder.mul(0, 1, 2, AvmMemoryTag::U8); - trace_builder.return_op(2, 1); - auto trace = trace_builder.finalize(); - - auto alu_row_index = common_validate_mul(trace, FF(13), FF(15), FF(195), FF(0), FF(1), FF(2), AvmMemoryTag::U8); - auto alu_row = trace.at(alu_row_index); - - EXPECT_EQ(alu_row.aluChip_alu_u8_tag, FF(1)); - - // Decomposition of integer multiplication in 8-bit registers - EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(195)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0)); - - validate_trace_proof(std::move(trace)); -} - -// Test on multiplication over u8 type with overflow. -TEST_F(AvmMiniArithmeticTestsU8, multiplicationOverflow) -{ - // trace_builder - trace_builder.set(200, 0, AvmMemoryTag::U8); - trace_builder.set(170, 1, AvmMemoryTag::U8); - - trace_builder.mul(0, 1, 2, AvmMemoryTag::U8); - trace_builder.return_op(2, 1); - auto trace = trace_builder.finalize(); - - auto alu_row_index = common_validate_mul(trace, FF(200), FF(170), FF(208), FF(0), FF(1), FF(2), AvmMemoryTag::U8); - auto alu_row = trace.at(alu_row_index); - - EXPECT_EQ(alu_row.aluChip_alu_u8_tag, FF(1)); - - // Decomposition of integer multiplication in 8-bit registers - // 34'000 = 208 + 132 * 256 - EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(208)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(132)); - - validate_trace_proof(std::move(trace)); -} - -/****************************************************************************** - * Positive Tests - U16 - ******************************************************************************/ - -// Test on basic addition over u16 type. -TEST_F(AvmMiniArithmeticTestsU16, addition) -{ - // trace_builder - trace_builder.set(1775, 119, AvmMemoryTag::U16); - trace_builder.set(33005, 546, AvmMemoryTag::U16); - - trace_builder.add(546, 119, 5, AvmMemoryTag::U16); - trace_builder.return_op(5, 1); - auto trace = trace_builder.finalize(); - - auto alu_row = - common_validate_add(trace, FF(33005), FF(1775), FF(34780), FF(546), FF(119), FF(5), AvmMemoryTag::U16); - - EXPECT_EQ(alu_row.aluChip_alu_u16_tag, FF(1)); - EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0xDC)); // 34780 = 0x87DC - EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0x87)); - - validate_trace_proof(std::move(trace)); -} - -// Test on basic addition over u16 type with carry. -TEST_F(AvmMiniArithmeticTestsU16, additionCarry) -{ - // trace_builder - trace_builder.set(UINT16_MAX - 982, 0, AvmMemoryTag::U16); - trace_builder.set(1000, 1, AvmMemoryTag::U16); - - trace_builder.add(1, 0, 0, AvmMemoryTag::U16); - trace_builder.return_op(0, 1); - auto trace = trace_builder.finalize(); - - auto alu_row = - common_validate_add(trace, FF(1000), FF(UINT16_MAX - 982), FF(17), FF(1), FF(0), FF(0), AvmMemoryTag::U16); - - EXPECT_EQ(alu_row.aluChip_alu_u16_tag, FF(1)); - EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(17)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0)); - - validate_trace_proof(std::move(trace)); -} - -// Test on basic subtraction over u16 type. -TEST_F(AvmMiniArithmeticTestsU16, subtraction) -{ - // trace_builder - trace_builder.set(1775, 119, AvmMemoryTag::U16); - trace_builder.set(33005, 546, AvmMemoryTag::U16); - - trace_builder.sub(546, 119, 5, AvmMemoryTag::U16); - trace_builder.return_op(5, 1); - auto trace = trace_builder.finalize(); - - auto alu_row = - common_validate_sub(trace, FF(33005), FF(1775), FF(31230), FF(546), FF(119), FF(5), AvmMemoryTag::U16); - - EXPECT_EQ(alu_row.aluChip_alu_u16_tag, FF(1)); - EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0xFE)); // 31230 in Hex: 79FE - EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0x79)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(0)); - - validate_trace_proof(std::move(trace)); -} - -// Test on basic subtraction over u16 type with carry. -// For a subtraction a - b = c, there is a carry flag iff a < b (equivalent to a < c) -TEST_F(AvmMiniArithmeticTestsU16, subtractionCarry) -{ - // trace_builder - trace_builder.set(UINT16_MAX - 982, 0, AvmMemoryTag::U16); - trace_builder.set(1000, 1, AvmMemoryTag::U16); - - trace_builder.sub(1, 0, 0, AvmMemoryTag::U16); - trace_builder.return_op(0, 1); - auto trace = trace_builder.finalize(); - - auto alu_row = - common_validate_sub(trace, FF(1000), FF(UINT16_MAX - 982), FF(1983), FF(1), FF(0), FF(0), AvmMemoryTag::U16); - - EXPECT_EQ(alu_row.aluChip_alu_u16_tag, FF(1)); - EXPECT_EQ(alu_row.aluChip_alu_cf, FF(1)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0xBF)); // 1983 = 0x7BF - EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(7)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(UINT16_MAX)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r1, FF(UINT16_MAX)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r2, FF(UINT16_MAX)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r3, FF(UINT16_MAX)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r4, FF(UINT16_MAX)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r5, FF(UINT16_MAX)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r6, FF(UINT16_MAX)); - - validate_trace_proof(std::move(trace)); -} - -// Test on basic multiplication over u16 type. -TEST_F(AvmMiniArithmeticTestsU16, multiplication) -{ - // trace_builder - trace_builder.set(200, 0, AvmMemoryTag::U16); - trace_builder.set(245, 1, AvmMemoryTag::U16); - - trace_builder.mul(0, 1, 2, AvmMemoryTag::U16); - trace_builder.return_op(2, 1); - auto trace = trace_builder.finalize(); - - auto alu_row_index = - common_validate_mul(trace, FF(200), FF(245), FF(49000), FF(0), FF(1), FF(2), AvmMemoryTag::U16); - auto alu_row = trace.at(alu_row_index); - - EXPECT_EQ(alu_row.aluChip_alu_u16_tag, FF(1)); - - // Decomposition of integer multiplication in 8-bit and 16-bit registers - EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0x68)); // 49000 = 0xBF68 - EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0xBF)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(0)); - - validate_trace_proof(std::move(trace)); -} - -// Test on multiplication over u16 type with overflow. -TEST_F(AvmMiniArithmeticTestsU16, multiplicationOverflow) -{ - // trace_builder - trace_builder.set(512, 0, AvmMemoryTag::U16); - trace_builder.set(1024, 1, AvmMemoryTag::U16); - - trace_builder.mul(0, 1, 2, AvmMemoryTag::U16); - trace_builder.return_op(2, 1); - auto trace = trace_builder.finalize(); - - auto alu_row_index = common_validate_mul(trace, FF(512), FF(1024), FF(0), FF(0), FF(1), FF(2), AvmMemoryTag::U16); - auto alu_row = trace.at(alu_row_index); - - EXPECT_EQ(alu_row.aluChip_alu_u16_tag, FF(1)); - - // Decomposition of integer multiplication in 8-bit and 16-bit registers - // 512 * 1024 = 0 + 8 * 2^16 - EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(8)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r1, FF(0)); - - validate_trace_proof(std::move(trace)); -} - -/****************************************************************************** - * Positive Tests - U32 - ******************************************************************************/ - -// Test on basic addition over u32 type. -TEST_F(AvmMiniArithmeticTestsU32, addition) -{ - // trace_builder - trace_builder.set(1000000000, 8, AvmMemoryTag::U32); - trace_builder.set(1234567891, 9, AvmMemoryTag::U32); - - trace_builder.add(8, 9, 0, AvmMemoryTag::U32); - trace_builder.return_op(0, 1); - auto trace = trace_builder.finalize(); - - auto alu_row = common_validate_add( - trace, FF(1000000000), FF(1234567891), FF(2234567891LLU), FF(8), FF(9), FF(0), AvmMemoryTag::U32); - - EXPECT_EQ(alu_row.aluChip_alu_u32_tag, FF(1)); - EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(2234567891LLU & UINT8_MAX)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF((2234567891LLU >> 8) & UINT8_MAX)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(2234567891LLU >> 16)); - - validate_trace_proof(std::move(trace)); -} - -// Test on basic addition over u32 type with carry. -TEST_F(AvmMiniArithmeticTestsU32, additionCarry) -{ - // trace_builder - trace_builder.set(UINT32_MAX - 1293, 8, AvmMemoryTag::U32); - trace_builder.set(2293, 9, AvmMemoryTag::U32); - - trace_builder.add(8, 9, 0, AvmMemoryTag::U32); - trace_builder.return_op(0, 1); - auto trace = trace_builder.finalize(); - - auto alu_row = - common_validate_add(trace, FF(UINT32_MAX - 1293), FF(2293), FF(999), FF(8), FF(9), FF(0), AvmMemoryTag::U32); - - EXPECT_EQ(alu_row.aluChip_alu_u32_tag, FF(1)); - EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(231)); // 999 = 3 * 256 + 231 - EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(3)); - - validate_trace_proof(std::move(trace)); -} - -// Test on basic subtraction over u32 type. -TEST_F(AvmMiniArithmeticTestsU32, subtraction) -{ - // trace_builder - trace_builder.set(1345678991, 8, AvmMemoryTag::U32); - trace_builder.set(1234567891, 9, AvmMemoryTag::U32); - - trace_builder.sub(8, 9, 0, AvmMemoryTag::U32); - trace_builder.return_op(0, 1); - auto trace = trace_builder.finalize(); - - auto alu_row = common_validate_sub( - trace, FF(1345678991), FF(1234567891), FF(111111100), FF(8), FF(9), FF(0), AvmMemoryTag::U32); - - EXPECT_EQ(alu_row.aluChip_alu_u32_tag, FF(1)); - EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); - - // 111111100 = 0x69F6BBC - EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0xBC)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0x6B)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(0x69F)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r1, FF(0)); - - validate_trace_proof(std::move(trace)); -} - -// Test on basic subtraction over u32 type with carry. -// For a subtraction a - b = c, there is a carry flag iff a < b (equivalent to a < c) -TEST_F(AvmMiniArithmeticTestsU32, subtractionCarry) -{ - // trace_builder - trace_builder.set(UINT32_MAX - 99, 8, AvmMemoryTag::U32); - trace_builder.set(3210987654, 9, AvmMemoryTag::U32); - - trace_builder.sub(9, 8, 0, AvmMemoryTag::U32); - trace_builder.return_op(0, 1); - auto trace = trace_builder.finalize(); - - auto alu_row = common_validate_sub( - trace, FF(3210987654LLU), FF(UINT32_MAX - 99), FF(3210987754LLU), FF(9), FF(8), FF(0), AvmMemoryTag::U32); - - EXPECT_EQ(alu_row.aluChip_alu_u32_tag, FF(1)); - EXPECT_EQ(alu_row.aluChip_alu_cf, FF(1)); - - // 3210987754 = 0xBF63C8EA - EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0xEA)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0xC8)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(0xBF63)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r1, FF(UINT16_MAX)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r2, FF(UINT16_MAX)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r3, FF(UINT16_MAX)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r4, FF(UINT16_MAX)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r5, FF(UINT16_MAX)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r6, FF(UINT16_MAX)); - - validate_trace_proof(std::move(trace)); -} - -// Test on basic multiplication over u32 type. -TEST_F(AvmMiniArithmeticTestsU32, multiplication) -{ - // trace_builder - trace_builder.set(11111, 0, AvmMemoryTag::U32); - trace_builder.set(11111, 1, AvmMemoryTag::U32); - - trace_builder.mul(0, 1, 2, AvmMemoryTag::U32); - trace_builder.return_op(2, 1); - auto trace = trace_builder.finalize(); - - auto alu_row_index = - common_validate_mul(trace, FF(11111), FF(11111), FF(123454321), FF(0), FF(1), FF(2), AvmMemoryTag::U32); - auto alu_row = trace.at(alu_row_index); - - EXPECT_EQ(alu_row.aluChip_alu_u32_tag, FF(1)); - - // Decomposition of integer multiplication in 8-bit and 16-bit registers - // 123454321 = 0x75BC371 - EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0x71)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0xC3)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(0x75B)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r1, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r2, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r3, FF(0)); - - validate_trace_proof(std::move(trace)); -} - -// Test on multiplication over u32 type with overflow. -TEST_F(AvmMiniArithmeticTestsU32, multiplicationOverflow) -{ - // trace_builder - trace_builder.set(11 << 25, 0, AvmMemoryTag::U32); - trace_builder.set(13 << 22, 1, AvmMemoryTag::U32); - - trace_builder.mul(0, 1, 2, AvmMemoryTag::U32); - trace_builder.return_op(2, 1); - auto trace = trace_builder.finalize(); - - auto alu_row_index = - common_validate_mul(trace, FF(11 << 25), FF(13 << 22), FF(0), FF(0), FF(1), FF(2), AvmMemoryTag::U32); - auto alu_row = trace.at(alu_row_index); - - EXPECT_EQ(alu_row.aluChip_alu_u32_tag, FF(1)); - - // Decomposition of integer multiplication in 8-bit and 16-bit registers - // 143 * 2^47 = 0 + 0 * 2^16 + 2^15 * 2^32 + 71 * 2^48 - EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r1, FF(32768)); // 2^15 - EXPECT_EQ(alu_row.aluChip_alu_u16_r2, FF(71)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r3, FF(0)); - - validate_trace_proof(std::move(trace)); -} - -/****************************************************************************** - * Positive Tests - U64 - ******************************************************************************/ - -// Test on basic addition over u64 type. -TEST_F(AvmMiniArithmeticTestsU64, addition) -{ - uint64_t const a = 7813981340746672LLU; - uint64_t const b = 2379061066771309LLU; - uint64_t const c = 10193042407517981LLU; - - // trace_builder - trace_builder.set(a, 8, AvmMemoryTag::U64); - trace_builder.set(b, 9, AvmMemoryTag::U64); - - trace_builder.add(8, 9, 9, AvmMemoryTag::U64); - trace_builder.return_op(9, 1); - auto trace = trace_builder.finalize(); - - auto alu_row = common_validate_add(trace, FF(a), FF(b), FF(c), FF(8), FF(9), FF(9), AvmMemoryTag::U64); - - EXPECT_EQ(alu_row.aluChip_alu_u64_tag, FF(1)); - EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); - - // c in HEX: 2436849FE16F1D - EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0x1D)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0x6F)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(0x9FE1)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r1, FF(0x3684)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r2, FF(0x24)); - - validate_trace_proof(std::move(trace)); -} - -// Test on basic addition over u64 type with carry. -TEST_F(AvmMiniArithmeticTestsU64, additionCarry) -{ - uint64_t const a = UINT64_MAX - 77LLU; - uint64_t const b = UINT64_MAX - 123LLU; - uint64_t const c = UINT64_MAX - 201LLU; - - // trace_builder - trace_builder.set(a, 0, AvmMemoryTag::U64); - trace_builder.set(b, 1, AvmMemoryTag::U64); - - trace_builder.add(0, 1, 0, AvmMemoryTag::U64); - trace_builder.return_op(0, 1); - auto trace = trace_builder.finalize(); - - auto alu_row = common_validate_add(trace, FF(a), FF(b), FF(c), FF(0), FF(1), FF(0), AvmMemoryTag::U64); - - EXPECT_EQ(alu_row.aluChip_alu_u64_tag, FF(1)); - EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(UINT8_MAX - 201)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(UINT8_MAX)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(UINT16_MAX)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r1, FF(UINT16_MAX)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r2, FF(UINT16_MAX)); - - validate_trace_proof(std::move(trace)); -} - -// Test on basic subtraction over u64 type. -TEST_F(AvmMiniArithmeticTestsU64, subtraction) -{ - uint64_t const a = 9876543210123456789LLU; - uint64_t const b = 9866543210123456789LLU; - uint64_t const c = 10000000000000000LLU; - - // trace_builder - trace_builder.set(a, 8, AvmMemoryTag::U64); - trace_builder.set(b, 9, AvmMemoryTag::U64); - - trace_builder.sub(8, 9, 9, AvmMemoryTag::U64); - trace_builder.return_op(9, 1); - auto trace = trace_builder.finalize(); - - auto alu_row = common_validate_sub(trace, FF(a), FF(b), FF(c), FF(8), FF(9), FF(9), AvmMemoryTag::U64); - - EXPECT_EQ(alu_row.aluChip_alu_u64_tag, FF(1)); - EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); - - // 10000000000000000 = 0x2386F26FC10000 - EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(0X6FC1)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r1, FF(0X86F2)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r2, FF(0X23)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r3, FF(0)); - - validate_trace_proof(std::move(trace)); -} - -// Test on basic subtraction over u64 type with carry. -// For a subtraction a - b = c, there is a carry flag iff a < b (equivalent to a < c) -TEST_F(AvmMiniArithmeticTestsU64, subtractionCarry) -{ - uint64_t const a = UINT64_MAX - 77LLU; - uint64_t const b = UINT64_MAX - 2LLU; - uint64_t const c = UINT64_MAX - 74; - - // trace_builder - trace_builder.set(a, 0, AvmMemoryTag::U64); - trace_builder.set(b, 1, AvmMemoryTag::U64); - - trace_builder.sub(0, 1, 0, AvmMemoryTag::U64); - trace_builder.return_op(0, 1); - auto trace = trace_builder.finalize(); - - auto alu_row = common_validate_sub(trace, FF(a), FF(b), FF(c), FF(0), FF(1), FF(0), AvmMemoryTag::U64); - - EXPECT_EQ(alu_row.aluChip_alu_u64_tag, FF(1)); - EXPECT_EQ(alu_row.aluChip_alu_cf, FF(1)); - - EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(UINT8_MAX - 74)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(UINT8_MAX)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(UINT16_MAX)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r1, FF(UINT16_MAX)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r2, FF(UINT16_MAX)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r3, FF(UINT16_MAX)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r4, FF(UINT16_MAX)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r5, FF(UINT16_MAX)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r6, FF(UINT16_MAX)); - validate_trace_proof(std::move(trace)); -} - -// Test on basic multiplication over u64 type. -TEST_F(AvmMiniArithmeticTestsU64, multiplication) -{ - // trace_builder - trace_builder.set(999888777, 0, AvmMemoryTag::U64); - trace_builder.set(555444333, 1, AvmMemoryTag::U64); - - trace_builder.mul(0, 1, 2, AvmMemoryTag::U64); - trace_builder.return_op(2, 1); - auto trace = trace_builder.finalize(); - - auto alu_row_index = common_validate_mul( - trace, FF(999888777), FF(555444333), FF(555382554814950741LLU), FF(0), FF(1), FF(2), AvmMemoryTag::U64); - auto alu_row = trace.at(alu_row_index); - - EXPECT_EQ(alu_row.aluChip_alu_u64_tag, FF(1)); - - // Decomposition of integer multiplication in 8-bit and 16-bit registers - // 555,382,554,814,950,741 = 0x 7B5 1D7D B631 AD55 - EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0x55)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0xAD)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(0xB631)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r1, FF(0x1D7D)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r2, FF(0x7B5)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r3, FF(0)); - - validate_trace_proof(std::move(trace)); -} - -// Test on multiplication over u64 type with overflow. -TEST_F(AvmMiniArithmeticTestsU64, multiplicationOverflow) -{ - uint64_t const a = UINT64_MAX; - uint64_t const b = UINT64_MAX; - // (2^64 - 1)^2 = 2^128 - 2^65 + 1 (mod. 2^64) = 1 - - // trace_builder - trace_builder.set(a, 0, AvmMemoryTag::U64); - trace_builder.set(b, 1, AvmMemoryTag::U64); - - trace_builder.mul(0, 1, 2, AvmMemoryTag::U64); - trace_builder.return_op(2, 1); - auto trace = trace_builder.finalize(); - - auto alu_row_index = common_validate_mul(trace, FF(a), FF(b), FF(1), FF(0), FF(1), FF(2), AvmMemoryTag::U64); - auto alu_row = trace.at(alu_row_index); - - EXPECT_EQ(alu_row.aluChip_alu_u64_tag, FF(1)); - - // Decomposition of integer multiplication in 8-bit and 16-bit registers - // 2^128 - 2^65 + 1 - EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(1)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r1, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r2, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r3, FF(UINT16_MAX - 1)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r4, FF(UINT16_MAX)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r5, FF(UINT16_MAX)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r6, FF(UINT16_MAX)); - - validate_trace_proof(std::move(trace)); -} - -/****************************************************************************** - * Positive Tests - U128 - ******************************************************************************/ - -// Test on basic addition over u128 type. -TEST_F(AvmMiniArithmeticTestsU128, addition) -{ - uint128_t const a = (uint128_t{ 0x5555222233334444LLU } << 64) + uint128_t{ 0x88889999AAAABBBBLLU }; - uint128_t const b = (uint128_t{ 0x3333222233331111LLU } << 64) + uint128_t{ 0x5555111155553333LLU }; - uint128_t const c = (uint128_t{ 0x8888444466665555LLU } << 64) + uint128_t{ 0xDDDDAAAAFFFFEEEELLU }; - - // trace_builder - trace_builder.set(a, 8, AvmMemoryTag::U128); - trace_builder.set(b, 9, AvmMemoryTag::U128); - - trace_builder.add(8, 9, 9, AvmMemoryTag::U128); - trace_builder.return_op(9, 1); - auto trace = trace_builder.finalize(); - - auto alu_row = common_validate_add(trace, - FF(uint256_t::from_uint128(a)), - FF(uint256_t::from_uint128(b)), - FF(uint256_t::from_uint128(c)), - FF(8), - FF(9), - FF(9), - AvmMemoryTag::U128); - - EXPECT_EQ(alu_row.aluChip_alu_u128_tag, FF(1)); - EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0xEE)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0xEE)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(0xFFFF)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r1, FF(0xAAAA)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r2, FF(0xDDDD)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r3, FF(0x5555)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r4, FF(0x6666)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r5, FF(0x4444)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r6, FF(0x8888)); - - validate_trace_proof(std::move(trace)); -} - -// Test on basic addition over u128 type with carry. -TEST_F(AvmMiniArithmeticTestsU128, additionCarry) -{ - uint128_t const a = (uint128_t{ UINT64_MAX } << 64) + uint128_t{ UINT64_MAX } - uint128_t{ 72948899 }; - uint128_t const b = (uint128_t{ UINT64_MAX } << 64) + uint128_t{ UINT64_MAX } - uint128_t{ 36177344 }; - uint128_t const c = - (uint128_t{ UINT64_MAX } << 64) + uint128_t{ UINT64_MAX } - uint128_t{ 36177345 } - uint128_t{ 72948899 }; - - // trace_builder - trace_builder.set(a, 8, AvmMemoryTag::U128); - trace_builder.set(b, 9, AvmMemoryTag::U128); - - trace_builder.add(8, 9, 9, AvmMemoryTag::U128); - trace_builder.return_op(9, 1); - auto trace = trace_builder.finalize(); - - auto alu_row = common_validate_add(trace, - FF(uint256_t::from_uint128(a)), - FF(uint256_t::from_uint128(b)), - FF(uint256_t::from_uint128(c)), - FF(8), - FF(9), - FF(9), - AvmMemoryTag::U128); - - EXPECT_EQ(alu_row.aluChip_alu_u128_tag, FF(1)); - EXPECT_EQ(alu_row.aluChip_alu_cf, FF(1)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0x9B)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0xDD)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(0xF97E)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r1, FF(0xFFFF)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r2, FF(0xFFFF)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r3, FF(0xFFFF)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r4, FF(0xFFFF)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r5, FF(0xFFFF)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r6, FF(0xFFFF)); - - validate_trace_proof(std::move(trace)); -} - -// Test on basic subtraction over u128 type. -TEST_F(AvmMiniArithmeticTestsU128, subtraction) -{ - uint128_t const a = (uint128_t{ UINT64_MAX } << 64) + uint128_t{ UINT64_MAX } - uint128_t{ 36177344 }; - uint128_t const b = (uint128_t{ UINT64_MAX } << 64) + uint128_t{ UINT64_MAX } - uint128_t{ 72948899 }; - uint128_t const c = 36771555; // 72948899 - 36177344 - - // trace_builder - trace_builder.set(a, 8, AvmMemoryTag::U128); - trace_builder.set(b, 9, AvmMemoryTag::U128); - - trace_builder.sub(8, 9, 9, AvmMemoryTag::U128); - trace_builder.return_op(9, 1); - auto trace = trace_builder.finalize(); - - auto alu_row = common_validate_sub(trace, - FF(uint256_t::from_uint128(a)), - FF(uint256_t::from_uint128(b)), - FF(uint256_t::from_uint128(c)), - FF(8), - FF(9), - FF(9), - AvmMemoryTag::U128); - - EXPECT_EQ(alu_row.aluChip_alu_u128_tag, FF(1)); - EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); - - // 36771555 = 23116E3 - EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0xE3)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0x16)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(0x231)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r1, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r2, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r3, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r4, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r5, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r6, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r7, FF(0)); - - validate_trace_proof(std::move(trace)); -} - -// Test on basic subtraction over u128 type with carry. -TEST_F(AvmMiniArithmeticTestsU128, subtractionCarry) -{ - uint128_t const a = (uint128_t{ 0x5555222233334444LLU } << 64) + uint128_t{ 0x88889999AAAABBBBLLU }; - uint128_t const b = (uint128_t{ 0x3333222233331111LLU } << 64) + uint128_t{ 0x5555111155553333LLU }; - uint128_t const c = (uint128_t{ 0x2222000000003333LLU } << 64) + uint128_t{ 0x3333888855558888LLU }; - - // trace_builder - trace_builder.set(a, 8, AvmMemoryTag::U128); - trace_builder.set(b, 9, AvmMemoryTag::U128); - - trace_builder.sub(8, 9, 9, AvmMemoryTag::U128); - trace_builder.return_op(9, 1); - auto trace = trace_builder.finalize(); - - auto alu_row = common_validate_sub(trace, - FF(uint256_t::from_uint128(a)), - FF(uint256_t::from_uint128(b)), - FF(uint256_t::from_uint128(c)), - FF(8), - FF(9), - FF(9), - AvmMemoryTag::U128); - - EXPECT_EQ(alu_row.aluChip_alu_u128_tag, FF(1)); - EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); - - EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0x88)); - EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0x88)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(0x5555)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r1, FF(0x8888)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r2, FF(0x3333)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r3, FF(0x3333)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r4, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r5, FF(0)); - EXPECT_EQ(alu_row.aluChip_alu_u16_r6, FF(0x2222)); - - validate_trace_proof(std::move(trace)); -} - -// Test on basic multiplication over u128 type. -TEST_F(AvmMiniArithmeticTestsU128, multiplication) -{ - // trace_builder - trace_builder.set(0x38D64BF685FFBLLU, 0, AvmMemoryTag::U128); - trace_builder.set(0x1F92C762C98DFLLU, 1, AvmMemoryTag::U128); - // Integer multiplication output in HEX: 70289AEB0A7DDA0BAE60CA3A5 - FF c{ uint256_t{ 0xA7DDA0BAE60CA3A5, 0x70289AEB0, 0, 0 } }; - - trace_builder.mul(0, 1, 2, AvmMemoryTag::U128); - trace_builder.return_op(2, 1); - auto trace = trace_builder.finalize(); - - auto alu_row_index = common_validate_mul( - trace, FF(0x38D64BF685FFBLLU), FF(555444333222111LLU), c, FF(0), FF(1), FF(2), AvmMemoryTag::U128); - auto alu_row_first = trace.at(alu_row_index); - - EXPECT_EQ(alu_row_first.aluChip_alu_u128_tag, FF(1)); - - // Decomposition of the first operand in 16-bit registers - EXPECT_EQ(alu_row_first.aluChip_alu_u16_r0, FF(0x5FFB)); - EXPECT_EQ(alu_row_first.aluChip_alu_u16_r1, FF(0xBF68)); - EXPECT_EQ(alu_row_first.aluChip_alu_u16_r2, FF(0x8D64)); - EXPECT_EQ(alu_row_first.aluChip_alu_u16_r3, FF(0x3)); - - // Decomposition of the second operand in 16-bit registers - auto alu_row_second = trace.at(alu_row_index + 1); - EXPECT_EQ(alu_row_second.aluChip_alu_u16_r0, FF(0x98DF)); - EXPECT_EQ(alu_row_second.aluChip_alu_u16_r1, FF(0x762C)); - EXPECT_EQ(alu_row_second.aluChip_alu_u16_r2, FF(0xF92C)); - EXPECT_EQ(alu_row_second.aluChip_alu_u16_r3, FF(0x1)); - validate_trace_proof(std::move(trace)); -} - -// Test on multiplication over u128 type with overflow. -TEST_F(AvmMiniArithmeticTestsU128, multiplicationOverflow) -{ - // (2^128 - 2) * (2^128 - 4) = 2^256 - 2^130 - 2^129 + 2^3 - // The above modulo 2^128 = 8 - uint128_t const a = (uint128_t{ UINT64_MAX } << 64) + uint128_t{ UINT64_MAX - 1 }; - uint128_t const b = (uint128_t{ UINT64_MAX } << 64) + uint128_t{ UINT64_MAX - 3 }; - - // trace_builder - trace_builder.set(a, 0, AvmMemoryTag::U128); - trace_builder.set(b, 1, AvmMemoryTag::U128); - - trace_builder.mul(0, 1, 2, AvmMemoryTag::U128); - trace_builder.return_op(2, 1); - auto trace = trace_builder.finalize(); - - auto alu_row_index = common_validate_mul(trace, - FF{ uint256_t::from_uint128(a) }, - FF{ uint256_t::from_uint128(b) }, - FF{ 8 }, - FF(0), - FF(1), - FF(2), - AvmMemoryTag::U128); - auto alu_row_first = trace.at(alu_row_index); - - EXPECT_EQ(alu_row_first.aluChip_alu_u128_tag, FF(1)); - - // Decomposition of the first operand in 16-bit registers - EXPECT_EQ(alu_row_first.aluChip_alu_u16_r0, FF(0xFFFE)); - EXPECT_EQ(alu_row_first.aluChip_alu_u16_r1, FF(UINT16_MAX)); - EXPECT_EQ(alu_row_first.aluChip_alu_u16_r2, FF(UINT16_MAX)); - EXPECT_EQ(alu_row_first.aluChip_alu_u16_r3, FF(UINT16_MAX)); - EXPECT_EQ(alu_row_first.aluChip_alu_u16_r4, FF(UINT16_MAX)); - EXPECT_EQ(alu_row_first.aluChip_alu_u16_r5, FF(UINT16_MAX)); - EXPECT_EQ(alu_row_first.aluChip_alu_u16_r6, FF(UINT16_MAX)); - EXPECT_EQ(alu_row_first.aluChip_alu_u16_r7, FF(UINT16_MAX)); - - // Decomposition of the second operand in 16-bit registers - auto alu_row_second = trace.at(alu_row_index + 1); - EXPECT_EQ(alu_row_second.aluChip_alu_u16_r0, FF(0xFFFC)); - EXPECT_EQ(alu_row_second.aluChip_alu_u16_r1, FF(UINT16_MAX)); - EXPECT_EQ(alu_row_second.aluChip_alu_u16_r2, FF(UINT16_MAX)); - EXPECT_EQ(alu_row_second.aluChip_alu_u16_r3, FF(UINT16_MAX)); - EXPECT_EQ(alu_row_second.aluChip_alu_u16_r4, FF(UINT16_MAX)); - EXPECT_EQ(alu_row_second.aluChip_alu_u16_r5, FF(UINT16_MAX)); - EXPECT_EQ(alu_row_second.aluChip_alu_u16_r6, FF(UINT16_MAX)); - EXPECT_EQ(alu_row_second.aluChip_alu_u16_r7, FF(UINT16_MAX)); - - // Other registers involved in the relevant relations - // PIL relation (alu_chip.pil): a * b_l + a_l * b_h * 2^64 = (CF * 2^64 + R') * 2^128 + c - // (2^128 - 2) * (2^64 - 4) + (2^64 - 2) * (2^64 - 1) * 2^64 = - // 2 * 2^192 + (- 4 - 2 - 1) * 2^128 + (-2 + 2) * 2^64 + 8 = (2^65 - 7) * 2^128 + 8 - // Therefore, CF = 1 and R' = 2^64 - 7 - EXPECT_EQ(alu_row_first.aluChip_alu_u64_r0, FF{ UINT64_MAX - 6 }); // 2^64 - 7 - EXPECT_EQ(alu_row_first.aluChip_alu_cf, FF(1)); - - validate_trace_proof(std::move(trace)); -} - /****************************************************************************** * * NEGATIVE TESTS - Finite Field Type @@ -1361,7 +277,7 @@ TEST_F(AvmMiniArithmeticTestsU128, multiplicationOverflow) * and division by having dedicated unit test for each of them. * A typical pattern is to wrongly mutate the result of the operation. The memory trace * is consistently adapted so that the negative test is applying to the relation - * of the arithmetic operation and not the layout of the memory trace. + * if the arithmetic operation and not the layout of the memory trace. * * Finding the row pertaining to the arithmetic operation is done through * a scan of all rows and stopping at the first one with the corresponding @@ -1369,39 +285,58 @@ TEST_F(AvmMiniArithmeticTestsU128, multiplicationOverflow) * will still correctly work along the development of the AVM. ******************************************************************************/ -/****************************************************************************** - * Negative Tests - FF - ******************************************************************************/ - // Test on basic incorrect addition over finite field type. -TEST_F(AvmMiniArithmeticNegativeTestsFF, addition) +TEST_F(AvmMiniArithmeticNegativeTests, additionFF) { - auto trace = gen_mutated_trace_add(FF(37), FF(4), FF(40), AvmMemoryTag::FF); - EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_ADD_SUB_1"); + trace_builder.call_data_copy(0, 3, 0, std::vector{ 37, 4, 11 }); + + // Memory layout: [37,4,11,0,0,0,....] + trace_builder.add(0, 1, 4, AvmMemoryTag::ff); // [37,4,11,0,41,0,....] + auto trace = trace_builder.finalize(); + + auto select_row = [](Row r) { return r.avmMini_sel_op_add == FF(1); }; + mutate_ic_in_trace(trace, std::move(select_row), FF(40)); + + EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "SUBOP_ADDITION_FF"); } // Test on basic incorrect subtraction over finite field type. -TEST_F(AvmMiniArithmeticNegativeTestsFF, subtraction) +TEST_F(AvmMiniArithmeticNegativeTests, subtractionFF) { - auto trace = gen_mutated_trace_sub(FF(17), FF(8), FF(-9), AvmMemoryTag::FF); - EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_ADD_SUB_1"); + trace_builder.call_data_copy(0, 3, 0, std::vector{ 8, 4, 17 }); + + // Memory layout: [8,4,17,0,0,0,....] + trace_builder.sub(2, 0, 1, AvmMemoryTag::ff); // [8,9,17,0,0,0....] + auto trace = trace_builder.finalize(); + + auto select_row = [](Row r) { return r.avmMini_sel_op_sub == FF(1); }; + mutate_ic_in_trace(trace, std::move(select_row), FF(-9)); + + EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "SUBOP_SUBTRACTION_FF"); } // Test on basic incorrect multiplication over finite field type. -TEST_F(AvmMiniArithmeticNegativeTestsFF, multiplication) +TEST_F(AvmMiniArithmeticNegativeTests, multiplicationFF) { - auto trace = gen_mutated_trace_mul(FF(9), FF(100), FF(9000000), AvmMemoryTag::FF); - EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_MULTIPLICATION_FF"); + trace_builder.call_data_copy(0, 3, 0, std::vector{ 5, 0, 20 }); + + // Memory layout: [5,0,20,0,0,0,....] + trace_builder.mul(2, 0, 1, AvmMemoryTag::ff); // [5,100,20,0,0,0....] + auto trace = trace_builder.finalize(); + + auto select_row = [](Row r) { return r.avmMini_sel_op_mul == FF(1); }; + mutate_ic_in_trace(trace, std::move(select_row), FF(1000)); + + EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "SUBOP_MULTIPLICATION_FF"); } // Test on basic incorrect division over finite field type. -TEST_F(AvmMiniArithmeticNegativeTestsFF, divisionFF) +TEST_F(AvmMiniArithmeticNegativeTests, divisionFF) { trace_builder.call_data_copy(0, 2, 0, std::vector{ 15, 315 }); // Memory layout: [15,315,0,0,0,0,....] - trace_builder.div(1, 0, 2, AvmMemoryTag::FF); // [15,315,21,0,0,0....] - trace_builder.halt(); + trace_builder.div(1, 0, 2, AvmMemoryTag::ff); // [15,315,21,0,0,0....] auto trace = trace_builder.finalize(); auto select_row = [](Row r) { return r.avmMini_sel_op_div == FF(1); }; @@ -1412,13 +347,12 @@ TEST_F(AvmMiniArithmeticNegativeTestsFF, divisionFF) // Test where division is not by zero but an operation error is wrongly raised // in the trace. -TEST_F(AvmMiniArithmeticNegativeTestsFF, divisionNoZeroButError) +TEST_F(AvmMiniArithmeticNegativeTests, divisionNoZeroButErrorFF) { trace_builder.call_data_copy(0, 2, 0, std::vector{ 15, 315 }); // Memory layout: [15,315,0,0,0,0,....] - trace_builder.div(1, 0, 2, AvmMemoryTag::FF); // [15,315,21,0,0,0....] - trace_builder.halt(); + trace_builder.div(1, 0, 2, AvmMemoryTag::ff); // [15,315,21,0,0,0....] auto trace = trace_builder.finalize(); // Find the first row enabling the division selector @@ -1438,12 +372,12 @@ TEST_F(AvmMiniArithmeticNegativeTestsFF, divisionNoZeroButError) } // Test with division by zero occurs and no error is raised (remove error flag) -TEST_F(AvmMiniArithmeticNegativeTestsFF, divisionByZeroNoError) +TEST_F(AvmMiniArithmeticNegativeTests, divisionByZeroNoErrorFF) { trace_builder.call_data_copy(0, 1, 0, std::vector{ 15 }); // Memory layout: [15,0,0,0,0,0,....] - trace_builder.div(0, 1, 2, AvmMemoryTag::FF); // [15,0,0,0,0,0....] + trace_builder.div(0, 1, 2, AvmMemoryTag::ff); // [15,0,0,0,0,0....] trace_builder.halt(); auto trace = trace_builder.finalize(); @@ -1457,11 +391,10 @@ TEST_F(AvmMiniArithmeticNegativeTestsFF, divisionByZeroNoError) } // Test with division of zero by zero occurs and no error is raised (remove error flag) -TEST_F(AvmMiniArithmeticNegativeTestsFF, divisionZeroByZeroNoError) +TEST_F(AvmMiniArithmeticNegativeTests, divisionZeroByZeroNoErrorFF) { // Memory layout: [0,0,0,0,0,0,....] - trace_builder.div(0, 1, 2, AvmMemoryTag::FF); // [0,0,0,0,0,0....] - trace_builder.halt(); + trace_builder.div(0, 1, 2, AvmMemoryTag::ff); // [0,0,0,0,0,0....] auto trace = trace_builder.finalize(); // Find the first row enabling the division selector @@ -1475,14 +408,13 @@ TEST_F(AvmMiniArithmeticNegativeTestsFF, divisionZeroByZeroNoError) // Test that error flag cannot be raised for a non-relevant operation such as // the addition, subtraction, multiplication. -TEST_F(AvmMiniArithmeticNegativeTestsFF, operationWithErrorFlag) +TEST_F(AvmMiniArithmeticNegativeTests, operationWithErrorFlagFF) { trace_builder.call_data_copy(0, 3, 0, std::vector{ 37, 4, 11 }); // Memory layout: [37,4,11,0,0,0,....] - trace_builder.add(0, 1, 4, AvmMemoryTag::FF); // [37,4,11,0,41,0,....] + trace_builder.add(0, 1, 4, AvmMemoryTag::ff); // [37,4,11,0,41,0,....] trace_builder.return_op(0, 5); - trace_builder.halt(); auto trace = trace_builder.finalize(); // Find the first row enabling the addition selector @@ -1498,7 +430,7 @@ TEST_F(AvmMiniArithmeticNegativeTestsFF, operationWithErrorFlag) trace_builder.call_data_copy(0, 3, 0, std::vector{ 8, 4, 17 }); // Memory layout: [8,4,17,0,0,0,....] - trace_builder.sub(2, 0, 1, AvmMemoryTag::FF); // [8,9,17,0,0,0....] + trace_builder.sub(2, 0, 1, AvmMemoryTag::ff); // [8,9,17,0,0,0....] trace_builder.return_op(0, 3); trace = trace_builder.finalize(); @@ -1515,7 +447,7 @@ TEST_F(AvmMiniArithmeticNegativeTestsFF, operationWithErrorFlag) trace_builder.call_data_copy(0, 3, 0, std::vector{ 5, 0, 20 }); // Memory layout: [5,0,20,0,0,0,....] - trace_builder.mul(2, 0, 1, AvmMemoryTag::FF); // [5,100,20,0,0,0....] + trace_builder.mul(2, 0, 1, AvmMemoryTag::ff); // [5,100,20,0,0,0....] trace_builder.return_op(0, 3); trace = trace_builder.finalize(); @@ -1528,151 +460,4 @@ TEST_F(AvmMiniArithmeticNegativeTestsFF, operationWithErrorFlag) EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "SUBOP_ERROR_RELEVANT_OP"); } -/****************************************************************************** - * Negative Tests - U8 - ******************************************************************************/ - -// Test on basic incorrect addition over U8. -TEST_F(AvmMiniArithmeticNegativeTestsU8, addition) -{ - auto trace = gen_mutated_trace_add(FF(234), FF(22), FF(1), AvmMemoryTag::U8); - EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_ADD_SUB_2"); -} - -// Test on basic incorrect subtraction over U8. -TEST_F(AvmMiniArithmeticNegativeTestsU8, subtraction) -{ - auto trace = gen_mutated_trace_sub(FF(100), FF(104), FF(253), AvmMemoryTag::U8); - EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_ADD_SUB_2"); -} - -// Test on basic incorrect multiplication over U8. -TEST_F(AvmMiniArithmeticNegativeTestsU8, multiplication) -{ - auto trace = gen_mutated_trace_mul(FF(9), FF(100), FF(55), AvmMemoryTag::U8); - EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_MUL_COMMON_2"); -} - -/****************************************************************************** - * Negative Tests - U16 - ******************************************************************************/ - -// Test on basic incorrect addition over U16. -TEST_F(AvmMiniArithmeticNegativeTestsU16, addition) -{ - auto trace = gen_mutated_trace_add(FF(8234), FF(7428), FF(653), AvmMemoryTag::U16); - EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_ADD_SUB_2"); -} - -// Test on basic incorrect subtraction over U16. -TEST_F(AvmMiniArithmeticNegativeTestsU16, subtraction) -{ - auto trace = gen_mutated_trace_sub(FF(100), FF(932), FF(25373), AvmMemoryTag::U16); - EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_ADD_SUB_2"); -} - -// Test on basic incorrect multiplication over U16. -TEST_F(AvmMiniArithmeticNegativeTestsU16, multiplication) -{ - auto trace = gen_mutated_trace_mul(FF(8096), FF(1024), FF(1), AvmMemoryTag::U16); - EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_MUL_COMMON_2"); -} - -/****************************************************************************** - * Negative Tests - U32 - ******************************************************************************/ - -// Test on basic incorrect addition over U32. -TEST_F(AvmMiniArithmeticNegativeTestsU32, addition) -{ - auto trace = gen_mutated_trace_add(FF(1972382341), FF(1111133221), FF(1222222222), AvmMemoryTag::U32); - EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_ADD_SUB_2"); -} - -// Test on basic incorrect subtraction over U32. -TEST_F(AvmMiniArithmeticNegativeTestsU32, subtraction) -{ - auto trace = gen_mutated_trace_sub(FF(3999888777LLU), FF(UINT32_MAX), FF(2537332433LLU), AvmMemoryTag::U32); - EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_ADD_SUB_2"); -} - -// Test on basic incorrect multiplication over U32. -TEST_F(AvmMiniArithmeticNegativeTestsU32, multiplication) -{ - auto trace = gen_mutated_trace_mul(FF(UINT32_MAX), FF(UINT32_MAX), FF(0), AvmMemoryTag::U32); - EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_MUL_COMMON_2"); -} - -/****************************************************************************** - * Negative Tests - U64 - ******************************************************************************/ - -// Test on basic incorrect addition over U64. -TEST_F(AvmMiniArithmeticNegativeTestsU64, addition) -{ - auto trace = gen_mutated_trace_add( - FF(3324236423198282341LLU), FF(999999991111133221LLU), FF(1222222222236LLU), AvmMemoryTag::U64); - EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_ADD_SUB_2"); -} - -// Test on basic incorrect subtraction over U64. -TEST_F(AvmMiniArithmeticNegativeTestsU64, subtraction) -{ - auto trace = - gen_mutated_trace_sub(FF(399988877723434LLU), FF(UINT64_MAX), FF(25373324332342LLU), AvmMemoryTag::U64); - EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_ADD_SUB_2"); -} - -// Test on basic incorrect multiplication over U64. -TEST_F(AvmMiniArithmeticNegativeTestsU64, multiplication) -{ - auto trace = - gen_mutated_trace_mul(FF(399988877723434LLU), FF(9998887772343LLU), FF(9283674827534LLU), AvmMemoryTag::U64); - EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_MUL_COMMON_2"); -} - -/****************************************************************************** - * Negative Tests - U128 - ******************************************************************************/ - -// Test on basic incorrect addition over U128. -TEST_F(AvmMiniArithmeticNegativeTestsU128, addition) -{ - uint128_t const a = (uint128_t{ 0x5555222233334444LLU } << 64) + uint128_t{ 0x88889999AAAABBBBLLU }; - uint128_t const b = (uint128_t{ 0x3333222233331111LLU } << 64) + uint128_t{ 0x5555111155553333LLU }; - uint128_t const c = (uint128_t{ 0x8888444466665555LLU } << 64) + uint128_t{ 0xDDDDAAAAFFFFEEEFLLU }; - - auto trace = gen_mutated_trace_add(FF{ uint256_t::from_uint128(a) }, - FF{ uint256_t::from_uint128(b) }, - FF{ uint256_t::from_uint128(c) }, - AvmMemoryTag::U128); - EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_ADD_SUB_2"); -} - -// Test on basic incorrect subtraction over U128. -TEST_F(AvmMiniArithmeticNegativeTestsU128, subtraction) -{ - uint128_t const a = (uint128_t{ 0x5555222233334444LLU } << 64) + uint128_t{ 0x88889999AAAABBBBLLU }; - uint128_t const b = (uint128_t{ 0x7333222233331111LLU } << 64) + uint128_t{ 0x5555111155553333LLU }; - uint128_t const c = (uint128_t{ 0x8888444466665555LLU } << 64) + uint128_t{ 0xDDDDALLU }; - - auto trace = gen_mutated_trace_sub(FF{ uint256_t::from_uint128(a) }, - FF{ uint256_t::from_uint128(b) }, - FF{ uint256_t::from_uint128(c) }, - AvmMemoryTag::U128); - EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_ADD_SUB_2"); -} - -// Test on basic incorrect multiplication over U128. -TEST_F(AvmMiniArithmeticNegativeTestsU128, multiplication) -{ - uint128_t const a = (uint128_t{ 0x5555222233334444LLU } << 64) + uint128_t{ 0x88889999AAAABBBBLLU }; - uint128_t const b = (uint128_t{ 0x7333222233331111LLU } << 64) + uint128_t{ 0x5555111155553333LLU }; - uint128_t const c = (uint128_t{ 0x8888444466665555LLU } << 64) + uint128_t{ 0xDDDDALLU }; - - auto trace = gen_mutated_trace_mul(FF{ uint256_t::from_uint128(a) }, - FF{ uint256_t::from_uint128(b) }, - FF{ uint256_t::from_uint128(c) }, - AvmMemoryTag::U128); - EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_MULTIPLICATION_OUT_U128"); -} \ No newline at end of file +} // namespace tests_avm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_common.test.hpp b/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_common.test.hpp deleted file mode 100644 index 4d7154552af1..000000000000 --- a/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_common.test.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include "barretenberg/vm/avm_trace/AvmMini_helper.hpp" -#include "barretenberg/vm/generated/AvmMini_composer.hpp" -#include "barretenberg/vm/generated/AvmMini_prover.hpp" -#include "barretenberg/vm/generated/AvmMini_verifier.hpp" -#include "helpers.test.hpp" - -#include -#include -#include -#include -#include \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_control_flow.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_control_flow.test.cpp index 657ae8e25b1b..eba7e312f211 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_control_flow.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_control_flow.test.cpp @@ -1,7 +1,17 @@ -#include "AvmMini_common.test.hpp" - +#include "barretenberg/vm/avm_trace/AvmMini_helper.hpp" +#include "barretenberg/vm/generated/AvmMini_composer.hpp" +#include "barretenberg/vm/generated/AvmMini_prover.hpp" +#include "barretenberg/vm/generated/AvmMini_verifier.hpp" +#include "helpers.test.hpp" + +#include +#include +#include +#include +#include + +namespace tests_avm { using namespace avm_trace; -using namespace tests_avm; class AvmMiniControlFlowTests : public ::testing::Test { public: @@ -11,7 +21,7 @@ class AvmMiniControlFlowTests : public ::testing::Test { // TODO(640): The Standard Honk on Grumpkin test suite fails unless the SRS is initialised for every test. void SetUp() override { - srs::init_crs_factory("../srs_db/ignition"); + bb::srs::init_crs_factory("../srs_db/ignition"); trace_builder = AvmMiniTraceBuilder(); // Clean instance for every run. }; }; @@ -285,3 +295,4 @@ TEST_F(AvmMiniControlFlowTests, multipleCallsAndReturns) validate_trace_proof(std::move(trace)); } +} // namespace tests_avm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_memory.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_memory.test.cpp index a5ccfd1076a7..79a3b03c96ad 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_memory.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_memory.test.cpp @@ -1,7 +1,18 @@ -#include "AvmMini_common.test.hpp" - -using namespace tests_avm; +#include "barretenberg/vm/avm_trace/AvmMini_helper.hpp" +#include "barretenberg/vm/generated/AvmMini_composer.hpp" +#include "barretenberg/vm/generated/AvmMini_prover.hpp" +#include "barretenberg/vm/generated/AvmMini_verifier.hpp" +#include "helpers.test.hpp" + +#include +#include +#include +#include +#include + +namespace tests_avm { using namespace avm_trace; + class AvmMiniMemoryTests : public ::testing::Test { public: AvmMiniTraceBuilder trace_builder; @@ -10,7 +21,7 @@ class AvmMiniMemoryTests : public ::testing::Test { // TODO(640): The Standard Honk on Grumpkin test suite fails unless the SRS is initialised for every test. void SetUp() override { - srs::init_crs_factory("../srs_db/ignition"); + bb::srs::init_crs_factory("../srs_db/ignition"); trace_builder = AvmMiniTraceBuilder(); // Clean instance for every run. }; }; @@ -34,7 +45,7 @@ TEST_F(AvmMiniMemoryTests, mismatchedTag) { trace_builder.call_data_copy(0, 2, 0, std::vector{ 98, 12 }); - trace_builder.add(0, 1, 4, AvmMemoryTag::U8); + trace_builder.add(0, 1, 4, AvmMemoryTag::u8); trace_builder.halt(); auto trace = trace_builder.finalize(); @@ -58,8 +69,8 @@ TEST_F(AvmMiniMemoryTests, mismatchedTag) EXPECT_TRUE(row != trace.end()); EXPECT_EQ(row->memTrace_m_tag_err, FF(1)); // Error is raised - EXPECT_EQ(row->memTrace_m_in_tag, FF(static_cast(AvmMemoryTag::U8))); - EXPECT_EQ(row->memTrace_m_tag, FF(static_cast(AvmMemoryTag::FF))); + EXPECT_EQ(row->memTrace_m_in_tag, FF(static_cast(AvmMemoryTag::u8))); + EXPECT_EQ(row->memTrace_m_tag, FF(static_cast(AvmMemoryTag::ff))); // Find the memory trace position corresponding to the add sub-operation of register ib. row = std::ranges::find_if(trace.begin(), trace.end(), [clk](Row r) { @@ -69,8 +80,8 @@ TEST_F(AvmMiniMemoryTests, mismatchedTag) EXPECT_TRUE(row != trace.end()); EXPECT_EQ(row->memTrace_m_tag_err, FF(1)); // Error is raised - EXPECT_EQ(row->memTrace_m_in_tag, FF(static_cast(AvmMemoryTag::U8))); - EXPECT_EQ(row->memTrace_m_tag, FF(static_cast(AvmMemoryTag::FF))); + EXPECT_EQ(row->memTrace_m_in_tag, FF(static_cast(AvmMemoryTag::u8))); + EXPECT_EQ(row->memTrace_m_tag, FF(static_cast(AvmMemoryTag::ff))); validate_trace_proof(std::move(trace)); } @@ -82,7 +93,7 @@ TEST_F(AvmMiniMemoryTests, mLastAccessViolation) trace_builder.call_data_copy(0, 2, 0, std::vector{ 4, 9 }); // Memory layout: [4,9,0,0,0,0,....] - trace_builder.sub(1, 0, 2, AvmMemoryTag::U8); // [4,9,5,0,0,0.....] + trace_builder.sub(1, 0, 2, AvmMemoryTag::u8); // [4,9,5,0,0,0.....] trace_builder.halt(); auto trace = trace_builder.finalize(); @@ -112,7 +123,7 @@ TEST_F(AvmMiniMemoryTests, readWriteConsistencyValViolation) trace_builder.call_data_copy(0, 2, 0, std::vector{ 4, 9 }); // Memory layout: [4,9,0,0,0,0,....] - trace_builder.mul(1, 0, 2, AvmMemoryTag::U8); // [4,9,36,0,0,0.....] + trace_builder.mul(1, 0, 2, AvmMemoryTag::u8); // [4,9,36,0,0,0.....] trace_builder.return_op(2, 1); // Return single memory word at position 2 (36) auto trace = trace_builder.finalize(); @@ -142,7 +153,7 @@ TEST_F(AvmMiniMemoryTests, readWriteConsistencyTagViolation) trace_builder.call_data_copy(0, 2, 0, std::vector{ 4, 9 }); // Memory layout: [4,9,0,0,0,0,....] - trace_builder.mul(1, 0, 2, AvmMemoryTag::U8); // [4,9,36,0,0,0.....] + trace_builder.mul(1, 0, 2, AvmMemoryTag::u8); // [4,9,36,0,0,0.....] trace_builder.return_op(2, 1); // Return single memory word at position 2 (36) auto trace = trace_builder.finalize(); @@ -160,7 +171,7 @@ TEST_F(AvmMiniMemoryTests, readWriteConsistencyTagViolation) EXPECT_TRUE(row != trace.end()); - row->memTrace_m_tag = static_cast(AvmMemoryTag::U16); + row->memTrace_m_tag = static_cast(AvmMemoryTag::u16); EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "MEM_READ_WRITE_TAG_CONSISTENCY"); } @@ -182,7 +193,7 @@ TEST_F(AvmMiniMemoryTests, mismatchedTagErrorViolation) { trace_builder.call_data_copy(0, 2, 0, std::vector{ 98, 12 }); - trace_builder.sub(0, 1, 4, AvmMemoryTag::U8); + trace_builder.sub(0, 1, 4, AvmMemoryTag::u8); trace_builder.halt(); auto trace = trace_builder.finalize(); @@ -216,7 +227,7 @@ TEST_F(AvmMiniMemoryTests, consistentTagNoErrorViolation) { trace_builder.call_data_copy(0, 2, 0, std::vector{ 84, 7 }); - trace_builder.div(0, 1, 4, AvmMemoryTag::FF); + trace_builder.div(0, 1, 4, AvmMemoryTag::ff); trace_builder.halt(); auto trace = trace_builder.finalize(); @@ -236,3 +247,4 @@ TEST_F(AvmMiniMemoryTests, consistentTagNoErrorViolation) EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "MEM_IN_TAG_CONSISTENCY_1"); } +} // namespace tests_avm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.cpp index 8377eba5ff87..8257b93eec89 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.cpp @@ -1,8 +1,13 @@ -#include "AvmMini_common.test.hpp" - -using namespace bb; +#include "helpers.test.hpp" +#include "barretenberg/vm/avm_trace/AvmMini_helper.hpp" +#include "barretenberg/vm/generated/AvmMini_composer.hpp" +#include "barretenberg/vm/generated/AvmMini_prover.hpp" +#include "barretenberg/vm/generated/AvmMini_verifier.hpp" +#include namespace tests_avm { +using namespace avm_trace; + /** * @brief Helper routine proving and verifying a proof based on the supplied trace * @@ -10,12 +15,12 @@ namespace tests_avm { */ void validate_trace_proof(std::vector&& trace) { - auto circuit_builder = AvmMiniCircuitBuilder(); + auto circuit_builder = bb::AvmMiniCircuitBuilder(); circuit_builder.set_trace(std::move(trace)); EXPECT_TRUE(circuit_builder.check_circuit()); - auto composer = honk::AvmMiniComposer(); + auto composer = bb::honk::AvmMiniComposer(); auto prover = composer.create_prover(circuit_builder); auto proof = prover.construct_proof(); @@ -23,7 +28,7 @@ void validate_trace_proof(std::vector&& trace) bool verified = verifier.verify_proof(proof); if (!verified) { - avm_trace::log_avmMini_trace(circuit_builder.rows, 0, 10); + log_avmMini_trace(circuit_builder.rows, 0, 10); } }; @@ -34,9 +39,8 @@ void validate_trace_proof(std::vector&& trace) * @param trace Execution trace * @param selectRow Lambda serving to select the row in trace * @param newValue The value that will be written in intermediate register Ic at the selected row. - * @param alu A boolean telling whether we mutate the ic value in alu as well. */ -void mutate_ic_in_trace(std::vector& trace, std::function&& selectRow, FF const& newValue, bool alu) +void mutate_ic_in_trace(std::vector& trace, std::function&& selectRow, FF const& newValue) { // Find the first row matching the criteria defined by selectRow auto row = std::ranges::find_if(trace.begin(), trace.end(), selectRow); @@ -47,18 +51,7 @@ void mutate_ic_in_trace(std::vector& trace, std::function&& sele // Mutate the correct result in the main trace row->avmMini_ic = newValue; - // Optionally mutate the corresponding ic value in alu - if (alu) { - auto const clk = row->avmMini_clk; - // Find the relevant alu trace entry. - auto alu_row = - std::ranges::find_if(trace.begin(), trace.end(), [clk](Row r) { return r.aluChip_alu_clk == clk; }); - - EXPECT_TRUE(alu_row != trace.end()); - alu_row->aluChip_alu_ic = newValue; - } - - // Adapt the memory trace to be consistent with the wrong result + // Adapt the memory trace to be consistent with the wrongly computed addition auto const clk = row->avmMini_clk; auto const addr = row->avmMini_mem_idx_c; @@ -70,4 +63,5 @@ void mutate_ic_in_trace(std::vector& trace, std::function&& sele EXPECT_TRUE(mem_row != trace.end()); mem_row->memTrace_m_val = newValue; }; + } // namespace tests_avm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.hpp b/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.hpp index 430c1cce45b0..145eb171457b 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.hpp @@ -10,11 +10,10 @@ std::string message = e.what(); \ EXPECT_TRUE(message.find(expectedMessage) != std::string::npos); \ } + namespace tests_avm { + void validate_trace_proof(std::vector&& trace); -void mutate_ic_in_trace(std::vector& trace, - std::function&& selectRow, - FF const& newValue, - bool alu = false); +void mutate_ic_in_trace(std::vector& trace, std::function&& selectRow, FF const& newValue); } // namespace tests_avm \ No newline at end of file diff --git a/barretenberg/exports.json b/barretenberg/exports.json index 3925ff1fa542..6a8bd360ccfd 100644 --- a/barretenberg/exports.json +++ b/barretenberg/exports.json @@ -466,17 +466,6 @@ ], "isAsync": false }, - { - "functionName": "acir_new_goblin_acir_composer", - "inArgs": [], - "outArgs": [ - { - "name": "out", - "type": "out_ptr" - } - ], - "isAsync": false - }, { "functionName": "acir_delete_acir_composer", "inArgs": [ @@ -551,31 +540,7 @@ "isAsync": false }, { - "functionName": "acir_goblin_accumulate", - "inArgs": [ - { - "name": "acir_composer_ptr", - "type": "in_ptr" - }, - { - "name": "constraint_system_buf", - "type": "const uint8_t *" - }, - { - "name": "witness_buf", - "type": "const uint8_t *" - } - ], - "outArgs": [ - { - "name": "out", - "type": "uint8_t **" - } - ], - "isAsync": false - }, - { - "functionName": "acir_goblin_prove", + "functionName": "acir_create_goblin_proof", "inArgs": [ { "name": "acir_composer_ptr", @@ -685,27 +650,7 @@ "isAsync": false }, { - "functionName": "acir_goblin_verify_accumulator", - "inArgs": [ - { - "name": "acir_composer_ptr", - "type": "in_ptr" - }, - { - "name": "proof_buf", - "type": "const uint8_t *" - } - ], - "outArgs": [ - { - "name": "result", - "type": "bool *" - } - ], - "isAsync": false - }, - { - "functionName": "acir_goblin_verify", + "functionName": "acir_verify_goblin_proof", "inArgs": [ { "name": "acir_composer_ptr", diff --git a/barretenberg/ts/CHANGELOG.md b/barretenberg/ts/CHANGELOG.md index 6feb64173df5..bb9690faac77 100644 --- a/barretenberg/ts/CHANGELOG.md +++ b/barretenberg/ts/CHANGELOG.md @@ -1,12 +1,5 @@ # Changelog -## [0.20.0](https://github.com/AztecProtocol/aztec-packages/compare/barretenberg.js-v0.19.0...barretenberg.js-v0.20.0) (2024-01-22) - - -### Features - -* Goblin acir composer ([#4112](https://github.com/AztecProtocol/aztec-packages/issues/4112)) ([5e85b92](https://github.com/AztecProtocol/aztec-packages/commit/5e85b92f48bc31fe55315de9f45c4907e417cb6a)) - ## [0.19.0](https://github.com/AztecProtocol/aztec-packages/compare/barretenberg.js-v0.18.0...barretenberg.js-v0.19.0) (2024-01-17) diff --git a/barretenberg/ts/package.json b/barretenberg/ts/package.json index 59b2a7236b0e..bca350451b04 100644 --- a/barretenberg/ts/package.json +++ b/barretenberg/ts/package.json @@ -1,6 +1,6 @@ { "name": "@aztec/bb.js", - "version": "0.20.0", + "version": "0.19.0", "homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/barretenberg/ts", "license": "MIT", "type": "module", diff --git a/barretenberg/ts/src/barretenberg_api/index.ts b/barretenberg/ts/src/barretenberg_api/index.ts index d62808515625..9ee50ba908b3 100644 --- a/barretenberg/ts/src/barretenberg_api/index.ts +++ b/barretenberg/ts/src/barretenberg_api/index.ts @@ -304,18 +304,6 @@ export class BarretenbergApi { return out[0]; } - async acirNewGoblinAcirComposer(): Promise { - const inArgs = [].map(serializeBufferable); - const outTypes: OutputType[] = [Ptr]; - const result = await this.wasm.callWasmExport( - 'acir_new_goblin_acir_composer', - inArgs, - outTypes.map(t => t.SIZE_IN_BYTES), - ); - const out = result.map((r, i) => outTypes[i].fromBuffer(r)); - return out[0]; - } - async acirDeleteAcirComposer(acirComposerPtr: Ptr): Promise { const inArgs = [acirComposerPtr].map(serializeBufferable); const outTypes: OutputType[] = []; @@ -369,23 +357,7 @@ export class BarretenbergApi { return out[0]; } - async acirGoblinAccumulate( - acirComposerPtr: Ptr, - constraintSystemBuf: Uint8Array, - witnessBuf: Uint8Array, - ): Promise { - const inArgs = [acirComposerPtr, constraintSystemBuf, witnessBuf].map(serializeBufferable); - const outTypes: OutputType[] = [BufferDeserializer()]; - const result = await this.wasm.callWasmExport( - 'acir_goblin_accumulate', - inArgs, - outTypes.map(t => t.SIZE_IN_BYTES), - ); - const out = result.map((r, i) => outTypes[i].fromBuffer(r)); - return out[0]; - } - - async acirGoblinProve( + async acirCreateGoblinProof( acirComposerPtr: Ptr, constraintSystemBuf: Uint8Array, witnessBuf: Uint8Array, @@ -393,7 +365,7 @@ export class BarretenbergApi { const inArgs = [acirComposerPtr, constraintSystemBuf, witnessBuf].map(serializeBufferable); const outTypes: OutputType[] = [BufferDeserializer()]; const result = await this.wasm.callWasmExport( - 'acir_goblin_prove', + 'acir_create_goblin_proof', inArgs, outTypes.map(t => t.SIZE_IN_BYTES), ); @@ -461,23 +433,11 @@ export class BarretenbergApi { return out[0]; } - async acirGoblinVerifyAccumulator(acirComposerPtr: Ptr, proofBuf: Uint8Array): Promise { - const inArgs = [acirComposerPtr, proofBuf].map(serializeBufferable); - const outTypes: OutputType[] = [BoolDeserializer()]; - const result = await this.wasm.callWasmExport( - 'acir_goblin_verify_accumulator', - inArgs, - outTypes.map(t => t.SIZE_IN_BYTES), - ); - const out = result.map((r, i) => outTypes[i].fromBuffer(r)); - return out[0]; - } - - async acirGoblinVerify(acirComposerPtr: Ptr, proofBuf: Uint8Array): Promise { + async acirVerifyGoblinProof(acirComposerPtr: Ptr, proofBuf: Uint8Array): Promise { const inArgs = [acirComposerPtr, proofBuf].map(serializeBufferable); const outTypes: OutputType[] = [BoolDeserializer()]; const result = await this.wasm.callWasmExport( - 'acir_goblin_verify', + 'acir_verify_goblin_proof', inArgs, outTypes.map(t => t.SIZE_IN_BYTES), ); @@ -817,18 +777,6 @@ export class BarretenbergApiSync { return out[0]; } - acirNewGoblinAcirComposer(): Ptr { - const inArgs = [].map(serializeBufferable); - const outTypes: OutputType[] = [Ptr]; - const result = this.wasm.callWasmExport( - 'acir_new_goblin_acir_composer', - inArgs, - outTypes.map(t => t.SIZE_IN_BYTES), - ); - const out = result.map((r, i) => outTypes[i].fromBuffer(r)); - return out[0]; - } - acirDeleteAcirComposer(acirComposerPtr: Ptr): void { const inArgs = [acirComposerPtr].map(serializeBufferable); const outTypes: OutputType[] = []; @@ -882,23 +830,11 @@ export class BarretenbergApiSync { return out[0]; } - acirGoblinAccumulate(acirComposerPtr: Ptr, constraintSystemBuf: Uint8Array, witnessBuf: Uint8Array): Uint8Array { - const inArgs = [acirComposerPtr, constraintSystemBuf, witnessBuf].map(serializeBufferable); - const outTypes: OutputType[] = [BufferDeserializer()]; - const result = this.wasm.callWasmExport( - 'acir_goblin_accumulate', - inArgs, - outTypes.map(t => t.SIZE_IN_BYTES), - ); - const out = result.map((r, i) => outTypes[i].fromBuffer(r)); - return out[0]; - } - - acirGoblinProve(acirComposerPtr: Ptr, constraintSystemBuf: Uint8Array, witnessBuf: Uint8Array): Uint8Array { + acirCreateGoblinProof(acirComposerPtr: Ptr, constraintSystemBuf: Uint8Array, witnessBuf: Uint8Array): Uint8Array { const inArgs = [acirComposerPtr, constraintSystemBuf, witnessBuf].map(serializeBufferable); const outTypes: OutputType[] = [BufferDeserializer()]; const result = this.wasm.callWasmExport( - 'acir_goblin_prove', + 'acir_create_goblin_proof', inArgs, outTypes.map(t => t.SIZE_IN_BYTES), ); @@ -966,23 +902,11 @@ export class BarretenbergApiSync { return out[0]; } - acirGoblinVerifyAccumulator(acirComposerPtr: Ptr, proofBuf: Uint8Array): boolean { - const inArgs = [acirComposerPtr, proofBuf].map(serializeBufferable); - const outTypes: OutputType[] = [BoolDeserializer()]; - const result = this.wasm.callWasmExport( - 'acir_goblin_verify_accumulator', - inArgs, - outTypes.map(t => t.SIZE_IN_BYTES), - ); - const out = result.map((r, i) => outTypes[i].fromBuffer(r)); - return out[0]; - } - - acirGoblinVerify(acirComposerPtr: Ptr, proofBuf: Uint8Array): boolean { + acirVerifyGoblinProof(acirComposerPtr: Ptr, proofBuf: Uint8Array): boolean { const inArgs = [acirComposerPtr, proofBuf].map(serializeBufferable); const outTypes: OutputType[] = [BoolDeserializer()]; const result = this.wasm.callWasmExport( - 'acir_goblin_verify', + 'acir_verify_goblin_proof', inArgs, outTypes.map(t => t.SIZE_IN_BYTES), ); diff --git a/barretenberg/ts/src/main.ts b/barretenberg/ts/src/main.ts index d06de96431d0..208c4851a1f9 100755 --- a/barretenberg/ts/src/main.ts +++ b/barretenberg/ts/src/main.ts @@ -76,7 +76,6 @@ async function initGoblin(bytecodePath: string, crsPath: string) { const hardcodedGrumpkinSubgroupSizeHack = 262144; const initData = await init(bytecodePath, crsPath, hardcodedGrumpkinSubgroupSizeHack); const { api } = initData; - initData.acirComposer = await api.acirNewGoblinAcirComposer(); // Plus 1 needed! (Move +1 into Crs?) // Need both grumpkin and bn254 SRS's currently @@ -129,35 +128,6 @@ export async function proveAndVerify(bytecodePath: string, witnessPath: string, /* eslint-enable camelcase */ } -export async function accumulateAndVerifyGoblin(bytecodePath: string, witnessPath: string, crsPath: string) { - /* eslint-disable camelcase */ - const acir_test = path.basename(process.cwd()); - - const { api, acirComposer, circuitSize, subgroupSize } = await initGoblin(bytecodePath, crsPath); - try { - debug(`In accumulateAndVerifyGoblin:`); - const bytecode = getBytecode(bytecodePath); - const witness = getWitness(witnessPath); - - writeBenchmark('gate_count', circuitSize, { acir_test, threads }); - writeBenchmark('subgroup_size', subgroupSize, { acir_test, threads }); - - debug(`acirGoblinAccumulate()`); - const proofTimer = new Timer(); - const proof = await api.acirGoblinAccumulate(acirComposer, bytecode, witness); - writeBenchmark('proof_construction_time', proofTimer.ms(), { acir_test, threads }); - - debug(`acirVerifyGoblinProof()`); - const verified = await api.acirGoblinVerifyAccumulator(acirComposer, proof); - debug(`verified: ${verified}`); - console.log({ verified }); - return verified; - } finally { - await api.destroy(); - } - /* eslint-enable camelcase */ -} - export async function proveAndVerifyGoblin(bytecodePath: string, witnessPath: string, crsPath: string) { /* eslint-disable camelcase */ const acir_test = path.basename(process.cwd()); @@ -172,11 +142,11 @@ export async function proveAndVerifyGoblin(bytecodePath: string, witnessPath: st writeBenchmark('subgroup_size', subgroupSize, { acir_test, threads }); const proofTimer = new Timer(); - const proof = await api.acirGoblinProve(acirComposer, bytecode, witness); + const proof = await api.acirCreateGoblinProof(acirComposer, bytecode, witness); writeBenchmark('proof_construction_time', proofTimer.ms(), { acir_test, threads }); debug(`verifying...`); - const verified = await api.acirGoblinVerify(acirComposer, proof); + const verified = await api.acirVerifyGoblinProof(acirComposer, proof); debug(`verified: ${verified}`); console.log({ verified }); return verified; @@ -386,20 +356,9 @@ program process.exit(result ? 0 : 1); }); -program - .command('accumulate_and_verify_goblin') - .description('Generate a GUH proof and verify it. Process exits with success or failure code.') - .option('-b, --bytecode-path ', 'Specify the bytecode path', './target/acir.gz') - .option('-w, --witness-path ', 'Specify the witness path', './target/witness.gz') - .action(async ({ bytecodePath, witnessPath, crsPath }) => { - handleGlobalOptions(); - const result = await accumulateAndVerifyGoblin(bytecodePath, witnessPath, crsPath); - process.exit(result ? 0 : 1); - }); - program .command('prove_and_verify_goblin') - .description('Generate a Goblin proof and verify it. Process exits with success or failure code.') + .description('Generate a proof and verify it. Process exits with success or failure code.') .option('-b, --bytecode-path ', 'Specify the bytecode path', './target/acir.gz') .option('-w, --witness-path ', 'Specify the witness path', './target/witness.gz') .action(async ({ bytecodePath, witnessPath, crsPath }) => { diff --git a/boxes/token/src/contracts/src/types/balance_set.nr b/boxes/token/src/contracts/src/types/balance_set.nr index 231320de558d..f81c33db5d48 100644 --- a/boxes/token/src/contracts/src/types/balance_set.nr +++ b/boxes/token/src/contracts/src/types/balance_set.nr @@ -18,6 +18,12 @@ use dep::aztec::note::{ note_interface::NoteInterface, utils::compute_note_hash_for_read_or_nullify, }; +use dep::aztec::oracle::{ + rand::rand, + get_secret_key::get_secret_key, + get_public_key::get_public_key, +}; + use crate::types::token_note::{TokenNote, TOKEN_NOTE_LEN, TokenNoteMethods}; // A set implementing standard manipulation of balances. diff --git a/boxes/token/src/contracts/src/types/token_note.nr b/boxes/token/src/contracts/src/types/token_note.nr index f8adf31959db..ed22cfc0e98f 100644 --- a/boxes/token/src/contracts/src/types/token_note.nr +++ b/boxes/token/src/contracts/src/types/token_note.nr @@ -17,7 +17,7 @@ use dep::aztec::{ }; use dep::aztec::oracle::{ rand::rand, - nullifier_key::get_nullifier_secret_key, + get_secret_key::get_secret_key, get_public_key::get_public_key, }; use dep::safe_math::SafeU120; @@ -72,9 +72,9 @@ impl TokenNote { } // docs:start:nullifier - pub fn compute_nullifier(self, context: &mut PrivateContext) -> Field { + pub fn compute_nullifier(self) -> Field { let note_hash_for_nullify = compute_note_hash_for_read_or_nullify(TokenNoteMethods, self); - let secret = context.request_nullifier_secret_key(self.owner); + let secret = get_secret_key(self.owner); // TODO(#1205) Should use a non-zero generator index. pedersen_hash([ note_hash_for_nullify, @@ -84,17 +84,6 @@ impl TokenNote { } // docs:end:nullifier - pub fn compute_nullifier_without_context(self) -> Field { - let note_hash_for_nullify = compute_note_hash_for_read_or_nullify(TokenNoteMethods, self); - let secret = get_nullifier_secret_key(self.owner); - // TODO(#1205) Should use a non-zero generator index. - pedersen_hash([ - note_hash_for_nullify, - secret.low, - secret.high, - ],0) - } - pub fn set_header(&mut self, header: NoteHeader) { self.header = header; } @@ -127,12 +116,8 @@ fn compute_note_hash(note: TokenNote) -> Field { note.compute_note_hash() } -fn compute_nullifier(note: TokenNote, context: &mut PrivateContext) -> Field { - note.compute_nullifier(context) -} - -fn compute_nullifier_without_context(note: TokenNote) -> Field { - note.compute_nullifier_without_context() +fn compute_nullifier(note: TokenNote) -> Field { + note.compute_nullifier() } fn get_header(note: TokenNote) -> NoteHeader { @@ -153,7 +138,6 @@ global TokenNoteMethods = NoteInterface { serialize, compute_note_hash, compute_nullifier, - compute_nullifier_without_context, get_header, set_header, broadcast, diff --git a/boxes/token/src/contracts/src/types/transparent_note.nr b/boxes/token/src/contracts/src/types/transparent_note.nr index deb2bcdf6f1b..034b4b3390f7 100644 --- a/boxes/token/src/contracts/src/types/transparent_note.nr +++ b/boxes/token/src/contracts/src/types/transparent_note.nr @@ -70,11 +70,7 @@ impl TransparentNote { ],0) } - pub fn compute_nullifier(self, _context: &mut PrivateContext) -> Field { - self.compute_nullifier_without_context() - } - - pub fn compute_nullifier_without_context(self) -> Field { + pub fn compute_nullifier(self) -> Field { // TODO(#1386): should use `compute_note_hash_for_read_or_nullify` once public functions inject nonce! let siloed_note_hash = compute_siloed_note_hash(TransparentNoteMethods, self); // TODO(#1205) Should use a non-zero generator index. @@ -106,12 +102,8 @@ fn compute_note_hash(note: TransparentNote) -> Field { note.compute_note_hash() } -fn compute_nullifier(note: TransparentNote, context: &mut PrivateContext) -> Field { - note.compute_nullifier(context) -} - -fn compute_nullifier_without_context(note: TransparentNote) -> Field { - note.compute_nullifier_without_context() +fn compute_nullifier(note: TransparentNote) -> Field { + note.compute_nullifier() } fn get_header(note: TransparentNote) -> NoteHeader { @@ -131,7 +123,6 @@ global TransparentNoteMethods = NoteInterface { serialize, compute_note_hash, compute_nullifier, - compute_nullifier_without_context, get_header, set_header, broadcast, diff --git a/circuits/cpp/src/aztec3/utils/types/circuit_types.hpp b/circuits/cpp/src/aztec3/utils/types/circuit_types.hpp index e9bc1fc610e3..3f312600c4b9 100644 --- a/circuits/cpp/src/aztec3/utils/types/circuit_types.hpp +++ b/circuits/cpp/src/aztec3/utils/types/circuit_types.hpp @@ -94,4 +94,4 @@ template struct CircuitTypes { static byte_array blake2s(const byte_array& input) { return plonk::stdlib::blake2s(input); } }; -} // namespace aztec3::utils::types +} // namespace aztec3::utils::types \ No newline at end of file diff --git a/docs/docs/about_aztec/history/history.mdx b/docs/docs/about_aztec/history/history.mdx new file mode 100644 index 000000000000..17924b86ce69 --- /dev/null +++ b/docs/docs/about_aztec/history/history.mdx @@ -0,0 +1,97 @@ +--- +title: History of blockchain privacy +--- + +import Image from "@theme/IdealImage"; + +# A brief history of blockchain privacy + + + +--- + +## Bitcoin + +The original blockchain. + +**Programmability**: + +- None. +- Transfer bitcoin only. + +**Privacy**: + +- None. + +--- + +## Ethereum + +**Programmability**: + +- Turing complete smart contracts. + +**Privacy**: + +- Originally: None. +- Now: + - some specific apps on L1 + - some specific apps, deployed via L2, like zk.money and Aztec Connect. + +--- + +## ZCash + +**Programmability**: + +- None. +- Transfer ZCash only. + +**Privacy**: + +- Transfers of shielded zcash are private. + +--- + +## zk.money + +**Programmability**: + +- Any custom ERC20 token (on Ethereum L1) can be deposited to L2, transferred within L2, and withdrawn from L2. + +**Privacy**: + +- Transfers of the ERC20 tokens within the L2 are private. + +--- + +## Aztec Connect + +**Programmability**: + +- The functionality of zk.money, plus: +- Tokens can be sent from the L2 shielded pool to many L1 DeFi contracts, and the resulting tokens can be re-shielded. This gives anonymity to L1 DeFi users. + +**Privacy**: + +- Transfers of the ERC20 tokens within the L2 are private. +- User DeFi interactions are private. + +--- + +## Aztec + +**Programmability**: + +- Fully programmable private smart contracts: + - Private functions which can edit general private state + - Cheap L2 public functions + - L1 (public) functions. + +**Privacy**: + +- Executing private functions grants: + - Function privacy + - Input privacy + - User privacy +- Executing a private function which calls a public function grants varying degrees of privacy, depending on the application someone deploys. (Similar to how deposits and withdrawals to/from shielded pools can leak privacy). diff --git a/docs/docs/about_aztec/overview.mdx b/docs/docs/about_aztec/overview.mdx index c2e3d1b97a38..9bd2afacf191 100644 --- a/docs/docs/about_aztec/overview.mdx +++ b/docs/docs/about_aztec/overview.mdx @@ -10,15 +10,17 @@ Aztec is an L2 that brings programmable privacy to Ethereum. A smart contract on Aztec is a collection of functions, written as ZK-SNARK circuits. These circuits can have different modes of execution: -1. Private Functions -- can read and write private state, read historical public state, consume or send messages to / from Ethereum, and read Ethereum state. They can call other private functions in the same contract, or other contracts, and can call public functions. +1. Secret Functions -- can read and write private state, read historical public state, consume or send messages to / from Ethereum, and read Ethereum state. They can call other secret functions in the same contract, or other contracts, and can call public functions. 2. Public Functions -- can read and write public state, write private state, consume or send messages to / from Ethereum and read Ethereum state. They can call other public functions on the same or other contracts. 3. Portal Contracts -- these are contracts on Ethereum that can receive messages from Aztec or send messages to Aztec from Ethereum contracts. Using these different modes of execution, developers can build applications with user privacy, data privacy and code privacy. -- User privacy - transactions may not reveal information about the sender or the recipient. -- Data privacy - transactions may not reveal information about the payload of the transaction, e.g., the asset or value being transacted. -- Code privacy - transactions may not reveal the program logic. +User privacy -- transactions may not reveal information about the sender or the recipient. + +Data privacy -- transactions may not reveal information about the payload of the transaction, e.g., the asset or value being transacted. + +Code privacy -- transactions may not reveal the program logic. Watch Zac, CEO of Aztec, describe our approach to building a privacy preserving smart contract blockchain. diff --git a/docs/docs/concepts/advanced/data_structures/trees.md b/docs/docs/concepts/advanced/data_structures/trees.md index d29f9c046697..658782ad010c 100644 --- a/docs/docs/concepts/advanced/data_structures/trees.md +++ b/docs/docs/concepts/advanced/data_structures/trees.md @@ -14,7 +14,7 @@ Data includes: - Nullifiers to invalidate old private state ([Nullifier tree](#nullifier-tree)) - Public state ([Public State tree](#public-state-tree)) - Contracts ([Contract tree](#contract-tree)) -- Archive tree for Historical access ([Archive tree](#archive-tree)) +- Previous block headers ([Archive tree](#archive-tree)) - Global Variables ```mermaid @@ -181,37 +181,9 @@ Aztec supports the ability to keep the logic of private functions of a smart con ## Archive Tree -The archive tree is an append-only Merkle tree that stores hashes of headers of all previous blocks in the chain as its leaves. +A block includes the root to the Archive Tree (sometimes called the blocks tree). -As private execution relies on proofs generated by the user, the current block header is not known. We can instead base the proofs on historical state. By including all prior block headers (which include commitments to the state), the historical access tree allows us to easily prove that the historical state that a transaction is using for a proof is valid. - -```mermaid -graph TD; - -PartialStateReference[Partial State
snapshot of note hash tree, nullifier tree, contract tree, public data tree] -StateReference[State Reference
snapshot of L1<>L2 message tree] -GlobalVariables[Global Variables
block number, timestamp, version, chain_id] -Header[Block Header
last snapshot of tree, hash of body] -Logs[Transaction Logs
encrypted & non-encrypted logs] -PublicDataWrite[Public Data Writes
] -ContractData[Contract Data
leaf, address] -TxEffect[Transaction Effects
note hashes, nullifiers, contracts, public writes] -Body[ Body
L1<>L2 messages, transaction effects] -ArchiveTree[Archive Tree
used to validate user-generated proofs and access historical data] - -StateReference --- PartialStateReference -Header --- Body -Header --- StateReference -Header --- GlobalVariables -TxEffect --- ContractData -TxEffect --- PublicDataWrite -TxEffect --- Logs -Body --- TxEffect -HistoricalAccessTree --- Header - -``` - -It can also be used to find information about notes, public state, and contracts that were included in a certain block using [inclusion and non-inclusion proofs](../../../dev_docs/contracts/syntax/historical_access/how_to_prove_history.md). +The leaves of the tree are hashes of previous block headers. This tree can be used to verify data of any of the trees above at some previous point in time by doing a membership check of the corresponding tree root in the block header and the block header hash in the blocks tree. ## Trees of valid Kernel/Rollup circuit Verification Keys diff --git a/docs/docs/concepts/foundation/accounts/keys.md b/docs/docs/concepts/foundation/accounts/keys.md index e5d897d0ffcc..21d0f240c818 100644 --- a/docs/docs/concepts/foundation/accounts/keys.md +++ b/docs/docs/concepts/foundation/accounts/keys.md @@ -82,7 +82,7 @@ Note that any accounts you own that have been added to the PXE are automatically In addition to deriving encryption keys, the privacy master key is used for deriving nullifier secrets. Whenever a private note is consumed, a nullifier deterministically derived from it is emitted. This mechanisms prevents double-spends, since nullifiers are checked by the protocol to be unique. Now, in order to preserve privacy, a third party should not be able to link a note commitment to its nullifier - this link is enforced by the note implementation. Therefore, calculating the nullifier for a note requires a secret from its owner. -An application in Aztec.nr can request a secret from the current user for computing the nullifier of a note via the `request_nullifier_secret_key` api: +An application in Aztec.nr can request a secret from the current user for computing the nullifier of a note via the `get_secret_key` oracle call: #include_code nullifier /yarn-project/aztec-nr/value-note/src/value_note.nr rust diff --git a/docs/docs/concepts/foundation/main.md b/docs/docs/concepts/foundation/main.md index 6c861dfe12d4..5d7e95798829 100644 --- a/docs/docs/concepts/foundation/main.md +++ b/docs/docs/concepts/foundation/main.md @@ -2,31 +2,15 @@ title: Foundational Concepts --- -Aztec Labs is building a layer 2 rollup on Ethereum focused on 3 things: +As a layer 2 rollup on Ethereum, the Aztec network includes components that look similar to other layer 2 networks, but since it handles private state it also includes many new components. -- Data privacy -- Confidentiality -- Trustlessness +On this page we will introduce the high level network architecture for Aztec with an emphasis on the concepts that are core to understanding Aztec, including: -## Data privacy - -Data privacy refers to the ability of Aztec smart contract to have private (encrypted) state. Aztec abstracts away many of the complexities associated with managing private state, providing developers with an interface that feels familiar, but is much more powerful. - - - -## Confidentiality - -Confidentiality is the ability of Aztec smart contracts to execute private functions and transactions. Aztec provides a secure, private environment for the execution of sensitive operations, ensuring private information and decrypted data are not accessible to unauthorized applications. - -When a user sends a private transaction on the network, the only information that an external observer can infer is that a transaction was sent. Transaction data, the sender, and the recipient can all be obfuscated. - -Aztec achieved this level of privacy by leveraging a Private eXecution Environment (PXE). This software runs client-side, for example in a browser, and is responsible for managing private keys, encrypting and decrypting data, and executing private functions. The PXE is also responsible for generating proofs of private function execution, which are then sent to the sequencer for inclusion in the rollup. - -## Trustlessness - -Aztec is building a permissionless, censorship resistant, peer-to-peer network. It aims to be credibly neutral, where the same transparent rules apply to everyone, enforced by the protocol. - -Aztec will have a network of sequencers that stake tokens to participate in the network. Sequencers are responsible for aggregating transactions into a block, generating proofs of the state updates (or delegating proof generation to the prover network) and posting it to the rollup contract on Ethereum, along with any required public data for data availability. +- [The state model](./state_model/main.md) +- [Accounts](./accounts/main.md) +- [Aztec Smart Contracts](./contracts.md) +- [Transactions](./transactions.md) +- [Communication between network components](./communication/main.md) ## High level network architecture @@ -50,8 +34,15 @@ The sequencer aggregates transactions into a block, generates proofs of the stat ## Further Reading -- [The state model](./state_model/main.md) -- [Accounts](./accounts/main.md) -- [Aztec Smart Contracts](./contracts.md) -- [Transactions](./transactions.md) -- [Communication between network components](./communication/main.md) +Here are links to pages with more information about the network components mentioned above: + +- Aztec.js + - [Dapp tutorial](../../dev_docs/tutorials/writing_dapp/main.md) + - [API reference](../../apis/aztec-js) +- Private Execution Environment (PXE) + - [Dapp tutorial](../../dev_docs/tutorials/writing_dapp/pxe_service.md) + - [API reference](../../apis/pxe/index.md) +- [Private Kernel Circuit](../advanced/circuits/kernels/private_kernel.md) +- [Sequencer](./nodes_clients/sequencer.md) +- Prover Network (coming soontm) +- [Rollup Circuit](../advanced/circuits/rollup_circuits/main.md) -- a component of the rollup contract diff --git a/docs/docs/dev_docs/contracts/syntax/historical_access/history_lib_reference.md b/docs/docs/dev_docs/contracts/syntax/historical_access/history_lib_reference.md deleted file mode 100644 index b798a129243b..000000000000 --- a/docs/docs/dev_docs/contracts/syntax/historical_access/history_lib_reference.md +++ /dev/null @@ -1,119 +0,0 @@ ---- -title: History Reference ---- - - - -## Note inclusion - -Note inclusion proves that a note existed (its hash was included in a note hash tree) at a specific block number. - -## prove_note_inclusion - -`prove_note_inclusion` takes 4 parameters: - -| Name | Type | Description | -|-----------------|------------------------|-----------------------------------------------------| -| note_interface | NoteInterface | Interface for the note with necessary functionality| -| note_with_header| Note | The note you are proving inclusion for | -| block_number | u32 | Block number for proving note's existence | -| context | PrivateContext | Private context | - -## prove_note_commitment_inclusion - -A **commitment**, also referred to as a **note hash** is a public acknowledgment of the existence of a note without revealing the content of the note. You can learn more about how to compress a note to a note hash [here](../../../../concepts/advanced/data_structures/trees.md#example-note). - -`prove_note_commitment_inclusion` takes 3 parameters: - -| Name | Type | Description | -|-----------------|------------------------|-----------------------------------------------------| -| commitment | Field | Note commitment we are checking inclusion of | -| block_number | u32 | Block number for proving note's existence | -| context| PrivateContext | Private Context | - -## Note validity - -This proves that a note exists and has not been nullified at a specified block. - -### prove_note_validity - -`prove_note_validity` takes 4 parameters: - -| Name | Type | Description | -|-----------------|------------------------|-----------------------------------------------------| -| note_interface | NoteInterface | Interface for the note with necessary functionality| -| note_with_header| Note | The note you are proving inclusion for | -| block_number | u32 | Block number for proving note's existence | -| context | PrivateContext | Private context | - -## Nullifier inclusion - -This proves that a nullifier was included in a certain block (can be used to prove that a note had been nullified). - -### prove_nullifier_inclusion - -`prove_nullifier_inclusion` takes 3 parameters: - -| Name | Type | Description | -|-----------------|------------------------|-----------------------------------------------------| -| nullifier | Field | The nullifier you are proving inclusion for | -| block_number | u32 | Block number for proving note's existence | -| context | PrivateContext | Private context | - -## Nullifier non inclusion - -This proves that a nullifier was not included in a certain block (can be used to prove that a note had not yet been nullified in a given block). - -### prove_nullifier_non_inclusion - -`prove_nullifier_non_inclusion` takes 3 parameters: - -| Name | Type | Description | -|-----------------|------------------------|-----------------------------------------------------| -| nullifier | Field | The nullifier you are proving inclusion for | -| block_number | u32 | Block number for proving note's existence | -| context | PrivateContext | Private context | - - -### note_not_nullified - -Instead of passing the nullifier, you can check that a note has not been nullified by passing the note. - -## Public value inclusion - -This proves that a public value exists at a certain block. - -### prove_public_value_inclusion - -`prove_public_value_inclusion` takes 4 parameters: - -| Name | Type | Description | -|-----------------|------------------------|-----------------------------------------------------| -| value | Field | The public value you are proving inclusion for | -| storage_slot | Field | Storage slot the value exists in | -| block_number | u32 | Block number for proving value's existence | -| context | PrivateContext | Private context | - -## Contract inclusion - -This proves that a contract exists in, ie had been deployed before or in, a certain block. - -### prove_contract_inclusion - -`prove_contract_inclusion` takes 7 parameters: - -| Name | Type | Description | -|---------------------------|-----------------|-------------------------------------------------------| -| deployer_public_key | GrumpkinPoint | Public key of the contract deployer | -| contract_address_salt | Field | Unique identifier for the contract's address | -| function_tree_root | Field | Root of the contract's function tree | -| constructor_hash | Field | Hash of the contract's constructor | -| portal_contract_address | EthAddress | Ethereum address of the associated portal contract | -| block_number | u32 | Block number for proof verification | -| context | PrivateContext | Private context | - -If there is no associated portal contract, you can use a zero Ethereum address: - -```ts -new EthAddress(Buffer.alloc(EthAddress.SIZE_IN_BYTES)); -``` diff --git a/docs/docs/dev_docs/contracts/syntax/historical_access/how_to_prove_history.md b/docs/docs/dev_docs/contracts/syntax/historical_access/how_to_prove_history.md deleted file mode 100644 index 28e3ea04ccf3..000000000000 --- a/docs/docs/dev_docs/contracts/syntax/historical_access/how_to_prove_history.md +++ /dev/null @@ -1,102 +0,0 @@ ---- -title: How to prove existence of historical notes and nullifiers ---- - -The Aztec Protocol uses an append-only Merkle tree to store hashes of the headers of all previous blocks in the chain as its leaves. This is known as an archive tree. You can learn more about how it works in the [concepts section](../../../../concepts/advanced/data_structures/trees.md#archive-tree). - -# History library - -The history library allows you to prove any of the following at a given block height before the current height: -* [Note inclusion](./history_lib_reference.md#note-inclusion) -* [Nullifier inclusion](./history_lib_reference.md#nullifier-inclusion) -* [Note validity](./history_lib_reference.md#note-validity) -* [Existence of public value](./history_lib_reference.md#public-value-inclusion) -* [Contract inclusion](./history_lib_reference.md#contract-inclusion) - -Using this library, you can check that specific notes or nullifiers were part of Aztec network state at specific blocks. This can be useful for things such as: - -* Verifying a minimum timestamp from a private context -* Checking eligibility based on historical events (e.g. for an airdrop by proving that you owned a note) -* Verifying historic ownership / relinquishing of assets -* Proving existence of a value in public data tree at a given contract slot -* Proving that a contract was deployed in a given block with some parameters - -**In this guide you will learn how to** -* Prove a note was included in a specified block -* Create a nullifier and prove it was not included in a specified block - -For a more extensive reference, go to [the reference page](./history_lib_reference.md). - -## 1. Import the `history` library from `aztec` - -```rust -aztec::{ - #include_code imports yarn-project/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr raw -} -``` - -This imports all functions from the `history` library. You should only import the functions you will use in your contract. - -## 2. Create a note to prove inclusion of - -In general you will likely have the note you want to prove inclusion of. But if you are just experimenting you can create a note with a function like below: - -#include_code create_note yarn-project/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr rust - -## 3. Get the note from the PXE - -Retrieve the note from the user's PXE. - -#include_code get_note_from_pxe yarn-project/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr rust - -In this example, the user's notes are stored in a map called `private_values`. We retrieve this map, then select 1 note from it with the value of `1`. - -## 4. Prove that a note was included in a specified block - -To prove that a note existed in a specified block, call `prove_note_inclusion` as shown in this example: - -#include_code prove_note_inclusion yarn-project/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr rust - -This function takes in 4 arguments: - -1. The note interface (`ValueNoteMethods`) -2. The note (`maybe_note.unwrap_unchecked()`). Here, `unwrap_unchecked()` returns the inner value without asserting `self.is_some()` -3. The block number -4. Private context - -Note: for this to work, you will need to import `ValueNoteMethods` at the beginning of the contract: - -#include_code value_note_imports yarn-project/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr rust - -This will only prove the note existed, not whether or not the note has been nullified. You can prove that a note existed and had not been nullified in a specified block by using `prove_note_validity` which takes the same arguments: - -#include_code prove_note_validity yarn-project/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr rust - -## 5. Create a nullifier to prove inclusion of - -You can easily nullify a note like so: - -#include_code nullify_note yarn-project/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr rust - -This function gets a note from the PXE like we did in [step 3](#3-get-the-note-from-the-pxe) and nullifies it with `remove()`. - -You can then compute this nullifier with `note.compute_nullifier(&mut context)`. - -## 6. Prove that a nullifier was included in a specified block - -Call `prove_nullifier_inclusion` like so: - -#include_code prove_nullifier_inclusion yarn-project/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr rust - -This takes three arguments: -1. The nullifier -2. Block number -3. Private context - -You can also prove that a nullifier was not included in a specified block by using `prove_nullifier_non_inclusion` which takes the same arguments: - -#include_code prove_nullifier_non_inclusion yarn-project/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr rust - -## Prove contract inclusion, public value inclusion, and note commitment inclusion - -To see what else you can do with the `history` library, check out the [reference](./history_lib_reference.md). diff --git a/docs/docs/dev_docs/contracts/syntax/storage/private_state.md b/docs/docs/dev_docs/contracts/syntax/storage/private_state.md index 8b38bb0a3657..bd50c7696a57 100644 --- a/docs/docs/dev_docs/contracts/syntax/storage/private_state.md +++ b/docs/docs/dev_docs/contracts/syntax/storage/private_state.md @@ -72,11 +72,7 @@ As part of the initialization of the `Storage` struct, the `Singleton` is create As mentioned, the Singleton is initialized to create the first note and value. -When this function is called, a nullifier of the storage slot is created, preventing this Singleton from being initialized again. - -:::danger Privacy-Leak -Beware that because this nullifier is created only from the storage slot without randomness it is "leaky". This means that if the storage slot depends on the an address then it is possible to link the nullifier to the address. For example, if the singleton is part of a `map` with an `AztecAddress` as the key then the nullifier will be linked to the address. -::: +When this function is called, a nullifier of the storage slot is created, preventing this Singleton from being initialized again. If an `owner` is specified, the nullifier will be hashed with the owner's secret key. It's crucial to provide an owner if the Singleton is associated with an account. Initializing it without an owner may inadvertently reveal important information about the owner's intention. Unlike public states, which have a default initial value of `0` (or many zeros, in the case of a struct, array or map), a private state (of type `Singleton`, `ImmutableSingleton` or `Set`) does not have a default initial value. The `initialize` method (or `insert`, in the case of a `Set`) must be called. @@ -94,7 +90,7 @@ To update the value of a `Singleton`, we can use the `replace` method. The metho An example of this is seen in a example card game, where we create a new note (a `CardNote`) containing some new data, and replace the current note with it: -#include_code state_vars-SingletonReplace /yarn-project/noir-contracts/contracts/docs_example_contract/src/main.nr rust +#include_code state_vars-SingletonReplace /yarn-project/noir-contracts/contracts/docs_example_contract/src/actions.nr rust If two people are trying to modify the Singleton at the same time, only one will succeed as we don't allow duplicate nullifiers! Developers should put in place appropriate access controls to avoid race conditions (unless a race is intended!). @@ -102,7 +98,7 @@ If two people are trying to modify the Singleton at the same time, only one will This function allows us to get the note of a Singleton, essentially reading the value. -#include_code state_vars-SingletonGet /yarn-project/noir-contracts/contracts/docs_example_contract/src/main.nr rust +#include_code state_vars-SingletonGet /yarn-project/noir-contracts/contracts/docs_example_contract/src/actions.nr rust #### Nullifying Note reads @@ -126,11 +122,7 @@ As part of the initialization of the `Storage` struct, the `Singleton` is create ### `initialize` -When this function is invoked, it creates a nullifier for the storage slot, ensuring that the ImmutableSingleton cannot be initialized again. - -:::danger Privacy-Leak -Beware that because this nullifier is created only from the storage slot without randomness it is "leaky". This means that if the storage slot depends on the an address then it is possible to link the nullifier to the address. For example, if the singleton is part of a `map` with an `AztecAddress` as the key then the nullifier will be linked to the address. -::: +When this function is invoked, it creates a nullifier for the storage slot, ensuring that the ImmutableSingleton cannot be initialized again. If an owner is specified, the nullifier will be hashed with the owner's secret key. It is crucial to provide an owner if the ImmutableSingleton is linked to an account; initializing it without one may inadvertently disclose sensitive information about the owner's intent. Set the value of an ImmutableSingleton by calling the `initialize` method: diff --git a/docs/docs/dev_docs/contracts/syntax/storage/public_state.md b/docs/docs/dev_docs/contracts/syntax/storage/public_state.md index e603cef5e42a..f99deee3b4e6 100644 --- a/docs/docs/dev_docs/contracts/syntax/storage/public_state.md +++ b/docs/docs/dev_docs/contracts/syntax/storage/public_state.md @@ -2,8 +2,9 @@ title: Public State --- -The `PublicState` struct is generic over the variable type `T` and its serialized size `T_SERIALIZED_LEN`. +To define that a variable is public, it is wrapped in the `PublicState` struct. +The `PublicState` struct is generic over the variable type `T` and its serialized size `T_SERIALIZED_LEN`. :::info Currently, the length of the types must be specified when declaring the storage struct but the intention is that this will be inferred in the future. ::: diff --git a/docs/docs/dev_docs/getting_started/core-concepts.md b/docs/docs/dev_docs/getting_started/core-concepts.md index e4549fb97317..cef4b5a6fa69 100644 --- a/docs/docs/dev_docs/getting_started/core-concepts.md +++ b/docs/docs/dev_docs/getting_started/core-concepts.md @@ -4,19 +4,18 @@ title: Core Concepts import Image from '@theme/IdealImage'; -This page outlines Aztec concepts that are essential for developers to understand. Understanding these concepts will help you as you start to dive deeper into smart contracts. +This page outlines Aztec concepts that are essential for developers to understand. Reading and understanding these concepts will help you massively when you start to dive deeper into smart contracts. A little bit of time here can save a lot down the road. -## Aztec Overview +# Aztec Overview - + To sum this up: - 1. A user interacts with Aztec through Aztec.js (like web3js or ethersjs) or Aztec CLI 2. Private functions are executed in the PXE, which is client-side -3. They are rolled up and sent to the Public VM (running on an Aztec node) +3. They are rolled up and sent to the Public VM 4. Public functions are executed in the Public VM 5. The Public VM rolls up the private & public transaction rollups 6. These rollups are submitted to Ethereum @@ -25,20 +24,20 @@ To sum this up: The PXE is unaware of the Public VM. And the Public VM is unaware of the PXE. They are completely separate execution environments. This means: -- The PXE and the Public VM cannot directly communicate with each other -- Private transactions in the PXE are executed first, followed by public transactions +* The PXE and the Public VM cannot directly communicate with each other +* Private transactions in the PXE are executed first, followed by public transactions You can call a public function from a private function by using `context.call_public_function`, like this: #include_code call_public_function yarn-project/noir-contracts/contracts/card_game_contract/src/main.nr rust -You cannot call a private function from a public function, but you can use a [slow updates tree](../contracts/syntax/slow_updates_tree.md) to read historical public state and stage writes to public state from a private function. +You cannot call a private function from a public function, but you can use a slow updates tree to read historical public state and stage writes to public state from a private function. ### Data types -Private state works with UTXOs, or what we call notes. To keep things private, everything is stored in an [append-only UTXO tree](../../concepts/advanced/data_structures/trees.md#note-hash-tree), and a nullifier is created when notes are invalidated. +Private state works with UTXOs, or what we call notes. To keep things private, everything is stored in an append-only UTXO tree, and a nullifier is created when notes are spent. -Public state works similarly to other chains like Ethereum, behaving like a public ledger. +Public state works similarly to other chains like Ethereum, behaving more like a public ledger. Working with private state is like creating commitments and nullifiers to state, whereas working with public state is like directly updating state. @@ -46,43 +45,52 @@ We have abstractions for working with private state so you don't have to worry a For example, let's say you're trying to work with an integer. We have a library called `EasyPrivateUint` that acts like an integer but in the background is actually updating notes in private state. For the public side, we instead have something called `SafeU120`. You cannot use EasyPrivateUint in a public environment, and you cannot use SafeU120 in a private environment. -## Storage +# Storage Currently, when writing Aztec.nr smart contracts, you will need to define two things when initiating storage: 1. The storage struct, ie what you are storing and their types 2. A storage `impl` block with `init` function that will be called when you use the storage in a function +The storage struct looks like this: + +#include_code storage_struct yarn-project/noir-contracts/contracts/token_contract/src/main.nr rust + +The storage impl block looks like this: + +#include_code storage_init yarn-project/noir-contracts/contracts/token_contract/src/main.nr rust + The `init` function must declare the storage struct with an instantiation defining how variables are accessed and manipulated. Each variable must be given a storage slot, which can be anything except 0. The impl block is likely to be abstracted away at a later date. Learn more about how to use storage [here](../contracts/syntax/storage/main.md). -## Portals +# Portals Aztec allows you to interact with Ethereum privately - ie no-one knows where the transaction is coming from, just that it is coming from somewhere on Aztec. This is achieved through portals - these are smart contracts written in Solidity that are related to the Ethereum smart contract you want to interact with. -A portal can be associated with multiple Aztec contracts, but an Aztec contract can only be associated with one portal. +A portal can be associated with multiple Aztec contracts, but an Aztec contract can only be associated with one portal. Learn more about how to work with portals [here](../contracts/portals/main.md). -## Accounts +# Account Abstraction -Every account in Aztec is a smart contract (account abstraction). This allows implementing different schemes for transaction signing, nonce management, and fee payments. +Every account in Aztec is a smart contract. This allows implementing different schemes for transaction signing, nonce management, and fee payments. You can write your own account contract to define the rules by which user transactions are authorized and paid for, as well as how user keys are managed. Learn more about account contracts [here](../../concepts/foundation/accounts/main.md). -## Noir Language +# Noir Language Aztec smart contracts are written in a framework on top of Noir, the zero-knowledge domain-specific language developed specifically for Aztec. Its syntax is similar to Rust. Outside of Aztec, Noir is used for writing circuits that can be verified in Solidity. A cursory understanding of Noir is sufficient for writing Aztec contracts. The [Noir docs](https://noir-lang.org) will be a helpful reference when you start writing more advanced contracts. -## Next steps +Now you're ready to dive into coding: -Continue through the getting started section by reviewing how to write a smart contract contract in [Getting started with Aztec.nr](./aztecnr-getting-started.md). +1. [Learn how to interact with a smart contract in Aztec.js](./aztecjs-getting-started.md) +2. [Write your first Aztec smart contract](./aztecnr-getting-started.md) \ No newline at end of file diff --git a/docs/docs/dev_docs/getting_started/main.md b/docs/docs/dev_docs/getting_started/main.md index f2f343b0c2e7..cfa7fa20c2e9 100644 --- a/docs/docs/dev_docs/getting_started/main.md +++ b/docs/docs/dev_docs/getting_started/main.md @@ -2,19 +2,13 @@ title: Getting Started --- -## Build - -If this is your first time using Aztec, and you want to get started by learning by doing, head to the [Quickstart section](quickstart.md). This section is the entry point to: +In this section, you will 1. Set up the Aztec sandbox and deploy a sample first contract with the CLI 2. Deploy and interact with a contract using Aztec.js 3. Write your first smart contract in Aztec.nr -## Learn - -If you want to read more about the high level concepts of Aztec before writing some code, head to the [Foundational Concepts section](../../concepts/foundation/main.md). - -## In this section +The whole section should take you less than 60 minutes. import DocCardList from '@theme/DocCardList'; diff --git a/docs/docs/dev_docs/getting_started/quickstart.md b/docs/docs/dev_docs/getting_started/quickstart.md index 62b56e10afe0..b5120e844894 100644 --- a/docs/docs/dev_docs/getting_started/quickstart.md +++ b/docs/docs/dev_docs/getting_started/quickstart.md @@ -4,8 +4,8 @@ title: Quickstart In this guide, you will -1. Set up the Aztec sandbox (local development environment) locally -2. Install the Aztec development kit +1. Set up the Aztec sandbox locally +2. Install the Aztec CLI 3. Use the CLI to deploy an example contract that comes with the sandbox 4. Use the CLI to interact with the contract you just deployed @@ -17,7 +17,7 @@ In this guide, you will ## Install Docker -See [this page of the Docker docs](https://docs.docker.com/get-docker/) for instructions on how to install Docker Desktop for your operating system. +See this page of the Docker docs for instructions on how to install Docker Desktop for your operating system: [https://docs.docker.com/get-docker/](https://docs.docker.com/get-docker/) Once you have Docker installed, make sure it is running by opening the Docker Desktop application. diff --git a/docs/docs/dev_docs/tutorials/token_portal/depositing_to_aztec.md b/docs/docs/dev_docs/tutorials/token_portal/depositing_to_aztec.md index 9452657be1f5..bbb5915ff12d 100644 --- a/docs/docs/dev_docs/tutorials/token_portal/depositing_to_aztec.md +++ b/docs/docs/dev_docs/tutorials/token_portal/depositing_to_aztec.md @@ -8,20 +8,7 @@ In this step, we will write our token portal contract on L1. In `l1-contracts/contracts` in your file called `TokenPortal.sol` paste this: -```solidity -pragma solidity >=0.8.18; - -import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; - -// Messaging -import {IRegistry} from "@aztec/l1-contracts/src/core/interfaces/messagebridge/IRegistry.sol"; -import {IInbox} from "@aztec/l1-contracts/src/core/interfaces/messagebridge/IInbox.sol"; -import {DataStructures} from "@aztec/l1-contracts/src/core/libraries/DataStructures.sol"; -import {Hash} from "@aztec/l1-contracts/src/core/libraries/Hash.sol"; - -#include_code init /l1-contracts/test/portals/TokenPortal.sol raw -``` +#include_code init /l1-contracts/test/portals/TokenPortal.sol solidity This imports relevant files including the interfaces used by the Aztec rollup. And initializes the contract with the following parameters: diff --git a/docs/docs/dev_docs/tutorials/token_portal/setup.md b/docs/docs/dev_docs/tutorials/token_portal/setup.md index 3f738e02fc0f..2c1e4472f48a 100644 --- a/docs/docs/dev_docs/tutorials/token_portal/setup.md +++ b/docs/docs/dev_docs/tutorials/token_portal/setup.md @@ -62,8 +62,7 @@ type = "contract" [dependencies] aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/aztec" } -token_portal_content_hash_lib = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/noir-contracts/contracts/token_portal_content_hash_lib" } -protocol_types = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/noir-protocol-circuits/src/crates/types"} +token_portal_content_hash_lib = { git="https://github.com/AztecProtocol/aztec-packages/", tag="aztec-packages-v0.16.9", directory="yarn-project/noir-contracts/contracts/token_portal_content_hash_lib" } ``` We will also be writing some helper functions that should exist elsewhere so we don't overcomplicated our contract. In `src` create two more files - one called `util.nr` and one called `token_interface` - so your dir structure should now look like this: @@ -75,7 +74,6 @@ aztec-contracts ├── src ├── main.nr ├── token_interface.nr - ├── util.nr ``` # Create a JS hardhat project @@ -101,7 +99,7 @@ touch TokenPortal.sol Now add dependencies that are required. These include interfaces to Aztec Inbox, Outbox and Registry smart contracts, OpenZeppelin contracts, and NomicFoundation. ```bash -yarn add @aztec/foundation @aztec/l1-contracts @openzeppelin/contracts && yarn add --dev @nomicfoundation/hardhat-network-helpers @nomicfoundation/hardhat-chai-matchers @nomiclabs/hardhat-ethers @nomiclabs/hardhat-etherscan @types/chai @types/mocha @typechain/ethers-v5 @typechain/hardhat chai@4.0.0 hardhat-gas-reporter solidity-coverage ts-node typechain typescript +yarn add @aztec/foundation @aztec/l1-contracts @openzeppelin/contracts && yarn add --dev @nomicfoundation/hardhat-network-helpers @nomicfoundation/hardhat-chai-matchers @nomiclabs/hardhat-ethers @nomiclabs/hardhat-etherscan @types/chai @types/mocha @typechain/ethers-v5 @typechain/hardhat chai hardhat-gas-reporter solidity-coverage ts-node typechain typescript ``` @@ -131,7 +129,7 @@ Inside the `packages` directory, run ```bash mkdir src && cd src && yarn init -yp -yarn add typescript @aztec/aztec.js @aztec/accounts @aztec/noir-contracts @aztec/types @aztec/foundation @aztec/l1-artifacts viem@1.21.4 "@types/node@^20.8.2" +yarn add @aztec/aztec.js @aztec/accounts @aztec/noir-contracts @aztec/circuit-types @aztec/foundation @aztec/l1-artifacts viem "@types/node@^20.8.2" yarn add -D jest @jest/globals ts-jest ``` @@ -146,7 +144,7 @@ In `package.json`, add: } ``` -Your `package.json` should look something like this (do not copy and paste): +Your `package.json` should look something like this: ```json { @@ -156,11 +154,18 @@ Your `package.json` should look something like this (do not copy and paste): "license": "MIT", "private": true, "type": "module", - "dependencies": { - "dep": "version", + "dependencies": { + "@aztec/aztec.js": "^0.8.7", + "@aztec/foundation": "^0.8.7", + "@aztec/noir-contracts": "^0.8.7", + "@aztec/circuit-types": "^0.8.7", + "@types/node": "^20.8.2", + "ethers": "^5.7" }, "devDependencies": { - "dep": "version", + "@jest/globals": "^29.7.0", + "jest": "^29.7.0", + "ts-jest": "^29.1.1" }, "scripts": { "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest)" @@ -222,6 +227,12 @@ Then create a jest config file: `jest.config.json` } ``` +You will also need to install some dependencies: + +```bash +yarn add --dev typescript @types/jest ts-jest +``` + Finally, we will create a test file. Run this in the `src` directory.: ```bash @@ -238,7 +249,6 @@ src └── cross_chain_messaging.test.ts ├── jest.config.json ├── package.json -├── tsconfig.json ``` In the next step, we’ll start writing our L1 smart contract with some logic to deposit tokens to Aztec from L1. diff --git a/docs/docs/dev_docs/tutorials/token_portal/typescript_glue_code.md b/docs/docs/dev_docs/tutorials/token_portal/typescript_glue_code.md index ca4e63c19941..7adc80a0154b 100644 --- a/docs/docs/dev_docs/tutorials/token_portal/typescript_glue_code.md +++ b/docs/docs/dev_docs/tutorials/token_portal/typescript_glue_code.md @@ -4,12 +4,19 @@ title: Deploy & Call Contracts with Typescript In this step we will write a Typescript test to interact with the sandbox and call our contracts! +Go to the `src/test` directory in your `packages` dir and create a new file called `cross_chain_messaging.test.ts`: + +```bash +cd src/test +touch cross_chain_messaging.test.ts +``` + ## Test imports and setup We need some helper files that can keep our code clean. Inside your `src/test` directory: ```bash -cd fixtures +mkdir fixtures && cd fixtures touch utils.ts cd .. && mkdir shared && cd shared touch cross_chain_test_harness.ts @@ -40,8 +47,8 @@ Open `cross_chain_messaging.test.ts` and paste the initial description of the te ```typescript import { expect, jest} from '@jest/globals' -import { AccountWallet, AztecAddress, DebugLogger, EthAddress, Fr, computeAuthWitMessageHash, createDebugLogger, createPXEClient, waitForSandbox } from '@aztec/aztec.js'; -import { getSandboxAccountsWallets } from '@aztec/accounts/testing'; +import { AccountWallet, AztecAddress, DebugLogger, EthAddress, Fr, computeAuthWitMessageHash, createDebugLogger, createPXEClient, waitForPXE } from '@aztec/aztec.js'; +import { getInitialTestAccountsWallets } from '@aztec/accounts/testing'; import { TokenContract } from '@aztec/noir-contracts/Token'; import { TokenBridgeContract } from '@aztec/noir-contracts/TokenBridge'; @@ -73,8 +80,8 @@ describe('e2e_cross_chain_messaging', () => { beforeEach(async () => { logger = createDebugLogger('aztec:e2e_uniswap'); const pxe = createPXEClient(PXE_URL); - await waitForSandbox(pxe); - const wallets = await getSandboxAccountsWallets(pxe); + await waitForPXE(pxe); + const wallets = await getInitialTestAccountsWallets(pxe); const walletClient = createWalletClient({ account: hdAccount, diff --git a/docs/docs/dev_docs/tutorials/token_portal/withdrawing_to_l1.md b/docs/docs/dev_docs/tutorials/token_portal/withdrawing_to_l1.md index 8716421c10b7..fd2a2ea17218 100644 --- a/docs/docs/dev_docs/tutorials/token_portal/withdrawing_to_l1.md +++ b/docs/docs/dev_docs/tutorials/token_portal/withdrawing_to_l1.md @@ -42,10 +42,8 @@ For both the public and private flow, we use the same mechanism to determine the After the transaction is completed on L2, the portal must call the outbox to successfully transfer funds to the user on L1. Like with deposits, things can be complex here. For example, what happens if the transaction was done on L2 to burn tokens but can’t be withdrawn to L1? Then the funds are lost forever! How do we prevent this? Paste this in your `TokenPortal.sol`: -```solidity -#include_code token_portal_withdraw /l1-contracts/test/portals/TokenPortal.sol raw -} -``` + +#include_code token_portal_withdraw /l1-contracts/test/portals/TokenPortal.sol solidity Here we reconstruct the L2 to L1 message and check that this message exists on the outbox. If so, we consume it and transfer the funds to the recipient. As part of the reconstruction, the content hash looks similar to what we did in our bridge contract on aztec where we pass the amount and recipient to the the hash. This way a malicious actor can’t change the recipient parameter to the address and withdraw funds to themselves. @@ -55,17 +53,13 @@ We call this pattern _designed caller_ which enables a new paradigm **where we c Before we can compile and use the contract, we need to add two additional functions. -We need a function that lets us read the token value. Paste this into `main.nr`: +We need a function that let's us read the token value. #include_code read_token /yarn-project/noir-contracts/contracts/token_bridge_contract/src/main.nr rust -And the `compute_note_hash_and_nullifier` required on every contract: - -```rust -#include_code compute_note_hash_and_nullifier_placeholder /yarn-project/noir-contracts/contracts/token_bridge_contract/src/main.nr raw -} -``` +And the `compute_note_hash_and_nullifier` required on every contract. +#include_code compute_note_hash_and_nullifier_placeholder /yarn-project/noir-contracts/contracts/token_bridge_contract/src/main.nr rust ## Compile code @@ -81,14 +75,14 @@ npx hardhat compile And compile your Aztec.nr contracts like this: ```bash -cd aztec-contracts/token_bridge +cd aztec-contracts/token-bridge aztec-nargo compile ``` And generate the TypeScript interface for the contract and add it to the test dir: ```bash -aztec-cli codegen target -o ../../src/test/fixtures --ts +aztec-cli codegen target -o ../../../src/test/fixtures --ts ``` This will create a TS interface in our `src/test` folder! diff --git a/docs/docs/dev_docs/tutorials/writing_private_voting_contract.md b/docs/docs/dev_docs/tutorials/writing_private_voting_contract.md index c8ab1e70f641..b5e6f0847211 100644 --- a/docs/docs/dev_docs/tutorials/writing_private_voting_contract.md +++ b/docs/docs/dev_docs/tutorials/writing_private_voting_contract.md @@ -71,7 +71,7 @@ Inside this, paste these imports: We are using various utils within the Aztec library: - `context` - exposes things such as the contract address, msg_sender, etc -- `context.request_nullifier_secret_key` - get your secret key to help us create a randomized nullifier +- `oracle::get_secret_key` - get your secret key to help us create a randomized nullifier - `FunctionSelector::from_signature` - compute a function selector from signature so we can call functions from other functions - `state_vars::{ map::Map, public_state::PublicState, }` - we will use a Map to store the votes (key = voteId, value = number of votes), and PublicState to hold our public values that we mentioned earlier - `types::type_serialization::{..}` - various serialization methods for defining how to use these types diff --git a/docs/docs/intro.md b/docs/docs/intro.md index ca9ff902fe90..f6f5757ad438 100644 --- a/docs/docs/intro.md +++ b/docs/docs/intro.md @@ -7,22 +7,66 @@ description: "Aztec introduces a privacy-centric zkRollup solution for Ethereum, # Aztec: Ethereum, encrypted -On Ethereum today, everything is publicly visible, by everyone. In the real world, people enjoy privacy. Aztec brings privacy to Ethereum. +On Ethereum today, everything is publicly visible, by everyone. -## Get started +In the real world, people enjoy privacy. -### Learn :book: +Aztec brings privacy to Ethereum. -Start on the [Foundational Concepts page](./concepts/foundation/main.md) to read about how Aztec works. +--- + +## Build with confidence. + +Design, build, and deploy private smart contracts with the following features: + +- Private functions +- Private arguments +- Private persistent state +- Private bytecode +- Private deployments +- Private execution +- Private transactions +- Private contract composability +- Encrypted state transitions +- Encrypted logs + +Plus: + +- Composability with Ethereum L1 +- Access to Ethereum's L1 liquidity +- Cheap, public logic, if you need it +- Cheap, public persistent state, if you need it + +--- + +## Play + +Visit the [getting started](./dev_docs/getting_started/main) section for an introduction. + +Go to the [Tutorials](./dev_docs/tutorials/main.md) section to dive into some more advanced walkthroughs. + +--- + +## But what _is_ Aztec? + +Aztec encrypts Ethereum. + +Aztec is the privacy layer of Ethereum. + +Aztec is a private smart contract platform. + +Aztec is a _fully programmable_ private smart contract platform. + +Aztec is an Ethereum Layer 2. -### Build :technologist: +Aztec is a zk-zk rollup. -Go to the [Getting Started section](./dev_docs/getting_started/main.md) of the developer docs to get your hands dirty and start developing on Aztec. +Aztec is a hybrid private/public rollup. -#### Go deeper 🔬 +Aztec is a network. -Check out the [Awesome Aztec repo](https://github.com/AztecProtocol/awesome-aztec) for a curated list of learning resources and tools to help you learn more about Aztec. +Still confused? Explore these docs! -Clone the [Aztec Starter repo](https://github.com/AztecProtocol/aztec-starter) to get a minimal project set up with Sandbox (local developer network), a simple contract and a test suite. +## Participate -Jump into one of the [tutorials](./dev_docs/tutorials/main.md) to learn how to build more complex applications on Aztec. +We are building the Aztec network in public. Keep up with the latest discussion and join the conversation in the [Aztec forum](https://discourse.aztec.network) and check out our code on [Github](https://github.com/AztecProtocol). diff --git a/docs/docs/misc/migration_notes.md b/docs/docs/misc/migration_notes.md index 54a95d598f92..262e693d2b55 100644 --- a/docs/docs/misc/migration_notes.md +++ b/docs/docs/misc/migration_notes.md @@ -6,61 +6,6 @@ keywords: [sandbox, cli, aztec, notes, migration, updating, upgrading] Aztec is in full-speed development. Literally every version breaks compatibility with the previous ones. This page attempts to target errors and difficulties you might encounter when upgrading, and how to resolve them. -## 0.20.0 - -### [Aztec.nr] Changes to `NoteInterface` - -1. Changing `compute_nullifier()` to `compute_nullifier(private_context: PrivateContext)` - - This API is invoked for nullifier generation within private functions. When using a secret key for nullifier creation, retrieve it through: - - `private_context.request_nullifier_secret_key(account_address)` - - The private context will generate a request for the kernel circuit to validate that the secret key does belong to the account. - - Before: - - ```rust - pub fn compute_nullifier(self) -> Field { - let secret = oracle.get_secret_key(self.owner); - pedersen_hash([ - self.value, - secret.low, - secret.high, - ]) - } - ``` - - Now: - - ```rust - pub fn compute_nullifier(self, context: &mut PrivateContext) -> Field { - let secret = context.request_nullifier_secret_key(self.owner); - pedersen_hash([ - self.value, - secret.low, - secret.high, - ]) - } - ``` - -2. New API `compute_nullifier_without_context()`. - - This API is used within unconstrained functions where the private context is not available, and using an unverified nullifier key won't affect the network or other users. For example, it's used in `compute_note_hash_and_nullifier()` to compute values for the user's own notes. - - ```rust - pub fn compute_nullifier_without_context(self) -> Field { - let secret = oracle.get_nullifier_secret_key(self.owner); - pedersen_hash([ - self.value, - secret.low, - secret.high, - ]) - } - ``` - - > Note that the `get_secret_key` oracle API has been renamed to `get_nullifier_secret_key`. - ## 0.18.0 ### [Aztec.nr] Remove `protocol_types` from Nargo.toml @@ -73,10 +18,9 @@ aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_ ### [Aztec.nr] key type definition in Map -The `Map` class now requires defining the key type in its declaration which _must_ implement the `ToField` trait. +The `Map` class now requires defining the key type in its declaration which *must* implement the `ToField` trait. Before: - ```rust struct Storage { balances: Map> @@ -86,7 +30,6 @@ let user_balance = balances.at(owner.to_field()) ``` Now: - ```rust struct Storage { balances: Map> @@ -97,31 +40,29 @@ let user_balance = balances.at(owner) ### [js] Updated function names -- `waitForSandbox` renamed to `waitForPXE` in `@aztec/aztec.js` +- `waitForSandbox` renamed to `waitForPXE` in `@aztec/aztec.js` - `getSandboxAccountsWallets` renamed to `getInitialTestAccountsWallets` in `@aztec/accounts/testing` ## 0.17.0 ### [js] New `@aztec/accounts` package -Before: +Before: ```js -import { getSchnorrAccount } from "@aztec/aztec.js"; // previously you would get the default accounts from the `aztec.js` package: +import { getSchnorrAccount } from "@aztec/aztec.js" // previously you would get the default accounts from the `aztec.js` package: ``` Now, import them from the new package `@aztec/accounts` ```js -import { getSchnorrAccount } from "@aztec/accounts"; +import { getSchnorrAccount } from "@aztec/accounts" ``` ### Typed Addresses - Address fields in Aztec.nr now is of type `AztecAddress` as opposed to `Field` Before: - ```rust unconstrained fn compute_note_hash_and_nullifier(contract_address: Field, nonce: Field, storage_slot: Field, serialized_note: [Field; VALUE_NOTE_LEN]) -> [Field; 4] { let note_header = NoteHeader::new(_address, nonce, storage_slot); @@ -129,7 +70,6 @@ unconstrained fn compute_note_hash_and_nullifier(contract_address: Field, nonce: ``` Now: - ```rust unconstrained fn compute_note_hash_and_nullifier( contract_address: AztecAddress, @@ -144,48 +84,39 @@ Similarly, there are changes when using aztec.js to call functions. To parse a `AztecAddress` to BigInt, use `.inner` Before: - ```js -const tokenBigInt = await bridge.methods.token().view(); +const tokenBigInt = await bridge.methods.token().view() ``` Now: - ```js -const tokenBigInt = (await bridge.methods.token().view()).inner; +const tokenBigInt = (await bridge.methods.token().view()).inner ``` ### [Aztec.nr] Add `protocol_types` to Nargo.toml - ```toml aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/aztec" } protocol_types = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/noir-protocol-circuits/src/crates/types"} ``` ### [Aztec.nr] moving compute_address func to AztecAddress - Before: - ```rust let calculated_address = compute_address(pub_key_x, pub_key_y, partial_address); ``` Now: - ```rust let calculated_address = AztecAddress::compute(pub_key_x, pub_key_y, partial_address); ``` ### [Aztec.nr] moving `compute_selector` to FunctionSelector - Before: - ```rust let selector = compute_selector("_initialize((Field))"); ``` Now: - ```rust let selector = FunctionSelector::from_signature("_initialize((Field))"); ``` @@ -195,13 +126,11 @@ let selector = FunctionSelector::from_signature("_initialize((Field))"); Contracts are now imported from a file with the type's name. Before: - ```js import { TokenContract } from "@aztec/noir-contracts/types"; ``` Now: - ```js import { TokenContract } from "@aztec/noir-contracts/Token"; ``` @@ -211,7 +140,6 @@ import { TokenContract } from "@aztec/noir-contracts/Token"; Aztec contracts are now moved outside of the `src` folder, so you need to update your imports. Before: - ```rust easy_private_token_contract = {git = "https://github.com/AztecProtocol/aztec-packages/", tag ="v0.16.9", directory = "yarn-project/noir-contracts/src/contracts/easy_private_token_contract"} ``` diff --git a/docs/sidebars.js b/docs/sidebars.js index 1e94f85f3544..bfa154565249 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -32,7 +32,7 @@ const sidebars = { label: "What is Aztec?", type: "category", link: { type: "doc", id: "intro" }, - items: ["about_aztec/overview"], + items: ["about_aztec/history/history", "about_aztec/overview"], }, "about_aztec/vision", @@ -217,8 +217,8 @@ const sidebars = { items: [ "dev_docs/getting_started/quickstart", "dev_docs/getting_started/core-concepts", - "dev_docs/getting_started/aztecnr-getting-started", "dev_docs/getting_started/aztecjs-getting-started", + "dev_docs/getting_started/aztecnr-getting-started", ], }, @@ -330,16 +330,7 @@ const sidebars = { }, "dev_docs/contracts/syntax/events", "dev_docs/contracts/syntax/functions", - { - label: "Proving Historical Blockchain Data", - type: "category", - items: [ - "dev_docs/contracts/syntax/historical_access/how_to_prove_history", - "dev_docs/contracts/syntax/historical_access/history_lib_reference", - ], - }, "dev_docs/contracts/syntax/slow_updates_tree", - "dev_docs/contracts/syntax/context", "dev_docs/contracts/syntax/globals", ], diff --git a/docs/yarn.lock b/docs/yarn.lock index be4e6d0886b7..3ac7b7d4c221 100644 --- a/docs/yarn.lock +++ b/docs/yarn.lock @@ -2,162 +2,153 @@ # yarn lockfile v1 -"@algolia/autocomplete-core@1.9.3": - version "1.9.3" - resolved "https://registry.yarnpkg.com/@algolia/autocomplete-core/-/autocomplete-core-1.9.3.tgz#1d56482a768c33aae0868c8533049e02e8961be7" - integrity sha512-009HdfugtGCdC4JdXUbVJClA0q0zh24yyePn+KUGk3rP7j8FEe/m5Yo/z65gn6nP/cM39PxpzqKrL7A6fP6PPw== - dependencies: - "@algolia/autocomplete-plugin-algolia-insights" "1.9.3" - "@algolia/autocomplete-shared" "1.9.3" - -"@algolia/autocomplete-plugin-algolia-insights@1.9.3": - version "1.9.3" - resolved "https://registry.yarnpkg.com/@algolia/autocomplete-plugin-algolia-insights/-/autocomplete-plugin-algolia-insights-1.9.3.tgz#9b7f8641052c8ead6d66c1623d444cbe19dde587" - integrity sha512-a/yTUkcO/Vyy+JffmAnTWbr4/90cLzw+CC3bRbhnULr/EM0fGNvM13oQQ14f2moLMcVDyAx/leczLlAOovhSZg== +"@algolia/autocomplete-core@1.7.4": + version "1.7.4" + resolved "https://registry.yarnpkg.com/@algolia/autocomplete-core/-/autocomplete-core-1.7.4.tgz#85ff36b2673654a393c8c505345eaedd6eaa4f70" + integrity sha512-daoLpQ3ps/VTMRZDEBfU8ixXd+amZcNJ4QSP3IERGyzqnL5Ch8uSRFt/4G8pUvW9c3o6GA4vtVv4I4lmnkdXyg== dependencies: - "@algolia/autocomplete-shared" "1.9.3" + "@algolia/autocomplete-shared" "1.7.4" -"@algolia/autocomplete-preset-algolia@1.9.3": - version "1.9.3" - resolved "https://registry.yarnpkg.com/@algolia/autocomplete-preset-algolia/-/autocomplete-preset-algolia-1.9.3.tgz#64cca4a4304cfcad2cf730e83067e0c1b2f485da" - integrity sha512-d4qlt6YmrLMYy95n5TB52wtNDr6EgAIPH81dvvvW8UmuWRgxEtY0NJiPwl/h95JtG2vmRM804M0DSwMCNZlzRA== +"@algolia/autocomplete-preset-algolia@1.7.4": + version "1.7.4" + resolved "https://registry.yarnpkg.com/@algolia/autocomplete-preset-algolia/-/autocomplete-preset-algolia-1.7.4.tgz#610ee1d887962f230b987cba2fd6556478000bc3" + integrity sha512-s37hrvLEIfcmKY8VU9LsAXgm2yfmkdHT3DnA3SgHaY93yjZ2qL57wzb5QweVkYuEBZkT2PIREvRoLXC2sxTbpQ== dependencies: - "@algolia/autocomplete-shared" "1.9.3" + "@algolia/autocomplete-shared" "1.7.4" -"@algolia/autocomplete-shared@1.9.3": - version "1.9.3" - resolved "https://registry.yarnpkg.com/@algolia/autocomplete-shared/-/autocomplete-shared-1.9.3.tgz#2e22e830d36f0a9cf2c0ccd3c7f6d59435b77dfa" - integrity sha512-Wnm9E4Ye6Rl6sTTqjoymD+l8DjSTHsHboVRYrKgEt8Q7UHm9nYbqhN/i0fhUYA3OAEH7WA8x3jfpnmJm3rKvaQ== +"@algolia/autocomplete-shared@1.7.4": + version "1.7.4" + resolved "https://registry.yarnpkg.com/@algolia/autocomplete-shared/-/autocomplete-shared-1.7.4.tgz#78aea1140a50c4d193e1f06a13b7f12c5e2cbeea" + integrity sha512-2VGCk7I9tA9Ge73Km99+Qg87w0wzW4tgUruvWAn/gfey1ZXgmxZtyIRBebk35R1O8TbK77wujVtCnpsGpRy1kg== -"@algolia/cache-browser-local-storage@4.22.1": - version "4.22.1" - resolved "https://registry.yarnpkg.com/@algolia/cache-browser-local-storage/-/cache-browser-local-storage-4.22.1.tgz#14b6dc9abc9e3a304a5fffb063d15f30af1032d1" - integrity sha512-Sw6IAmOCvvP6QNgY9j+Hv09mvkvEIDKjYW8ow0UDDAxSXy664RBNQk3i/0nt7gvceOJ6jGmOTimaZoY1THmU7g== +"@algolia/cache-browser-local-storage@4.14.3": + version "4.14.3" + resolved "https://registry.yarnpkg.com/@algolia/cache-browser-local-storage/-/cache-browser-local-storage-4.14.3.tgz#b9e0da012b2f124f785134a4d468ee0841b2399d" + integrity sha512-hWH1yCxgG3+R/xZIscmUrWAIBnmBFHH5j30fY/+aPkEZWt90wYILfAHIOZ1/Wxhho5SkPfwFmT7ooX2d9JeQBw== dependencies: - "@algolia/cache-common" "4.22.1" + "@algolia/cache-common" "4.14.3" -"@algolia/cache-common@4.22.1": - version "4.22.1" - resolved "https://registry.yarnpkg.com/@algolia/cache-common/-/cache-common-4.22.1.tgz#c625dff4bc2a74e79f9aed67b4e053b0ef1b3ec1" - integrity sha512-TJMBKqZNKYB9TptRRjSUtevJeQVXRmg6rk9qgFKWvOy8jhCPdyNZV1nB3SKGufzvTVbomAukFR8guu/8NRKBTA== +"@algolia/cache-common@4.14.3": + version "4.14.3" + resolved "https://registry.yarnpkg.com/@algolia/cache-common/-/cache-common-4.14.3.tgz#a78e9faee3dfec018eab7b0996e918e06b476ac7" + integrity sha512-oZJofOoD9FQOwiGTzyRnmzvh3ZP8WVTNPBLH5xU5JNF7drDbRT0ocVT0h/xB2rPHYzOeXRrLaQQBwRT/CKom0Q== -"@algolia/cache-in-memory@4.22.1": - version "4.22.1" - resolved "https://registry.yarnpkg.com/@algolia/cache-in-memory/-/cache-in-memory-4.22.1.tgz#858a3d887f521362e87d04f3943e2810226a0d71" - integrity sha512-ve+6Ac2LhwpufuWavM/aHjLoNz/Z/sYSgNIXsinGofWOysPilQZPUetqLj8vbvi+DHZZaYSEP9H5SRVXnpsNNw== +"@algolia/cache-in-memory@4.14.3": + version "4.14.3" + resolved "https://registry.yarnpkg.com/@algolia/cache-in-memory/-/cache-in-memory-4.14.3.tgz#96cefb942aeb80e51e6a7e29f25f4f7f3439b736" + integrity sha512-ES0hHQnzWjeioLQf5Nq+x1AWdZJ50znNPSH3puB/Y4Xsg4Av1bvLmTJe7SY2uqONaeMTvL0OaVcoVtQgJVw0vg== dependencies: - "@algolia/cache-common" "4.22.1" + "@algolia/cache-common" "4.14.3" -"@algolia/client-account@4.22.1": - version "4.22.1" - resolved "https://registry.yarnpkg.com/@algolia/client-account/-/client-account-4.22.1.tgz#a7fb8b66b9a4f0a428e1426b2561144267d76d43" - integrity sha512-k8m+oegM2zlns/TwZyi4YgCtyToackkOpE+xCaKCYfBfDtdGOaVZCM5YvGPtK+HGaJMIN/DoTL8asbM3NzHonw== +"@algolia/client-account@4.14.3": + version "4.14.3" + resolved "https://registry.yarnpkg.com/@algolia/client-account/-/client-account-4.14.3.tgz#6d7d032a65c600339ce066505c77013d9a9e4966" + integrity sha512-PBcPb0+f5Xbh5UfLZNx2Ow589OdP8WYjB4CnvupfYBrl9JyC1sdH4jcq/ri8osO/mCZYjZrQsKAPIqW/gQmizQ== dependencies: - "@algolia/client-common" "4.22.1" - "@algolia/client-search" "4.22.1" - "@algolia/transporter" "4.22.1" + "@algolia/client-common" "4.14.3" + "@algolia/client-search" "4.14.3" + "@algolia/transporter" "4.14.3" -"@algolia/client-analytics@4.22.1": - version "4.22.1" - resolved "https://registry.yarnpkg.com/@algolia/client-analytics/-/client-analytics-4.22.1.tgz#506558740b4d49b1b1e3393861f729a8ce921851" - integrity sha512-1ssi9pyxyQNN4a7Ji9R50nSdISIumMFDwKNuwZipB6TkauJ8J7ha/uO60sPJFqQyqvvI+px7RSNRQT3Zrvzieg== +"@algolia/client-analytics@4.14.3": + version "4.14.3" + resolved "https://registry.yarnpkg.com/@algolia/client-analytics/-/client-analytics-4.14.3.tgz#ca409d00a8fff98fdcc215dc96731039900055dc" + integrity sha512-eAwQq0Hb/aauv9NhCH5Dp3Nm29oFx28sayFN2fdOWemwSeJHIl7TmcsxVlRsO50fsD8CtPcDhtGeD3AIFLNvqw== dependencies: - "@algolia/client-common" "4.22.1" - "@algolia/client-search" "4.22.1" - "@algolia/requester-common" "4.22.1" - "@algolia/transporter" "4.22.1" + "@algolia/client-common" "4.14.3" + "@algolia/client-search" "4.14.3" + "@algolia/requester-common" "4.14.3" + "@algolia/transporter" "4.14.3" -"@algolia/client-common@4.22.1": - version "4.22.1" - resolved "https://registry.yarnpkg.com/@algolia/client-common/-/client-common-4.22.1.tgz#042b19c1b6157c485fa1b551349ab313944d2b05" - integrity sha512-IvaL5v9mZtm4k4QHbBGDmU3wa/mKokmqNBqPj0K7lcR8ZDKzUorhcGp/u8PkPC/e0zoHSTvRh7TRkGX3Lm7iOQ== +"@algolia/client-common@4.14.3": + version "4.14.3" + resolved "https://registry.yarnpkg.com/@algolia/client-common/-/client-common-4.14.3.tgz#c44e48652b2121a20d7a40cfd68d095ebb4191a8" + integrity sha512-jkPPDZdi63IK64Yg4WccdCsAP4pHxSkr4usplkUZM5C1l1oEpZXsy2c579LQ0rvwCs5JFmwfNG4ahOszidfWPw== dependencies: - "@algolia/requester-common" "4.22.1" - "@algolia/transporter" "4.22.1" + "@algolia/requester-common" "4.14.3" + "@algolia/transporter" "4.14.3" -"@algolia/client-personalization@4.22.1": - version "4.22.1" - resolved "https://registry.yarnpkg.com/@algolia/client-personalization/-/client-personalization-4.22.1.tgz#ff088d797648224fb582e9fe5828f8087835fa3d" - integrity sha512-sl+/klQJ93+4yaqZ7ezOttMQ/nczly/3GmgZXJ1xmoewP5jmdP/X/nV5U7EHHH3hCUEHeN7X1nsIhGPVt9E1cQ== +"@algolia/client-personalization@4.14.3": + version "4.14.3" + resolved "https://registry.yarnpkg.com/@algolia/client-personalization/-/client-personalization-4.14.3.tgz#8f71325035aa2a5fa7d1d567575235cf1d6c654f" + integrity sha512-UCX1MtkVNgaOL9f0e22x6tC9e2H3unZQlSUdnVaSKpZ+hdSChXGaRjp2UIT7pxmPqNCyv51F597KEX5WT60jNg== dependencies: - "@algolia/client-common" "4.22.1" - "@algolia/requester-common" "4.22.1" - "@algolia/transporter" "4.22.1" + "@algolia/client-common" "4.14.3" + "@algolia/requester-common" "4.14.3" + "@algolia/transporter" "4.14.3" -"@algolia/client-search@4.22.1": - version "4.22.1" - resolved "https://registry.yarnpkg.com/@algolia/client-search/-/client-search-4.22.1.tgz#508cc6ab3d1f4e9c02735a630d4dff6fbb8514a2" - integrity sha512-yb05NA4tNaOgx3+rOxAmFztgMTtGBi97X7PC3jyNeGiwkAjOZc2QrdZBYyIdcDLoI09N0gjtpClcackoTN0gPA== +"@algolia/client-search@4.14.3": + version "4.14.3" + resolved "https://registry.yarnpkg.com/@algolia/client-search/-/client-search-4.14.3.tgz#cf1e77549f5c3e73408ffe6441ede985fde69da0" + integrity sha512-I2U7xBx5OPFdPLA8AXKUPPxGY3HDxZ4r7+mlZ8ZpLbI8/ri6fnu6B4z3wcL7sgHhDYMwnAE8Xr0AB0h3Hnkp4A== dependencies: - "@algolia/client-common" "4.22.1" - "@algolia/requester-common" "4.22.1" - "@algolia/transporter" "4.22.1" + "@algolia/client-common" "4.14.3" + "@algolia/requester-common" "4.14.3" + "@algolia/transporter" "4.14.3" "@algolia/events@^4.0.1": version "4.0.1" resolved "https://registry.yarnpkg.com/@algolia/events/-/events-4.0.1.tgz#fd39e7477e7bc703d7f893b556f676c032af3950" integrity sha512-FQzvOCgoFXAbf5Y6mYozw2aj5KCJoA3m4heImceldzPSMbdyS4atVjJzXKMsfX3wnZTFYwkkt8/z8UesLHlSBQ== -"@algolia/logger-common@4.22.1": - version "4.22.1" - resolved "https://registry.yarnpkg.com/@algolia/logger-common/-/logger-common-4.22.1.tgz#79cf4cd295de0377a94582c6aaac59b1ded731d9" - integrity sha512-OnTFymd2odHSO39r4DSWRFETkBufnY2iGUZNrMXpIhF5cmFE8pGoINNPzwg02QLBlGSaLqdKy0bM8S0GyqPLBg== +"@algolia/logger-common@4.14.3": + version "4.14.3" + resolved "https://registry.yarnpkg.com/@algolia/logger-common/-/logger-common-4.14.3.tgz#87d4725e7f56ea5a39b605771b7149fff62032a7" + integrity sha512-kUEAZaBt/J3RjYi8MEBT2QEexJR2kAE2mtLmezsmqMQZTV502TkHCxYzTwY2dE7OKcUTxi4OFlMuS4GId9CWPw== -"@algolia/logger-console@4.22.1": - version "4.22.1" - resolved "https://registry.yarnpkg.com/@algolia/logger-console/-/logger-console-4.22.1.tgz#0355345f6940f67aaa78ae9b81c06e44e49f2336" - integrity sha512-O99rcqpVPKN1RlpgD6H3khUWylU24OXlzkavUAMy6QZd1776QAcauE3oP8CmD43nbaTjBexZj2nGsBH9Tc0FVA== +"@algolia/logger-console@4.14.3": + version "4.14.3" + resolved "https://registry.yarnpkg.com/@algolia/logger-console/-/logger-console-4.14.3.tgz#1f19f8f0a5ef11f01d1f9545290eb6a89b71fb8a" + integrity sha512-ZWqAlUITktiMN2EiFpQIFCJS10N96A++yrexqC2Z+3hgF/JcKrOxOdT4nSCQoEPvU4Ki9QKbpzbebRDemZt/hw== dependencies: - "@algolia/logger-common" "4.22.1" + "@algolia/logger-common" "4.14.3" -"@algolia/requester-browser-xhr@4.22.1": - version "4.22.1" - resolved "https://registry.yarnpkg.com/@algolia/requester-browser-xhr/-/requester-browser-xhr-4.22.1.tgz#f04df6fe9690a071b267c77d26b83a3be9280361" - integrity sha512-dtQGYIg6MteqT1Uay3J/0NDqD+UciHy3QgRbk7bNddOJu+p3hzjTRYESqEnoX/DpEkaNYdRHUKNylsqMpgwaEw== +"@algolia/requester-browser-xhr@4.14.3": + version "4.14.3" + resolved "https://registry.yarnpkg.com/@algolia/requester-browser-xhr/-/requester-browser-xhr-4.14.3.tgz#bcf55cba20f58fd9bc95ee55793b5219f3ce8888" + integrity sha512-AZeg2T08WLUPvDncl2XLX2O67W5wIO8MNaT7z5ii5LgBTuk/rU4CikTjCe2xsUleIZeFl++QrPAi4Bdxws6r/Q== dependencies: - "@algolia/requester-common" "4.22.1" + "@algolia/requester-common" "4.14.3" -"@algolia/requester-common@4.22.1": - version "4.22.1" - resolved "https://registry.yarnpkg.com/@algolia/requester-common/-/requester-common-4.22.1.tgz#27be35f3718aafcb6b388ff9c3aa2defabd559ff" - integrity sha512-dgvhSAtg2MJnR+BxrIFqlLtkLlVVhas9HgYKMk2Uxiy5m6/8HZBL40JVAMb2LovoPFs9I/EWIoFVjOrFwzn5Qg== +"@algolia/requester-common@4.14.3": + version "4.14.3" + resolved "https://registry.yarnpkg.com/@algolia/requester-common/-/requester-common-4.14.3.tgz#2d02fbe01afb7ae5651ae8dfe62d6c089f103714" + integrity sha512-RrRzqNyKFDP7IkTuV3XvYGF9cDPn9h6qEDl595lXva3YUk9YSS8+MGZnnkOMHvjkrSCKfoLeLbm/T4tmoIeclw== -"@algolia/requester-node-http@4.22.1": - version "4.22.1" - resolved "https://registry.yarnpkg.com/@algolia/requester-node-http/-/requester-node-http-4.22.1.tgz#589a6fa828ad0f325e727a6fcaf4e1a2343cc62b" - integrity sha512-JfmZ3MVFQkAU+zug8H3s8rZ6h0ahHZL/SpMaSasTCGYR5EEJsCc8SI5UZ6raPN2tjxa5bxS13BRpGSBUens7EA== +"@algolia/requester-node-http@4.14.3": + version "4.14.3" + resolved "https://registry.yarnpkg.com/@algolia/requester-node-http/-/requester-node-http-4.14.3.tgz#72389e1c2e5d964702451e75e368eefe85a09d8f" + integrity sha512-O5wnPxtDRPuW2U0EaOz9rMMWdlhwP0J0eSL1Z7TtXF8xnUeeUyNJrdhV5uy2CAp6RbhM1VuC3sOJcIR6Av+vbA== dependencies: - "@algolia/requester-common" "4.22.1" + "@algolia/requester-common" "4.14.3" -"@algolia/transporter@4.22.1": - version "4.22.1" - resolved "https://registry.yarnpkg.com/@algolia/transporter/-/transporter-4.22.1.tgz#8843841b857dc021668f31647aa557ff19cd9cb1" - integrity sha512-kzWgc2c9IdxMa3YqA6TN0NW5VrKYYW/BELIn7vnLyn+U/RFdZ4lxxt9/8yq3DKV5snvoDzzO4ClyejZRdV3lMQ== +"@algolia/transporter@4.14.3": + version "4.14.3" + resolved "https://registry.yarnpkg.com/@algolia/transporter/-/transporter-4.14.3.tgz#5593036bd9cf2adfd077fdc3e81d2e6118660a7a" + integrity sha512-2qlKlKsnGJ008exFRb5RTeTOqhLZj0bkMCMVskxoqWejs2Q2QtWmsiH98hDfpw0fmnyhzHEt0Z7lqxBYp8bW2w== dependencies: - "@algolia/cache-common" "4.22.1" - "@algolia/logger-common" "4.22.1" - "@algolia/requester-common" "4.22.1" + "@algolia/cache-common" "4.14.3" + "@algolia/logger-common" "4.14.3" + "@algolia/requester-common" "4.14.3" "@ampproject/remapping@^2.2.0": - version "2.2.1" - resolved "https://registry.yarnpkg.com/@ampproject/remapping/-/remapping-2.2.1.tgz#99e8e11851128b8702cd57c33684f1d0f260b630" - integrity sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg== + version "2.2.0" + resolved "https://registry.yarnpkg.com/@ampproject/remapping/-/remapping-2.2.0.tgz#56c133824780de3174aed5ab6834f3026790154d" + integrity sha512-qRmjj8nj9qmLTQXXmaR1cck3UXSRMPrbsLJAasZpF+t3riI71BXed5ebIOYwQntykeZuhjsdweEc9BxH5Jc26w== dependencies: - "@jridgewell/gen-mapping" "^0.3.0" + "@jridgewell/gen-mapping" "^0.1.0" "@jridgewell/trace-mapping" "^0.3.9" -"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.10.4", "@babel/code-frame@^7.16.0", "@babel/code-frame@^7.22.13", "@babel/code-frame@^7.23.5", "@babel/code-frame@^7.8.3": - version "7.23.5" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.23.5.tgz#9009b69a8c602293476ad598ff53e4562e15c244" - integrity sha512-CgH3s1a96LipHCmSUmYFPwY7MNx8C3avkq7i4Wl3cfa662ldtUe4VM1TPXX70pfmrlWTb6jLqTYrZyT2ZTJBgA== +"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.10.4", "@babel/code-frame@^7.16.0", "@babel/code-frame@^7.18.6", "@babel/code-frame@^7.8.3": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.18.6.tgz#3b25d38c89600baa2dcc219edfa88a74eb2c427a" + integrity sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q== dependencies: - "@babel/highlight" "^7.23.4" - chalk "^2.4.2" + "@babel/highlight" "^7.18.6" -"@babel/compat-data@^7.22.6", "@babel/compat-data@^7.23.3", "@babel/compat-data@^7.23.5": - version "7.23.5" - resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.23.5.tgz#ffb878728bb6bdcb6f4510aa51b1be9afb8cfd98" - integrity sha512-uU27kfDRlhfKl+w1U6vp16IuvSLtjAxdArVXPa9BvLkrr7CYIsxH5adpHObeAGY/41+syctUWOZ140a2Rvkgjw== +"@babel/compat-data@^7.17.7", "@babel/compat-data@^7.20.1", "@babel/compat-data@^7.20.5": + version "7.21.0" + resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.21.0.tgz#c241dc454e5b5917e40d37e525e2f4530c399298" + integrity sha512-gMuZsmsgxk/ENC3O/fRw5QY8A9/uxQbbCEypnLIiYYc/qVJtEV7ouxC3EllIIwNzMqAQee5tanFabWsUOutS7g== "@babel/core@7.12.9": version "7.12.9" @@ -182,278 +173,349 @@ source-map "^0.5.0" "@babel/core@^7.18.6", "@babel/core@^7.19.6": - version "7.23.7" - resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.23.7.tgz#4d8016e06a14b5f92530a13ed0561730b5c6483f" - integrity sha512-+UpDgowcmqe36d4NwqvKsyPMlOLNGMsfMmQ5WGCu+siCe3t3dfe9njrzGfdN4qq+bcNUt0+Vw6haRxBOycs4dw== + version "7.21.0" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.21.0.tgz#1341aefdcc14ccc7553fcc688dd8986a2daffc13" + integrity sha512-PuxUbxcW6ZYe656yL3EAhpy7qXKq0DmYsrJLpbB8XrsCP9Nm+XCg9XFMb5vIDliPD7+U/+M+QJlH17XOcB7eXA== dependencies: "@ampproject/remapping" "^2.2.0" - "@babel/code-frame" "^7.23.5" - "@babel/generator" "^7.23.6" - "@babel/helper-compilation-targets" "^7.23.6" - "@babel/helper-module-transforms" "^7.23.3" - "@babel/helpers" "^7.23.7" - "@babel/parser" "^7.23.6" - "@babel/template" "^7.22.15" - "@babel/traverse" "^7.23.7" - "@babel/types" "^7.23.6" - convert-source-map "^2.0.0" + "@babel/code-frame" "^7.18.6" + "@babel/generator" "^7.21.0" + "@babel/helper-compilation-targets" "^7.20.7" + "@babel/helper-module-transforms" "^7.21.0" + "@babel/helpers" "^7.21.0" + "@babel/parser" "^7.21.0" + "@babel/template" "^7.20.7" + "@babel/traverse" "^7.21.0" + "@babel/types" "^7.21.0" + convert-source-map "^1.7.0" debug "^4.1.0" gensync "^1.0.0-beta.2" - json5 "^2.2.3" - semver "^6.3.1" + json5 "^2.2.2" + semver "^6.3.0" -"@babel/generator@^7.12.5", "@babel/generator@^7.18.7", "@babel/generator@^7.23.6": - version "7.23.6" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.23.6.tgz#9e1fca4811c77a10580d17d26b57b036133f3c2e" - integrity sha512-qrSfCYxYQB5owCmGLbl8XRpX1ytXlpueOb0N0UmQwA073KZxejgQTzAmJezxvpwQD9uGtK2shHdi55QT+MbjIw== +"@babel/generator@^7.12.5", "@babel/generator@^7.18.7", "@babel/generator@^7.21.0", "@babel/generator@^7.21.1": + version "7.21.1" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.21.1.tgz#951cc626057bc0af2c35cd23e9c64d384dea83dd" + integrity sha512-1lT45bAYlQhFn/BHivJs43AiW2rg3/UbLyShGfF3C0KmHvO5fSghWd5kBJy30kpRRucGzXStvnnCFniCR2kXAA== dependencies: - "@babel/types" "^7.23.6" + "@babel/types" "^7.21.0" "@jridgewell/gen-mapping" "^0.3.2" "@jridgewell/trace-mapping" "^0.3.17" jsesc "^2.5.1" -"@babel/helper-annotate-as-pure@^7.22.5": - version "7.22.5" - resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.22.5.tgz#e7f06737b197d580a01edf75d97e2c8be99d3882" - integrity sha512-LvBTxu8bQSQkcyKOU+a1btnNFQ1dMAd0R6PyW3arXes06F6QLWLIrd681bxRPIXlrMGR3XYnW9JyML7dP3qgxg== +"@babel/helper-annotate-as-pure@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.18.6.tgz#eaa49f6f80d5a33f9a5dd2276e6d6e451be0a6bb" + integrity sha512-duORpUiYrEpzKIop6iNbjnwKLAKnJ47csTyRACyEmWj0QdUrm5aqNJGHSSEQSUAvNW0ojX0dOmK9dZduvkfeXA== dependencies: - "@babel/types" "^7.22.5" + "@babel/types" "^7.18.6" -"@babel/helper-builder-binary-assignment-operator-visitor@^7.22.15": - version "7.22.15" - resolved "https://registry.yarnpkg.com/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.22.15.tgz#5426b109cf3ad47b91120f8328d8ab1be8b0b956" - integrity sha512-QkBXwGgaoC2GtGZRoma6kv7Szfv06khvhFav67ZExau2RaXzy8MpHSMO2PNoP2XtmQphJQRHFfg77Bq731Yizw== +"@babel/helper-builder-binary-assignment-operator-visitor@^7.18.6": + version "7.18.9" + resolved "https://registry.yarnpkg.com/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.18.9.tgz#acd4edfd7a566d1d51ea975dff38fd52906981bb" + integrity sha512-yFQ0YCHoIqarl8BCRwBL8ulYUaZpz3bNsA7oFepAzee+8/+ImtADXNOmO5vJvsPff3qi+hvpkY/NYBTrBQgdNw== dependencies: - "@babel/types" "^7.22.15" + "@babel/helper-explode-assignable-expression" "^7.18.6" + "@babel/types" "^7.18.9" -"@babel/helper-compilation-targets@^7.22.15", "@babel/helper-compilation-targets@^7.22.6", "@babel/helper-compilation-targets@^7.23.6": - version "7.23.6" - resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.23.6.tgz#4d79069b16cbcf1461289eccfbbd81501ae39991" - integrity sha512-9JB548GZoQVmzrFgp8o7KxdgkTGm6xs9DW0o/Pim72UDjzr5ObUQ6ZzYPqA+g9OTS2bBQoctLJrky0RDCAWRgQ== +"@babel/helper-compilation-targets@^7.17.7", "@babel/helper-compilation-targets@^7.18.9", "@babel/helper-compilation-targets@^7.20.0", "@babel/helper-compilation-targets@^7.20.7": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.20.7.tgz#a6cd33e93629f5eb473b021aac05df62c4cd09bb" + integrity sha512-4tGORmfQcrc+bvrjb5y3dG9Mx1IOZjsHqQVUz7XCNHO+iTmqxWnVg3KRygjGmpRLJGdQSKuvFinbIb0CnZwHAQ== dependencies: - "@babel/compat-data" "^7.23.5" - "@babel/helper-validator-option" "^7.23.5" - browserslist "^4.22.2" + "@babel/compat-data" "^7.20.5" + "@babel/helper-validator-option" "^7.18.6" + browserslist "^4.21.3" lru-cache "^5.1.1" - semver "^6.3.1" - -"@babel/helper-create-class-features-plugin@^7.22.15", "@babel/helper-create-class-features-plugin@^7.23.6": - version "7.23.7" - resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.23.7.tgz#b2e6826e0e20d337143655198b79d58fdc9bd43d" - integrity sha512-xCoqR/8+BoNnXOY7RVSgv6X+o7pmT5q1d+gGcRlXYkI+9B31glE4jeejhKVpA04O1AtzOt7OSQ6VYKP5FcRl9g== - dependencies: - "@babel/helper-annotate-as-pure" "^7.22.5" - "@babel/helper-environment-visitor" "^7.22.20" - "@babel/helper-function-name" "^7.23.0" - "@babel/helper-member-expression-to-functions" "^7.23.0" - "@babel/helper-optimise-call-expression" "^7.22.5" - "@babel/helper-replace-supers" "^7.22.20" - "@babel/helper-skip-transparent-expression-wrappers" "^7.22.5" - "@babel/helper-split-export-declaration" "^7.22.6" - semver "^6.3.1" - -"@babel/helper-create-regexp-features-plugin@^7.18.6", "@babel/helper-create-regexp-features-plugin@^7.22.15", "@babel/helper-create-regexp-features-plugin@^7.22.5": - version "7.22.15" - resolved "https://registry.yarnpkg.com/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.22.15.tgz#5ee90093914ea09639b01c711db0d6775e558be1" - integrity sha512-29FkPLFjn4TPEa3RE7GpW+qbE8tlsu3jntNYNfcGsc49LphF1PQIiD+vMZ1z1xVOKt+93khA9tc2JBs3kBjA7w== - dependencies: - "@babel/helper-annotate-as-pure" "^7.22.5" - regexpu-core "^5.3.1" - semver "^6.3.1" + semver "^6.3.0" -"@babel/helper-define-polyfill-provider@^0.4.4": - version "0.4.4" - resolved "https://registry.yarnpkg.com/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.4.4.tgz#64df615451cb30e94b59a9696022cffac9a10088" - integrity sha512-QcJMILQCu2jm5TFPGA3lCpJJTeEP+mqeXooG/NZbg/h5FTFi6V0+99ahlRsW8/kRLyb24LZVCCiclDedhLKcBA== - dependencies: - "@babel/helper-compilation-targets" "^7.22.6" - "@babel/helper-plugin-utils" "^7.22.5" - debug "^4.1.1" - lodash.debounce "^4.0.8" - resolve "^1.14.2" +"@babel/helper-create-class-features-plugin@^7.18.6", "@babel/helper-create-class-features-plugin@^7.21.0": + version "7.21.0" + resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.21.0.tgz#64f49ecb0020532f19b1d014b03bccaa1ab85fb9" + integrity sha512-Q8wNiMIdwsv5la5SPxNYzzkPnjgC0Sy0i7jLkVOCdllu/xcVNkr3TeZzbHBJrj+XXRqzX5uCyCoV9eu6xUG7KQ== + dependencies: + "@babel/helper-annotate-as-pure" "^7.18.6" + "@babel/helper-environment-visitor" "^7.18.9" + "@babel/helper-function-name" "^7.21.0" + "@babel/helper-member-expression-to-functions" "^7.21.0" + "@babel/helper-optimise-call-expression" "^7.18.6" + "@babel/helper-replace-supers" "^7.20.7" + "@babel/helper-skip-transparent-expression-wrappers" "^7.20.0" + "@babel/helper-split-export-declaration" "^7.18.6" + +"@babel/helper-create-regexp-features-plugin@^7.18.6", "@babel/helper-create-regexp-features-plugin@^7.20.5": + version "7.21.0" + resolved "https://registry.yarnpkg.com/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.21.0.tgz#53ff78472e5ce10a52664272a239787107603ebb" + integrity sha512-N+LaFW/auRSWdx7SHD/HiARwXQju1vXTW4fKr4u5SgBUTm51OKEjKgj+cs00ggW3kEvNqwErnlwuq7Y3xBe4eg== + dependencies: + "@babel/helper-annotate-as-pure" "^7.18.6" + regexpu-core "^5.3.1" -"@babel/helper-define-polyfill-provider@^0.5.0": - version "0.5.0" - resolved "https://registry.yarnpkg.com/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.5.0.tgz#465805b7361f461e86c680f1de21eaf88c25901b" - integrity sha512-NovQquuQLAQ5HuyjCz7WQP9MjRj7dx++yspwiyUiGl9ZyadHRSql1HZh5ogRd8W8w6YM6EQ/NTB8rgjLt5W65Q== +"@babel/helper-define-polyfill-provider@^0.3.3": + version "0.3.3" + resolved "https://registry.yarnpkg.com/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.3.3.tgz#8612e55be5d51f0cd1f36b4a5a83924e89884b7a" + integrity sha512-z5aQKU4IzbqCC1XH0nAqfsFLMVSo22SBKUc0BxGrLkolTdPTructy0ToNnlO2zA4j9Q/7pjMZf0DSY+DSTYzww== dependencies: - "@babel/helper-compilation-targets" "^7.22.6" - "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-compilation-targets" "^7.17.7" + "@babel/helper-plugin-utils" "^7.16.7" debug "^4.1.1" lodash.debounce "^4.0.8" resolve "^1.14.2" + semver "^6.1.2" -"@babel/helper-environment-visitor@^7.22.20": - version "7.22.20" - resolved "https://registry.yarnpkg.com/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz#96159db61d34a29dba454c959f5ae4a649ba9167" - integrity sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA== - -"@babel/helper-function-name@^7.22.5", "@babel/helper-function-name@^7.23.0": - version "7.23.0" - resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.23.0.tgz#1f9a3cdbd5b2698a670c30d2735f9af95ed52759" - integrity sha512-OErEqsrxjZTJciZ4Oo+eoZqeW9UIiOcuYKRJA4ZAgV9myA+pOXhhmpfNCKjEH/auVfEYVFJ6y1Tc4r0eIApqiw== - dependencies: - "@babel/template" "^7.22.15" - "@babel/types" "^7.23.0" +"@babel/helper-environment-visitor@^7.18.9": + version "7.18.9" + resolved "https://registry.yarnpkg.com/@babel/helper-environment-visitor/-/helper-environment-visitor-7.18.9.tgz#0c0cee9b35d2ca190478756865bb3528422f51be" + integrity sha512-3r/aACDJ3fhQ/EVgFy0hpj8oHyHpQc+LPtJoY9SzTThAsStm4Ptegq92vqKoE3vD706ZVFWITnMnxucw+S9Ipg== -"@babel/helper-hoist-variables@^7.22.5": - version "7.22.5" - resolved "https://registry.yarnpkg.com/@babel/helper-hoist-variables/-/helper-hoist-variables-7.22.5.tgz#c01a007dac05c085914e8fb652b339db50d823bb" - integrity sha512-wGjk9QZVzvknA6yKIUURb8zY3grXCcOZt+/7Wcy8O2uctxhplmUPkOdlgoNhmdVee2c92JXbf1xpMtVNbfoxRw== +"@babel/helper-explode-assignable-expression@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.18.6.tgz#41f8228ef0a6f1a036b8dfdfec7ce94f9a6bc096" + integrity sha512-eyAYAsQmB80jNfg4baAtLeWAQHfHFiR483rzFK+BhETlGZaQC9bsfrugfXDCbRHLQbIA7U5NxhhOxN7p/dWIcg== dependencies: - "@babel/types" "^7.22.5" + "@babel/types" "^7.18.6" -"@babel/helper-member-expression-to-functions@^7.22.15", "@babel/helper-member-expression-to-functions@^7.23.0": - version "7.23.0" - resolved "https://registry.yarnpkg.com/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.23.0.tgz#9263e88cc5e41d39ec18c9a3e0eced59a3e7d366" - integrity sha512-6gfrPwh7OuT6gZyJZvd6WbTfrqAo7vm4xCzAXOusKqq/vWdKXphTpj5klHKNmRUU6/QRGlBsyU9mAIPaWHlqJA== +"@babel/helper-function-name@^7.18.9", "@babel/helper-function-name@^7.19.0", "@babel/helper-function-name@^7.21.0": + version "7.21.0" + resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.21.0.tgz#d552829b10ea9f120969304023cd0645fa00b1b4" + integrity sha512-HfK1aMRanKHpxemaY2gqBmL04iAPOPRj7DxtNbiDOrJK+gdwkiNRVpCpUJYbUT+aZyemKN8brqTOxzCaG6ExRg== dependencies: - "@babel/types" "^7.23.0" + "@babel/template" "^7.20.7" + "@babel/types" "^7.21.0" -"@babel/helper-module-imports@^7.22.15": - version "7.22.15" - resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.22.15.tgz#16146307acdc40cc00c3b2c647713076464bdbf0" - integrity sha512-0pYVBnDKZO2fnSPCrgM/6WMc7eS20Fbok+0r88fp+YtWVLZrp4CkafFGIp+W0VKw4a22sgebPT99y+FDNMdP4w== +"@babel/helper-hoist-variables@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/helper-hoist-variables/-/helper-hoist-variables-7.18.6.tgz#d4d2c8fb4baeaa5c68b99cc8245c56554f926678" + integrity sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q== dependencies: - "@babel/types" "^7.22.15" + "@babel/types" "^7.18.6" -"@babel/helper-module-transforms@^7.12.1", "@babel/helper-module-transforms@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.23.3.tgz#d7d12c3c5d30af5b3c0fcab2a6d5217773e2d0f1" - integrity sha512-7bBs4ED9OmswdfDzpz4MpWgSrV7FXlc3zIagvLFjS5H+Mk7Snr21vQ6QwrsoCGMfNC4e4LQPdoULEt4ykz0SRQ== +"@babel/helper-member-expression-to-functions@^7.20.7", "@babel/helper-member-expression-to-functions@^7.21.0": + version "7.21.0" + resolved "https://registry.yarnpkg.com/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.21.0.tgz#319c6a940431a133897148515877d2f3269c3ba5" + integrity sha512-Muu8cdZwNN6mRRNG6lAYErJ5X3bRevgYR2O8wN0yn7jJSnGDu6eG59RfT29JHxGUovyfrh6Pj0XzmR7drNVL3Q== dependencies: - "@babel/helper-environment-visitor" "^7.22.20" - "@babel/helper-module-imports" "^7.22.15" - "@babel/helper-simple-access" "^7.22.5" - "@babel/helper-split-export-declaration" "^7.22.6" - "@babel/helper-validator-identifier" "^7.22.20" + "@babel/types" "^7.21.0" -"@babel/helper-optimise-call-expression@^7.22.5": - version "7.22.5" - resolved "https://registry.yarnpkg.com/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.22.5.tgz#f21531a9ccbff644fdd156b4077c16ff0c3f609e" - integrity sha512-HBwaojN0xFRx4yIvpwGqxiV2tUfl7401jlok564NgB9EHS1y6QT17FmKWm4ztqjeVdXLuC4fSvHc5ePpQjoTbw== +"@babel/helper-module-imports@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.18.6.tgz#1e3ebdbbd08aad1437b428c50204db13c5a3ca6e" + integrity sha512-0NFvs3VkuSYbFi1x2Vd6tKrywq+z/cLeYC/RJNFrIX/30Bf5aiGYbtvGXolEktzJH8o5E5KJ3tT+nkxuuZFVlA== + dependencies: + "@babel/types" "^7.18.6" + +"@babel/helper-module-transforms@^7.12.1", "@babel/helper-module-transforms@^7.18.6", "@babel/helper-module-transforms@^7.20.11", "@babel/helper-module-transforms@^7.21.0", "@babel/helper-module-transforms@^7.21.2": + version "7.21.2" + resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.21.2.tgz#160caafa4978ac8c00ac66636cb0fa37b024e2d2" + integrity sha512-79yj2AR4U/Oqq/WOV7Lx6hUjau1Zfo4cI+JLAVYeMV5XIlbOhmjEk5ulbTc9fMpmlojzZHkUUxAiK+UKn+hNQQ== + dependencies: + "@babel/helper-environment-visitor" "^7.18.9" + "@babel/helper-module-imports" "^7.18.6" + "@babel/helper-simple-access" "^7.20.2" + "@babel/helper-split-export-declaration" "^7.18.6" + "@babel/helper-validator-identifier" "^7.19.1" + "@babel/template" "^7.20.7" + "@babel/traverse" "^7.21.2" + "@babel/types" "^7.21.2" + +"@babel/helper-optimise-call-expression@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.18.6.tgz#9369aa943ee7da47edab2cb4e838acf09d290ffe" + integrity sha512-HP59oD9/fEHQkdcbgFCnbmgH5vIQTJbxh2yf+CdM89/glUNnuzr87Q8GIjGEnOktTROemO0Pe0iPAYbqZuOUiA== dependencies: - "@babel/types" "^7.22.5" + "@babel/types" "^7.18.6" "@babel/helper-plugin-utils@7.10.4": version "7.10.4" resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.10.4.tgz#2f75a831269d4f677de49986dff59927533cf375" integrity sha512-O4KCvQA6lLiMU9l2eawBPMf1xPP8xPfB3iEQw150hOVTqj/rfXz0ThTb4HEzqQfs2Bmo5Ay8BzxfzVtBrr9dVg== -"@babel/helper-plugin-utils@^7.0.0", "@babel/helper-plugin-utils@^7.10.4", "@babel/helper-plugin-utils@^7.12.13", "@babel/helper-plugin-utils@^7.14.5", "@babel/helper-plugin-utils@^7.18.6", "@babel/helper-plugin-utils@^7.22.5", "@babel/helper-plugin-utils@^7.8.0", "@babel/helper-plugin-utils@^7.8.3": - version "7.22.5" - resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.22.5.tgz#dd7ee3735e8a313b9f7b05a773d892e88e6d7295" - integrity sha512-uLls06UVKgFG9QD4OeFYLEGteMIAa5kpTPcFL28yuCIIzsf6ZyKZMllKVOCZFhiZ5ptnwX4mtKdWCBE/uT4amg== +"@babel/helper-plugin-utils@^7.0.0", "@babel/helper-plugin-utils@^7.10.4", "@babel/helper-plugin-utils@^7.12.13", "@babel/helper-plugin-utils@^7.14.5", "@babel/helper-plugin-utils@^7.16.7", "@babel/helper-plugin-utils@^7.18.6", "@babel/helper-plugin-utils@^7.18.9", "@babel/helper-plugin-utils@^7.19.0", "@babel/helper-plugin-utils@^7.20.2", "@babel/helper-plugin-utils@^7.8.0", "@babel/helper-plugin-utils@^7.8.3": + version "7.20.2" + resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.20.2.tgz#d1b9000752b18d0877cff85a5c376ce5c3121629" + integrity sha512-8RvlJG2mj4huQ4pZ+rU9lqKi9ZKiRmuvGuM2HlWmkmgOhbs6zEAw6IEiJ5cQqGbDzGZOhwuOQNtZMi/ENLjZoQ== + +"@babel/helper-remap-async-to-generator@^7.18.9": + version "7.18.9" + resolved "https://registry.yarnpkg.com/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.18.9.tgz#997458a0e3357080e54e1d79ec347f8a8cd28519" + integrity sha512-dI7q50YKd8BAv3VEfgg7PS7yD3Rtbi2J1XMXaalXO0W0164hYLnh8zpjRS0mte9MfVp/tltvr/cfdXPvJr1opA== + dependencies: + "@babel/helper-annotate-as-pure" "^7.18.6" + "@babel/helper-environment-visitor" "^7.18.9" + "@babel/helper-wrap-function" "^7.18.9" + "@babel/types" "^7.18.9" + +"@babel/helper-replace-supers@^7.18.6", "@babel/helper-replace-supers@^7.20.7": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.20.7.tgz#243ecd2724d2071532b2c8ad2f0f9f083bcae331" + integrity sha512-vujDMtB6LVfNW13jhlCrp48QNslK6JXi7lQG736HVbHz/mbf4Dc7tIRh1Xf5C0rF7BP8iiSxGMCmY6Ci1ven3A== + dependencies: + "@babel/helper-environment-visitor" "^7.18.9" + "@babel/helper-member-expression-to-functions" "^7.20.7" + "@babel/helper-optimise-call-expression" "^7.18.6" + "@babel/template" "^7.20.7" + "@babel/traverse" "^7.20.7" + "@babel/types" "^7.20.7" + +"@babel/helper-simple-access@^7.20.2": + version "7.20.2" + resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.20.2.tgz#0ab452687fe0c2cfb1e2b9e0015de07fc2d62dd9" + integrity sha512-+0woI/WPq59IrqDYbVGfshjT5Dmk/nnbdpcF8SnMhhXObpTq2KNBdLFRFrkVdbDOyUmHBCxzm5FHV1rACIkIbA== + dependencies: + "@babel/types" "^7.20.2" + +"@babel/helper-skip-transparent-expression-wrappers@^7.20.0": + version "7.20.0" + resolved "https://registry.yarnpkg.com/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.20.0.tgz#fbe4c52f60518cab8140d77101f0e63a8a230684" + integrity sha512-5y1JYeNKfvnT8sZcK9DVRtpTbGiomYIHviSP3OQWmDPU3DeH4a1ZlT/N2lyQ5P8egjcRaT/Y9aNqUxK0WsnIIg== + dependencies: + "@babel/types" "^7.20.0" -"@babel/helper-remap-async-to-generator@^7.22.20": - version "7.22.20" - resolved "https://registry.yarnpkg.com/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.22.20.tgz#7b68e1cb4fa964d2996fd063723fb48eca8498e0" - integrity sha512-pBGyV4uBqOns+0UvhsTO8qgl8hO89PmiDYv+/COyp1aeMcmfrfruz+/nCMFiYyFF/Knn0yfrC85ZzNFjembFTw== +"@babel/helper-split-export-declaration@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz#7367949bc75b20c6d5a5d4a97bba2824ae8ef075" + integrity sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA== + dependencies: + "@babel/types" "^7.18.6" + +"@babel/helper-string-parser@^7.19.4": + version "7.19.4" + resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.19.4.tgz#38d3acb654b4701a9b77fb0615a96f775c3a9e63" + integrity sha512-nHtDoQcuqFmwYNYPz3Rah5ph2p8PFeFCsZk9A/48dPc/rGocJ5J3hAAZ7pb76VWX3fZKu+uEr/FhH5jLx7umrw== + +"@babel/helper-validator-identifier@^7.18.6", "@babel/helper-validator-identifier@^7.19.1": + version "7.19.1" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz#7eea834cf32901ffdc1a7ee555e2f9c27e249ca2" + integrity sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w== + +"@babel/helper-validator-option@^7.18.6", "@babel/helper-validator-option@^7.21.0": + version "7.21.0" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.21.0.tgz#8224c7e13ace4bafdc4004da2cf064ef42673180" + integrity sha512-rmL/B8/f0mKS2baE9ZpyTcTavvEuWhTTW8amjzXNvYG4AwBsqTLikfXsEofsJEfKHf+HQVQbFOHy6o+4cnC/fQ== + +"@babel/helper-wrap-function@^7.18.9": + version "7.20.5" + resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.20.5.tgz#75e2d84d499a0ab3b31c33bcfe59d6b8a45f62e3" + integrity sha512-bYMxIWK5mh+TgXGVqAtnu5Yn1un+v8DDZtqyzKRLUzrh70Eal2O3aZ7aPYiMADO4uKlkzOiRiZ6GX5q3qxvW9Q== + dependencies: + "@babel/helper-function-name" "^7.19.0" + "@babel/template" "^7.18.10" + "@babel/traverse" "^7.20.5" + "@babel/types" "^7.20.5" + +"@babel/helpers@^7.12.5", "@babel/helpers@^7.21.0": + version "7.21.0" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.21.0.tgz#9dd184fb5599862037917cdc9eecb84577dc4e7e" + integrity sha512-XXve0CBtOW0pd7MRzzmoyuSj0e3SEzj8pgyFxnTT1NJZL38BD1MK7yYrm8yefRPIDvNNe14xR4FdbHwpInD4rA== + dependencies: + "@babel/template" "^7.20.7" + "@babel/traverse" "^7.21.0" + "@babel/types" "^7.21.0" + +"@babel/highlight@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.18.6.tgz#81158601e93e2563795adcbfbdf5d64be3f2ecdf" + integrity sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g== dependencies: - "@babel/helper-annotate-as-pure" "^7.22.5" - "@babel/helper-environment-visitor" "^7.22.20" - "@babel/helper-wrap-function" "^7.22.20" + "@babel/helper-validator-identifier" "^7.18.6" + chalk "^2.0.0" + js-tokens "^4.0.0" -"@babel/helper-replace-supers@^7.22.20": - version "7.22.20" - resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.22.20.tgz#e37d367123ca98fe455a9887734ed2e16eb7a793" - integrity sha512-qsW0In3dbwQUbK8kejJ4R7IHVGwHJlV6lpG6UA7a9hSa2YEiAib+N1T2kr6PEeUT+Fl7najmSOS6SmAwCHK6Tw== +"@babel/parser@^7.12.7", "@babel/parser@^7.18.8", "@babel/parser@^7.20.7", "@babel/parser@^7.21.0", "@babel/parser@^7.21.2": + version "7.21.2" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.21.2.tgz#dacafadfc6d7654c3051a66d6fe55b6cb2f2a0b3" + integrity sha512-URpaIJQwEkEC2T9Kn+Ai6Xe/02iNaVCuT/PtoRz3GPVJVDpPd7mLo+VddTbhCRU9TXqW5mSrQfXZyi8kDKOVpQ== + +"@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/-/plugin-bugfix-safari-id-destructuring-collision-in-function-expression-7.18.6.tgz#da5b8f9a580acdfbe53494dba45ea389fb09a4d2" + integrity sha512-Dgxsyg54Fx1d4Nge8UnvTrED63vrwOdPmyvPzlNN/boaliRP54pm3pGzZD1SJUwrBA+Cs/xdG8kXX6Mn/RfISQ== dependencies: - "@babel/helper-environment-visitor" "^7.22.20" - "@babel/helper-member-expression-to-functions" "^7.22.15" - "@babel/helper-optimise-call-expression" "^7.22.5" + "@babel/helper-plugin-utils" "^7.18.6" -"@babel/helper-simple-access@^7.22.5": - version "7.22.5" - resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.22.5.tgz#4938357dc7d782b80ed6dbb03a0fba3d22b1d5de" - integrity sha512-n0H99E/K+Bika3++WNL17POvo4rKWZ7lZEp1Q+fStVbUi8nxPQEBOlTmCOxW/0JsS56SKKQ+ojAe2pHKJHN35w== +"@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@^7.18.9": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/-/plugin-bugfix-v8-spread-parameters-in-optional-chaining-7.20.7.tgz#d9c85589258539a22a901033853101a6198d4ef1" + integrity sha512-sbr9+wNE5aXMBBFBICk01tt7sBf2Oc9ikRFEcem/ZORup9IMUdNhW7/wVLEbbtlWOsEubJet46mHAL2C8+2jKQ== dependencies: - "@babel/types" "^7.22.5" + "@babel/helper-plugin-utils" "^7.20.2" + "@babel/helper-skip-transparent-expression-wrappers" "^7.20.0" + "@babel/plugin-proposal-optional-chaining" "^7.20.7" -"@babel/helper-skip-transparent-expression-wrappers@^7.22.5": - version "7.22.5" - resolved "https://registry.yarnpkg.com/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.22.5.tgz#007f15240b5751c537c40e77abb4e89eeaaa8847" - integrity sha512-tK14r66JZKiC43p8Ki33yLBVJKlQDFoA8GYN67lWCDCqoL6EMMSuM9b+Iff2jHaM/RRFYl7K+iiru7hbRqNx8Q== +"@babel/plugin-proposal-async-generator-functions@^7.20.1": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.20.7.tgz#bfb7276d2d573cb67ba379984a2334e262ba5326" + integrity sha512-xMbiLsn/8RK7Wq7VeVytytS2L6qE69bXPB10YCmMdDZbKF4okCqY74pI/jJQ/8U0b/F6NrT2+14b8/P9/3AMGA== dependencies: - "@babel/types" "^7.22.5" + "@babel/helper-environment-visitor" "^7.18.9" + "@babel/helper-plugin-utils" "^7.20.2" + "@babel/helper-remap-async-to-generator" "^7.18.9" + "@babel/plugin-syntax-async-generators" "^7.8.4" -"@babel/helper-split-export-declaration@^7.22.6": - version "7.22.6" - resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.6.tgz#322c61b7310c0997fe4c323955667f18fcefb91c" - integrity sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g== - dependencies: - "@babel/types" "^7.22.5" - -"@babel/helper-string-parser@^7.23.4": - version "7.23.4" - resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.23.4.tgz#9478c707febcbbe1ddb38a3d91a2e054ae622d83" - integrity sha512-803gmbQdqwdf4olxrX4AJyFBV/RTr3rSmOj0rKwesmzlfhYNDEs+/iOcznzpNWlJlIlTJC2QfPFcHB6DlzdVLQ== - -"@babel/helper-validator-identifier@^7.22.20": - version "7.22.20" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz#c4ae002c61d2879e724581d96665583dbc1dc0e0" - integrity sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A== - -"@babel/helper-validator-option@^7.22.15", "@babel/helper-validator-option@^7.23.5": - version "7.23.5" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.23.5.tgz#907a3fbd4523426285365d1206c423c4c5520307" - integrity sha512-85ttAOMLsr53VgXkTbkx8oA6YTfT4q7/HzXSLEYmjcSTJPMPQtvq1BD79Byep5xMUYbGRzEpDsjUf3dyp54IKw== - -"@babel/helper-wrap-function@^7.22.20": - version "7.22.20" - resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.22.20.tgz#15352b0b9bfb10fc9c76f79f6342c00e3411a569" - integrity sha512-pms/UwkOpnQe/PDAEdV/d7dVCoBbB+R4FvYoHGZz+4VPcg7RtYy2KP7S2lbuWM6FCSgob5wshfGESbC/hzNXZw== - dependencies: - "@babel/helper-function-name" "^7.22.5" - "@babel/template" "^7.22.15" - "@babel/types" "^7.22.19" - -"@babel/helpers@^7.12.5", "@babel/helpers@^7.23.7": - version "7.23.8" - resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.23.8.tgz#fc6b2d65b16847fd50adddbd4232c76378959e34" - integrity sha512-KDqYz4PiOWvDFrdHLPhKtCThtIcKVy6avWD2oG4GEvyQ+XDZwHD4YQd+H2vNMnq2rkdxsDkU82T+Vk8U/WXHRQ== - dependencies: - "@babel/template" "^7.22.15" - "@babel/traverse" "^7.23.7" - "@babel/types" "^7.23.6" - -"@babel/highlight@^7.23.4": - version "7.23.4" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.23.4.tgz#edaadf4d8232e1a961432db785091207ead0621b" - integrity sha512-acGdbYSfp2WheJoJm/EBBBLh/ID8KDc64ISZ9DYtBmC8/Q204PZJLHyzeB5qMzJ5trcOkybd78M4x2KWsUq++A== - dependencies: - "@babel/helper-validator-identifier" "^7.22.20" - chalk "^2.4.2" - js-tokens "^4.0.0" +"@babel/plugin-proposal-class-properties@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.18.6.tgz#b110f59741895f7ec21a6fff696ec46265c446a3" + integrity sha512-cumfXOF0+nzZrrN8Rf0t7M+tF6sZc7vhQwYQck9q1/5w2OExlD+b4v4RpMJFaV1Z7WcDRgO6FqvxqxGlwo+RHQ== + dependencies: + "@babel/helper-create-class-features-plugin" "^7.18.6" + "@babel/helper-plugin-utils" "^7.18.6" -"@babel/parser@^7.12.7", "@babel/parser@^7.18.8", "@babel/parser@^7.22.15", "@babel/parser@^7.23.6": - version "7.23.6" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.23.6.tgz#ba1c9e512bda72a47e285ae42aff9d2a635a9e3b" - integrity sha512-Z2uID7YJ7oNvAI20O9X0bblw7Qqs8Q2hFy0R9tAfnfLkp5MW0UH9eUvnDSnFwKZ0AvgS1ucqR4KzvVHgnke1VQ== +"@babel/plugin-proposal-class-static-block@^7.18.6": + version "7.21.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-static-block/-/plugin-proposal-class-static-block-7.21.0.tgz#77bdd66fb7b605f3a61302d224bdfacf5547977d" + integrity sha512-XP5G9MWNUskFuP30IfFSEFB0Z6HzLIUcjYM4bYOPHXl7eiJ9HFv8tWj6TXTN5QODiEhDZAeI4hLok2iHFFV4hw== + dependencies: + "@babel/helper-create-class-features-plugin" "^7.21.0" + "@babel/helper-plugin-utils" "^7.20.2" + "@babel/plugin-syntax-class-static-block" "^7.14.5" -"@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/-/plugin-bugfix-safari-id-destructuring-collision-in-function-expression-7.23.3.tgz#5cd1c87ba9380d0afb78469292c954fee5d2411a" - integrity sha512-iRkKcCqb7iGnq9+3G6rZ+Ciz5VywC4XNRHe57lKM+jOeYAoR0lVqdeeDRfh0tQcTfw/+vBhHn926FmQhLtlFLQ== +"@babel/plugin-proposal-dynamic-import@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.18.6.tgz#72bcf8d408799f547d759298c3c27c7e7faa4d94" + integrity sha512-1auuwmK+Rz13SJj36R+jqFPMJWyKEDd7lLSdOj4oJK0UTgGueSAtkrCvz9ewmgyU/P941Rv2fQwZJN8s6QruXw== dependencies: - "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-plugin-utils" "^7.18.6" + "@babel/plugin-syntax-dynamic-import" "^7.8.3" -"@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/-/plugin-bugfix-v8-spread-parameters-in-optional-chaining-7.23.3.tgz#f6652bb16b94f8f9c20c50941e16e9756898dc5d" - integrity sha512-WwlxbfMNdVEpQjZmK5mhm7oSwD3dS6eU+Iwsi4Knl9wAletWem7kaRsGOG+8UEbRyqxY4SS5zvtfXwX+jMxUwQ== +"@babel/plugin-proposal-export-namespace-from@^7.18.9": + version "7.18.9" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-export-namespace-from/-/plugin-proposal-export-namespace-from-7.18.9.tgz#5f7313ab348cdb19d590145f9247540e94761203" + integrity sha512-k1NtHyOMvlDDFeb9G5PhUXuGj8m/wiwojgQVEhJ/fsVsMCpLyOP4h0uGEjYJKrRI+EVPlb5Jk+Gt9P97lOGwtA== dependencies: - "@babel/helper-plugin-utils" "^7.22.5" - "@babel/helper-skip-transparent-expression-wrappers" "^7.22.5" - "@babel/plugin-transform-optional-chaining" "^7.23.3" + "@babel/helper-plugin-utils" "^7.18.9" + "@babel/plugin-syntax-export-namespace-from" "^7.8.3" -"@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly@^7.23.7": - version "7.23.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly/-/plugin-bugfix-v8-static-class-fields-redefine-readonly-7.23.7.tgz#516462a95d10a9618f197d39ad291a9b47ae1d7b" - integrity sha512-LlRT7HgaifEpQA1ZgLVOIJZZFVPWN5iReq/7/JixwBtwcoeVGDBD53ZV28rrsLYOZs1Y/EHhA8N/Z6aazHR8cw== +"@babel/plugin-proposal-json-strings@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.18.6.tgz#7e8788c1811c393aff762817e7dbf1ebd0c05f0b" + integrity sha512-lr1peyn9kOdbYc0xr0OdHTZ5FMqS6Di+H0Fz2I/JwMzGmzJETNeOFq2pBySw6X/KFL5EWDjlJuMsUGRFb8fQgQ== dependencies: - "@babel/helper-environment-visitor" "^7.22.20" - "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-plugin-utils" "^7.18.6" + "@babel/plugin-syntax-json-strings" "^7.8.3" + +"@babel/plugin-proposal-logical-assignment-operators@^7.18.9": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-logical-assignment-operators/-/plugin-proposal-logical-assignment-operators-7.20.7.tgz#dfbcaa8f7b4d37b51e8bfb46d94a5aea2bb89d83" + integrity sha512-y7C7cZgpMIjWlKE5T7eJwp+tnRYM89HmRvWM5EQuB5BoHEONjmQ8lSNmBUwOyy/GFRsohJED51YBF79hE1djug== + dependencies: + "@babel/helper-plugin-utils" "^7.20.2" + "@babel/plugin-syntax-logical-assignment-operators" "^7.10.4" + +"@babel/plugin-proposal-nullish-coalescing-operator@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.18.6.tgz#fdd940a99a740e577d6c753ab6fbb43fdb9467e1" + integrity sha512-wQxQzxYeJqHcfppzBDnm1yAY0jSRkUXR2z8RePZYrKwMKgMlE8+Z6LUno+bd6LvbGh8Gltvy74+9pIYkr+XkKA== + dependencies: + "@babel/helper-plugin-utils" "^7.18.6" + "@babel/plugin-syntax-nullish-coalescing-operator" "^7.8.3" + +"@babel/plugin-proposal-numeric-separator@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-numeric-separator/-/plugin-proposal-numeric-separator-7.18.6.tgz#899b14fbafe87f053d2c5ff05b36029c62e13c75" + integrity sha512-ozlZFogPqoLm8WBr5Z8UckIoE4YQ5KESVcNudyXOR8uqIkliTEgJ3RoketfG6pmzLdeZF0H/wjE9/cCEitBl7Q== + dependencies: + "@babel/helper-plugin-utils" "^7.18.6" + "@babel/plugin-syntax-numeric-separator" "^7.10.4" "@babel/plugin-proposal-object-rest-spread@7.12.1": version "7.12.1" @@ -464,10 +526,59 @@ "@babel/plugin-syntax-object-rest-spread" "^7.8.0" "@babel/plugin-transform-parameters" "^7.12.1" -"@babel/plugin-proposal-private-property-in-object@7.21.0-placeholder-for-preset-env.2": - version "7.21.0-placeholder-for-preset-env.2" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.0-placeholder-for-preset-env.2.tgz#7844f9289546efa9febac2de4cfe358a050bd703" - integrity sha512-SOSkfJDddaM7mak6cPEpswyTRnuRltl429hMraQEglW+OkovnCzsiszTmsrlY//qLFjCpQDFRvjdm2wA5pPm9w== +"@babel/plugin-proposal-object-rest-spread@^7.20.2": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.20.7.tgz#aa662940ef425779c75534a5c41e9d936edc390a" + integrity sha512-d2S98yCiLxDVmBmE8UjGcfPvNEUbA1U5q5WxaWFUGRzJSVAZqm5W6MbPct0jxnegUZ0niLeNX+IOzEs7wYg9Dg== + dependencies: + "@babel/compat-data" "^7.20.5" + "@babel/helper-compilation-targets" "^7.20.7" + "@babel/helper-plugin-utils" "^7.20.2" + "@babel/plugin-syntax-object-rest-spread" "^7.8.3" + "@babel/plugin-transform-parameters" "^7.20.7" + +"@babel/plugin-proposal-optional-catch-binding@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.18.6.tgz#f9400d0e6a3ea93ba9ef70b09e72dd6da638a2cb" + integrity sha512-Q40HEhs9DJQyaZfUjjn6vE8Cv4GmMHCYuMGIWUnlxH6400VGxOuwWsPt4FxXxJkC/5eOzgn0z21M9gMT4MOhbw== + dependencies: + "@babel/helper-plugin-utils" "^7.18.6" + "@babel/plugin-syntax-optional-catch-binding" "^7.8.3" + +"@babel/plugin-proposal-optional-chaining@^7.18.9", "@babel/plugin-proposal-optional-chaining@^7.20.7": + version "7.21.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.21.0.tgz#886f5c8978deb7d30f678b2e24346b287234d3ea" + integrity sha512-p4zeefM72gpmEe2fkUr/OnOXpWEf8nAgk7ZYVqqfFiyIG7oFfVZcCrU64hWn5xp4tQ9LkV4bTIa5rD0KANpKNA== + dependencies: + "@babel/helper-plugin-utils" "^7.20.2" + "@babel/helper-skip-transparent-expression-wrappers" "^7.20.0" + "@babel/plugin-syntax-optional-chaining" "^7.8.3" + +"@babel/plugin-proposal-private-methods@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-private-methods/-/plugin-proposal-private-methods-7.18.6.tgz#5209de7d213457548a98436fa2882f52f4be6bea" + integrity sha512-nutsvktDItsNn4rpGItSNV2sz1XwS+nfU0Rg8aCx3W3NOKVzdMjJRu0O5OkgDp3ZGICSTbgRpxZoWsxoKRvbeA== + dependencies: + "@babel/helper-create-class-features-plugin" "^7.18.6" + "@babel/helper-plugin-utils" "^7.18.6" + +"@babel/plugin-proposal-private-property-in-object@^7.18.6": + version "7.21.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.0.tgz#19496bd9883dd83c23c7d7fc45dcd9ad02dfa1dc" + integrity sha512-ha4zfehbJjc5MmXBlHec1igel5TJXXLDDRbuJ4+XT2TJcyD9/V1919BA8gMvsdHcNMBy4WBUBiRb3nw/EQUtBw== + dependencies: + "@babel/helper-annotate-as-pure" "^7.18.6" + "@babel/helper-create-class-features-plugin" "^7.21.0" + "@babel/helper-plugin-utils" "^7.20.2" + "@babel/plugin-syntax-private-property-in-object" "^7.14.5" + +"@babel/plugin-proposal-unicode-property-regex@^7.18.6", "@babel/plugin-proposal-unicode-property-regex@^7.4.4": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.18.6.tgz#af613d2cd5e643643b65cded64207b15c85cb78e" + integrity sha512-2BShG/d5yoZyXZfVePH91urL5wTG6ASZU9M4o03lKK8u8UW1y08OMttBSOADTcJrnPMpvDXRG3G8fyLh4ovs8w== + dependencies: + "@babel/helper-create-regexp-features-plugin" "^7.18.6" + "@babel/helper-plugin-utils" "^7.18.6" "@babel/plugin-syntax-async-generators@^7.8.4": version "7.8.4" @@ -504,26 +615,12 @@ dependencies: "@babel/helper-plugin-utils" "^7.8.3" -"@babel/plugin-syntax-import-assertions@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-import-assertions/-/plugin-syntax-import-assertions-7.23.3.tgz#9c05a7f592982aff1a2768260ad84bcd3f0c77fc" - integrity sha512-lPgDSU+SJLK3xmFDTV2ZRQAiM7UuUjGidwBywFavObCiZc1BeAAcMtHJKUya92hPHO+at63JJPLygilZard8jw== - dependencies: - "@babel/helper-plugin-utils" "^7.22.5" - -"@babel/plugin-syntax-import-attributes@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-import-attributes/-/plugin-syntax-import-attributes-7.23.3.tgz#992aee922cf04512461d7dae3ff6951b90a2dc06" - integrity sha512-pawnE0P9g10xgoP7yKr6CK63K2FMsTE+FZidZO/1PwRdzmAPVs+HS1mAURUsgaoxammTJvULUdIkEK0gOcU2tA== - dependencies: - "@babel/helper-plugin-utils" "^7.22.5" - -"@babel/plugin-syntax-import-meta@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-import-meta/-/plugin-syntax-import-meta-7.10.4.tgz#ee601348c370fa334d2207be158777496521fd51" - integrity sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g== +"@babel/plugin-syntax-import-assertions@^7.20.0": + version "7.20.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-import-assertions/-/plugin-syntax-import-assertions-7.20.0.tgz#bb50e0d4bea0957235390641209394e87bdb9cc4" + integrity sha512-IUh1vakzNoWalR8ch/areW7qFopR2AEw03JlG7BbrDqmQ4X3q9uuipQwSGrUn7oGiemKjtSLDhNtQHzMHr1JdQ== dependencies: - "@babel/helper-plugin-utils" "^7.10.4" + "@babel/helper-plugin-utils" "^7.19.0" "@babel/plugin-syntax-json-strings@^7.8.3": version "7.8.3" @@ -539,12 +636,12 @@ dependencies: "@babel/helper-plugin-utils" "^7.10.4" -"@babel/plugin-syntax-jsx@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.23.3.tgz#8f2e4f8a9b5f9aa16067e142c1ac9cd9f810f473" - integrity sha512-EB2MELswq55OHUoRZLGg/zC7QWUKfNLpE57m/S2yr1uEneIgsTgrSzXP3NXEsMkVn76OlaVVnzN+ugObuYGwhg== +"@babel/plugin-syntax-jsx@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.18.6.tgz#a8feef63b010150abd97f1649ec296e849943ca0" + integrity sha512-6mmljtAedFGTWu2p/8WIORGwy+61PLgOMPOdazc7YoJ9ZCWUyFy3A6CpPkRKLKD1ToAesxX8KGEViAiLo9N+7Q== dependencies: - "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-plugin-utils" "^7.18.6" "@babel/plugin-syntax-logical-assignment-operators@^7.10.4": version "7.10.4" @@ -602,492 +699,357 @@ dependencies: "@babel/helper-plugin-utils" "^7.14.5" -"@babel/plugin-syntax-typescript@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.23.3.tgz#24f460c85dbbc983cd2b9c4994178bcc01df958f" - integrity sha512-9EiNjVJOMwCO+43TqoTrgQ8jMwcAd0sWyXi9RPfIsLTj4R2MADDDQXELhffaUx/uJv2AYcxBgPwH6j4TIA4ytQ== - dependencies: - "@babel/helper-plugin-utils" "^7.22.5" - -"@babel/plugin-syntax-unicode-sets-regex@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-unicode-sets-regex/-/plugin-syntax-unicode-sets-regex-7.18.6.tgz#d49a3b3e6b52e5be6740022317580234a6a47357" - integrity sha512-727YkEAPwSIQTv5im8QHz3upqp92JTWhidIC81Tdx4VJYIte/VndKf1qKrfnnhPLiPghStWfvC/iFaMCQu7Nqg== - dependencies: - "@babel/helper-create-regexp-features-plugin" "^7.18.6" - "@babel/helper-plugin-utils" "^7.18.6" - -"@babel/plugin-transform-arrow-functions@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.23.3.tgz#94c6dcfd731af90f27a79509f9ab7fb2120fc38b" - integrity sha512-NzQcQrzaQPkaEwoTm4Mhyl8jI1huEL/WWIEvudjTCMJ9aBZNpsJbMASx7EQECtQQPS/DcnFpo0FIh3LvEO9cxQ== - dependencies: - "@babel/helper-plugin-utils" "^7.22.5" - -"@babel/plugin-transform-async-generator-functions@^7.23.7": - version "7.23.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-async-generator-functions/-/plugin-transform-async-generator-functions-7.23.7.tgz#3aa0b4f2fa3788b5226ef9346cf6d16ec61f99cd" - integrity sha512-PdxEpL71bJp1byMG0va5gwQcXHxuEYC/BgI/e88mGTtohbZN28O5Yit0Plkkm/dBzCF/BxmbNcses1RH1T+urA== +"@babel/plugin-syntax-typescript@^7.20.0": + version "7.20.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.20.0.tgz#4e9a0cfc769c85689b77a2e642d24e9f697fc8c7" + integrity sha512-rd9TkG+u1CExzS4SM1BlMEhMXwFLKVjOAFFCDx9PbX5ycJWDoWMcwdJH9RhkPu1dOgn5TrxLot/Gx6lWFuAUNQ== dependencies: - "@babel/helper-environment-visitor" "^7.22.20" - "@babel/helper-plugin-utils" "^7.22.5" - "@babel/helper-remap-async-to-generator" "^7.22.20" - "@babel/plugin-syntax-async-generators" "^7.8.4" - -"@babel/plugin-transform-async-to-generator@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.23.3.tgz#d1f513c7a8a506d43f47df2bf25f9254b0b051fa" - integrity sha512-A7LFsKi4U4fomjqXJlZg/u0ft/n8/7n7lpffUP/ZULx/DtV9SGlNKZolHH6PE8Xl1ngCc0M11OaeZptXVkfKSw== - dependencies: - "@babel/helper-module-imports" "^7.22.15" - "@babel/helper-plugin-utils" "^7.22.5" - "@babel/helper-remap-async-to-generator" "^7.22.20" + "@babel/helper-plugin-utils" "^7.19.0" -"@babel/plugin-transform-block-scoped-functions@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.23.3.tgz#fe1177d715fb569663095e04f3598525d98e8c77" - integrity sha512-vI+0sIaPIO6CNuM9Kk5VmXcMVRiOpDh7w2zZt9GXzmE/9KD70CUEVhvPR/etAeNK/FAEkhxQtXOzVF3EuRL41A== +"@babel/plugin-transform-arrow-functions@^7.18.6": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.20.7.tgz#bea332b0e8b2dab3dafe55a163d8227531ab0551" + integrity sha512-3poA5E7dzDomxj9WXWwuD6A5F3kc7VXwIJO+E+J8qtDtS+pXPAhrgEyh+9GBwBgPq1Z+bB+/JD60lp5jsN7JPQ== dependencies: - "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-plugin-utils" "^7.20.2" -"@babel/plugin-transform-block-scoping@^7.23.4": - version "7.23.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.23.4.tgz#b2d38589531c6c80fbe25e6b58e763622d2d3cf5" - integrity sha512-0QqbP6B6HOh7/8iNR4CQU2Th/bbRtBp4KS9vcaZd1fZ0wSh5Fyssg0UCIHwxh+ka+pNDREbVLQnHCMHKZfPwfw== +"@babel/plugin-transform-async-to-generator@^7.18.6": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.20.7.tgz#dfee18623c8cb31deb796aa3ca84dda9cea94354" + integrity sha512-Uo5gwHPT9vgnSXQxqGtpdufUiWp96gk7yiP4Mp5bm1QMkEmLXBO7PAGYbKoJ6DhAwiNkcHFBol/x5zZZkL/t0Q== dependencies: - "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-module-imports" "^7.18.6" + "@babel/helper-plugin-utils" "^7.20.2" + "@babel/helper-remap-async-to-generator" "^7.18.9" -"@babel/plugin-transform-class-properties@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-class-properties/-/plugin-transform-class-properties-7.23.3.tgz#35c377db11ca92a785a718b6aa4e3ed1eb65dc48" - integrity sha512-uM+AN8yCIjDPccsKGlw271xjJtGii+xQIF/uMPS8H15L12jZTsLfF4o5vNO7d/oUguOyfdikHGc/yi9ge4SGIg== - dependencies: - "@babel/helper-create-class-features-plugin" "^7.22.15" - "@babel/helper-plugin-utils" "^7.22.5" - -"@babel/plugin-transform-class-static-block@^7.23.4": - version "7.23.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-class-static-block/-/plugin-transform-class-static-block-7.23.4.tgz#2a202c8787a8964dd11dfcedf994d36bfc844ab5" - integrity sha512-nsWu/1M+ggti1SOALj3hfx5FXzAY06fwPJsUZD4/A5e1bWi46VUIWtD+kOX6/IdhXGsXBWllLFDSnqSCdUNydQ== +"@babel/plugin-transform-block-scoped-functions@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.18.6.tgz#9187bf4ba302635b9d70d986ad70f038726216a8" + integrity sha512-ExUcOqpPWnliRcPqves5HJcJOvHvIIWfuS4sroBUenPuMdmW+SMHDakmtS7qOo13sVppmUijqeTv7qqGsvURpQ== dependencies: - "@babel/helper-create-class-features-plugin" "^7.22.15" - "@babel/helper-plugin-utils" "^7.22.5" - "@babel/plugin-syntax-class-static-block" "^7.14.5" + "@babel/helper-plugin-utils" "^7.18.6" -"@babel/plugin-transform-classes@^7.23.8": - version "7.23.8" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-classes/-/plugin-transform-classes-7.23.8.tgz#d08ae096c240347badd68cdf1b6d1624a6435d92" - integrity sha512-yAYslGsY1bX6Knmg46RjiCiNSwJKv2IUC8qOdYKqMMr0491SXFhcHqOdRDeCRohOOIzwN/90C6mQ9qAKgrP7dg== - dependencies: - "@babel/helper-annotate-as-pure" "^7.22.5" - "@babel/helper-compilation-targets" "^7.23.6" - "@babel/helper-environment-visitor" "^7.22.20" - "@babel/helper-function-name" "^7.23.0" - "@babel/helper-plugin-utils" "^7.22.5" - "@babel/helper-replace-supers" "^7.22.20" - "@babel/helper-split-export-declaration" "^7.22.6" +"@babel/plugin-transform-block-scoping@^7.20.2": + version "7.21.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.21.0.tgz#e737b91037e5186ee16b76e7ae093358a5634f02" + integrity sha512-Mdrbunoh9SxwFZapeHVrwFmri16+oYotcZysSzhNIVDwIAb1UV+kvnxULSYq9J3/q5MDG+4X6w8QVgD1zhBXNQ== + dependencies: + "@babel/helper-plugin-utils" "^7.20.2" + +"@babel/plugin-transform-classes@^7.20.2": + version "7.21.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-classes/-/plugin-transform-classes-7.21.0.tgz#f469d0b07a4c5a7dbb21afad9e27e57b47031665" + integrity sha512-RZhbYTCEUAe6ntPehC4hlslPWosNHDox+vAs4On/mCLRLfoDVHf6hVEd7kuxr1RnHwJmxFfUM3cZiZRmPxJPXQ== + dependencies: + "@babel/helper-annotate-as-pure" "^7.18.6" + "@babel/helper-compilation-targets" "^7.20.7" + "@babel/helper-environment-visitor" "^7.18.9" + "@babel/helper-function-name" "^7.21.0" + "@babel/helper-optimise-call-expression" "^7.18.6" + "@babel/helper-plugin-utils" "^7.20.2" + "@babel/helper-replace-supers" "^7.20.7" + "@babel/helper-split-export-declaration" "^7.18.6" globals "^11.1.0" -"@babel/plugin-transform-computed-properties@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.23.3.tgz#652e69561fcc9d2b50ba4f7ac7f60dcf65e86474" - integrity sha512-dTj83UVTLw/+nbiHqQSFdwO9CbTtwq1DsDqm3CUEtDrZNET5rT5E6bIdTlOftDTDLMYxvxHNEYO4B9SLl8SLZw== - dependencies: - "@babel/helper-plugin-utils" "^7.22.5" - "@babel/template" "^7.22.15" - -"@babel/plugin-transform-destructuring@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.23.3.tgz#8c9ee68228b12ae3dff986e56ed1ba4f3c446311" - integrity sha512-n225npDqjDIr967cMScVKHXJs7rout1q+tt50inyBCPkyZ8KxeI6d+GIbSBTT/w/9WdlWDOej3V9HE5Lgk57gw== - dependencies: - "@babel/helper-plugin-utils" "^7.22.5" - -"@babel/plugin-transform-dotall-regex@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.23.3.tgz#3f7af6054882ede89c378d0cf889b854a993da50" - integrity sha512-vgnFYDHAKzFaTVp+mneDsIEbnJ2Np/9ng9iviHw3P/KVcgONxpNULEW/51Z/BaFojG2GI2GwwXck5uV1+1NOYQ== +"@babel/plugin-transform-computed-properties@^7.18.9": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.20.7.tgz#704cc2fd155d1c996551db8276d55b9d46e4d0aa" + integrity sha512-Lz7MvBK6DTjElHAmfu6bfANzKcxpyNPeYBGEafyA6E5HtRpjpZwU+u7Qrgz/2OR0z+5TvKYbPdphfSaAcZBrYQ== dependencies: - "@babel/helper-create-regexp-features-plugin" "^7.22.15" - "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-plugin-utils" "^7.20.2" + "@babel/template" "^7.20.7" -"@babel/plugin-transform-duplicate-keys@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.23.3.tgz#664706ca0a5dfe8d066537f99032fc1dc8b720ce" - integrity sha512-RrqQ+BQmU3Oyav3J+7/myfvRCq7Tbz+kKLLshUmMwNlDHExbGL7ARhajvoBJEvc+fCguPPu887N+3RRXBVKZUA== +"@babel/plugin-transform-destructuring@^7.20.2": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.20.7.tgz#8bda578f71620c7de7c93af590154ba331415454" + integrity sha512-Xwg403sRrZb81IVB79ZPqNQME23yhugYVqgTxAhT99h485F4f+GMELFhhOsscDUB7HCswepKeCKLn/GZvUKoBA== dependencies: - "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-plugin-utils" "^7.20.2" -"@babel/plugin-transform-dynamic-import@^7.23.4": - version "7.23.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-dynamic-import/-/plugin-transform-dynamic-import-7.23.4.tgz#c7629e7254011ac3630d47d7f34ddd40ca535143" - integrity sha512-V6jIbLhdJK86MaLh4Jpghi8ho5fGzt3imHOBu/x0jlBaPYqDoWz4RDXjmMOfnh+JWNaQleEAByZLV0QzBT4YQQ== - dependencies: - "@babel/helper-plugin-utils" "^7.22.5" - "@babel/plugin-syntax-dynamic-import" "^7.8.3" - -"@babel/plugin-transform-exponentiation-operator@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.23.3.tgz#ea0d978f6b9232ba4722f3dbecdd18f450babd18" - integrity sha512-5fhCsl1odX96u7ILKHBj4/Y8vipoqwsJMh4csSA8qFfxrZDEA4Ssku2DyNvMJSmZNOEBT750LfFPbtrnTP90BQ== - dependencies: - "@babel/helper-builder-binary-assignment-operator-visitor" "^7.22.15" - "@babel/helper-plugin-utils" "^7.22.5" - -"@babel/plugin-transform-export-namespace-from@^7.23.4": - version "7.23.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-export-namespace-from/-/plugin-transform-export-namespace-from-7.23.4.tgz#084c7b25e9a5c8271e987a08cf85807b80283191" - integrity sha512-GzuSBcKkx62dGzZI1WVgTWvkkz84FZO5TC5T8dl/Tht/rAla6Dg/Mz9Yhypg+ezVACf/rgDuQt3kbWEv7LdUDQ== - dependencies: - "@babel/helper-plugin-utils" "^7.22.5" - "@babel/plugin-syntax-export-namespace-from" "^7.8.3" - -"@babel/plugin-transform-for-of@^7.23.6": - version "7.23.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.23.6.tgz#81c37e24171b37b370ba6aaffa7ac86bcb46f94e" - integrity sha512-aYH4ytZ0qSuBbpfhuofbg/e96oQ7U2w1Aw/UQmKT+1l39uEhUPoFS3fHevDc1G0OvewyDudfMKY1OulczHzWIw== - dependencies: - "@babel/helper-plugin-utils" "^7.22.5" - "@babel/helper-skip-transparent-expression-wrappers" "^7.22.5" - -"@babel/plugin-transform-function-name@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.23.3.tgz#8f424fcd862bf84cb9a1a6b42bc2f47ed630f8dc" - integrity sha512-I1QXp1LxIvt8yLaib49dRW5Okt7Q4oaxao6tFVKS/anCdEOMtYwWVKoiOA1p34GOWIZjUK0E+zCp7+l1pfQyiw== - dependencies: - "@babel/helper-compilation-targets" "^7.22.15" - "@babel/helper-function-name" "^7.23.0" - "@babel/helper-plugin-utils" "^7.22.5" - -"@babel/plugin-transform-json-strings@^7.23.4": - version "7.23.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-json-strings/-/plugin-transform-json-strings-7.23.4.tgz#a871d9b6bd171976efad2e43e694c961ffa3714d" - integrity sha512-81nTOqM1dMwZ/aRXQ59zVubN9wHGqk6UtqRK+/q+ciXmRy8fSolhGVvG09HHRGo4l6fr/c4ZhXUQH0uFW7PZbg== - dependencies: - "@babel/helper-plugin-utils" "^7.22.5" - "@babel/plugin-syntax-json-strings" "^7.8.3" - -"@babel/plugin-transform-literals@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-literals/-/plugin-transform-literals-7.23.3.tgz#8214665f00506ead73de157eba233e7381f3beb4" - integrity sha512-wZ0PIXRxnwZvl9AYpqNUxpZ5BiTGrYt7kueGQ+N5FiQ7RCOD4cm8iShd6S6ggfVIWaJf2EMk8eRzAh52RfP4rQ== - dependencies: - "@babel/helper-plugin-utils" "^7.22.5" - -"@babel/plugin-transform-logical-assignment-operators@^7.23.4": - version "7.23.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-logical-assignment-operators/-/plugin-transform-logical-assignment-operators-7.23.4.tgz#e599f82c51d55fac725f62ce55d3a0886279ecb5" - integrity sha512-Mc/ALf1rmZTP4JKKEhUwiORU+vcfarFVLfcFiolKUo6sewoxSEgl36ak5t+4WamRsNr6nzjZXQjM35WsU+9vbg== - dependencies: - "@babel/helper-plugin-utils" "^7.22.5" - "@babel/plugin-syntax-logical-assignment-operators" "^7.10.4" - -"@babel/plugin-transform-member-expression-literals@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.23.3.tgz#e37b3f0502289f477ac0e776b05a833d853cabcc" - integrity sha512-sC3LdDBDi5x96LA+Ytekz2ZPk8i/Ck+DEuDbRAll5rknJ5XRTSaPKEYwomLcs1AA8wg9b3KjIQRsnApj+q51Ag== - dependencies: - "@babel/helper-plugin-utils" "^7.22.5" - -"@babel/plugin-transform-modules-amd@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.23.3.tgz#e19b55436a1416829df0a1afc495deedfae17f7d" - integrity sha512-vJYQGxeKM4t8hYCKVBlZX/gtIY2I7mRGFNcm85sgXGMTBcoV3QdVtdpbcWEbzbfUIUZKwvgFT82mRvaQIebZzw== +"@babel/plugin-transform-dotall-regex@^7.18.6", "@babel/plugin-transform-dotall-regex@^7.4.4": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.18.6.tgz#b286b3e7aae6c7b861e45bed0a2fafd6b1a4fef8" + integrity sha512-6S3jpun1eEbAxq7TdjLotAsl4WpQI9DxfkycRcKrjhQYzU87qpXdknpBg/e+TdcMehqGnLFi7tnFUBR02Vq6wg== dependencies: - "@babel/helper-module-transforms" "^7.23.3" - "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-create-regexp-features-plugin" "^7.18.6" + "@babel/helper-plugin-utils" "^7.18.6" -"@babel/plugin-transform-modules-commonjs@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.23.3.tgz#661ae831b9577e52be57dd8356b734f9700b53b4" - integrity sha512-aVS0F65LKsdNOtcz6FRCpE4OgsP2OFnW46qNxNIX9h3wuzaNcSQsJysuMwqSibC98HPrf2vCgtxKNwS0DAlgcA== +"@babel/plugin-transform-duplicate-keys@^7.18.9": + version "7.18.9" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.18.9.tgz#687f15ee3cdad6d85191eb2a372c4528eaa0ae0e" + integrity sha512-d2bmXCtZXYc59/0SanQKbiWINadaJXqtvIQIzd4+hNwkWBgyCd5F/2t1kXoUdvPMrxzPvhK6EMQRROxsue+mfw== dependencies: - "@babel/helper-module-transforms" "^7.23.3" - "@babel/helper-plugin-utils" "^7.22.5" - "@babel/helper-simple-access" "^7.22.5" + "@babel/helper-plugin-utils" "^7.18.9" -"@babel/plugin-transform-modules-systemjs@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.23.3.tgz#fa7e62248931cb15b9404f8052581c302dd9de81" - integrity sha512-ZxyKGTkF9xT9YJuKQRo19ewf3pXpopuYQd8cDXqNzc3mUNbOME0RKMoZxviQk74hwzfQsEe66dE92MaZbdHKNQ== +"@babel/plugin-transform-exponentiation-operator@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.18.6.tgz#421c705f4521888c65e91fdd1af951bfefd4dacd" + integrity sha512-wzEtc0+2c88FVR34aQmiz56dxEkxr2g8DQb/KfaFa1JYXOFVsbhvAonFN6PwVWj++fKmku8NP80plJ5Et4wqHw== dependencies: - "@babel/helper-hoist-variables" "^7.22.5" - "@babel/helper-module-transforms" "^7.23.3" - "@babel/helper-plugin-utils" "^7.22.5" - "@babel/helper-validator-identifier" "^7.22.20" + "@babel/helper-builder-binary-assignment-operator-visitor" "^7.18.6" + "@babel/helper-plugin-utils" "^7.18.6" -"@babel/plugin-transform-modules-umd@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.23.3.tgz#5d4395fccd071dfefe6585a4411aa7d6b7d769e9" - integrity sha512-zHsy9iXX2nIsCBFPud3jKn1IRPWg3Ing1qOZgeKV39m1ZgIdpJqvlWVeiHBZC6ITRG0MfskhYe9cLgntfSFPIg== +"@babel/plugin-transform-for-of@^7.18.8": + version "7.21.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.21.0.tgz#964108c9988de1a60b4be2354a7d7e245f36e86e" + integrity sha512-LlUYlydgDkKpIY7mcBWvyPPmMcOphEyYA27Ef4xpbh1IiDNLr0kZsos2nf92vz3IccvJI25QUwp86Eo5s6HmBQ== dependencies: - "@babel/helper-module-transforms" "^7.23.3" - "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-plugin-utils" "^7.20.2" -"@babel/plugin-transform-named-capturing-groups-regex@^7.22.5": - version "7.22.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.22.5.tgz#67fe18ee8ce02d57c855185e27e3dc959b2e991f" - integrity sha512-YgLLKmS3aUBhHaxp5hi1WJTgOUb/NCuDHzGT9z9WTt3YG+CPRhJs6nprbStx6DnWM4dh6gt7SU3sZodbZ08adQ== +"@babel/plugin-transform-function-name@^7.18.9": + version "7.18.9" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.18.9.tgz#cc354f8234e62968946c61a46d6365440fc764e0" + integrity sha512-WvIBoRPaJQ5yVHzcnJFor7oS5Ls0PYixlTYE63lCj2RtdQEl15M68FXQlxnG6wdraJIXRdR7KI+hQ7q/9QjrCQ== dependencies: - "@babel/helper-create-regexp-features-plugin" "^7.22.5" - "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-compilation-targets" "^7.18.9" + "@babel/helper-function-name" "^7.18.9" + "@babel/helper-plugin-utils" "^7.18.9" -"@babel/plugin-transform-new-target@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.23.3.tgz#5491bb78ed6ac87e990957cea367eab781c4d980" - integrity sha512-YJ3xKqtJMAT5/TIZnpAR3I+K+WaDowYbN3xyxI8zxx/Gsypwf9B9h0VB+1Nh6ACAAPRS5NSRje0uVv5i79HYGQ== +"@babel/plugin-transform-literals@^7.18.9": + version "7.18.9" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-literals/-/plugin-transform-literals-7.18.9.tgz#72796fdbef80e56fba3c6a699d54f0de557444bc" + integrity sha512-IFQDSRoTPnrAIrI5zoZv73IFeZu2dhu6irxQjY9rNjTT53VmKg9fenjvoiOWOkJ6mm4jKVPtdMzBY98Fp4Z4cg== dependencies: - "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-plugin-utils" "^7.18.9" -"@babel/plugin-transform-nullish-coalescing-operator@^7.23.4": - version "7.23.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-nullish-coalescing-operator/-/plugin-transform-nullish-coalescing-operator-7.23.4.tgz#45556aad123fc6e52189ea749e33ce090637346e" - integrity sha512-jHE9EVVqHKAQx+VePv5LLGHjmHSJR76vawFPTdlxR/LVJPfOEGxREQwQfjuZEOPTwG92X3LINSh3M40Rv4zpVA== +"@babel/plugin-transform-member-expression-literals@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.18.6.tgz#ac9fdc1a118620ac49b7e7a5d2dc177a1bfee88e" + integrity sha512-qSF1ihLGO3q+/g48k85tUjD033C29TNTVB2paCwZPVmOsjn9pClvYYrM2VeJpBY2bcNkuny0YUyTNRyRxJ54KA== dependencies: - "@babel/helper-plugin-utils" "^7.22.5" - "@babel/plugin-syntax-nullish-coalescing-operator" "^7.8.3" + "@babel/helper-plugin-utils" "^7.18.6" -"@babel/plugin-transform-numeric-separator@^7.23.4": - version "7.23.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-numeric-separator/-/plugin-transform-numeric-separator-7.23.4.tgz#03d08e3691e405804ecdd19dd278a40cca531f29" - integrity sha512-mps6auzgwjRrwKEZA05cOwuDc9FAzoyFS4ZsG/8F43bTLf/TgkJg7QXOrPO1JO599iA3qgK9MXdMGOEC8O1h6Q== +"@babel/plugin-transform-modules-amd@^7.19.6": + version "7.20.11" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.20.11.tgz#3daccca8e4cc309f03c3a0c4b41dc4b26f55214a" + integrity sha512-NuzCt5IIYOW0O30UvqktzHYR2ud5bOWbY0yaxWZ6G+aFzOMJvrs5YHNikrbdaT15+KNO31nPOy5Fim3ku6Zb5g== dependencies: - "@babel/helper-plugin-utils" "^7.22.5" - "@babel/plugin-syntax-numeric-separator" "^7.10.4" + "@babel/helper-module-transforms" "^7.20.11" + "@babel/helper-plugin-utils" "^7.20.2" -"@babel/plugin-transform-object-rest-spread@^7.23.4": - version "7.23.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-object-rest-spread/-/plugin-transform-object-rest-spread-7.23.4.tgz#2b9c2d26bf62710460bdc0d1730d4f1048361b83" - integrity sha512-9x9K1YyeQVw0iOXJlIzwm8ltobIIv7j2iLyP2jIhEbqPRQ7ScNgwQufU2I0Gq11VjyG4gI4yMXt2VFags+1N3g== +"@babel/plugin-transform-modules-commonjs@^7.19.6": + version "7.21.2" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.21.2.tgz#6ff5070e71e3192ef2b7e39820a06fb78e3058e7" + integrity sha512-Cln+Yy04Gxua7iPdj6nOV96smLGjpElir5YwzF0LBPKoPlLDNJePNlrGGaybAJkd0zKRnOVXOgizSqPYMNYkzA== dependencies: - "@babel/compat-data" "^7.23.3" - "@babel/helper-compilation-targets" "^7.22.15" - "@babel/helper-plugin-utils" "^7.22.5" - "@babel/plugin-syntax-object-rest-spread" "^7.8.3" - "@babel/plugin-transform-parameters" "^7.23.3" + "@babel/helper-module-transforms" "^7.21.2" + "@babel/helper-plugin-utils" "^7.20.2" + "@babel/helper-simple-access" "^7.20.2" -"@babel/plugin-transform-object-super@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.23.3.tgz#81fdb636dcb306dd2e4e8fd80db5b2362ed2ebcd" - integrity sha512-BwQ8q0x2JG+3lxCVFohg+KbQM7plfpBwThdW9A6TMtWwLsbDA01Ek2Zb/AgDN39BiZsExm4qrXxjk+P1/fzGrA== +"@babel/plugin-transform-modules-systemjs@^7.19.6": + version "7.20.11" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.20.11.tgz#467ec6bba6b6a50634eea61c9c232654d8a4696e" + integrity sha512-vVu5g9BPQKSFEmvt2TA4Da5N+QVS66EX21d8uoOihC+OCpUoGvzVsXeqFdtAEfVa5BILAeFt+U7yVmLbQnAJmw== dependencies: - "@babel/helper-plugin-utils" "^7.22.5" - "@babel/helper-replace-supers" "^7.22.20" + "@babel/helper-hoist-variables" "^7.18.6" + "@babel/helper-module-transforms" "^7.20.11" + "@babel/helper-plugin-utils" "^7.20.2" + "@babel/helper-validator-identifier" "^7.19.1" -"@babel/plugin-transform-optional-catch-binding@^7.23.4": - version "7.23.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-optional-catch-binding/-/plugin-transform-optional-catch-binding-7.23.4.tgz#318066de6dacce7d92fa244ae475aa8d91778017" - integrity sha512-XIq8t0rJPHf6Wvmbn9nFxU6ao4c7WhghTR5WyV8SrJfUFzyxhCm4nhC+iAp3HFhbAKLfYpgzhJ6t4XCtVwqO5A== +"@babel/plugin-transform-modules-umd@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.18.6.tgz#81d3832d6034b75b54e62821ba58f28ed0aab4b9" + integrity sha512-dcegErExVeXcRqNtkRU/z8WlBLnvD4MRnHgNs3MytRO1Mn1sHRyhbcpYbVMGclAqOjdW+9cfkdZno9dFdfKLfQ== dependencies: - "@babel/helper-plugin-utils" "^7.22.5" - "@babel/plugin-syntax-optional-catch-binding" "^7.8.3" + "@babel/helper-module-transforms" "^7.18.6" + "@babel/helper-plugin-utils" "^7.18.6" -"@babel/plugin-transform-optional-chaining@^7.23.3", "@babel/plugin-transform-optional-chaining@^7.23.4": - version "7.23.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-optional-chaining/-/plugin-transform-optional-chaining-7.23.4.tgz#6acf61203bdfc4de9d4e52e64490aeb3e52bd017" - integrity sha512-ZU8y5zWOfjM5vZ+asjgAPwDaBjJzgufjES89Rs4Lpq63O300R/kOz30WCLo6BxxX6QVEilwSlpClnG5cZaikTA== +"@babel/plugin-transform-named-capturing-groups-regex@^7.19.1": + version "7.20.5" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.20.5.tgz#626298dd62ea51d452c3be58b285d23195ba69a8" + integrity sha512-mOW4tTzi5iTLnw+78iEq3gr8Aoq4WNRGpmSlrogqaiCBoR1HFhpU4JkpQFOHfeYx3ReVIFWOQJS4aZBRvuZ6mA== dependencies: - "@babel/helper-plugin-utils" "^7.22.5" - "@babel/helper-skip-transparent-expression-wrappers" "^7.22.5" - "@babel/plugin-syntax-optional-chaining" "^7.8.3" + "@babel/helper-create-regexp-features-plugin" "^7.20.5" + "@babel/helper-plugin-utils" "^7.20.2" -"@babel/plugin-transform-parameters@^7.12.1", "@babel/plugin-transform-parameters@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.23.3.tgz#83ef5d1baf4b1072fa6e54b2b0999a7b2527e2af" - integrity sha512-09lMt6UsUb3/34BbECKVbVwrT9bO6lILWln237z7sLaWnMsTi7Yc9fhX5DLpkJzAGfaReXI22wP41SZmnAA3Vw== +"@babel/plugin-transform-new-target@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.18.6.tgz#d128f376ae200477f37c4ddfcc722a8a1b3246a8" + integrity sha512-DjwFA/9Iu3Z+vrAn+8pBUGcjhxKguSMlsFqeCKbhb9BAV756v0krzVK04CRDi/4aqmk8BsHb4a/gFcaA5joXRw== dependencies: - "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-plugin-utils" "^7.18.6" -"@babel/plugin-transform-private-methods@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-private-methods/-/plugin-transform-private-methods-7.23.3.tgz#b2d7a3c97e278bfe59137a978d53b2c2e038c0e4" - integrity sha512-UzqRcRtWsDMTLrRWFvUBDwmw06tCQH9Rl1uAjfh6ijMSmGYQ+fpdB+cnqRC8EMh5tuuxSv0/TejGL+7vyj+50g== +"@babel/plugin-transform-object-super@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.18.6.tgz#fb3c6ccdd15939b6ff7939944b51971ddc35912c" + integrity sha512-uvGz6zk+pZoS1aTZrOvrbj6Pp/kK2mp45t2B+bTDre2UgsZZ8EZLSJtUg7m/no0zOJUWgFONpB7Zv9W2tSaFlA== dependencies: - "@babel/helper-create-class-features-plugin" "^7.22.15" - "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-plugin-utils" "^7.18.6" + "@babel/helper-replace-supers" "^7.18.6" -"@babel/plugin-transform-private-property-in-object@^7.23.4": - version "7.23.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-private-property-in-object/-/plugin-transform-private-property-in-object-7.23.4.tgz#3ec711d05d6608fd173d9b8de39872d8dbf68bf5" - integrity sha512-9G3K1YqTq3F4Vt88Djx1UZ79PDyj+yKRnUy7cZGSMe+a7jkwD259uKKuUzQlPkGam7R+8RJwh5z4xO27fA1o2A== +"@babel/plugin-transform-parameters@^7.12.1", "@babel/plugin-transform-parameters@^7.20.1", "@babel/plugin-transform-parameters@^7.20.7": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.20.7.tgz#0ee349e9d1bc96e78e3b37a7af423a4078a7083f" + integrity sha512-WiWBIkeHKVOSYPO0pWkxGPfKeWrCJyD3NJ53+Lrp/QMSZbsVPovrVl2aWZ19D/LTVnaDv5Ap7GJ/B2CTOZdrfA== dependencies: - "@babel/helper-annotate-as-pure" "^7.22.5" - "@babel/helper-create-class-features-plugin" "^7.22.15" - "@babel/helper-plugin-utils" "^7.22.5" - "@babel/plugin-syntax-private-property-in-object" "^7.14.5" + "@babel/helper-plugin-utils" "^7.20.2" -"@babel/plugin-transform-property-literals@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.23.3.tgz#54518f14ac4755d22b92162e4a852d308a560875" - integrity sha512-jR3Jn3y7cZp4oEWPFAlRsSWjxKe4PZILGBSd4nis1TsC5qeSpb+nrtihJuDhNI7QHiVbUaiXa0X2RZY3/TI6Nw== +"@babel/plugin-transform-property-literals@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.18.6.tgz#e22498903a483448e94e032e9bbb9c5ccbfc93a3" + integrity sha512-cYcs6qlgafTud3PAzrrRNbQtfpQ8+y/+M5tKmksS9+M1ckbH6kzY8MrexEM9mcA6JDsukE19iIRvAyYl463sMg== dependencies: - "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-plugin-utils" "^7.18.6" "@babel/plugin-transform-react-constant-elements@^7.18.12": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-constant-elements/-/plugin-transform-react-constant-elements-7.23.3.tgz#5efc001d07ef0f7da0d73c3a86c132f73d28e43c" - integrity sha512-zP0QKq/p6O42OL94udMgSfKXyse4RyJ0JqbQ34zDAONWjyrEsghYEyTSK5FIpmXmCpB55SHokL1cRRKHv8L2Qw== + version "7.20.2" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-constant-elements/-/plugin-transform-react-constant-elements-7.20.2.tgz#3f02c784e0b711970d7d8ccc96c4359d64e27ac7" + integrity sha512-KS/G8YI8uwMGKErLFOHS/ekhqdHhpEloxs43NecQHVgo2QuQSyJhGIY1fL8UGl9wy5ItVwwoUL4YxVqsplGq2g== dependencies: - "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-plugin-utils" "^7.20.2" -"@babel/plugin-transform-react-display-name@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-display-name/-/plugin-transform-react-display-name-7.23.3.tgz#70529f034dd1e561045ad3c8152a267f0d7b6200" - integrity sha512-GnvhtVfA2OAtzdX58FJxU19rhoGeQzyVndw3GgtdECQvQFXPEZIOVULHVZGAYmOgmqjXpVpfocAbSjh99V/Fqw== +"@babel/plugin-transform-react-display-name@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-display-name/-/plugin-transform-react-display-name-7.18.6.tgz#8b1125f919ef36ebdfff061d664e266c666b9415" + integrity sha512-TV4sQ+T013n61uMoygyMRm+xf04Bd5oqFpv2jAEQwSZ8NwQA7zeRPg1LMVg2PWi3zWBz+CLKD+v5bcpZ/BS0aA== dependencies: - "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-plugin-utils" "^7.18.6" -"@babel/plugin-transform-react-jsx-development@^7.22.5": - version "7.22.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx-development/-/plugin-transform-react-jsx-development-7.22.5.tgz#e716b6edbef972a92165cd69d92f1255f7e73e87" - integrity sha512-bDhuzwWMuInwCYeDeMzyi7TaBgRQei6DqxhbyniL7/VG4RSS7HtSL2QbY4eESy1KJqlWt8g3xeEBGPuo+XqC8A== +"@babel/plugin-transform-react-jsx-development@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx-development/-/plugin-transform-react-jsx-development-7.18.6.tgz#dbe5c972811e49c7405b630e4d0d2e1380c0ddc5" + integrity sha512-SA6HEjwYFKF7WDjWcMcMGUimmw/nhNRDWxr+KaLSCrkD/LMDBvWRmHAYgE1HDeF8KUuI8OAu+RT6EOtKxSW2qA== dependencies: - "@babel/plugin-transform-react-jsx" "^7.22.5" + "@babel/plugin-transform-react-jsx" "^7.18.6" -"@babel/plugin-transform-react-jsx@^7.22.15", "@babel/plugin-transform-react-jsx@^7.22.5": - version "7.23.4" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx/-/plugin-transform-react-jsx-7.23.4.tgz#393f99185110cea87184ea47bcb4a7b0c2e39312" - integrity sha512-5xOpoPguCZCRbo/JeHlloSkTA8Bld1J/E1/kLfD1nsuiW1m8tduTA1ERCgIZokDflX/IBzKcqR3l7VlRgiIfHA== +"@babel/plugin-transform-react-jsx@^7.18.6": + version "7.21.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx/-/plugin-transform-react-jsx-7.21.0.tgz#656b42c2fdea0a6d8762075d58ef9d4e3c4ab8a2" + integrity sha512-6OAWljMvQrZjR2DaNhVfRz6dkCAVV+ymcLUmaf8bccGOHn2v5rHJK3tTpij0BuhdYWP4LLaqj5lwcdlpAAPuvg== dependencies: - "@babel/helper-annotate-as-pure" "^7.22.5" - "@babel/helper-module-imports" "^7.22.15" - "@babel/helper-plugin-utils" "^7.22.5" - "@babel/plugin-syntax-jsx" "^7.23.3" - "@babel/types" "^7.23.4" + "@babel/helper-annotate-as-pure" "^7.18.6" + "@babel/helper-module-imports" "^7.18.6" + "@babel/helper-plugin-utils" "^7.20.2" + "@babel/plugin-syntax-jsx" "^7.18.6" + "@babel/types" "^7.21.0" -"@babel/plugin-transform-react-pure-annotations@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-pure-annotations/-/plugin-transform-react-pure-annotations-7.23.3.tgz#fabedbdb8ee40edf5da96f3ecfc6958e3783b93c" - integrity sha512-qMFdSS+TUhB7Q/3HVPnEdYJDQIk57jkntAwSuz9xfSE4n+3I+vHYCli3HoHawN1Z3RfCz/y1zXA/JXjG6cVImQ== +"@babel/plugin-transform-react-pure-annotations@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-pure-annotations/-/plugin-transform-react-pure-annotations-7.18.6.tgz#561af267f19f3e5d59291f9950fd7b9663d0d844" + integrity sha512-I8VfEPg9r2TRDdvnHgPepTKvuRomzA8+u+nhY7qSI1fR2hRNebasZEETLyM5mAUr0Ku56OkXJ0I7NHJnO6cJiQ== dependencies: - "@babel/helper-annotate-as-pure" "^7.22.5" - "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-annotate-as-pure" "^7.18.6" + "@babel/helper-plugin-utils" "^7.18.6" -"@babel/plugin-transform-regenerator@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.23.3.tgz#141afd4a2057298602069fce7f2dc5173e6c561c" - integrity sha512-KP+75h0KghBMcVpuKisx3XTu9Ncut8Q8TuvGO4IhY+9D5DFEckQefOuIsB/gQ2tG71lCke4NMrtIPS8pOj18BQ== +"@babel/plugin-transform-regenerator@^7.18.6": + version "7.20.5" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.20.5.tgz#57cda588c7ffb7f4f8483cc83bdcea02a907f04d" + integrity sha512-kW/oO7HPBtntbsahzQ0qSE3tFvkFwnbozz3NWFhLGqH75vLEg+sCGngLlhVkePlCs3Jv0dBBHDzCHxNiFAQKCQ== dependencies: - "@babel/helper-plugin-utils" "^7.22.5" - regenerator-transform "^0.15.2" + "@babel/helper-plugin-utils" "^7.20.2" + regenerator-transform "^0.15.1" -"@babel/plugin-transform-reserved-words@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-reserved-words/-/plugin-transform-reserved-words-7.23.3.tgz#4130dcee12bd3dd5705c587947eb715da12efac8" - integrity sha512-QnNTazY54YqgGxwIexMZva9gqbPa15t/x9VS+0fsEFWplwVpXYZivtgl43Z1vMpc1bdPP2PP8siFeVcnFvA3Cg== +"@babel/plugin-transform-reserved-words@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-reserved-words/-/plugin-transform-reserved-words-7.18.6.tgz#b1abd8ebf8edaa5f7fe6bbb8d2133d23b6a6f76a" + integrity sha512-oX/4MyMoypzHjFrT1CdivfKZ+XvIPMFXwwxHp/r0Ddy2Vuomt4HDFGmft1TAY2yiTKiNSsh3kjBAzcM8kSdsjA== dependencies: - "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-plugin-utils" "^7.18.6" "@babel/plugin-transform-runtime@^7.18.6": - version "7.23.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.23.7.tgz#52bbd20054855beb9deae3bee9ceb05289c343e6" - integrity sha512-fa0hnfmiXc9fq/weK34MUV0drz2pOL/vfKWvN7Qw127hiUPabFCUMgAbYWcchRzMJit4o5ARsK/s+5h0249pLw== - dependencies: - "@babel/helper-module-imports" "^7.22.15" - "@babel/helper-plugin-utils" "^7.22.5" - babel-plugin-polyfill-corejs2 "^0.4.7" - babel-plugin-polyfill-corejs3 "^0.8.7" - babel-plugin-polyfill-regenerator "^0.5.4" - semver "^6.3.1" - -"@babel/plugin-transform-shorthand-properties@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.23.3.tgz#97d82a39b0e0c24f8a981568a8ed851745f59210" - integrity sha512-ED2fgqZLmexWiN+YNFX26fx4gh5qHDhn1O2gvEhreLW2iI63Sqm4llRLCXALKrCnbN4Jy0VcMQZl/SAzqug/jg== - dependencies: - "@babel/helper-plugin-utils" "^7.22.5" - -"@babel/plugin-transform-spread@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-spread/-/plugin-transform-spread-7.23.3.tgz#41d17aacb12bde55168403c6f2d6bdca563d362c" - integrity sha512-VvfVYlrlBVu+77xVTOAoxQ6mZbnIq5FM0aGBSFEcIh03qHf+zNqA4DC/3XMUozTg7bZV3e3mZQ0i13VB6v5yUg== - dependencies: - "@babel/helper-plugin-utils" "^7.22.5" - "@babel/helper-skip-transparent-expression-wrappers" "^7.22.5" + version "7.21.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.21.0.tgz#2a884f29556d0a68cd3d152dcc9e6c71dfb6eee8" + integrity sha512-ReY6pxwSzEU0b3r2/T/VhqMKg/AkceBT19X0UptA3/tYi5Pe2eXgEUH+NNMC5nok6c6XQz5tyVTUpuezRfSMSg== + dependencies: + "@babel/helper-module-imports" "^7.18.6" + "@babel/helper-plugin-utils" "^7.20.2" + babel-plugin-polyfill-corejs2 "^0.3.3" + babel-plugin-polyfill-corejs3 "^0.6.0" + babel-plugin-polyfill-regenerator "^0.4.1" + semver "^6.3.0" -"@babel/plugin-transform-sticky-regex@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.23.3.tgz#dec45588ab4a723cb579c609b294a3d1bd22ff04" - integrity sha512-HZOyN9g+rtvnOU3Yh7kSxXrKbzgrm5X4GncPY1QOquu7epga5MxKHVpYu2hvQnry/H+JjckSYRb93iNfsioAGg== +"@babel/plugin-transform-shorthand-properties@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.18.6.tgz#6d6df7983d67b195289be24909e3f12a8f664dc9" + integrity sha512-eCLXXJqv8okzg86ywZJbRn19YJHU4XUa55oz2wbHhaQVn/MM+XhukiT7SYqp/7o00dg52Rj51Ny+Ecw4oyoygw== dependencies: - "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-plugin-utils" "^7.18.6" -"@babel/plugin-transform-template-literals@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.23.3.tgz#5f0f028eb14e50b5d0f76be57f90045757539d07" - integrity sha512-Flok06AYNp7GV2oJPZZcP9vZdszev6vPBkHLwxwSpaIqx75wn6mUd3UFWsSsA0l8nXAKkyCmL/sR02m8RYGeHg== +"@babel/plugin-transform-spread@^7.19.0": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-spread/-/plugin-transform-spread-7.20.7.tgz#c2d83e0b99d3bf83e07b11995ee24bf7ca09401e" + integrity sha512-ewBbHQ+1U/VnH1fxltbJqDeWBU1oNLG8Dj11uIv3xVf7nrQu0bPGe5Rf716r7K5Qz+SqtAOVswoVunoiBtGhxw== dependencies: - "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-plugin-utils" "^7.20.2" + "@babel/helper-skip-transparent-expression-wrappers" "^7.20.0" -"@babel/plugin-transform-typeof-symbol@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.23.3.tgz#9dfab97acc87495c0c449014eb9c547d8966bca4" - integrity sha512-4t15ViVnaFdrPC74be1gXBSMzXk3B4Us9lP7uLRQHTFpV5Dvt33pn+2MyyNxmN3VTTm3oTrZVMUmuw3oBnQ2oQ== +"@babel/plugin-transform-sticky-regex@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.18.6.tgz#c6706eb2b1524028e317720339583ad0f444adcc" + integrity sha512-kfiDrDQ+PBsQDO85yj1icueWMfGfJFKN1KCkndygtu/C9+XUfydLC8Iv5UYJqRwy4zk8EcplRxEOeLyjq1gm6Q== dependencies: - "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-plugin-utils" "^7.18.6" -"@babel/plugin-transform-typescript@^7.23.3": - version "7.23.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.23.6.tgz#aa36a94e5da8d94339ae3a4e22d40ed287feb34c" - integrity sha512-6cBG5mBvUu4VUD04OHKnYzbuHNP8huDsD3EDqqpIpsswTDoqHCjLoHb6+QgsV1WsT2nipRqCPgxD3LXnEO7XfA== +"@babel/plugin-transform-template-literals@^7.18.9": + version "7.18.9" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.18.9.tgz#04ec6f10acdaa81846689d63fae117dd9c243a5e" + integrity sha512-S8cOWfT82gTezpYOiVaGHrCbhlHgKhQt8XH5ES46P2XWmX92yisoZywf5km75wv5sYcXDUCLMmMxOLCtthDgMA== dependencies: - "@babel/helper-annotate-as-pure" "^7.22.5" - "@babel/helper-create-class-features-plugin" "^7.23.6" - "@babel/helper-plugin-utils" "^7.22.5" - "@babel/plugin-syntax-typescript" "^7.23.3" + "@babel/helper-plugin-utils" "^7.18.9" -"@babel/plugin-transform-unicode-escapes@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.23.3.tgz#1f66d16cab01fab98d784867d24f70c1ca65b925" - integrity sha512-OMCUx/bU6ChE3r4+ZdylEqAjaQgHAgipgW8nsCfu5pGqDcFytVd91AwRvUJSBZDz0exPGgnjoqhgRYLRjFZc9Q== +"@babel/plugin-transform-typeof-symbol@^7.18.9": + version "7.18.9" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.18.9.tgz#c8cea68263e45addcd6afc9091429f80925762c0" + integrity sha512-SRfwTtF11G2aemAZWivL7PD+C9z52v9EvMqH9BuYbabyPuKUvSWks3oCg6041pT925L4zVFqaVBeECwsmlguEw== dependencies: - "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-plugin-utils" "^7.18.9" -"@babel/plugin-transform-unicode-property-regex@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-property-regex/-/plugin-transform-unicode-property-regex-7.23.3.tgz#19e234129e5ffa7205010feec0d94c251083d7ad" - integrity sha512-KcLIm+pDZkWZQAFJ9pdfmh89EwVfmNovFBcXko8szpBeF8z68kWIPeKlmSOkT9BXJxs2C0uk+5LxoxIv62MROA== +"@babel/plugin-transform-typescript@^7.21.0": + version "7.21.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.21.0.tgz#f0956a153679e3b377ae5b7f0143427151e4c848" + integrity sha512-xo///XTPp3mDzTtrqXoBlK9eiAYW3wv9JXglcn/u1bi60RW11dEUxIgA8cbnDhutS1zacjMRmAwxE0gMklLnZg== dependencies: - "@babel/helper-create-regexp-features-plugin" "^7.22.15" - "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-create-class-features-plugin" "^7.21.0" + "@babel/helper-plugin-utils" "^7.20.2" + "@babel/plugin-syntax-typescript" "^7.20.0" -"@babel/plugin-transform-unicode-regex@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.23.3.tgz#26897708d8f42654ca4ce1b73e96140fbad879dc" - integrity sha512-wMHpNA4x2cIA32b/ci3AfwNgheiva2W0WUKWTK7vBHBhDKfPsc5cFGNWm69WBqpwd86u1qwZ9PWevKqm1A3yAw== +"@babel/plugin-transform-unicode-escapes@^7.18.10": + version "7.18.10" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.18.10.tgz#1ecfb0eda83d09bbcb77c09970c2dd55832aa246" + integrity sha512-kKAdAI+YzPgGY/ftStBFXTI1LZFju38rYThnfMykS+IXy8BVx+res7s2fxf1l8I35DV2T97ezo6+SGrXz6B3iQ== dependencies: - "@babel/helper-create-regexp-features-plugin" "^7.22.15" - "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-plugin-utils" "^7.18.9" -"@babel/plugin-transform-unicode-sets-regex@^7.23.3": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-sets-regex/-/plugin-transform-unicode-sets-regex-7.23.3.tgz#4fb6f0a719c2c5859d11f6b55a050cc987f3799e" - integrity sha512-W7lliA/v9bNR83Qc3q1ip9CQMZ09CcHDbHfbLRDNuAhn1Mvkr1ZNF7hPmztMQvtTGVLJ9m8IZqWsTkXOml8dbw== +"@babel/plugin-transform-unicode-regex@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.18.6.tgz#194317225d8c201bbae103364ffe9e2cea36cdca" + integrity sha512-gE7A6Lt7YLnNOL3Pb9BNeZvi+d8l7tcRrG4+pwJjK9hD2xX4mEvjlQW60G9EEmfXVYRPv9VRQcyegIVHCql/AA== dependencies: - "@babel/helper-create-regexp-features-plugin" "^7.22.15" - "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-create-regexp-features-plugin" "^7.18.6" + "@babel/helper-plugin-utils" "^7.18.6" "@babel/preset-env@^7.18.6", "@babel/preset-env@^7.19.4": - version "7.23.8" - resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.23.8.tgz#7d6f8171ea7c221ecd28059e65ad37c20e441e3e" - integrity sha512-lFlpmkApLkEP6woIKprO6DO60RImpatTQKtz4sUcDjVcK8M8mQ4sZsuxaTMNOZf0sqAq/ReYW1ZBHnOQwKpLWA== - dependencies: - "@babel/compat-data" "^7.23.5" - "@babel/helper-compilation-targets" "^7.23.6" - "@babel/helper-plugin-utils" "^7.22.5" - "@babel/helper-validator-option" "^7.23.5" - "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression" "^7.23.3" - "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining" "^7.23.3" - "@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly" "^7.23.7" - "@babel/plugin-proposal-private-property-in-object" "7.21.0-placeholder-for-preset-env.2" + version "7.20.2" + resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.20.2.tgz#9b1642aa47bb9f43a86f9630011780dab7f86506" + integrity sha512-1G0efQEWR1EHkKvKHqbG+IN/QdgwfByUpM5V5QroDzGV2t3S/WXNQd693cHiHTlCFMpr9B6FkPFXDA2lQcKoDg== + dependencies: + "@babel/compat-data" "^7.20.1" + "@babel/helper-compilation-targets" "^7.20.0" + "@babel/helper-plugin-utils" "^7.20.2" + "@babel/helper-validator-option" "^7.18.6" + "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression" "^7.18.6" + "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining" "^7.18.9" + "@babel/plugin-proposal-async-generator-functions" "^7.20.1" + "@babel/plugin-proposal-class-properties" "^7.18.6" + "@babel/plugin-proposal-class-static-block" "^7.18.6" + "@babel/plugin-proposal-dynamic-import" "^7.18.6" + "@babel/plugin-proposal-export-namespace-from" "^7.18.9" + "@babel/plugin-proposal-json-strings" "^7.18.6" + "@babel/plugin-proposal-logical-assignment-operators" "^7.18.9" + "@babel/plugin-proposal-nullish-coalescing-operator" "^7.18.6" + "@babel/plugin-proposal-numeric-separator" "^7.18.6" + "@babel/plugin-proposal-object-rest-spread" "^7.20.2" + "@babel/plugin-proposal-optional-catch-binding" "^7.18.6" + "@babel/plugin-proposal-optional-chaining" "^7.18.9" + "@babel/plugin-proposal-private-methods" "^7.18.6" + "@babel/plugin-proposal-private-property-in-object" "^7.18.6" + "@babel/plugin-proposal-unicode-property-regex" "^7.18.6" "@babel/plugin-syntax-async-generators" "^7.8.4" "@babel/plugin-syntax-class-properties" "^7.12.13" "@babel/plugin-syntax-class-static-block" "^7.14.5" "@babel/plugin-syntax-dynamic-import" "^7.8.3" "@babel/plugin-syntax-export-namespace-from" "^7.8.3" - "@babel/plugin-syntax-import-assertions" "^7.23.3" - "@babel/plugin-syntax-import-attributes" "^7.23.3" - "@babel/plugin-syntax-import-meta" "^7.10.4" + "@babel/plugin-syntax-import-assertions" "^7.20.0" "@babel/plugin-syntax-json-strings" "^7.8.3" "@babel/plugin-syntax-logical-assignment-operators" "^7.10.4" "@babel/plugin-syntax-nullish-coalescing-operator" "^7.8.3" @@ -1097,93 +1059,77 @@ "@babel/plugin-syntax-optional-chaining" "^7.8.3" "@babel/plugin-syntax-private-property-in-object" "^7.14.5" "@babel/plugin-syntax-top-level-await" "^7.14.5" - "@babel/plugin-syntax-unicode-sets-regex" "^7.18.6" - "@babel/plugin-transform-arrow-functions" "^7.23.3" - "@babel/plugin-transform-async-generator-functions" "^7.23.7" - "@babel/plugin-transform-async-to-generator" "^7.23.3" - "@babel/plugin-transform-block-scoped-functions" "^7.23.3" - "@babel/plugin-transform-block-scoping" "^7.23.4" - "@babel/plugin-transform-class-properties" "^7.23.3" - "@babel/plugin-transform-class-static-block" "^7.23.4" - "@babel/plugin-transform-classes" "^7.23.8" - "@babel/plugin-transform-computed-properties" "^7.23.3" - "@babel/plugin-transform-destructuring" "^7.23.3" - "@babel/plugin-transform-dotall-regex" "^7.23.3" - "@babel/plugin-transform-duplicate-keys" "^7.23.3" - "@babel/plugin-transform-dynamic-import" "^7.23.4" - "@babel/plugin-transform-exponentiation-operator" "^7.23.3" - "@babel/plugin-transform-export-namespace-from" "^7.23.4" - "@babel/plugin-transform-for-of" "^7.23.6" - "@babel/plugin-transform-function-name" "^7.23.3" - "@babel/plugin-transform-json-strings" "^7.23.4" - "@babel/plugin-transform-literals" "^7.23.3" - "@babel/plugin-transform-logical-assignment-operators" "^7.23.4" - "@babel/plugin-transform-member-expression-literals" "^7.23.3" - "@babel/plugin-transform-modules-amd" "^7.23.3" - "@babel/plugin-transform-modules-commonjs" "^7.23.3" - "@babel/plugin-transform-modules-systemjs" "^7.23.3" - "@babel/plugin-transform-modules-umd" "^7.23.3" - "@babel/plugin-transform-named-capturing-groups-regex" "^7.22.5" - "@babel/plugin-transform-new-target" "^7.23.3" - "@babel/plugin-transform-nullish-coalescing-operator" "^7.23.4" - "@babel/plugin-transform-numeric-separator" "^7.23.4" - "@babel/plugin-transform-object-rest-spread" "^7.23.4" - "@babel/plugin-transform-object-super" "^7.23.3" - "@babel/plugin-transform-optional-catch-binding" "^7.23.4" - "@babel/plugin-transform-optional-chaining" "^7.23.4" - "@babel/plugin-transform-parameters" "^7.23.3" - "@babel/plugin-transform-private-methods" "^7.23.3" - "@babel/plugin-transform-private-property-in-object" "^7.23.4" - "@babel/plugin-transform-property-literals" "^7.23.3" - "@babel/plugin-transform-regenerator" "^7.23.3" - "@babel/plugin-transform-reserved-words" "^7.23.3" - "@babel/plugin-transform-shorthand-properties" "^7.23.3" - "@babel/plugin-transform-spread" "^7.23.3" - "@babel/plugin-transform-sticky-regex" "^7.23.3" - "@babel/plugin-transform-template-literals" "^7.23.3" - "@babel/plugin-transform-typeof-symbol" "^7.23.3" - "@babel/plugin-transform-unicode-escapes" "^7.23.3" - "@babel/plugin-transform-unicode-property-regex" "^7.23.3" - "@babel/plugin-transform-unicode-regex" "^7.23.3" - "@babel/plugin-transform-unicode-sets-regex" "^7.23.3" - "@babel/preset-modules" "0.1.6-no-external-plugins" - babel-plugin-polyfill-corejs2 "^0.4.7" - babel-plugin-polyfill-corejs3 "^0.8.7" - babel-plugin-polyfill-regenerator "^0.5.4" - core-js-compat "^3.31.0" - semver "^6.3.1" - -"@babel/preset-modules@0.1.6-no-external-plugins": - version "0.1.6-no-external-plugins" - resolved "https://registry.yarnpkg.com/@babel/preset-modules/-/preset-modules-0.1.6-no-external-plugins.tgz#ccb88a2c49c817236861fee7826080573b8a923a" - integrity sha512-HrcgcIESLm9aIR842yhJ5RWan/gebQUJ6E/E5+rf0y9o6oj7w0Br+sWuL6kEQ/o/AdfvR1Je9jG18/gnpwjEyA== + "@babel/plugin-transform-arrow-functions" "^7.18.6" + "@babel/plugin-transform-async-to-generator" "^7.18.6" + "@babel/plugin-transform-block-scoped-functions" "^7.18.6" + "@babel/plugin-transform-block-scoping" "^7.20.2" + "@babel/plugin-transform-classes" "^7.20.2" + "@babel/plugin-transform-computed-properties" "^7.18.9" + "@babel/plugin-transform-destructuring" "^7.20.2" + "@babel/plugin-transform-dotall-regex" "^7.18.6" + "@babel/plugin-transform-duplicate-keys" "^7.18.9" + "@babel/plugin-transform-exponentiation-operator" "^7.18.6" + "@babel/plugin-transform-for-of" "^7.18.8" + "@babel/plugin-transform-function-name" "^7.18.9" + "@babel/plugin-transform-literals" "^7.18.9" + "@babel/plugin-transform-member-expression-literals" "^7.18.6" + "@babel/plugin-transform-modules-amd" "^7.19.6" + "@babel/plugin-transform-modules-commonjs" "^7.19.6" + "@babel/plugin-transform-modules-systemjs" "^7.19.6" + "@babel/plugin-transform-modules-umd" "^7.18.6" + "@babel/plugin-transform-named-capturing-groups-regex" "^7.19.1" + "@babel/plugin-transform-new-target" "^7.18.6" + "@babel/plugin-transform-object-super" "^7.18.6" + "@babel/plugin-transform-parameters" "^7.20.1" + "@babel/plugin-transform-property-literals" "^7.18.6" + "@babel/plugin-transform-regenerator" "^7.18.6" + "@babel/plugin-transform-reserved-words" "^7.18.6" + "@babel/plugin-transform-shorthand-properties" "^7.18.6" + "@babel/plugin-transform-spread" "^7.19.0" + "@babel/plugin-transform-sticky-regex" "^7.18.6" + "@babel/plugin-transform-template-literals" "^7.18.9" + "@babel/plugin-transform-typeof-symbol" "^7.18.9" + "@babel/plugin-transform-unicode-escapes" "^7.18.10" + "@babel/plugin-transform-unicode-regex" "^7.18.6" + "@babel/preset-modules" "^0.1.5" + "@babel/types" "^7.20.2" + babel-plugin-polyfill-corejs2 "^0.3.3" + babel-plugin-polyfill-corejs3 "^0.6.0" + babel-plugin-polyfill-regenerator "^0.4.1" + core-js-compat "^3.25.1" + semver "^6.3.0" + +"@babel/preset-modules@^0.1.5": + version "0.1.5" + resolved "https://registry.yarnpkg.com/@babel/preset-modules/-/preset-modules-0.1.5.tgz#ef939d6e7f268827e1841638dc6ff95515e115d9" + integrity sha512-A57th6YRG7oR3cq/yt/Y84MvGgE0eJG2F1JLhKuyG+jFxEgrd/HAMJatiFtmOiZurz+0DkrvbheCLaV5f2JfjA== dependencies: "@babel/helper-plugin-utils" "^7.0.0" + "@babel/plugin-proposal-unicode-property-regex" "^7.4.4" + "@babel/plugin-transform-dotall-regex" "^7.4.4" "@babel/types" "^7.4.4" esutils "^2.0.2" "@babel/preset-react@^7.18.6": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/preset-react/-/preset-react-7.23.3.tgz#f73ca07e7590f977db07eb54dbe46538cc015709" - integrity sha512-tbkHOS9axH6Ysf2OUEqoSZ6T3Fa2SrNH6WTWSPBboxKzdxNc9qOICeLXkNG0ZEwbQ1HY8liwOce4aN/Ceyuq6w== + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/preset-react/-/preset-react-7.18.6.tgz#979f76d6277048dc19094c217b507f3ad517dd2d" + integrity sha512-zXr6atUmyYdiWRVLOZahakYmOBHtWc2WGCkP8PYTgZi0iJXDY2CN180TdrIW4OGOAdLc7TifzDIvtx6izaRIzg== dependencies: - "@babel/helper-plugin-utils" "^7.22.5" - "@babel/helper-validator-option" "^7.22.15" - "@babel/plugin-transform-react-display-name" "^7.23.3" - "@babel/plugin-transform-react-jsx" "^7.22.15" - "@babel/plugin-transform-react-jsx-development" "^7.22.5" - "@babel/plugin-transform-react-pure-annotations" "^7.23.3" + "@babel/helper-plugin-utils" "^7.18.6" + "@babel/helper-validator-option" "^7.18.6" + "@babel/plugin-transform-react-display-name" "^7.18.6" + "@babel/plugin-transform-react-jsx" "^7.18.6" + "@babel/plugin-transform-react-jsx-development" "^7.18.6" + "@babel/plugin-transform-react-pure-annotations" "^7.18.6" "@babel/preset-typescript@^7.18.6": - version "7.23.3" - resolved "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.23.3.tgz#14534b34ed5b6d435aa05f1ae1c5e7adcc01d913" - integrity sha512-17oIGVlqz6CchO9RFYn5U6ZpWRZIngayYCtrPRSgANSwC2V1Jb+iP74nVxzzXJte8b8BYxrL1yY96xfhTBrNNQ== + version "7.21.0" + resolved "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.21.0.tgz#bcbbca513e8213691fe5d4b23d9251e01f00ebff" + integrity sha512-myc9mpoVA5m1rF8K8DgLEatOYFDpwC+RkMkjZ0Du6uI62YvDe8uxIEYVs/VCdSJ097nlALiU/yBC7//3nI+hNg== dependencies: - "@babel/helper-plugin-utils" "^7.22.5" - "@babel/helper-validator-option" "^7.22.15" - "@babel/plugin-syntax-jsx" "^7.23.3" - "@babel/plugin-transform-modules-commonjs" "^7.23.3" - "@babel/plugin-transform-typescript" "^7.23.3" + "@babel/helper-plugin-utils" "^7.20.2" + "@babel/helper-validator-option" "^7.21.0" + "@babel/plugin-transform-typescript" "^7.21.0" "@babel/regjsgen@^0.8.0": version "0.8.0" @@ -1191,58 +1137,72 @@ integrity sha512-x/rqGMdzj+fWZvCOYForTghzbtqPDZ5gPwaoNGHdgDfF2QA/XZbCBp4Moo5scrkAMPhB7z26XM/AaHuIJdgauA== "@babel/runtime-corejs3@^7.18.6": - version "7.23.8" - resolved "https://registry.yarnpkg.com/@babel/runtime-corejs3/-/runtime-corejs3-7.23.8.tgz#b8aa3d47570bdd08fed77fdfd69542118af0df26" - integrity sha512-2ZzmcDugdm0/YQKFVYsXiwUN7USPX8PM7cytpb4PFl87fM+qYPSvTZX//8tyeJB1j0YDmafBJEbl5f8NfLyuKw== - dependencies: - core-js-pure "^3.30.2" - regenerator-runtime "^0.14.0" - -"@babel/runtime@^7.1.2", "@babel/runtime@^7.10.3", "@babel/runtime@^7.12.13", "@babel/runtime@^7.12.5", "@babel/runtime@^7.18.6", "@babel/runtime@^7.20.13", "@babel/runtime@^7.21.0", "@babel/runtime@^7.8.4": - version "7.23.8" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.23.8.tgz#8ee6fe1ac47add7122902f257b8ddf55c898f650" - integrity sha512-Y7KbAP984rn1VGMbGqKmBLio9V7y5Je9GvU4rQPCPinCyNfUcToxIXl06d59URp/F3LwinvODxab5N/G6qggkw== - dependencies: - regenerator-runtime "^0.14.0" - -"@babel/template@^7.12.7", "@babel/template@^7.22.15": - version "7.22.15" - resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.22.15.tgz#09576efc3830f0430f4548ef971dde1350ef2f38" - integrity sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w== - dependencies: - "@babel/code-frame" "^7.22.13" - "@babel/parser" "^7.22.15" - "@babel/types" "^7.22.15" - -"@babel/traverse@^7.12.9", "@babel/traverse@^7.18.8", "@babel/traverse@^7.23.7": - version "7.23.7" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.23.7.tgz#9a7bf285c928cb99b5ead19c3b1ce5b310c9c305" - integrity sha512-tY3mM8rH9jM0YHFGyfC0/xf+SB5eKUu7HPj7/k3fpi9dAlsMc5YbQvDi0Sh2QTPXqMhyaAtzAr807TIyfQrmyg== - dependencies: - "@babel/code-frame" "^7.23.5" - "@babel/generator" "^7.23.6" - "@babel/helper-environment-visitor" "^7.22.20" - "@babel/helper-function-name" "^7.23.0" - "@babel/helper-hoist-variables" "^7.22.5" - "@babel/helper-split-export-declaration" "^7.22.6" - "@babel/parser" "^7.23.6" - "@babel/types" "^7.23.6" - debug "^4.3.1" + version "7.21.0" + resolved "https://registry.yarnpkg.com/@babel/runtime-corejs3/-/runtime-corejs3-7.21.0.tgz#6e4939d9d9789ff63e2dc58e88f13a3913a24eba" + integrity sha512-TDD4UJzos3JJtM+tHX+w2Uc+KWj7GV+VKKFdMVd2Rx8sdA19hcc3P3AHFYd5LVOw+pYuSd5lICC3gm52B6Rwxw== + dependencies: + core-js-pure "^3.25.1" + regenerator-runtime "^0.13.11" + +"@babel/runtime@^7.1.2", "@babel/runtime@^7.10.3", "@babel/runtime@^7.12.13", "@babel/runtime@^7.12.5", "@babel/runtime@^7.18.6", "@babel/runtime@^7.8.4": + version "7.21.0" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.21.0.tgz#5b55c9d394e5fcf304909a8b00c07dc217b56673" + integrity sha512-xwII0//EObnq89Ji5AKYQaRYiW/nZ3llSv29d49IuxPhKbtJoLP+9QUUZ4nVragQVtaVGeZrpB+ZtG/Pdy/POw== + dependencies: + regenerator-runtime "^0.13.11" + +"@babel/runtime@^7.10.2": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.20.7.tgz#fcb41a5a70550e04a7b708037c7c32f7f356d8fd" + integrity sha512-UF0tvkUtxwAgZ5W/KrkHf0Rn0fdnLDU9ScxBrEVNUprE/MzirjK4MJUX1/BVDv00Sv8cljtukVK1aky++X1SjQ== + dependencies: + regenerator-runtime "^0.13.11" + +"@babel/runtime@^7.21.0": + version "7.22.6" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.22.6.tgz#57d64b9ae3cff1d67eb067ae117dac087f5bd438" + integrity sha512-wDb5pWm4WDdF6LFUde3Jl8WzPA+3ZbxYqkC6xAXuD3irdEHN1k0NfTRrJD8ZD378SJ61miMLCqIOXYhd8x+AJQ== + dependencies: + regenerator-runtime "^0.13.11" + +"@babel/template@^7.12.7", "@babel/template@^7.18.10", "@babel/template@^7.20.7": + version "7.20.7" + resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.20.7.tgz#a15090c2839a83b02aa996c0b4994005841fd5a8" + integrity sha512-8SegXApWe6VoNw0r9JHpSteLKTpTiLZ4rMlGIm9JQ18KiCtyQiAMEazujAHrUS5flrcqYZa75ukev3P6QmUwUw== + dependencies: + "@babel/code-frame" "^7.18.6" + "@babel/parser" "^7.20.7" + "@babel/types" "^7.20.7" + +"@babel/traverse@^7.12.9", "@babel/traverse@^7.18.8", "@babel/traverse@^7.20.5", "@babel/traverse@^7.20.7", "@babel/traverse@^7.21.0", "@babel/traverse@^7.21.2": + version "7.21.2" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.21.2.tgz#ac7e1f27658750892e815e60ae90f382a46d8e75" + integrity sha512-ts5FFU/dSUPS13tv8XiEObDu9K+iagEKME9kAbaP7r0Y9KtZJZ+NGndDvWoRAYNpeWafbpFeki3q9QoMD6gxyw== + dependencies: + "@babel/code-frame" "^7.18.6" + "@babel/generator" "^7.21.1" + "@babel/helper-environment-visitor" "^7.18.9" + "@babel/helper-function-name" "^7.21.0" + "@babel/helper-hoist-variables" "^7.18.6" + "@babel/helper-split-export-declaration" "^7.18.6" + "@babel/parser" "^7.21.2" + "@babel/types" "^7.21.2" + debug "^4.1.0" globals "^11.1.0" -"@babel/types@^7.12.7", "@babel/types@^7.20.0", "@babel/types@^7.22.15", "@babel/types@^7.22.19", "@babel/types@^7.22.5", "@babel/types@^7.23.0", "@babel/types@^7.23.4", "@babel/types@^7.23.6", "@babel/types@^7.4.4": - version "7.23.6" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.23.6.tgz#be33fdb151e1f5a56877d704492c240fc71c7ccd" - integrity sha512-+uarb83brBzPKN38NX1MkB6vb6+mwvR6amUulqAE7ccQw1pEl+bCia9TbdG1lsnFP7lZySvUn37CHyXQdfTwzg== +"@babel/types@^7.12.7", "@babel/types@^7.18.6", "@babel/types@^7.18.9", "@babel/types@^7.20.0", "@babel/types@^7.20.2", "@babel/types@^7.20.5", "@babel/types@^7.20.7", "@babel/types@^7.21.0", "@babel/types@^7.21.2", "@babel/types@^7.4.4": + version "7.21.2" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.21.2.tgz#92246f6e00f91755893c2876ad653db70c8310d1" + integrity sha512-3wRZSs7jiFaB8AjxiiD+VqN5DTG2iRvJGQ+qYFrs/654lg6kGTQWIOFjlBo5RaXuAZjBmP3+OQH4dmhqiiyYxw== dependencies: - "@babel/helper-string-parser" "^7.23.4" - "@babel/helper-validator-identifier" "^7.22.20" + "@babel/helper-string-parser" "^7.19.4" + "@babel/helper-validator-identifier" "^7.19.1" to-fast-properties "^2.0.0" "@braintree/sanitize-url@^6.0.0": - version "6.0.4" - resolved "https://registry.yarnpkg.com/@braintree/sanitize-url/-/sanitize-url-6.0.4.tgz#923ca57e173c6b232bbbb07347b1be982f03e783" - integrity sha512-s3jaWicZd0pkP0jf5ysyHUI/RE7MHos6qlToFcGWXVp+ykHOy77OUMrfbgJ9it2C5bow7OIQwYYaHjk9XlBQ2A== + version "6.0.2" + resolved "https://registry.yarnpkg.com/@braintree/sanitize-url/-/sanitize-url-6.0.2.tgz#6110f918d273fe2af8ea1c4398a88774bb9fc12f" + integrity sha512-Tbsj02wXCbqGmzdnXNk0SOF19ChhRU70BsroIi4Pm6Ehp56in6vch94mfbdQ17DozxkL3BAVjbZ4Qc1a0HFRAg== "@colors/colors@1.5.0": version "1.5.0" @@ -1254,25 +1214,25 @@ resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz#1d572bfbbe14b7704e0ba0f39b74815b84870d70" integrity sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw== -"@docsearch/css@3.5.2": - version "3.5.2" - resolved "https://registry.yarnpkg.com/@docsearch/css/-/css-3.5.2.tgz#610f47b48814ca94041df969d9fcc47b91fc5aac" - integrity sha512-SPiDHaWKQZpwR2siD0KQUwlStvIAnEyK6tAE2h2Wuoq8ue9skzhlyVQ1ddzOxX6khULnAALDiR/isSF3bnuciA== +"@docsearch/css@3.3.2": + version "3.3.2" + resolved "https://registry.yarnpkg.com/@docsearch/css/-/css-3.3.2.tgz#2c49995e6fbc7834c75f317b277ed6e4019223a4" + integrity sha512-dctFYiwbvDZkksMlsmc7pj6W6By/EjnVXJq5TEPd05MwQe+dcdHJgaIn1c8wfsucxHpIsdrUcgSkACHCq6aIhw== "@docsearch/react@^3.1.1": - version "3.5.2" - resolved "https://registry.yarnpkg.com/@docsearch/react/-/react-3.5.2.tgz#2e6bbee00eb67333b64906352734da6aef1232b9" - integrity sha512-9Ahcrs5z2jq/DcAvYtvlqEBHImbm4YJI8M9y0x6Tqg598P40HTEkX7hsMcIuThI+hTFxRGZ9hll0Wygm2yEjng== + version "3.3.2" + resolved "https://registry.yarnpkg.com/@docsearch/react/-/react-3.3.2.tgz#252b659c66682f24902bf6db257f63ee73ffe8fa" + integrity sha512-ugILab2TYKSh6IEHf6Z9xZbOovsYbsdfo60PBj+Bw+oMJ1MHJ7pBt1TTcmPki1hSgg8mysgKy2hDiVdPm7XWSQ== dependencies: - "@algolia/autocomplete-core" "1.9.3" - "@algolia/autocomplete-preset-algolia" "1.9.3" - "@docsearch/css" "3.5.2" - algoliasearch "^4.19.1" + "@algolia/autocomplete-core" "1.7.4" + "@algolia/autocomplete-preset-algolia" "1.7.4" + "@docsearch/css" "3.3.2" + algoliasearch "^4.0.0" -"@docusaurus/core@2.4.3", "@docusaurus/core@^2.4.1": - version "2.4.3" - resolved "https://registry.yarnpkg.com/@docusaurus/core/-/core-2.4.3.tgz#d86624901386fd8164ce4bff9cc7f16fde57f523" - integrity sha512-dWH5P7cgeNSIg9ufReX6gaCl/TmrGKD38Orbwuz05WPhAQtFXHd5B8Qym1TiXfvUNvwoYKkAJOJuGe8ou0Z7PA== +"@docusaurus/core@2.4.1", "@docusaurus/core@^2.4.1": + version "2.4.1" + resolved "https://registry.yarnpkg.com/@docusaurus/core/-/core-2.4.1.tgz#4b8ff5766131ce3fbccaad0b1daf2ad4dc76f62d" + integrity sha512-SNsY7PshK3Ri7vtsLXVeAJGS50nJN3RgF836zkyUfAD01Fq+sAk5EwWgLw+nnm5KVNGDu7PRR2kRGDsWvqpo0g== dependencies: "@babel/core" "^7.18.6" "@babel/generator" "^7.18.7" @@ -1284,13 +1244,13 @@ "@babel/runtime" "^7.18.6" "@babel/runtime-corejs3" "^7.18.6" "@babel/traverse" "^7.18.8" - "@docusaurus/cssnano-preset" "2.4.3" - "@docusaurus/logger" "2.4.3" - "@docusaurus/mdx-loader" "2.4.3" + "@docusaurus/cssnano-preset" "2.4.1" + "@docusaurus/logger" "2.4.1" + "@docusaurus/mdx-loader" "2.4.1" "@docusaurus/react-loadable" "5.5.2" - "@docusaurus/utils" "2.4.3" - "@docusaurus/utils-common" "2.4.3" - "@docusaurus/utils-validation" "2.4.3" + "@docusaurus/utils" "2.4.1" + "@docusaurus/utils-common" "2.4.1" + "@docusaurus/utils-validation" "2.4.1" "@slorber/static-site-generator-webpack-plugin" "^4.0.7" "@svgr/webpack" "^6.2.1" autoprefixer "^10.4.7" @@ -1346,44 +1306,44 @@ webpack-merge "^5.8.0" webpackbar "^5.0.2" -"@docusaurus/cssnano-preset@2.4.3": - version "2.4.3" - resolved "https://registry.yarnpkg.com/@docusaurus/cssnano-preset/-/cssnano-preset-2.4.3.tgz#1d7e833c41ce240fcc2812a2ac27f7b862f32de0" - integrity sha512-ZvGSRCi7z9wLnZrXNPG6DmVPHdKGd8dIn9pYbEOFiYihfv4uDR3UtxogmKf+rT8ZlKFf5Lqne8E8nt08zNM8CA== +"@docusaurus/cssnano-preset@2.4.1": + version "2.4.1" + resolved "https://registry.yarnpkg.com/@docusaurus/cssnano-preset/-/cssnano-preset-2.4.1.tgz#eacadefb1e2e0f59df3467a0fe83e4ff79eed163" + integrity sha512-ka+vqXwtcW1NbXxWsh6yA1Ckii1klY9E53cJ4O9J09nkMBgrNX3iEFED1fWdv8wf4mJjvGi5RLZ2p9hJNjsLyQ== dependencies: cssnano-preset-advanced "^5.3.8" postcss "^8.4.14" postcss-sort-media-queries "^4.2.1" tslib "^2.4.0" -"@docusaurus/logger@2.4.3": - version "2.4.3" - resolved "https://registry.yarnpkg.com/@docusaurus/logger/-/logger-2.4.3.tgz#518bbc965fb4ebe8f1d0b14e5f4161607552d34c" - integrity sha512-Zxws7r3yLufk9xM1zq9ged0YHs65mlRmtsobnFkdZTxWXdTYlWWLWdKyNKAsVC+D7zg+pv2fGbyabdOnyZOM3w== +"@docusaurus/logger@2.4.1": + version "2.4.1" + resolved "https://registry.yarnpkg.com/@docusaurus/logger/-/logger-2.4.1.tgz#4d2c0626b40752641f9fdd93ad9b5a7a0792f767" + integrity sha512-5h5ysIIWYIDHyTVd8BjheZmQZmEgWDR54aQ1BX9pjFfpyzFo5puKXKYrYJXbjEHGyVhEzmB9UXwbxGfaZhOjcg== dependencies: chalk "^4.1.2" tslib "^2.4.0" -"@docusaurus/lqip-loader@2.4.3": - version "2.4.3" - resolved "https://registry.yarnpkg.com/@docusaurus/lqip-loader/-/lqip-loader-2.4.3.tgz#aab8b7d873317e7490f29027047a05076d499746" - integrity sha512-hdumVOGbI4eiQQsZvbbosnm86FNkp23GikNanC0MJIIz8j3sCg8I0GEmg9nnVZor/2tE4ud5AWqjsVrx1CwcjA== +"@docusaurus/lqip-loader@2.4.1": + version "2.4.1" + resolved "https://registry.yarnpkg.com/@docusaurus/lqip-loader/-/lqip-loader-2.4.1.tgz#5e6a279982af898e646f042097fc4053fa15b4b8" + integrity sha512-XJ0z/xSx5HtAQ+/xBoAiRZ7DY9zEP6IImAKlAk6RxuFzyB4HT8eINWN+LwLnOsTh5boIj37JCX+T76bH0ieULA== dependencies: - "@docusaurus/logger" "2.4.3" + "@docusaurus/logger" "2.4.1" file-loader "^6.2.0" lodash "^4.17.21" sharp "^0.30.7" tslib "^2.4.0" -"@docusaurus/mdx-loader@2.4.3": - version "2.4.3" - resolved "https://registry.yarnpkg.com/@docusaurus/mdx-loader/-/mdx-loader-2.4.3.tgz#e8ff37f30a060eaa97b8121c135f74cb531a4a3e" - integrity sha512-b1+fDnWtl3GiqkL0BRjYtc94FZrcDDBV1j8446+4tptB9BAOlePwG2p/pK6vGvfL53lkOsszXMghr2g67M0vCw== +"@docusaurus/mdx-loader@2.4.1": + version "2.4.1" + resolved "https://registry.yarnpkg.com/@docusaurus/mdx-loader/-/mdx-loader-2.4.1.tgz#6425075d7fc136dbfdc121349060cedd64118393" + integrity sha512-4KhUhEavteIAmbBj7LVFnrVYDiU51H5YWW1zY6SmBSte/YLhDutztLTBE0PQl1Grux1jzUJeaSvAzHpTn6JJDQ== dependencies: "@babel/parser" "^7.18.8" "@babel/traverse" "^7.18.8" - "@docusaurus/logger" "2.4.3" - "@docusaurus/utils" "2.4.3" + "@docusaurus/logger" "2.4.1" + "@docusaurus/utils" "2.4.1" "@mdx-js/mdx" "^1.6.22" escape-html "^1.0.3" file-loader "^6.2.0" @@ -1398,13 +1358,13 @@ url-loader "^4.1.1" webpack "^5.73.0" -"@docusaurus/module-type-aliases@2.4.3", "@docusaurus/module-type-aliases@^2.4.1": - version "2.4.3" - resolved "https://registry.yarnpkg.com/@docusaurus/module-type-aliases/-/module-type-aliases-2.4.3.tgz#d08ef67e4151e02f352a2836bcf9ecde3b9c56ac" - integrity sha512-cwkBkt1UCiduuvEAo7XZY01dJfRn7UR/75mBgOdb1hKknhrabJZ8YH+7savd/y9kLExPyrhe0QwdS9GuzsRRIA== +"@docusaurus/module-type-aliases@2.4.1", "@docusaurus/module-type-aliases@^2.4.1": + version "2.4.1" + resolved "https://registry.yarnpkg.com/@docusaurus/module-type-aliases/-/module-type-aliases-2.4.1.tgz#38b3c2d2ae44bea6d57506eccd84280216f0171c" + integrity sha512-gLBuIFM8Dp2XOCWffUDSjtxY7jQgKvYujt7Mx5s4FCTfoL5dN1EVbnrn+O2Wvh8b0a77D57qoIDY7ghgmatR1A== dependencies: "@docusaurus/react-loadable" "5.5.2" - "@docusaurus/types" "2.4.3" + "@docusaurus/types" "2.4.1" "@types/history" "^4.7.11" "@types/react" "*" "@types/react-router-config" "*" @@ -1412,18 +1372,18 @@ react-helmet-async "*" react-loadable "npm:@docusaurus/react-loadable@5.5.2" -"@docusaurus/plugin-content-blog@2.4.3": - version "2.4.3" - resolved "https://registry.yarnpkg.com/@docusaurus/plugin-content-blog/-/plugin-content-blog-2.4.3.tgz#6473b974acab98e967414d8bbb0d37e0cedcea14" - integrity sha512-PVhypqaA0t98zVDpOeTqWUTvRqCEjJubtfFUQ7zJNYdbYTbS/E/ytq6zbLVsN/dImvemtO/5JQgjLxsh8XLo8Q== - dependencies: - "@docusaurus/core" "2.4.3" - "@docusaurus/logger" "2.4.3" - "@docusaurus/mdx-loader" "2.4.3" - "@docusaurus/types" "2.4.3" - "@docusaurus/utils" "2.4.3" - "@docusaurus/utils-common" "2.4.3" - "@docusaurus/utils-validation" "2.4.3" +"@docusaurus/plugin-content-blog@2.4.1": + version "2.4.1" + resolved "https://registry.yarnpkg.com/@docusaurus/plugin-content-blog/-/plugin-content-blog-2.4.1.tgz#c705a8b1a36a34f181dcf43b7770532e4dcdc4a3" + integrity sha512-E2i7Knz5YIbE1XELI6RlTnZnGgS52cUO4BlCiCUCvQHbR+s1xeIWz4C6BtaVnlug0Ccz7nFSksfwDpVlkujg5Q== + dependencies: + "@docusaurus/core" "2.4.1" + "@docusaurus/logger" "2.4.1" + "@docusaurus/mdx-loader" "2.4.1" + "@docusaurus/types" "2.4.1" + "@docusaurus/utils" "2.4.1" + "@docusaurus/utils-common" "2.4.1" + "@docusaurus/utils-validation" "2.4.1" cheerio "^1.0.0-rc.12" feed "^4.2.2" fs-extra "^10.1.0" @@ -1434,18 +1394,18 @@ utility-types "^3.10.0" webpack "^5.73.0" -"@docusaurus/plugin-content-docs@2.4.3": - version "2.4.3" - resolved "https://registry.yarnpkg.com/@docusaurus/plugin-content-docs/-/plugin-content-docs-2.4.3.tgz#aa224c0512351e81807adf778ca59fd9cd136973" - integrity sha512-N7Po2LSH6UejQhzTCsvuX5NOzlC+HiXOVvofnEPj0WhMu1etpLEXE6a4aTxrtg95lQ5kf0xUIdjX9sh3d3G76A== - dependencies: - "@docusaurus/core" "2.4.3" - "@docusaurus/logger" "2.4.3" - "@docusaurus/mdx-loader" "2.4.3" - "@docusaurus/module-type-aliases" "2.4.3" - "@docusaurus/types" "2.4.3" - "@docusaurus/utils" "2.4.3" - "@docusaurus/utils-validation" "2.4.3" +"@docusaurus/plugin-content-docs@2.4.1": + version "2.4.1" + resolved "https://registry.yarnpkg.com/@docusaurus/plugin-content-docs/-/plugin-content-docs-2.4.1.tgz#ed94d9721b5ce7a956fb01cc06c40d8eee8dfca7" + integrity sha512-Lo7lSIcpswa2Kv4HEeUcGYqaasMUQNpjTXpV0N8G6jXgZaQurqp7E8NGYeGbDXnb48czmHWbzDL4S3+BbK0VzA== + dependencies: + "@docusaurus/core" "2.4.1" + "@docusaurus/logger" "2.4.1" + "@docusaurus/mdx-loader" "2.4.1" + "@docusaurus/module-type-aliases" "2.4.1" + "@docusaurus/types" "2.4.1" + "@docusaurus/utils" "2.4.1" + "@docusaurus/utils-validation" "2.4.1" "@types/react-router-config" "^5.0.6" combine-promises "^1.1.0" fs-extra "^10.1.0" @@ -1456,112 +1416,112 @@ utility-types "^3.10.0" webpack "^5.73.0" -"@docusaurus/plugin-content-pages@2.4.3": - version "2.4.3" - resolved "https://registry.yarnpkg.com/@docusaurus/plugin-content-pages/-/plugin-content-pages-2.4.3.tgz#7f285e718b53da8c8d0101e70840c75b9c0a1ac0" - integrity sha512-txtDVz7y3zGk67q0HjG0gRttVPodkHqE0bpJ+7dOaTH40CQFLSh7+aBeGnPOTl+oCPG+hxkim4SndqPqXjQ8Bg== - dependencies: - "@docusaurus/core" "2.4.3" - "@docusaurus/mdx-loader" "2.4.3" - "@docusaurus/types" "2.4.3" - "@docusaurus/utils" "2.4.3" - "@docusaurus/utils-validation" "2.4.3" +"@docusaurus/plugin-content-pages@2.4.1": + version "2.4.1" + resolved "https://registry.yarnpkg.com/@docusaurus/plugin-content-pages/-/plugin-content-pages-2.4.1.tgz#c534f7e49967699a45bbe67050d1605ebbf3d285" + integrity sha512-/UjuH/76KLaUlL+o1OvyORynv6FURzjurSjvn2lbWTFc4tpYY2qLYTlKpTCBVPhlLUQsfyFnshEJDLmPneq2oA== + dependencies: + "@docusaurus/core" "2.4.1" + "@docusaurus/mdx-loader" "2.4.1" + "@docusaurus/types" "2.4.1" + "@docusaurus/utils" "2.4.1" + "@docusaurus/utils-validation" "2.4.1" fs-extra "^10.1.0" tslib "^2.4.0" webpack "^5.73.0" -"@docusaurus/plugin-debug@2.4.3": - version "2.4.3" - resolved "https://registry.yarnpkg.com/@docusaurus/plugin-debug/-/plugin-debug-2.4.3.tgz#2f90eb0c9286a9f225444e3a88315676fe02c245" - integrity sha512-LkUbuq3zCmINlFb+gAd4ZvYr+bPAzMC0hwND4F7V9bZ852dCX8YoWyovVUBKq4er1XsOwSQaHmNGtObtn8Av8Q== +"@docusaurus/plugin-debug@2.4.1": + version "2.4.1" + resolved "https://registry.yarnpkg.com/@docusaurus/plugin-debug/-/plugin-debug-2.4.1.tgz#461a2c77b0c5a91b2c05257c8f9585412aaa59dc" + integrity sha512-7Yu9UPzRShlrH/G8btOpR0e6INFZr0EegWplMjOqelIwAcx3PKyR8mgPTxGTxcqiYj6hxSCRN0D8R7YrzImwNA== dependencies: - "@docusaurus/core" "2.4.3" - "@docusaurus/types" "2.4.3" - "@docusaurus/utils" "2.4.3" + "@docusaurus/core" "2.4.1" + "@docusaurus/types" "2.4.1" + "@docusaurus/utils" "2.4.1" fs-extra "^10.1.0" react-json-view "^1.21.3" tslib "^2.4.0" -"@docusaurus/plugin-google-analytics@2.4.3": - version "2.4.3" - resolved "https://registry.yarnpkg.com/@docusaurus/plugin-google-analytics/-/plugin-google-analytics-2.4.3.tgz#0d19993136ade6f7a7741251b4f617400d92ab45" - integrity sha512-KzBV3k8lDkWOhg/oYGxlK5o9bOwX7KpPc/FTWoB+SfKhlHfhq7qcQdMi1elAaVEIop8tgK6gD1E58Q+XC6otSQ== +"@docusaurus/plugin-google-analytics@2.4.1": + version "2.4.1" + resolved "https://registry.yarnpkg.com/@docusaurus/plugin-google-analytics/-/plugin-google-analytics-2.4.1.tgz#30de1c35773bf9d52bb2d79b201b23eb98022613" + integrity sha512-dyZJdJiCoL+rcfnm0RPkLt/o732HvLiEwmtoNzOoz9MSZz117UH2J6U2vUDtzUzwtFLIf32KkeyzisbwUCgcaQ== dependencies: - "@docusaurus/core" "2.4.3" - "@docusaurus/types" "2.4.3" - "@docusaurus/utils-validation" "2.4.3" + "@docusaurus/core" "2.4.1" + "@docusaurus/types" "2.4.1" + "@docusaurus/utils-validation" "2.4.1" tslib "^2.4.0" -"@docusaurus/plugin-google-gtag@2.4.3": - version "2.4.3" - resolved "https://registry.yarnpkg.com/@docusaurus/plugin-google-gtag/-/plugin-google-gtag-2.4.3.tgz#e1a80b0696771b488562e5b60eff21c9932d9e1c" - integrity sha512-5FMg0rT7sDy4i9AGsvJC71MQrqQZwgLNdDetLEGDHLfSHLvJhQbTCUGbGXknUgWXQJckcV/AILYeJy+HhxeIFA== +"@docusaurus/plugin-google-gtag@2.4.1": + version "2.4.1" + resolved "https://registry.yarnpkg.com/@docusaurus/plugin-google-gtag/-/plugin-google-gtag-2.4.1.tgz#6a3eb91022714735e625c7ca70ef5188fa7bd0dc" + integrity sha512-mKIefK+2kGTQBYvloNEKtDmnRD7bxHLsBcxgnbt4oZwzi2nxCGjPX6+9SQO2KCN5HZbNrYmGo5GJfMgoRvy6uA== dependencies: - "@docusaurus/core" "2.4.3" - "@docusaurus/types" "2.4.3" - "@docusaurus/utils-validation" "2.4.3" + "@docusaurus/core" "2.4.1" + "@docusaurus/types" "2.4.1" + "@docusaurus/utils-validation" "2.4.1" tslib "^2.4.0" -"@docusaurus/plugin-google-tag-manager@2.4.3": - version "2.4.3" - resolved "https://registry.yarnpkg.com/@docusaurus/plugin-google-tag-manager/-/plugin-google-tag-manager-2.4.3.tgz#e41fbf79b0ffc2de1cc4013eb77798cff0ad98e3" - integrity sha512-1jTzp71yDGuQiX9Bi0pVp3alArV0LSnHXempvQTxwCGAEzUWWaBg4d8pocAlTpbP9aULQQqhgzrs8hgTRPOM0A== +"@docusaurus/plugin-google-tag-manager@2.4.1": + version "2.4.1" + resolved "https://registry.yarnpkg.com/@docusaurus/plugin-google-tag-manager/-/plugin-google-tag-manager-2.4.1.tgz#b99f71aec00b112bbf509ef2416e404a95eb607e" + integrity sha512-Zg4Ii9CMOLfpeV2nG74lVTWNtisFaH9QNtEw48R5QE1KIwDBdTVaiSA18G1EujZjrzJJzXN79VhINSbOJO/r3g== dependencies: - "@docusaurus/core" "2.4.3" - "@docusaurus/types" "2.4.3" - "@docusaurus/utils-validation" "2.4.3" + "@docusaurus/core" "2.4.1" + "@docusaurus/types" "2.4.1" + "@docusaurus/utils-validation" "2.4.1" tslib "^2.4.0" "@docusaurus/plugin-ideal-image@^2.4.1": - version "2.4.3" - resolved "https://registry.yarnpkg.com/@docusaurus/plugin-ideal-image/-/plugin-ideal-image-2.4.3.tgz#b4988f4e82c3351596c54474eb35bddd9c827deb" - integrity sha512-cwnOKz5HwR/WwNL5lzGOWppyhaHQ2dPj1/x9hwv5VPwNmDDnWsYEwfBOTq8AYT27vFrYAH1tx9UX7QurRaIa4A== + version "2.4.1" + resolved "https://registry.yarnpkg.com/@docusaurus/plugin-ideal-image/-/plugin-ideal-image-2.4.1.tgz#110e9814ad3af66235c849d2e00c9e84f552c961" + integrity sha512-jxvgCGPmHxdae2Y2uskzxIbMCA4WLTfzkufsLbD4mEAjCRIkt6yzux6q5kqKTrO+AxzpANVcJNGmaBtKZGv5aw== dependencies: - "@docusaurus/core" "2.4.3" - "@docusaurus/lqip-loader" "2.4.3" + "@docusaurus/core" "2.4.1" + "@docusaurus/lqip-loader" "2.4.1" "@docusaurus/responsive-loader" "^1.7.0" - "@docusaurus/theme-translations" "2.4.3" - "@docusaurus/types" "2.4.3" - "@docusaurus/utils-validation" "2.4.3" + "@docusaurus/theme-translations" "2.4.1" + "@docusaurus/types" "2.4.1" + "@docusaurus/utils-validation" "2.4.1" "@endiliey/react-ideal-image" "^0.0.11" react-waypoint "^10.3.0" sharp "^0.30.7" tslib "^2.4.0" webpack "^5.73.0" -"@docusaurus/plugin-sitemap@2.4.3": - version "2.4.3" - resolved "https://registry.yarnpkg.com/@docusaurus/plugin-sitemap/-/plugin-sitemap-2.4.3.tgz#1b3930900a8f89670ce7e8f83fb4730cd3298c32" - integrity sha512-LRQYrK1oH1rNfr4YvWBmRzTL0LN9UAPxBbghgeFRBm5yloF6P+zv1tm2pe2hQTX/QP5bSKdnajCvfnScgKXMZQ== - dependencies: - "@docusaurus/core" "2.4.3" - "@docusaurus/logger" "2.4.3" - "@docusaurus/types" "2.4.3" - "@docusaurus/utils" "2.4.3" - "@docusaurus/utils-common" "2.4.3" - "@docusaurus/utils-validation" "2.4.3" +"@docusaurus/plugin-sitemap@2.4.1": + version "2.4.1" + resolved "https://registry.yarnpkg.com/@docusaurus/plugin-sitemap/-/plugin-sitemap-2.4.1.tgz#8a7a76ed69dc3e6b4474b6abb10bb03336a9de6d" + integrity sha512-lZx+ijt/+atQ3FVE8FOHV/+X3kuok688OydDXrqKRJyXBJZKgGjA2Qa8RjQ4f27V2woaXhtnyrdPop/+OjVMRg== + dependencies: + "@docusaurus/core" "2.4.1" + "@docusaurus/logger" "2.4.1" + "@docusaurus/types" "2.4.1" + "@docusaurus/utils" "2.4.1" + "@docusaurus/utils-common" "2.4.1" + "@docusaurus/utils-validation" "2.4.1" fs-extra "^10.1.0" sitemap "^7.1.1" tslib "^2.4.0" "@docusaurus/preset-classic@^2.4.1": - version "2.4.3" - resolved "https://registry.yarnpkg.com/@docusaurus/preset-classic/-/preset-classic-2.4.3.tgz#074c57ebf29fa43d23bd1c8ce691226f542bc262" - integrity sha512-tRyMliepY11Ym6hB1rAFSNGwQDpmszvWYJvlK1E+md4SW8i6ylNHtpZjaYFff9Mdk3i/Pg8ItQq9P0daOJAvQw== - dependencies: - "@docusaurus/core" "2.4.3" - "@docusaurus/plugin-content-blog" "2.4.3" - "@docusaurus/plugin-content-docs" "2.4.3" - "@docusaurus/plugin-content-pages" "2.4.3" - "@docusaurus/plugin-debug" "2.4.3" - "@docusaurus/plugin-google-analytics" "2.4.3" - "@docusaurus/plugin-google-gtag" "2.4.3" - "@docusaurus/plugin-google-tag-manager" "2.4.3" - "@docusaurus/plugin-sitemap" "2.4.3" - "@docusaurus/theme-classic" "2.4.3" - "@docusaurus/theme-common" "2.4.3" - "@docusaurus/theme-search-algolia" "2.4.3" - "@docusaurus/types" "2.4.3" + version "2.4.1" + resolved "https://registry.yarnpkg.com/@docusaurus/preset-classic/-/preset-classic-2.4.1.tgz#072f22d0332588e9c5f512d4bded8d7c99f91497" + integrity sha512-P4//+I4zDqQJ+UDgoFrjIFaQ1MeS9UD1cvxVQaI6O7iBmiHQm0MGROP1TbE7HlxlDPXFJjZUK3x3cAoK63smGQ== + dependencies: + "@docusaurus/core" "2.4.1" + "@docusaurus/plugin-content-blog" "2.4.1" + "@docusaurus/plugin-content-docs" "2.4.1" + "@docusaurus/plugin-content-pages" "2.4.1" + "@docusaurus/plugin-debug" "2.4.1" + "@docusaurus/plugin-google-analytics" "2.4.1" + "@docusaurus/plugin-google-gtag" "2.4.1" + "@docusaurus/plugin-google-tag-manager" "2.4.1" + "@docusaurus/plugin-sitemap" "2.4.1" + "@docusaurus/theme-classic" "2.4.1" + "@docusaurus/theme-common" "2.4.1" + "@docusaurus/theme-search-algolia" "2.4.1" + "@docusaurus/types" "2.4.1" "@docusaurus/react-loadable@5.5.2", "react-loadable@npm:@docusaurus/react-loadable@5.5.2": version "5.5.2" @@ -1578,23 +1538,23 @@ dependencies: loader-utils "^2.0.0" -"@docusaurus/theme-classic@2.4.3": - version "2.4.3" - resolved "https://registry.yarnpkg.com/@docusaurus/theme-classic/-/theme-classic-2.4.3.tgz#29360f2eb03a0e1686eb19668633ef313970ee8f" - integrity sha512-QKRAJPSGPfDY2yCiPMIVyr+MqwZCIV2lxNzqbyUW0YkrlmdzzP3WuQJPMGLCjWgQp/5c9kpWMvMxjhpZx1R32Q== - dependencies: - "@docusaurus/core" "2.4.3" - "@docusaurus/mdx-loader" "2.4.3" - "@docusaurus/module-type-aliases" "2.4.3" - "@docusaurus/plugin-content-blog" "2.4.3" - "@docusaurus/plugin-content-docs" "2.4.3" - "@docusaurus/plugin-content-pages" "2.4.3" - "@docusaurus/theme-common" "2.4.3" - "@docusaurus/theme-translations" "2.4.3" - "@docusaurus/types" "2.4.3" - "@docusaurus/utils" "2.4.3" - "@docusaurus/utils-common" "2.4.3" - "@docusaurus/utils-validation" "2.4.3" +"@docusaurus/theme-classic@2.4.1": + version "2.4.1" + resolved "https://registry.yarnpkg.com/@docusaurus/theme-classic/-/theme-classic-2.4.1.tgz#0060cb263c1a73a33ac33f79bb6bc2a12a56ad9e" + integrity sha512-Rz0wKUa+LTW1PLXmwnf8mn85EBzaGSt6qamqtmnh9Hflkc+EqiYMhtUJeLdV+wsgYq4aG0ANc+bpUDpsUhdnwg== + dependencies: + "@docusaurus/core" "2.4.1" + "@docusaurus/mdx-loader" "2.4.1" + "@docusaurus/module-type-aliases" "2.4.1" + "@docusaurus/plugin-content-blog" "2.4.1" + "@docusaurus/plugin-content-docs" "2.4.1" + "@docusaurus/plugin-content-pages" "2.4.1" + "@docusaurus/theme-common" "2.4.1" + "@docusaurus/theme-translations" "2.4.1" + "@docusaurus/types" "2.4.1" + "@docusaurus/utils" "2.4.1" + "@docusaurus/utils-common" "2.4.1" + "@docusaurus/utils-validation" "2.4.1" "@mdx-js/react" "^1.6.22" clsx "^1.2.1" copy-text-to-clipboard "^3.0.1" @@ -1609,18 +1569,18 @@ tslib "^2.4.0" utility-types "^3.10.0" -"@docusaurus/theme-common@2.4.3": - version "2.4.3" - resolved "https://registry.yarnpkg.com/@docusaurus/theme-common/-/theme-common-2.4.3.tgz#bb31d70b6b67d0bdef9baa343192dcec49946a2e" - integrity sha512-7KaDJBXKBVGXw5WOVt84FtN8czGWhM0lbyWEZXGp8AFfL6sZQfRTluFp4QriR97qwzSyOfQb+nzcDZZU4tezUw== - dependencies: - "@docusaurus/mdx-loader" "2.4.3" - "@docusaurus/module-type-aliases" "2.4.3" - "@docusaurus/plugin-content-blog" "2.4.3" - "@docusaurus/plugin-content-docs" "2.4.3" - "@docusaurus/plugin-content-pages" "2.4.3" - "@docusaurus/utils" "2.4.3" - "@docusaurus/utils-common" "2.4.3" +"@docusaurus/theme-common@2.4.1": + version "2.4.1" + resolved "https://registry.yarnpkg.com/@docusaurus/theme-common/-/theme-common-2.4.1.tgz#03e16f7aa96455e952f3243ac99757b01a3c83d4" + integrity sha512-G7Zau1W5rQTaFFB3x3soQoZpkgMbl/SYNG8PfMFIjKa3M3q8n0m/GRf5/H/e5BqOvt8c+ZWIXGCiz+kUCSHovA== + dependencies: + "@docusaurus/mdx-loader" "2.4.1" + "@docusaurus/module-type-aliases" "2.4.1" + "@docusaurus/plugin-content-blog" "2.4.1" + "@docusaurus/plugin-content-docs" "2.4.1" + "@docusaurus/plugin-content-pages" "2.4.1" + "@docusaurus/utils" "2.4.1" + "@docusaurus/utils-common" "2.4.1" "@types/history" "^4.7.11" "@types/react" "*" "@types/react-router-config" "*" @@ -1632,32 +1592,32 @@ utility-types "^3.10.0" "@docusaurus/theme-mermaid@^2.4.1": - version "2.4.3" - resolved "https://registry.yarnpkg.com/@docusaurus/theme-mermaid/-/theme-mermaid-2.4.3.tgz#b40194fb4f46813a18d1350a188d43b68a8192dd" - integrity sha512-S1tZ3xpowtFiTrpTKmvVbRHUYGOlEG5CnPzWlO4huJT1sAwLR+pD6f9DYUlPv2+9NezF3EfUrUyW9xLH0UP58w== - dependencies: - "@docusaurus/core" "2.4.3" - "@docusaurus/module-type-aliases" "2.4.3" - "@docusaurus/theme-common" "2.4.3" - "@docusaurus/types" "2.4.3" - "@docusaurus/utils-validation" "2.4.3" + version "2.4.1" + resolved "https://registry.yarnpkg.com/@docusaurus/theme-mermaid/-/theme-mermaid-2.4.1.tgz#6bf644f9f7ef3db0e938b484f510d6d80d601419" + integrity sha512-cM0ImKIqZfjmlaC+uAjep39kNBvb1bjz429QBHGs32maob4+UnRzVPPpCUCltyPVb4xjG5h1Tyq4pHzhtIikqA== + dependencies: + "@docusaurus/core" "2.4.1" + "@docusaurus/module-type-aliases" "2.4.1" + "@docusaurus/theme-common" "2.4.1" + "@docusaurus/types" "2.4.1" + "@docusaurus/utils-validation" "2.4.1" "@mdx-js/react" "^1.6.22" mermaid "^9.2.2" tslib "^2.4.0" -"@docusaurus/theme-search-algolia@2.4.3": - version "2.4.3" - resolved "https://registry.yarnpkg.com/@docusaurus/theme-search-algolia/-/theme-search-algolia-2.4.3.tgz#32d4cbefc3deba4112068fbdb0bde11ac51ece53" - integrity sha512-jziq4f6YVUB5hZOB85ELATwnxBz/RmSLD3ksGQOLDPKVzat4pmI8tddNWtriPpxR04BNT+ZfpPUMFkNFetSW1Q== +"@docusaurus/theme-search-algolia@2.4.1": + version "2.4.1" + resolved "https://registry.yarnpkg.com/@docusaurus/theme-search-algolia/-/theme-search-algolia-2.4.1.tgz#906bd2cca3fced0241985ef502c892f58ff380fc" + integrity sha512-6BcqW2lnLhZCXuMAvPRezFs1DpmEKzXFKlYjruuas+Xy3AQeFzDJKTJFIm49N77WFCTyxff8d3E4Q9pi/+5McQ== dependencies: "@docsearch/react" "^3.1.1" - "@docusaurus/core" "2.4.3" - "@docusaurus/logger" "2.4.3" - "@docusaurus/plugin-content-docs" "2.4.3" - "@docusaurus/theme-common" "2.4.3" - "@docusaurus/theme-translations" "2.4.3" - "@docusaurus/utils" "2.4.3" - "@docusaurus/utils-validation" "2.4.3" + "@docusaurus/core" "2.4.1" + "@docusaurus/logger" "2.4.1" + "@docusaurus/plugin-content-docs" "2.4.1" + "@docusaurus/theme-common" "2.4.1" + "@docusaurus/theme-translations" "2.4.1" + "@docusaurus/utils" "2.4.1" + "@docusaurus/utils-validation" "2.4.1" algoliasearch "^4.13.1" algoliasearch-helper "^3.10.0" clsx "^1.2.1" @@ -1667,18 +1627,18 @@ tslib "^2.4.0" utility-types "^3.10.0" -"@docusaurus/theme-translations@2.4.3": - version "2.4.3" - resolved "https://registry.yarnpkg.com/@docusaurus/theme-translations/-/theme-translations-2.4.3.tgz#91ac73fc49b8c652b7a54e88b679af57d6ac6102" - integrity sha512-H4D+lbZbjbKNS/Zw1Lel64PioUAIT3cLYYJLUf3KkuO/oc9e0QCVhIYVtUI2SfBCF2NNdlyhBDQEEMygsCedIg== +"@docusaurus/theme-translations@2.4.1": + version "2.4.1" + resolved "https://registry.yarnpkg.com/@docusaurus/theme-translations/-/theme-translations-2.4.1.tgz#4d49df5865dae9ef4b98a19284ede62ae6f98726" + integrity sha512-T1RAGP+f86CA1kfE8ejZ3T3pUU3XcyvrGMfC/zxCtc2BsnoexuNI9Vk2CmuKCb+Tacvhxjv5unhxXce0+NKyvA== dependencies: fs-extra "^10.1.0" tslib "^2.4.0" -"@docusaurus/types@2.4.3": - version "2.4.3" - resolved "https://registry.yarnpkg.com/@docusaurus/types/-/types-2.4.3.tgz#4aead281ca09f721b3c0a9b926818450cfa3db31" - integrity sha512-W6zNLGQqfrp/EoPD0bhb9n7OobP+RHpmvVzpA+Z/IuU3Q63njJM24hmT0GYboovWcDtFmnIJC9wcyx4RVPQscw== +"@docusaurus/types@2.4.1": + version "2.4.1" + resolved "https://registry.yarnpkg.com/@docusaurus/types/-/types-2.4.1.tgz#d8e82f9e0f704984f98df1f93d6b4554d5458705" + integrity sha512-0R+cbhpMkhbRXX138UOc/2XZFF8hiZa6ooZAEEJFp5scytzCw4tC1gChMFXrpa3d2tYE6AX8IrOEpSonLmfQuQ== dependencies: "@types/history" "^4.7.11" "@types/react" "*" @@ -1689,30 +1649,30 @@ webpack "^5.73.0" webpack-merge "^5.8.0" -"@docusaurus/utils-common@2.4.3": - version "2.4.3" - resolved "https://registry.yarnpkg.com/@docusaurus/utils-common/-/utils-common-2.4.3.tgz#30656c39ef1ce7e002af7ba39ea08330f58efcfb" - integrity sha512-/jascp4GbLQCPVmcGkPzEQjNaAk3ADVfMtudk49Ggb+131B1WDD6HqlSmDf8MxGdy7Dja2gc+StHf01kiWoTDQ== +"@docusaurus/utils-common@2.4.1": + version "2.4.1" + resolved "https://registry.yarnpkg.com/@docusaurus/utils-common/-/utils-common-2.4.1.tgz#7f72e873e49bd5179588869cc3ab7449a56aae63" + integrity sha512-bCVGdZU+z/qVcIiEQdyx0K13OC5mYwxhSuDUR95oFbKVuXYRrTVrwZIqQljuo1fyJvFTKHiL9L9skQOPokuFNQ== dependencies: tslib "^2.4.0" -"@docusaurus/utils-validation@2.4.3": - version "2.4.3" - resolved "https://registry.yarnpkg.com/@docusaurus/utils-validation/-/utils-validation-2.4.3.tgz#8122c394feef3e96c73f6433987837ec206a63fb" - integrity sha512-G2+Vt3WR5E/9drAobP+hhZQMaswRwDlp6qOMi7o7ZypB+VO7N//DZWhZEwhcRGepMDJGQEwtPv7UxtYwPL9PBw== +"@docusaurus/utils-validation@2.4.1": + version "2.4.1" + resolved "https://registry.yarnpkg.com/@docusaurus/utils-validation/-/utils-validation-2.4.1.tgz#19959856d4a886af0c5cfb357f4ef68b51151244" + integrity sha512-unII3hlJlDwZ3w8U+pMO3Lx3RhI4YEbY3YNsQj4yzrkZzlpqZOLuAiZK2JyULnD+TKbceKU0WyWkQXtYbLNDFA== dependencies: - "@docusaurus/logger" "2.4.3" - "@docusaurus/utils" "2.4.3" + "@docusaurus/logger" "2.4.1" + "@docusaurus/utils" "2.4.1" joi "^17.6.0" js-yaml "^4.1.0" tslib "^2.4.0" -"@docusaurus/utils@2.4.3": - version "2.4.3" - resolved "https://registry.yarnpkg.com/@docusaurus/utils/-/utils-2.4.3.tgz#52b000d989380a2125831b84e3a7327bef471e89" - integrity sha512-fKcXsjrD86Smxv8Pt0TBFqYieZZCPh4cbf9oszUq/AMhZn3ujwpKaVYZACPX8mmjtYx0JOgNx52CREBfiGQB4A== +"@docusaurus/utils@2.4.1": + version "2.4.1" + resolved "https://registry.yarnpkg.com/@docusaurus/utils/-/utils-2.4.1.tgz#9c5f76eae37b71f3819c1c1f0e26e6807c99a4fc" + integrity sha512-1lvEZdAQhKNht9aPXPoh69eeKnV0/62ROhQeFKKxmzd0zkcuE/Oc5Gpnt00y/f5bIsmOsYMY7Pqfm/5rteT5GA== dependencies: - "@docusaurus/logger" "2.4.3" + "@docusaurus/logger" "2.4.1" "@svgr/webpack" "^6.2.1" escape-string-regexp "^4.0.0" file-loader "^6.2.0" @@ -1734,76 +1694,84 @@ resolved "https://registry.yarnpkg.com/@endiliey/react-ideal-image/-/react-ideal-image-0.0.11.tgz#dc3803d04e1409cf88efa4bba0f67667807bdf27" integrity sha512-QxMjt/Gvur/gLxSoCy7VIyGGGrGmDN+VHcXkN3R2ApoWX0EYUE+hMgPHSW/PV6VVebZ1Nd4t2UnGRBDihu16JQ== -"@hapi/hoek@^9.0.0", "@hapi/hoek@^9.3.0": +"@hapi/hoek@^9.0.0": version "9.3.0" resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.3.0.tgz#8368869dcb735be2e7f5cb7647de78e167a251fb" integrity sha512-/c6rf4UJlmHlC9b5BaNvzAcFv7HZ2QHaV0D4/HNlBdvFnvQq8RI4kYdhyPCl7Xj+oWvTWQ8ujhqS53LIgAe6KQ== -"@hapi/topo@^5.1.0": +"@hapi/topo@^5.0.0": version "5.1.0" resolved "https://registry.yarnpkg.com/@hapi/topo/-/topo-5.1.0.tgz#dc448e332c6c6e37a4dc02fd84ba8d44b9afb012" integrity sha512-foQZKJig7Ob0BMAYBfcJk8d77QtOe7Wo4ox7ff1lQYoNNAb6jwcY1ncdoy2e9wQZzvNy7ODZCYJkK8kzmcAnAg== dependencies: "@hapi/hoek" "^9.0.0" -"@jest/schemas@^29.6.3": - version "29.6.3" - resolved "https://registry.yarnpkg.com/@jest/schemas/-/schemas-29.6.3.tgz#430b5ce8a4e0044a7e3819663305a7b3091c8e03" - integrity sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA== +"@jest/schemas@^29.4.3": + version "29.4.3" + resolved "https://registry.yarnpkg.com/@jest/schemas/-/schemas-29.4.3.tgz#39cf1b8469afc40b6f5a2baaa146e332c4151788" + integrity sha512-VLYKXQmtmuEz6IxJsrZwzG9NvtkQsWNnWMsKxqWNu3+CnfzJQhp0WDDKWLVV9hLKr0l3SLLFRqcYHjhtyuDVxg== dependencies: - "@sinclair/typebox" "^0.27.8" + "@sinclair/typebox" "^0.25.16" -"@jest/types@^29.6.3": - version "29.6.3" - resolved "https://registry.yarnpkg.com/@jest/types/-/types-29.6.3.tgz#1131f8cf634e7e84c5e77bab12f052af585fba59" - integrity sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw== +"@jest/types@^29.5.0": + version "29.5.0" + resolved "https://registry.yarnpkg.com/@jest/types/-/types-29.5.0.tgz#f59ef9b031ced83047c67032700d8c807d6e1593" + integrity sha512-qbu7kN6czmVRc3xWFQcAN03RAUamgppVUdXrvl1Wr3jlNF93o9mJbGcDWrwGB6ht44u7efB1qCFgVQmca24Uog== dependencies: - "@jest/schemas" "^29.6.3" + "@jest/schemas" "^29.4.3" "@types/istanbul-lib-coverage" "^2.0.0" "@types/istanbul-reports" "^3.0.0" "@types/node" "*" "@types/yargs" "^17.0.8" chalk "^4.0.0" +"@jridgewell/gen-mapping@^0.1.0": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz#e5d2e450306a9491e3bd77e323e38d7aff315996" + integrity sha512-sQXCasFk+U8lWYEe66WxRDOE9PjVz4vSM51fTu3Hw+ClTpUSQb718772vH3pyS5pShp6lvQM7SxgIDXXXmOX7w== + dependencies: + "@jridgewell/set-array" "^1.0.0" + "@jridgewell/sourcemap-codec" "^1.4.10" + "@jridgewell/gen-mapping@^0.3.0", "@jridgewell/gen-mapping@^0.3.2": - version "0.3.3" - resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz#7e02e6eb5df901aaedb08514203b096614024098" - integrity sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ== + version "0.3.2" + resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz#c1aedc61e853f2bb9f5dfe6d4442d3b565b253b9" + integrity sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A== dependencies: "@jridgewell/set-array" "^1.0.1" "@jridgewell/sourcemap-codec" "^1.4.10" "@jridgewell/trace-mapping" "^0.3.9" -"@jridgewell/resolve-uri@^3.1.0": - version "3.1.1" - resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz#c08679063f279615a3326583ba3a90d1d82cc721" - integrity sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA== +"@jridgewell/resolve-uri@3.1.0": + version "3.1.0" + resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz#2203b118c157721addfe69d47b70465463066d78" + integrity sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w== -"@jridgewell/set-array@^1.0.1": +"@jridgewell/set-array@^1.0.0", "@jridgewell/set-array@^1.0.1": version "1.1.2" resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.2.tgz#7c6cf998d6d20b914c0a55a91ae928ff25965e72" integrity sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw== -"@jridgewell/source-map@^0.3.3": - version "0.3.5" - resolved "https://registry.yarnpkg.com/@jridgewell/source-map/-/source-map-0.3.5.tgz#a3bb4d5c6825aab0d281268f47f6ad5853431e91" - integrity sha512-UTYAUj/wviwdsMfzoSJspJxbkH5o1snzwX0//0ENX1u/55kkZZkcTZP6u9bwKGkv+dkk9at4m1Cpt0uY80kcpQ== +"@jridgewell/source-map@^0.3.2": + version "0.3.2" + resolved "https://registry.yarnpkg.com/@jridgewell/source-map/-/source-map-0.3.2.tgz#f45351aaed4527a298512ec72f81040c998580fb" + integrity sha512-m7O9o2uR8k2ObDysZYzdfhb08VuEml5oWGiosa1VdaPZ/A6QyPkAJuwN0Q1lhULOf6B7MtQmHENS743hWtCrgw== dependencies: "@jridgewell/gen-mapping" "^0.3.0" "@jridgewell/trace-mapping" "^0.3.9" -"@jridgewell/sourcemap-codec@^1.4.10", "@jridgewell/sourcemap-codec@^1.4.14": - version "1.4.15" - resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz#d7c6e6755c78567a951e04ab52ef0fd26de59f32" - integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg== +"@jridgewell/sourcemap-codec@1.4.14", "@jridgewell/sourcemap-codec@^1.4.10": + version "1.4.14" + resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24" + integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw== -"@jridgewell/trace-mapping@^0.3.17", "@jridgewell/trace-mapping@^0.3.20", "@jridgewell/trace-mapping@^0.3.9": - version "0.3.21" - resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.21.tgz#5dc1df7b3dc4a6209e503a924e1ca56097a2bb15" - integrity sha512-SRfKmRe1KvYnxjEMtxEr+J4HIeMX5YBg/qhRHpxEIGjhX1rshcHlnFUE9K0GazhVKWM7B+nARSkV8LuvJdJ5/g== +"@jridgewell/trace-mapping@^0.3.14", "@jridgewell/trace-mapping@^0.3.17", "@jridgewell/trace-mapping@^0.3.9": + version "0.3.17" + resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.17.tgz#793041277af9073b0951a7fe0f0d8c4c98c36985" + integrity sha512-MCNzAp77qzKca9+W/+I0+sEpaUnZoeasnghNeVc41VZCEKaCH73Vq3BZZ/SzWIgrqE4H4ceI+p+b6C0mHf9T4g== dependencies: - "@jridgewell/resolve-uri" "^3.1.0" - "@jridgewell/sourcemap-codec" "^1.4.14" + "@jridgewell/resolve-uri" "3.1.0" + "@jridgewell/sourcemap-codec" "1.4.14" "@leichtgewicht/ip-codec@^2.0.1": version "2.0.4" @@ -1866,12 +1834,12 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" -"@polka/url@^1.0.0-next.24": - version "1.0.0-next.24" - resolved "https://registry.yarnpkg.com/@polka/url/-/url-1.0.0-next.24.tgz#58601079e11784d20f82d0585865bb42305c4df3" - integrity sha512-2LuNTFBIO0m7kKIQvvPHN6UE63VjpmL9rnEEaOOaiSPbZK+zUOYIzBAWcED+3XYzhYsd/0mD57VdxAEqqV52CQ== +"@polka/url@^1.0.0-next.20": + version "1.0.0-next.21" + resolved "https://registry.yarnpkg.com/@polka/url/-/url-1.0.0-next.21.tgz#5de5a2385a35309427f6011992b544514d559aa1" + integrity sha512-a5Sab1C4/icpTZVzZc5Ghpz88yQtGOyNqYXcZgOssB2uuAr+wF/MvN6bgtW32q7HHrvBki+BsZ0OuNv6EV3K9g== -"@sideway/address@^4.1.4": +"@sideway/address@^4.1.3": version "4.1.4" resolved "https://registry.yarnpkg.com/@sideway/address/-/address-4.1.4.tgz#03dccebc6ea47fdc226f7d3d1ad512955d4783f0" integrity sha512-7vwq+rOHVWjyXxVlR76Agnvhy8I9rpzjosTESvmhNeXOXdZZB15Fl+TI9x1SiHZH5Jv2wTGduSxFDIaq0m3DUw== @@ -1888,10 +1856,10 @@ resolved "https://registry.yarnpkg.com/@sideway/pinpoint/-/pinpoint-2.0.0.tgz#cff8ffadc372ad29fd3f78277aeb29e632cc70df" integrity sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ== -"@sinclair/typebox@^0.27.8": - version "0.27.8" - resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.27.8.tgz#6667fac16c436b5434a387a34dedb013198f6e6e" - integrity sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA== +"@sinclair/typebox@^0.25.16": + version "0.25.24" + resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.25.24.tgz#8c7688559979f7079aacaf31aa881c3aa410b718" + integrity sha512-XJfwUVUKDHF5ugKwIcxEgc9k8b7HbznCp6eUfWgu710hMPNIO4aw4/zB5RogDQz8nd6gyCDpU9O/m6qYEWY6yQ== "@sindresorhus/is@^0.14.0": version "0.14.0" @@ -1913,14 +1881,14 @@ integrity sha512-9PYGcXrAxitycIjRmZB+Q0JaN07GZIWaTBIGQzfaZv+qr1n8X1XUEJ5rZ/vx6OVD9RRYlrNnXWExQXcmZeD/BQ== "@svgr/babel-plugin-remove-jsx-attribute@*": - version "8.0.0" - resolved "https://registry.yarnpkg.com/@svgr/babel-plugin-remove-jsx-attribute/-/babel-plugin-remove-jsx-attribute-8.0.0.tgz#69177f7937233caca3a1afb051906698f2f59186" - integrity sha512-BcCkm/STipKvbCl6b7QFrMh/vx00vIP63k2eM66MfHJzPr6O2U0jYEViXkHJWqXqQYjdeA9cuCl5KWmlwjDvbA== + version "6.5.0" + resolved "https://registry.yarnpkg.com/@svgr/babel-plugin-remove-jsx-attribute/-/babel-plugin-remove-jsx-attribute-6.5.0.tgz#652bfd4ed0a0699843585cda96faeb09d6e1306e" + integrity sha512-8zYdkym7qNyfXpWvu4yq46k41pyNM9SOstoWhKlm+IfdCE1DdnRKeMUPsWIEO/DEkaWxJ8T9esNdG3QwQ93jBA== "@svgr/babel-plugin-remove-jsx-empty-expression@*": - version "8.0.0" - resolved "https://registry.yarnpkg.com/@svgr/babel-plugin-remove-jsx-empty-expression/-/babel-plugin-remove-jsx-empty-expression-8.0.0.tgz#c2c48104cfd7dcd557f373b70a56e9e3bdae1d44" - integrity sha512-5BcGCBfBxB5+XSDSWnhTThfI9jcO5f0Ai2V24gZpG+wXF14BzwxxdDb4g6trdOux0rhibGs385BeFMSmxtS3uA== + version "6.5.0" + resolved "https://registry.yarnpkg.com/@svgr/babel-plugin-remove-jsx-empty-expression/-/babel-plugin-remove-jsx-empty-expression-6.5.0.tgz#4b78994ab7d39032c729903fc2dd5c0fa4565cb8" + integrity sha512-NFdxMq3xA42Kb1UbzCVxplUc0iqSyM9X8kopImvFnB+uSDdzIHOdbs1op8ofAvVRtbg4oZiyRl3fTYeKcOe9Iw== "@svgr/babel-plugin-replace-jsx-attribute-value@^6.5.1": version "6.5.1" @@ -2026,75 +1994,79 @@ integrity sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA== "@tsconfig/docusaurus@^1.0.5": - version "1.0.7" - resolved "https://registry.yarnpkg.com/@tsconfig/docusaurus/-/docusaurus-1.0.7.tgz#a3ee3c8109b3fec091e3d61a61834e563aeee3c3" - integrity sha512-ffTXxGIP/IRMCjuzHd6M4/HdIrw1bMfC7Bv8hMkTadnePkpe0lG0oDSdbRpSDZb2rQMAgpbWiR10BvxvNYwYrg== + version "1.0.6" + resolved "https://registry.yarnpkg.com/@tsconfig/docusaurus/-/docusaurus-1.0.6.tgz#7305a7fa590decc0d5968500234e95fd68788978" + integrity sha512-1QxDaP54hpzM6bq9E+yFEo4F9WbWHhsDe4vktZXF/iDlc9FqGr9qlg+3X/nuKQXx8QxHV7ue8NXFazzajsxFBA== "@types/body-parser@*": - version "1.19.5" - resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.19.5.tgz#04ce9a3b677dc8bd681a17da1ab9835dc9d3ede4" - integrity sha512-fB3Zu92ucau0iQ0JMCFQE7b/dv8Ot07NI3KaZIkIUNXq82k4eBAqUaneXfleGY9JWskeS9y+u0nXMyspcuQrCg== + version "1.19.2" + resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.19.2.tgz#aea2059e28b7658639081347ac4fab3de166e6f0" + integrity sha512-ALYone6pm6QmwZoAgeyNksccT9Q4AWZQ6PvfwR37GT6r6FWUPguq6sUmNGSMV2Wr761oQoBxwGGa6DR5o1DC9g== dependencies: "@types/connect" "*" "@types/node" "*" "@types/bonjour@^3.5.9": - version "3.5.13" - resolved "https://registry.yarnpkg.com/@types/bonjour/-/bonjour-3.5.13.tgz#adf90ce1a105e81dd1f9c61fdc5afda1bfb92956" - integrity sha512-z9fJ5Im06zvUL548KvYNecEVlA7cVDkGUi6kZusb04mpyEFKCIZJvloCcmpmLaIahDpOQGHaHmG6imtPMmPXGQ== + version "3.5.10" + resolved "https://registry.yarnpkg.com/@types/bonjour/-/bonjour-3.5.10.tgz#0f6aadfe00ea414edc86f5d106357cda9701e275" + integrity sha512-p7ienRMiS41Nu2/igbJxxLDWrSZ0WxM8UQgCeO9KhoVF7cOVFkrKsiDr1EsJIla8vV3oEEjGcz11jc5yimhzZw== dependencies: "@types/node" "*" "@types/connect-history-api-fallback@^1.3.5": - version "1.5.4" - resolved "https://registry.yarnpkg.com/@types/connect-history-api-fallback/-/connect-history-api-fallback-1.5.4.tgz#7de71645a103056b48ac3ce07b3520b819c1d5b3" - integrity sha512-n6Cr2xS1h4uAulPRdlw6Jl6s1oG8KrVilPN2yUITEs+K48EzMJJ3W1xy8K5eWuFvjp3R74AOIGSmp2UfBJ8HFw== + version "1.3.5" + resolved "https://registry.yarnpkg.com/@types/connect-history-api-fallback/-/connect-history-api-fallback-1.3.5.tgz#d1f7a8a09d0ed5a57aee5ae9c18ab9b803205dae" + integrity sha512-h8QJa8xSb1WD4fpKBDcATDNGXghFj6/3GRWG6dhmRcu0RX1Ubasur2Uvx5aeEwlf0MwblEC2bMzzMQntxnw/Cw== dependencies: "@types/express-serve-static-core" "*" "@types/node" "*" "@types/connect@*": - version "3.4.38" - resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.38.tgz#5ba7f3bc4fbbdeaff8dded952e5ff2cc53f8d858" - integrity sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug== + version "3.4.35" + resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.35.tgz#5fcf6ae445e4021d1fc2219a4873cc73a3bb2ad1" + integrity sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ== dependencies: "@types/node" "*" "@types/eslint-scope@^3.7.3": - version "3.7.7" - resolved "https://registry.yarnpkg.com/@types/eslint-scope/-/eslint-scope-3.7.7.tgz#3108bd5f18b0cdb277c867b3dd449c9ed7079ac5" - integrity sha512-MzMFlSLBqNF2gcHWO0G1vP/YQyfvrxZ0bF+u7mzUdZ1/xK4A4sru+nraZz5i3iEIk1l1uyicaDVTB4QbbEkAYg== + version "3.7.4" + resolved "https://registry.yarnpkg.com/@types/eslint-scope/-/eslint-scope-3.7.4.tgz#37fc1223f0786c39627068a12e94d6e6fc61de16" + integrity sha512-9K4zoImiZc3HlIp6AVUDE4CWYx22a+lhSZMYNpbjW04+YF0KWj4pJXnEMjdnFTiQibFFmElcsasJXDbdI/EPhA== dependencies: "@types/eslint" "*" "@types/estree" "*" "@types/eslint@*": - version "8.56.2" - resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-8.56.2.tgz#1c72a9b794aa26a8b94ad26d5b9aa51c8a6384bb" - integrity sha512-uQDwm1wFHmbBbCZCqAlq6Do9LYwByNZHWzXppSnay9SuwJ+VRbjkbLABer54kcPnMSlG6Fdiy2yaFXm/z9Z5gw== + version "8.21.1" + resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-8.21.1.tgz#110b441a210d53ab47795124dbc3e9bb993d1e7c" + integrity sha512-rc9K8ZpVjNcLs8Fp0dkozd5Pt2Apk1glO4Vgz8ix1u6yFByxfqo5Yavpy65o+93TAe24jr7v+eSBtFLvOQtCRQ== dependencies: "@types/estree" "*" "@types/json-schema" "*" -"@types/estree@*", "@types/estree@^1.0.0": - version "1.0.5" - resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.5.tgz#a6ce3e556e00fd9895dd872dd172ad0d4bd687f4" - integrity sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw== +"@types/estree@*": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.0.tgz#5fb2e536c1ae9bf35366eed879e827fa59ca41c2" + integrity sha512-WulqXMDUTYAXCjZnk6JtIHPigp55cVtDgDrO2gHRwhyJto21+1zbVCtOYB2L1F9w4qCQ0rOGWBnBe0FNTiEJIQ== + +"@types/estree@^0.0.51": + version "0.0.51" + resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.51.tgz#cfd70924a25a3fd32b218e5e420e6897e1ac4f40" + integrity sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ== "@types/express-serve-static-core@*", "@types/express-serve-static-core@^4.17.33": - version "4.17.41" - resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.17.41.tgz#5077defa630c2e8d28aa9ffc2c01c157c305bef6" - integrity sha512-OaJ7XLaelTgrvlZD8/aa0vvvxZdUmlCn6MtWeB7TkiKW70BQLc9XEPpDLPdbo52ZhXUCrznlWdCHWxJWtdyajA== + version "4.17.33" + resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.17.33.tgz#de35d30a9d637dc1450ad18dd583d75d5733d543" + integrity sha512-TPBqmR/HRYI3eC2E5hmiivIzv+bidAfXofM+sbonAGvyDhySGw9/PQZFt2BLOrjUUR++4eJVpx6KnLQK1Fk9tA== dependencies: "@types/node" "*" "@types/qs" "*" "@types/range-parser" "*" - "@types/send" "*" "@types/express@*", "@types/express@^4.17.13": - version "4.17.21" - resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.21.tgz#c26d4a151e60efe0084b23dc3369ebc631ed192d" - integrity sha512-ejlPM315qwLpaQlQDTjPdsUFSc6ZsP4AN6AlWnogPjQ7CVi7PYF3YVz+CY3jE2pwYf7E/7HlDAN0rV2GxTG0HQ== + version "4.17.17" + resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.17.tgz#01d5437f6ef9cfa8668e616e13c2f2ac9a491ae4" + integrity sha512-Q4FmmuLGBG58btUnfS1c1r/NQdlp3DMfGDGig8WhfpA2YRUtEkxAjkZb0yvplJGYdF1fsQ81iMDcH24sSCNC/Q== dependencies: "@types/body-parser" "*" "@types/express-serve-static-core" "^4.17.33" @@ -2102,11 +2074,11 @@ "@types/serve-static" "*" "@types/hast@^2.0.0": - version "2.3.9" - resolved "https://registry.yarnpkg.com/@types/hast/-/hast-2.3.9.tgz#a9a1b5bbce46e8a1312e977364bacabc8e93d2cf" - integrity sha512-pTHyNlaMD/oKJmS+ZZUyFUcsZeBZpC0lmGquw98CqRVNgAdJZJeD7GoeLiT6Xbx5rU9VCjSt0RwEvDgzh4obFw== + version "2.3.4" + resolved "https://registry.yarnpkg.com/@types/hast/-/hast-2.3.4.tgz#8aa5ef92c117d20d974a82bdfb6a648b08c0bafc" + integrity sha512-wLEm0QvaoawEDoTRwzTXp4b4jpwiJDvR5KMnFnVodm3scufTlBOWRD6N1OBf9TZMhjlNsSfcO5V+7AF4+Vy+9g== dependencies: - "@types/unist" "^2" + "@types/unist" "*" "@types/history@^4.7.11": version "4.7.11" @@ -2118,41 +2090,36 @@ resolved "https://registry.yarnpkg.com/@types/html-minifier-terser/-/html-minifier-terser-6.1.0.tgz#4fc33a00c1d0c16987b1a20cf92d20614c55ac35" integrity sha512-oh/6byDPnL1zeNXFrDXFLyZjkr1MsBG667IM792caf1L2UPOOMf65NFzjUH/ltyfwjAGfs1rsX1eftK0jC/KIg== -"@types/http-errors@*": - version "2.0.4" - resolved "https://registry.yarnpkg.com/@types/http-errors/-/http-errors-2.0.4.tgz#7eb47726c391b7345a6ec35ad7f4de469cf5ba4f" - integrity sha512-D0CFMMtydbJAegzOyHjtiKPLlvnm3iTZyZRSZoLq2mRhDdmLfIWOCYPfQJ4cu2erKghU++QvjcUjp/5h7hESpA== - "@types/http-proxy@^1.17.8": - version "1.17.14" - resolved "https://registry.yarnpkg.com/@types/http-proxy/-/http-proxy-1.17.14.tgz#57f8ccaa1c1c3780644f8a94f9c6b5000b5e2eec" - integrity sha512-SSrD0c1OQzlFX7pGu1eXxSEjemej64aaNPRhhVYUGqXh0BtldAAx37MG8btcumvpgKyZp1F5Gn3JkktdxiFv6w== + version "1.17.10" + resolved "https://registry.yarnpkg.com/@types/http-proxy/-/http-proxy-1.17.10.tgz#e576c8e4a0cc5c6a138819025a88e167ebb38d6c" + integrity sha512-Qs5aULi+zV1bwKAg5z1PWnDXWmsn+LxIvUGv6E2+OOMYhclZMO+OXd9pYVf2gLykf2I7IV2u7oTHwChPNsvJ7g== dependencies: "@types/node" "*" "@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0": - version "2.0.6" - resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz#7739c232a1fee9b4d3ce8985f314c0c6d33549d7" - integrity sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w== + version "2.0.4" + resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz#8467d4b3c087805d63580480890791277ce35c44" + integrity sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g== "@types/istanbul-lib-report@*": - version "3.0.3" - resolved "https://registry.yarnpkg.com/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.3.tgz#53047614ae72e19fc0401d872de3ae2b4ce350bf" - integrity sha512-NQn7AHQnk/RSLOxrBbGyJM/aVQ+pjj5HCgasFxc0K/KhoATfQ/47AyUl15I2yBUpihjmas+a+VJBOqecrFH+uA== + version "3.0.0" + resolved "https://registry.yarnpkg.com/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz#c14c24f18ea8190c118ee7562b7ff99a36552686" + integrity sha512-plGgXAPfVKFoYfa9NpYDAkseG+g6Jr294RqeqcqDixSbU34MZVJRi/P+7Y8GDpzkEwLaGZZOpKIEmeVZNtKsrg== dependencies: "@types/istanbul-lib-coverage" "*" "@types/istanbul-reports@^3.0.0": - version "3.0.4" - resolved "https://registry.yarnpkg.com/@types/istanbul-reports/-/istanbul-reports-3.0.4.tgz#0f03e3d2f670fbdac586e34b433783070cc16f54" - integrity sha512-pk2B1NWalF9toCRu6gjBzR69syFjP4Od8WRAX+0mmf9lAjCRicLOWc+ZrxZHx/0XRjotgkF9t6iaMJ+aXcOdZQ== + version "3.0.1" + resolved "https://registry.yarnpkg.com/@types/istanbul-reports/-/istanbul-reports-3.0.1.tgz#9153fe98bba2bd565a63add9436d6f0d7f8468ff" + integrity sha512-c3mAZEuK0lvBp8tmuL74XRKn1+y2dcwOUpH7x4WrF6gk1GIgiluDRgMYQtw2OFcBvAJWlt6ASU3tSqxp0Uu0Aw== dependencies: "@types/istanbul-lib-report" "*" "@types/json-schema@*", "@types/json-schema@^7.0.4", "@types/json-schema@^7.0.5", "@types/json-schema@^7.0.8", "@types/json-schema@^7.0.9": - version "7.0.15" - resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841" - integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA== + version "7.0.11" + resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3" + integrity sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ== "@types/katex@^0.11.0": version "0.11.1" @@ -2160,35 +2127,21 @@ integrity sha512-DUlIj2nk0YnJdlWgsFuVKcX27MLW0KbKmGVoUHmFr+74FYYNUDAaj9ZqTADvsbE8rfxuVmSFc7KczYn5Y09ozg== "@types/mdast@^3.0.0": - version "3.0.15" - resolved "https://registry.yarnpkg.com/@types/mdast/-/mdast-3.0.15.tgz#49c524a263f30ffa28b71ae282f813ed000ab9f5" - integrity sha512-LnwD+mUEfxWMa1QpDraczIn6k0Ee3SMicuYSSzS6ZYl2gKS09EClnJYGd8Du6rfc5r/GZEk5o1mRb8TaTj03sQ== + version "3.0.10" + resolved "https://registry.yarnpkg.com/@types/mdast/-/mdast-3.0.10.tgz#4724244a82a4598884cbbe9bcfd73dff927ee8af" + integrity sha512-W864tg/Osz1+9f4lrGTZpCSO5/z4608eUp19tbozkq2HJK6i3z1kT0H9tlADXuYIb1YYOBByU4Jsqkk75q48qA== dependencies: - "@types/unist" "^2" + "@types/unist" "*" "@types/mime@*": - version "3.0.4" - resolved "https://registry.yarnpkg.com/@types/mime/-/mime-3.0.4.tgz#2198ac274de6017b44d941e00261d5bc6a0e0a45" - integrity sha512-iJt33IQnVRkqeqC7PzBHPTC6fDlRNRW8vjrgqtScAhrmMwe8c4Eo7+fUGTa+XdWrpEgpyKWMYmi2dIwMAYRzPw== - -"@types/mime@^1": - version "1.3.5" - resolved "https://registry.yarnpkg.com/@types/mime/-/mime-1.3.5.tgz#1ef302e01cf7d2b5a0fa526790c9123bf1d06690" - integrity sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w== - -"@types/node-forge@^1.3.0": - version "1.3.11" - resolved "https://registry.yarnpkg.com/@types/node-forge/-/node-forge-1.3.11.tgz#0972ea538ddb0f4d9c2fa0ec5db5724773a604da" - integrity sha512-FQx220y22OKNTqaByeBGqHWYz4cl94tpcxeFdvBo3wjG6XPBuZ0BNgNZRV5J5TFmmcsJ4IzsLkmGRiQbnYsBEQ== - dependencies: - "@types/node" "*" + version "3.0.1" + resolved "https://registry.yarnpkg.com/@types/mime/-/mime-3.0.1.tgz#5f8f2bca0a5863cb69bc0b0acd88c96cb1d4ae10" + integrity sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA== "@types/node@*": - version "20.11.5" - resolved "https://registry.yarnpkg.com/@types/node/-/node-20.11.5.tgz#be10c622ca7fcaa3cf226cf80166abc31389d86e" - integrity sha512-g557vgQjUUfN76MZAN/dt1z3dzcUsimuysco0KeluHgrPdJXkP/XdAURgyO2W9fZWHRtRBiVKzKn8vyOAwlG+w== - dependencies: - undici-types "~5.26.4" + version "18.14.6" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.14.6.tgz#ae1973dd2b1eeb1825695bb11ebfb746d27e3e93" + integrity sha512-93+VvleD3mXwlLI/xASjw0FzKcwzl3OdTCzm1LaRfqgS21gfFtK3zDXM5Op9TeeMsJVOaJ2VRDpT9q4Y3d0AvA== "@types/node@^17.0.5": version "17.0.45" @@ -2196,9 +2149,9 @@ integrity sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw== "@types/parse-json@^4.0.0": - version "4.0.2" - resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.2.tgz#5950e50960793055845e956c427fc2b0d70c5239" - integrity sha512-dISoDXWWQwUquiKsyZ4Ng+HX2KsPL7LyHKHQwgGFEA3IaKac4Obd+h2a/a6waisAoepJlBcx9paWqjA8/HVjCw== + version "4.0.0" + resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0" + integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA== "@types/parse5@^5.0.0": version "5.0.3" @@ -2206,28 +2159,28 @@ integrity sha512-kUNnecmtkunAoQ3CnjmMkzNU/gtxG8guhi+Fk2U/kOpIKjIMKnXGp4IJCgQJrXSgMsWYimYG4TGjz/UzbGEBTw== "@types/prop-types@*": - version "15.7.11" - resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.11.tgz#2596fb352ee96a1379c657734d4b913a613ad563" - integrity sha512-ga8y9v9uyeiLdpKddhxYQkxNDrfvuPrlFb0N1qnZZByvcElJaXthF1UhvCh9TLWJBEHeNtdnbysW7Y6Uq8CVng== + version "15.7.5" + resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.5.tgz#5f19d2b85a98e9558036f6a3cacc8819420f05cf" + integrity sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w== "@types/qs@*": - version "6.9.11" - resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.11.tgz#208d8a30bc507bd82e03ada29e4732ea46a6bbda" - integrity sha512-oGk0gmhnEJK4Yyk+oI7EfXsLayXatCWPHary1MtcmbAifkobT9cM9yutG/hZKIseOU0MqbIwQ/u2nn/Gb+ltuQ== + version "6.9.7" + resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.7.tgz#63bb7d067db107cc1e457c303bc25d511febf6cb" + integrity sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw== "@types/range-parser@*": - version "1.2.7" - resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.7.tgz#50ae4353eaaddc04044279812f52c8c65857dbcb" - integrity sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ== + version "1.2.4" + resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.4.tgz#cd667bcfdd025213aafb7ca5915a932590acdcdc" + integrity sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw== "@types/react-router-config@*", "@types/react-router-config@^5.0.6": - version "5.0.11" - resolved "https://registry.yarnpkg.com/@types/react-router-config/-/react-router-config-5.0.11.tgz#2761a23acc7905a66a94419ee40294a65aaa483a" - integrity sha512-WmSAg7WgqW7m4x8Mt4N6ZyKz0BubSj/2tVUMsAHp+Yd2AMwcSbeFq9WympT19p5heCFmF97R9eD5uUR/t4HEqw== + version "5.0.6" + resolved "https://registry.yarnpkg.com/@types/react-router-config/-/react-router-config-5.0.6.tgz#87c5c57e72d241db900d9734512c50ccec062451" + integrity sha512-db1mx37a1EJDf1XeX8jJN7R3PZABmJQXR8r28yUjVMFSjkmnQo6X6pOEEmNl+Tp2gYQOGPdYbFIipBtdElZ3Yg== dependencies: "@types/history" "^4.7.11" "@types/react" "*" - "@types/react-router" "^5.1.0" + "@types/react-router" "*" "@types/react-router-dom@*": version "5.3.3" @@ -2238,7 +2191,7 @@ "@types/react" "*" "@types/react-router" "*" -"@types/react-router@*", "@types/react-router@^5.1.0": +"@types/react-router@*": version "5.1.20" resolved "https://registry.yarnpkg.com/@types/react-router/-/react-router-5.1.20.tgz#88eccaa122a82405ef3efbcaaa5dcdd9f021387c" integrity sha512-jGjmu/ZqS7FjSH6owMcD5qpq19+1RS9DeVRqfl1FeBMxTDQAGwlMWOcs52NDoXaNKyG3d1cYQFMs9rCrb88o9Q== @@ -2247,9 +2200,9 @@ "@types/react" "*" "@types/react@*": - version "18.2.48" - resolved "https://registry.yarnpkg.com/@types/react/-/react-18.2.48.tgz#11df5664642d0bd879c1f58bc1d37205b064e8f1" - integrity sha512-qboRCl6Ie70DQQG9hhNREz81jqC1cs9EVNcjQ1AU+jH6NFfSAhVVbrrY/+nSF+Bsk4AOwm9Qa61InvMCyV+H3w== + version "18.0.28" + resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.28.tgz#accaeb8b86f4908057ad629a26635fe641480065" + integrity sha512-RD0ivG1kEztNBdoAK7lekI9M+azSnitIn85h4iOiaLjaTrMjzslhaqCGaI4IyCJ1RljWiLCEu4jyrLLgqxBTew== dependencies: "@types/prop-types" "*" "@types/scheduler" "*" @@ -2261,191 +2214,182 @@ integrity sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA== "@types/sax@^1.2.1": - version "1.2.7" - resolved "https://registry.yarnpkg.com/@types/sax/-/sax-1.2.7.tgz#ba5fe7df9aa9c89b6dff7688a19023dd2963091d" - integrity sha512-rO73L89PJxeYM3s3pPPjiPgVVcymqU490g0YO5n5By0k2Erzj6tay/4lr1CHAAU4JyOWd1rpQ8bCf6cZfHU96A== + version "1.2.4" + resolved "https://registry.yarnpkg.com/@types/sax/-/sax-1.2.4.tgz#8221affa7f4f3cb21abd22f244cfabfa63e6a69e" + integrity sha512-pSAff4IAxJjfAXUG6tFkO7dsSbTmf8CtUpfhhZ5VhkRpC4628tJhh3+V6H1E+/Gs9piSzYKT5yzHO5M4GG9jkw== dependencies: "@types/node" "*" "@types/scheduler@*": - version "0.16.8" - resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.8.tgz#ce5ace04cfeabe7ef87c0091e50752e36707deff" - integrity sha512-WZLiwShhwLRmeV6zH+GkbOFT6Z6VklCItrDioxUnv+u4Ll+8vKeFySoFyK/0ctcRpOmwAicELfmys1sDc/Rw+A== - -"@types/send@*": - version "0.17.4" - resolved "https://registry.yarnpkg.com/@types/send/-/send-0.17.4.tgz#6619cd24e7270793702e4e6a4b958a9010cfc57a" - integrity sha512-x2EM6TJOybec7c52BX0ZspPodMsQUd5L6PRwOunVyVUhXiBSKf3AezDL8Dgvgt5o0UfKNfuA0eMLr2wLT4AiBA== - dependencies: - "@types/mime" "^1" - "@types/node" "*" + version "0.16.2" + resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.2.tgz#1a62f89525723dde24ba1b01b092bf5df8ad4d39" + integrity sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew== "@types/serve-index@^1.9.1": - version "1.9.4" - resolved "https://registry.yarnpkg.com/@types/serve-index/-/serve-index-1.9.4.tgz#e6ae13d5053cb06ed36392110b4f9a49ac4ec898" - integrity sha512-qLpGZ/c2fhSs5gnYsQxtDEq3Oy8SXPClIXkW5ghvAvsNuVSA8k+gCONcUCS/UjLEYvYps+e8uBtfgXgvhwfNug== + version "1.9.1" + resolved "https://registry.yarnpkg.com/@types/serve-index/-/serve-index-1.9.1.tgz#1b5e85370a192c01ec6cec4735cf2917337a6278" + integrity sha512-d/Hs3nWDxNL2xAczmOVZNj92YZCS6RGxfBPjKzuu/XirCgXdpKEb88dYNbrYGint6IVWLNP+yonwVAuRC0T2Dg== dependencies: "@types/express" "*" "@types/serve-static@*", "@types/serve-static@^1.13.10": - version "1.15.5" - resolved "https://registry.yarnpkg.com/@types/serve-static/-/serve-static-1.15.5.tgz#15e67500ec40789a1e8c9defc2d32a896f05b033" - integrity sha512-PDRk21MnK70hja/YF8AHfC7yIsiQHn1rcXx7ijCFBX/k+XQJhQT/gw3xekXKJvx+5SXaMMS8oqQy09Mzvz2TuQ== + version "1.15.1" + resolved "https://registry.yarnpkg.com/@types/serve-static/-/serve-static-1.15.1.tgz#86b1753f0be4f9a1bee68d459fcda5be4ea52b5d" + integrity sha512-NUo5XNiAdULrJENtJXZZ3fHtfMolzZwczzBbnAeBbqBwG+LaG6YaJtuwzwGSQZ2wsCrxjEhNNjAkKigy3n8teQ== dependencies: - "@types/http-errors" "*" "@types/mime" "*" "@types/node" "*" "@types/sockjs@^0.3.33": - version "0.3.36" - resolved "https://registry.yarnpkg.com/@types/sockjs/-/sockjs-0.3.36.tgz#ce322cf07bcc119d4cbf7f88954f3a3bd0f67535" - integrity sha512-MK9V6NzAS1+Ud7JV9lJLFqW85VbC9dq3LmwZCuBe4wBDgKC0Kj/jd8Xl+nSviU+Qc3+m7umHHyHg//2KSa0a0Q== + version "0.3.33" + resolved "https://registry.yarnpkg.com/@types/sockjs/-/sockjs-0.3.33.tgz#570d3a0b99ac995360e3136fd6045113b1bd236f" + integrity sha512-f0KEEe05NvUnat+boPTZ0dgaLZ4SfSouXUgv5noUiefG2ajgKjmETo9ZJyuqsl7dfl2aHlLJUiki6B4ZYldiiw== dependencies: "@types/node" "*" -"@types/unist@^2", "@types/unist@^2.0.0", "@types/unist@^2.0.2", "@types/unist@^2.0.3": - version "2.0.10" - resolved "https://registry.yarnpkg.com/@types/unist/-/unist-2.0.10.tgz#04ffa7f406ab628f7f7e97ca23e290cd8ab15efc" - integrity sha512-IfYcSBWE3hLpBg8+X2SEa8LVkJdJEkT2Ese2aaLs3ptGdVtABxndrMaxuFlQ1qdFf9Q5rDvDpxI3WwgvKFAsQA== +"@types/unist@*", "@types/unist@^2.0.0", "@types/unist@^2.0.2", "@types/unist@^2.0.3": + version "2.0.6" + resolved "https://registry.yarnpkg.com/@types/unist/-/unist-2.0.6.tgz#250a7b16c3b91f672a24552ec64678eeb1d3a08d" + integrity sha512-PBjIUxZHOuj0R15/xuwJYjFi+KZdNFrehocChv4g5hu6aFroHue8m0lBP0POdK2nKzbw0cgV1mws8+V/JAcEkQ== -"@types/ws@^8.5.5": - version "8.5.10" - resolved "https://registry.yarnpkg.com/@types/ws/-/ws-8.5.10.tgz#4acfb517970853fa6574a3a6886791d04a396787" - integrity sha512-vmQSUcfalpIq0R9q7uTo2lXs6eGIpt9wtnLdMv9LVpIjCA/+ufZRozlVoVelIYixx1ugCBKDhn89vnsEGOCx9A== +"@types/ws@^8.5.1": + version "8.5.4" + resolved "https://registry.yarnpkg.com/@types/ws/-/ws-8.5.4.tgz#bb10e36116d6e570dd943735f86c933c1587b8a5" + integrity sha512-zdQDHKUgcX/zBc4GrwsE/7dVdAD8JR4EuiAXiiUhhfyIJXXb2+PrGshFyeXWQPMmmZ2XxgaqclgpIC7eTXc1mg== dependencies: "@types/node" "*" "@types/yargs-parser@*": - version "21.0.3" - resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-21.0.3.tgz#815e30b786d2e8f0dcd85fd5bcf5e1a04d008f15" - integrity sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ== + version "21.0.0" + resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-21.0.0.tgz#0c60e537fa790f5f9472ed2776c2b71ec117351b" + integrity sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA== "@types/yargs@^17.0.8": - version "17.0.32" - resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.32.tgz#030774723a2f7faafebf645f4e5a48371dca6229" - integrity sha512-xQ67Yc/laOG5uMfX/093MRlGGCIBzZMarVa+gfNKJxWAIgykYpVGkBdbqEzGDDfCrVUj6Hiff4mTZ5BA6TmAog== + version "17.0.22" + resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.22.tgz#7dd37697691b5f17d020f3c63e7a45971ff71e9a" + integrity sha512-pet5WJ9U8yPVRhkwuEIp5ktAeAqRZOq4UdAyWLWzxbtpyXnzbtLdKiXAjJzi/KLmPGS9wk86lUFWZFN6sISo4g== dependencies: "@types/yargs-parser" "*" -"@webassemblyjs/ast@1.11.6", "@webassemblyjs/ast@^1.11.5": - version "1.11.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.11.6.tgz#db046555d3c413f8966ca50a95176a0e2c642e24" - integrity sha512-IN1xI7PwOvLPgjcf180gC1bqn3q/QaOCwYUahIOhbYUu8KA/3tw2RT/T0Gidi1l7Hhj5D/INhJxiICObqpMu4Q== +"@webassemblyjs/ast@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.11.1.tgz#2bfd767eae1a6996f432ff7e8d7fc75679c0b6a7" + integrity sha512-ukBh14qFLjxTQNTXocdyksN5QdM28S1CxHt2rdskFyL+xFV7VremuBLVbmCePj+URalXBENx/9Lm7lnhihtCSw== dependencies: - "@webassemblyjs/helper-numbers" "1.11.6" - "@webassemblyjs/helper-wasm-bytecode" "1.11.6" + "@webassemblyjs/helper-numbers" "1.11.1" + "@webassemblyjs/helper-wasm-bytecode" "1.11.1" -"@webassemblyjs/floating-point-hex-parser@1.11.6": - version "1.11.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.6.tgz#dacbcb95aff135c8260f77fa3b4c5fea600a6431" - integrity sha512-ejAj9hfRJ2XMsNHk/v6Fu2dGS+i4UaXBXGemOfQ/JfQ6mdQg/WXtwleQRLLS4OvfDhv8rYnVwH27YJLMyYsxhw== +"@webassemblyjs/floating-point-hex-parser@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.1.tgz#f6c61a705f0fd7a6aecaa4e8198f23d9dc179e4f" + integrity sha512-iGRfyc5Bq+NnNuX8b5hwBrRjzf0ocrJPI6GWFodBFzmFnyvrQ83SHKhmilCU/8Jv67i4GJZBMhEzltxzcNagtQ== -"@webassemblyjs/helper-api-error@1.11.6": - version "1.11.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.6.tgz#6132f68c4acd59dcd141c44b18cbebbd9f2fa768" - integrity sha512-o0YkoP4pVu4rN8aTJgAyj9hC2Sv5UlkzCHhxqWj8butaLvnpdc2jOwh4ewE6CX0txSfLn/UYaV/pheS2Txg//Q== +"@webassemblyjs/helper-api-error@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.1.tgz#1a63192d8788e5c012800ba6a7a46c705288fd16" + integrity sha512-RlhS8CBCXfRUR/cwo2ho9bkheSXG0+NwooXcc3PAILALf2QLdFyj7KGsKRbVc95hZnhnERon4kW/D3SZpp6Tcg== -"@webassemblyjs/helper-buffer@1.11.6": - version "1.11.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-buffer/-/helper-buffer-1.11.6.tgz#b66d73c43e296fd5e88006f18524feb0f2c7c093" - integrity sha512-z3nFzdcp1mb8nEOFFk8DrYLpHvhKC3grJD2ardfKOzmbmJvEf/tPIqCY+sNcwZIY8ZD7IkB2l7/pqhUhqm7hLA== +"@webassemblyjs/helper-buffer@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-buffer/-/helper-buffer-1.11.1.tgz#832a900eb444884cde9a7cad467f81500f5e5ab5" + integrity sha512-gwikF65aDNeeXa8JxXa2BAk+REjSyhrNC9ZwdT0f8jc4dQQeDQ7G4m0f2QCLPJiMTTO6wfDmRmj/pW0PsUvIcA== -"@webassemblyjs/helper-numbers@1.11.6": - version "1.11.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.6.tgz#cbce5e7e0c1bd32cf4905ae444ef64cea919f1b5" - integrity sha512-vUIhZ8LZoIWHBohiEObxVm6hwP034jwmc9kuq5GdHZH0wiLVLIPcMCdpJzG4C11cHoQ25TFIQj9kaVADVX7N3g== +"@webassemblyjs/helper-numbers@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.1.tgz#64d81da219fbbba1e3bd1bfc74f6e8c4e10a62ae" + integrity sha512-vDkbxiB8zfnPdNK9Rajcey5C0w+QJugEglN0of+kmO8l7lDb77AnlKYQF7aarZuCrv+l0UvqL+68gSDr3k9LPQ== dependencies: - "@webassemblyjs/floating-point-hex-parser" "1.11.6" - "@webassemblyjs/helper-api-error" "1.11.6" + "@webassemblyjs/floating-point-hex-parser" "1.11.1" + "@webassemblyjs/helper-api-error" "1.11.1" "@xtuc/long" "4.2.2" -"@webassemblyjs/helper-wasm-bytecode@1.11.6": - version "1.11.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.6.tgz#bb2ebdb3b83aa26d9baad4c46d4315283acd51e9" - integrity sha512-sFFHKwcmBprO9e7Icf0+gddyWYDViL8bpPjJJl0WHxCdETktXdmtWLGVzoHbqUcY4Be1LkNfwTmXOJUFZYSJdA== +"@webassemblyjs/helper-wasm-bytecode@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.1.tgz#f328241e41e7b199d0b20c18e88429c4433295e1" + integrity sha512-PvpoOGiJwXeTrSf/qfudJhwlvDQxFgelbMqtq52WWiXC6Xgg1IREdngmPN3bs4RoO83PnL/nFrxucXj1+BX62Q== -"@webassemblyjs/helper-wasm-section@1.11.6": - version "1.11.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.11.6.tgz#ff97f3863c55ee7f580fd5c41a381e9def4aa577" - integrity sha512-LPpZbSOwTpEC2cgn4hTydySy1Ke+XEu+ETXuoyvuyezHO3Kjdu90KK95Sh9xTbmjrCsUwvWwCOQQNta37VrS9g== +"@webassemblyjs/helper-wasm-section@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.11.1.tgz#21ee065a7b635f319e738f0dd73bfbda281c097a" + integrity sha512-10P9No29rYX1j7F3EVPX3JvGPQPae+AomuSTPiF9eBQeChHI6iqjMIwR9JmOJXwpnn/oVGDk7I5IlskuMwU/pg== dependencies: - "@webassemblyjs/ast" "1.11.6" - "@webassemblyjs/helper-buffer" "1.11.6" - "@webassemblyjs/helper-wasm-bytecode" "1.11.6" - "@webassemblyjs/wasm-gen" "1.11.6" + "@webassemblyjs/ast" "1.11.1" + "@webassemblyjs/helper-buffer" "1.11.1" + "@webassemblyjs/helper-wasm-bytecode" "1.11.1" + "@webassemblyjs/wasm-gen" "1.11.1" -"@webassemblyjs/ieee754@1.11.6": - version "1.11.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/ieee754/-/ieee754-1.11.6.tgz#bb665c91d0b14fffceb0e38298c329af043c6e3a" - integrity sha512-LM4p2csPNvbij6U1f19v6WR56QZ8JcHg3QIJTlSwzFcmx6WSORicYj6I63f9yU1kEUtrpG+kjkiIAkevHpDXrg== +"@webassemblyjs/ieee754@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/ieee754/-/ieee754-1.11.1.tgz#963929e9bbd05709e7e12243a099180812992614" + integrity sha512-hJ87QIPtAMKbFq6CGTkZYJivEwZDbQUgYd3qKSadTNOhVY7p+gfP6Sr0lLRVTaG1JjFj+r3YchoqRYxNH3M0GQ== dependencies: "@xtuc/ieee754" "^1.2.0" -"@webassemblyjs/leb128@1.11.6": - version "1.11.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/leb128/-/leb128-1.11.6.tgz#70e60e5e82f9ac81118bc25381a0b283893240d7" - integrity sha512-m7a0FhE67DQXgouf1tbN5XQcdWoNgaAuoULHIfGFIEVKA6tu/edls6XnIlkmS6FrXAquJRPni3ZZKjw6FSPjPQ== +"@webassemblyjs/leb128@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/leb128/-/leb128-1.11.1.tgz#ce814b45574e93d76bae1fb2644ab9cdd9527aa5" + integrity sha512-BJ2P0hNZ0u+Th1YZXJpzW6miwqQUGcIHT1G/sf72gLVD9DZ5AdYTqPNbHZh6K1M5VmKvFXwGSWZADz+qBWxeRw== dependencies: "@xtuc/long" "4.2.2" -"@webassemblyjs/utf8@1.11.6": - version "1.11.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/utf8/-/utf8-1.11.6.tgz#90f8bc34c561595fe156603be7253cdbcd0fab5a" - integrity sha512-vtXf2wTQ3+up9Zsg8sa2yWiQpzSsMyXj0qViVP6xKGCUT8p8YJ6HqI7l5eCnWx1T/FYdsv07HQs2wTFbbof/RA== - -"@webassemblyjs/wasm-edit@^1.11.5": - version "1.11.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-edit/-/wasm-edit-1.11.6.tgz#c72fa8220524c9b416249f3d94c2958dfe70ceab" - integrity sha512-Ybn2I6fnfIGuCR+Faaz7YcvtBKxvoLV3Lebn1tM4o/IAJzmi9AWYIPWpyBfU8cC+JxAO57bk4+zdsTjJR+VTOw== - dependencies: - "@webassemblyjs/ast" "1.11.6" - "@webassemblyjs/helper-buffer" "1.11.6" - "@webassemblyjs/helper-wasm-bytecode" "1.11.6" - "@webassemblyjs/helper-wasm-section" "1.11.6" - "@webassemblyjs/wasm-gen" "1.11.6" - "@webassemblyjs/wasm-opt" "1.11.6" - "@webassemblyjs/wasm-parser" "1.11.6" - "@webassemblyjs/wast-printer" "1.11.6" - -"@webassemblyjs/wasm-gen@1.11.6": - version "1.11.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-gen/-/wasm-gen-1.11.6.tgz#fb5283e0e8b4551cc4e9c3c0d7184a65faf7c268" - integrity sha512-3XOqkZP/y6B4F0PBAXvI1/bky7GryoogUtfwExeP/v7Nzwo1QLcq5oQmpKlftZLbT+ERUOAZVQjuNVak6UXjPA== - dependencies: - "@webassemblyjs/ast" "1.11.6" - "@webassemblyjs/helper-wasm-bytecode" "1.11.6" - "@webassemblyjs/ieee754" "1.11.6" - "@webassemblyjs/leb128" "1.11.6" - "@webassemblyjs/utf8" "1.11.6" - -"@webassemblyjs/wasm-opt@1.11.6": - version "1.11.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-opt/-/wasm-opt-1.11.6.tgz#d9a22d651248422ca498b09aa3232a81041487c2" - integrity sha512-cOrKuLRE7PCe6AsOVl7WasYf3wbSo4CeOk6PkrjS7g57MFfVUF9u6ysQBBODX0LdgSvQqRiGz3CXvIDKcPNy4g== - dependencies: - "@webassemblyjs/ast" "1.11.6" - "@webassemblyjs/helper-buffer" "1.11.6" - "@webassemblyjs/wasm-gen" "1.11.6" - "@webassemblyjs/wasm-parser" "1.11.6" - -"@webassemblyjs/wasm-parser@1.11.6", "@webassemblyjs/wasm-parser@^1.11.5": - version "1.11.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-parser/-/wasm-parser-1.11.6.tgz#bb85378c527df824004812bbdb784eea539174a1" - integrity sha512-6ZwPeGzMJM3Dqp3hCsLgESxBGtT/OeCvCZ4TA1JUPYgmhAx38tTPR9JaKy0S5H3evQpO/h2uWs2j6Yc/fjkpTQ== - dependencies: - "@webassemblyjs/ast" "1.11.6" - "@webassemblyjs/helper-api-error" "1.11.6" - "@webassemblyjs/helper-wasm-bytecode" "1.11.6" - "@webassemblyjs/ieee754" "1.11.6" - "@webassemblyjs/leb128" "1.11.6" - "@webassemblyjs/utf8" "1.11.6" - -"@webassemblyjs/wast-printer@1.11.6": - version "1.11.6" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-printer/-/wast-printer-1.11.6.tgz#a7bf8dd7e362aeb1668ff43f35cb849f188eff20" - integrity sha512-JM7AhRcE+yW2GWYaKeHL5vt4xqee5N2WcezptmgyhNS+ScggqcT1OtXykhAb13Sn5Yas0j2uv9tHgrjwvzAP4A== - dependencies: - "@webassemblyjs/ast" "1.11.6" +"@webassemblyjs/utf8@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/utf8/-/utf8-1.11.1.tgz#d1f8b764369e7c6e6bae350e854dec9a59f0a3ff" + integrity sha512-9kqcxAEdMhiwQkHpkNiorZzqpGrodQQ2IGrHHxCy+Ozng0ofyMA0lTqiLkVs1uzTRejX+/O0EOT7KxqVPuXosQ== + +"@webassemblyjs/wasm-edit@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-edit/-/wasm-edit-1.11.1.tgz#ad206ebf4bf95a058ce9880a8c092c5dec8193d6" + integrity sha512-g+RsupUC1aTHfR8CDgnsVRVZFJqdkFHpsHMfJuWQzWU3tvnLC07UqHICfP+4XyL2tnr1amvl1Sdp06TnYCmVkA== + dependencies: + "@webassemblyjs/ast" "1.11.1" + "@webassemblyjs/helper-buffer" "1.11.1" + "@webassemblyjs/helper-wasm-bytecode" "1.11.1" + "@webassemblyjs/helper-wasm-section" "1.11.1" + "@webassemblyjs/wasm-gen" "1.11.1" + "@webassemblyjs/wasm-opt" "1.11.1" + "@webassemblyjs/wasm-parser" "1.11.1" + "@webassemblyjs/wast-printer" "1.11.1" + +"@webassemblyjs/wasm-gen@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-gen/-/wasm-gen-1.11.1.tgz#86c5ea304849759b7d88c47a32f4f039ae3c8f76" + integrity sha512-F7QqKXwwNlMmsulj6+O7r4mmtAlCWfO/0HdgOxSklZfQcDu0TpLiD1mRt/zF25Bk59FIjEuGAIyn5ei4yMfLhA== + dependencies: + "@webassemblyjs/ast" "1.11.1" + "@webassemblyjs/helper-wasm-bytecode" "1.11.1" + "@webassemblyjs/ieee754" "1.11.1" + "@webassemblyjs/leb128" "1.11.1" + "@webassemblyjs/utf8" "1.11.1" + +"@webassemblyjs/wasm-opt@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-opt/-/wasm-opt-1.11.1.tgz#657b4c2202f4cf3b345f8a4c6461c8c2418985f2" + integrity sha512-VqnkNqnZlU5EB64pp1l7hdm3hmQw7Vgqa0KF/KCNO9sIpI6Fk6brDEiX+iCOYrvMuBWDws0NkTOxYEb85XQHHw== + dependencies: + "@webassemblyjs/ast" "1.11.1" + "@webassemblyjs/helper-buffer" "1.11.1" + "@webassemblyjs/wasm-gen" "1.11.1" + "@webassemblyjs/wasm-parser" "1.11.1" + +"@webassemblyjs/wasm-parser@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-parser/-/wasm-parser-1.11.1.tgz#86ca734534f417e9bd3c67c7a1c75d8be41fb199" + integrity sha512-rrBujw+dJu32gYB7/Lup6UhdkPx9S9SnobZzRVL7VcBH9Bt9bCBLEuX/YXOOtBsOZ4NQrRykKhffRWHvigQvOA== + dependencies: + "@webassemblyjs/ast" "1.11.1" + "@webassemblyjs/helper-api-error" "1.11.1" + "@webassemblyjs/helper-wasm-bytecode" "1.11.1" + "@webassemblyjs/ieee754" "1.11.1" + "@webassemblyjs/leb128" "1.11.1" + "@webassemblyjs/utf8" "1.11.1" + +"@webassemblyjs/wast-printer@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-printer/-/wast-printer-1.11.1.tgz#d0c73beda8eec5426f10ae8ef55cee5e7084c2f0" + integrity sha512-IQboUWM4eKzWW+N/jij2sRatKMh99QEelo3Eb2q0qXkvPRISAj8Qxtmw5itwqK+TTkBuUIE45AxYPToqPtL5gg== + dependencies: + "@webassemblyjs/ast" "1.11.1" "@xtuc/long" "4.2.2" "@xtuc/ieee754@^1.2.0": @@ -2471,20 +2415,20 @@ accepts@~1.3.4, accepts@~1.3.5, accepts@~1.3.8: mime-types "~2.1.34" negotiator "0.6.3" -acorn-import-assertions@^1.9.0: - version "1.9.0" - resolved "https://registry.yarnpkg.com/acorn-import-assertions/-/acorn-import-assertions-1.9.0.tgz#507276249d684797c84e0734ef84860334cfb1ac" - integrity sha512-cmMwop9x+8KFhxvKrKfPYmN6/pKTYYHBqLa0DfvVZcKMJWNyWLnaqND7dx/qn66R7ewM1UX5XMaDVP5wlVTaVA== +acorn-import-assertions@^1.7.6: + version "1.8.0" + resolved "https://registry.yarnpkg.com/acorn-import-assertions/-/acorn-import-assertions-1.8.0.tgz#ba2b5939ce62c238db6d93d81c9b111b29b855e9" + integrity sha512-m7VZ3jwz4eK6A4Vtt8Ew1/mNbP24u0FhdyfA7fSvnJR6LMdfOYnmuIrrJAgrYfYJ10F/otaHTtrtrtmHdMNzEw== acorn-walk@^8.0.0: - version "8.3.2" - resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.3.2.tgz#7703af9415f1b6db9315d6895503862e231d34aa" - integrity sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A== + version "8.2.0" + resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1" + integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA== -acorn@^8.0.4, acorn@^8.7.1, acorn@^8.8.2: - version "8.11.3" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.11.3.tgz#71e0b14e13a4ec160724b38fb7b0f233b1b81d7a" - integrity sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg== +acorn@^8.0.4, acorn@^8.5.0, acorn@^8.7.1: + version "8.8.2" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.2.tgz#1b2f25db02af965399b9776b0c2c391276d37c4a" + integrity sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw== address@^1.0.1, address@^1.1.2: version "1.2.2" @@ -2511,7 +2455,7 @@ ajv-keywords@^3.4.1, ajv-keywords@^3.5.2: resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d" integrity sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ== -ajv-keywords@^5.1.0: +ajv-keywords@^5.0.0: version "5.1.0" resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-5.1.0.tgz#69d4d385a4733cdbeab44964a1170a88f87f0e16" integrity sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw== @@ -2528,7 +2472,7 @@ ajv@^6.12.2, ajv@^6.12.4, ajv@^6.12.5: json-schema-traverse "^0.4.1" uri-js "^4.2.2" -ajv@^8.0.0, ajv@^8.9.0: +ajv@^8.0.0, ajv@^8.8.0: version "8.12.0" resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.12.0.tgz#d1a0527323e22f53562c567c00991577dfbe19d1" integrity sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA== @@ -2539,31 +2483,31 @@ ajv@^8.0.0, ajv@^8.9.0: uri-js "^4.2.2" algoliasearch-helper@^3.10.0: - version "3.16.1" - resolved "https://registry.yarnpkg.com/algoliasearch-helper/-/algoliasearch-helper-3.16.1.tgz#421e3554ec86e14e60e7e0bf796aef61cf4a06ec" - integrity sha512-qxAHVjjmT7USVvrM8q6gZGaJlCK1fl4APfdAA7o8O6iXEc68G0xMNrzRkxoB/HmhhvyHnoteS/iMTiHiTcQQcg== + version "3.11.2" + resolved "https://registry.yarnpkg.com/algoliasearch-helper/-/algoliasearch-helper-3.11.2.tgz#f42db10433e6264f1d1ba503699cbdbff7b48dff" + integrity sha512-eKvSM5hz5w9RcUowu8LnQ5v0KRrFLCvF4K3KF/Ab3VwCT726rWgZUWUIQUPjr9qDENUMukQ/IHZ7bGUVYRGP0g== dependencies: "@algolia/events" "^4.0.1" -algoliasearch@^4.13.1, algoliasearch@^4.19.1: - version "4.22.1" - resolved "https://registry.yarnpkg.com/algoliasearch/-/algoliasearch-4.22.1.tgz#f10fbecdc7654639ec20d62f109c1b3a46bc6afc" - integrity sha512-jwydKFQJKIx9kIZ8Jm44SdpigFwRGPESaxZBaHSV0XWN2yBJAOT4mT7ppvlrpA4UGzz92pqFnVKr/kaZXrcreg== - dependencies: - "@algolia/cache-browser-local-storage" "4.22.1" - "@algolia/cache-common" "4.22.1" - "@algolia/cache-in-memory" "4.22.1" - "@algolia/client-account" "4.22.1" - "@algolia/client-analytics" "4.22.1" - "@algolia/client-common" "4.22.1" - "@algolia/client-personalization" "4.22.1" - "@algolia/client-search" "4.22.1" - "@algolia/logger-common" "4.22.1" - "@algolia/logger-console" "4.22.1" - "@algolia/requester-browser-xhr" "4.22.1" - "@algolia/requester-common" "4.22.1" - "@algolia/requester-node-http" "4.22.1" - "@algolia/transporter" "4.22.1" +algoliasearch@^4.0.0, algoliasearch@^4.13.1: + version "4.14.3" + resolved "https://registry.yarnpkg.com/algoliasearch/-/algoliasearch-4.14.3.tgz#f02a77a4db17de2f676018938847494b692035e7" + integrity sha512-GZTEuxzfWbP/vr7ZJfGzIl8fOsoxN916Z6FY2Egc9q2TmZ6hvq5KfAxY89pPW01oW/2HDEKA8d30f9iAH9eXYg== + dependencies: + "@algolia/cache-browser-local-storage" "4.14.3" + "@algolia/cache-common" "4.14.3" + "@algolia/cache-in-memory" "4.14.3" + "@algolia/client-account" "4.14.3" + "@algolia/client-analytics" "4.14.3" + "@algolia/client-common" "4.14.3" + "@algolia/client-personalization" "4.14.3" + "@algolia/client-search" "4.14.3" + "@algolia/logger-common" "4.14.3" + "@algolia/logger-console" "4.14.3" + "@algolia/requester-browser-xhr" "4.14.3" + "@algolia/requester-common" "4.14.3" + "@algolia/requester-node-http" "4.14.3" + "@algolia/transporter" "4.14.3" ansi-align@^3.0.0, ansi-align@^3.0.1: version "3.0.1" @@ -2641,6 +2585,11 @@ array-flatten@1.1.1: resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" integrity sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg== +array-flatten@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-2.1.2.tgz#24ef80a28c1a893617e2149b0c6d0d788293b099" + integrity sha512-hNfzcOV8W4NdualtqBFPyVO+54DSJuZGY9qT4pRroB6S9e3iiido2ISIC5h9R2sPJ8H3FHCIiEnsv1lPXO3KtQ== + array-union@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d" @@ -2662,13 +2611,13 @@ at-least-node@^1.0.0: integrity sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg== autoprefixer@^10.4.12, autoprefixer@^10.4.7: - version "10.4.17" - resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-10.4.17.tgz#35cd5695cbbe82f536a50fa025d561b01fdec8be" - integrity sha512-/cpVNRLSfhOtcGflT13P2794gVSgmPgTR+erw5ifnMLZb0UnSlkK4tquLmkd3BhA+nLo5tX8Cu0upUsGKvKbmg== + version "10.4.13" + resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-10.4.13.tgz#b5136b59930209a321e9fa3dca2e7c4d223e83a8" + integrity sha512-49vKpMqcZYsJjwotvt4+h/BCjJVnhGwcLpDt5xkcaOG3eLrG/HUYLagrihYsQ+qrIBgIzX1Rw7a6L8I/ZA1Atg== dependencies: - browserslist "^4.22.2" - caniuse-lite "^1.0.30001578" - fraction.js "^4.3.7" + browserslist "^4.21.4" + caniuse-lite "^1.0.30001426" + fraction.js "^4.2.0" normalize-range "^0.1.2" picocolors "^1.0.0" postcss-value-parser "^4.2.0" @@ -2681,11 +2630,11 @@ axios@^0.25.0: follow-redirects "^1.14.7" axios@^1.4.0: - version "1.6.5" - resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.5.tgz#2c090da14aeeab3770ad30c3a1461bc970fb0cd8" - integrity sha512-Ii012v05KEVuUoFWmMW/UQv9aRIc3ZwkWDcM+h5Il8izZCtRVpDUfwpoFf7eOtajT3QiGR4yDUx7lPqHJULgbg== + version "1.4.0" + resolved "https://registry.yarnpkg.com/axios/-/axios-1.4.0.tgz#38a7bf1224cd308de271146038b551d725f0be1f" + integrity sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA== dependencies: - follow-redirects "^1.15.4" + follow-redirects "^1.15.0" form-data "^4.0.0" proxy-from-env "^1.1.0" @@ -2721,29 +2670,29 @@ babel-plugin-extract-import-names@1.6.22: dependencies: "@babel/helper-plugin-utils" "7.10.4" -babel-plugin-polyfill-corejs2@^0.4.7: - version "0.4.8" - resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.4.8.tgz#dbcc3c8ca758a290d47c3c6a490d59429b0d2269" - integrity sha512-OtIuQfafSzpo/LhnJaykc0R/MMnuLSSVjVYy9mHArIZ9qTCSZ6TpWCuEKZYVoN//t8HqBNScHrOtCrIK5IaGLg== +babel-plugin-polyfill-corejs2@^0.3.3: + version "0.3.3" + resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.3.3.tgz#5d1bd3836d0a19e1b84bbf2d9640ccb6f951c122" + integrity sha512-8hOdmFYFSZhqg2C/JgLUQ+t52o5nirNwaWM2B9LWteozwIvM14VSwdsCAUET10qT+kmySAlseadmfeeSWFCy+Q== dependencies: - "@babel/compat-data" "^7.22.6" - "@babel/helper-define-polyfill-provider" "^0.5.0" - semver "^6.3.1" + "@babel/compat-data" "^7.17.7" + "@babel/helper-define-polyfill-provider" "^0.3.3" + semver "^6.1.1" -babel-plugin-polyfill-corejs3@^0.8.7: - version "0.8.7" - resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.8.7.tgz#941855aa7fdaac06ed24c730a93450d2b2b76d04" - integrity sha512-KyDvZYxAzkC0Aj2dAPyDzi2Ym15e5JKZSK+maI7NAwSqofvuFglbSsxE7wUOvTg9oFVnHMzVzBKcqEb4PJgtOA== +babel-plugin-polyfill-corejs3@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.6.0.tgz#56ad88237137eade485a71b52f72dbed57c6230a" + integrity sha512-+eHqR6OPcBhJOGgsIar7xoAB1GcSwVUA3XjAd7HJNzOXT4wv6/H7KIdA/Nc60cvUlDbKApmqNvD1B1bzOt4nyA== dependencies: - "@babel/helper-define-polyfill-provider" "^0.4.4" - core-js-compat "^3.33.1" + "@babel/helper-define-polyfill-provider" "^0.3.3" + core-js-compat "^3.25.1" -babel-plugin-polyfill-regenerator@^0.5.4: - version "0.5.5" - resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.5.5.tgz#8b0c8fc6434239e5d7b8a9d1f832bb2b0310f06a" - integrity sha512-OJGYZlhLqBh2DDHeqAxWB1XIvr49CxiJ2gIt61/PU55CQK4Z58OzMqjDe1zwQdQk+rBYsRc+1rJmdajM3gimHg== +babel-plugin-polyfill-regenerator@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.4.1.tgz#390f91c38d90473592ed43351e801a9d3e0fd747" + integrity sha512-NtQGmyQDXjQqQ+IzRkBVwEOz9lQ4zxAQZgoAYEtU9dJjnl1Oc98qnN7jcp+bE7O7aYzVpavXE3/VKXNzUbh7aw== dependencies: - "@babel/helper-define-polyfill-provider" "^0.5.0" + "@babel/helper-define-polyfill-provider" "^0.3.3" bail@^1.0.0: version "1.0.5" @@ -2808,10 +2757,12 @@ body-parser@1.20.1: unpipe "1.0.0" bonjour-service@^1.0.11: - version "1.2.1" - resolved "https://registry.yarnpkg.com/bonjour-service/-/bonjour-service-1.2.1.tgz#eb41b3085183df3321da1264719fbada12478d02" - integrity sha512-oSzCS2zV14bh2kji6vNe7vrpJYCHGvcZnlffFQ1MEoX/WOeQ/teD8SYWKR942OI3INjq8OMNJlbPK5LLLUxFDw== + version "1.1.0" + resolved "https://registry.yarnpkg.com/bonjour-service/-/bonjour-service-1.1.0.tgz#424170268d68af26ff83a5c640b95def01803a13" + integrity sha512-LVRinRB3k1/K0XzZ2p58COnWvkQknIY6sf0zF2rpErvcJXpMBttEPQSxK+HEXSS9VmpZlDoDnQWv8ftJT20B0Q== dependencies: + array-flatten "^2.1.2" + dns-equal "^1.0.0" fast-deep-equal "^3.1.3" multicast-dns "^7.2.5" @@ -2870,15 +2821,15 @@ braces@^3.0.2, braces@~3.0.2: dependencies: fill-range "^7.0.1" -browserslist@^4.0.0, browserslist@^4.14.5, browserslist@^4.18.1, browserslist@^4.21.4, browserslist@^4.22.2: - version "4.22.2" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.22.2.tgz#704c4943072bd81ea18997f3bd2180e89c77874b" - integrity sha512-0UgcrvQmBDvZHFGdYUehrCNIazki7/lUP3kkoi/r3YB2amZbFM9J43ZRkJTXBUZK4gmx56+Sqk9+Vs9mwZx9+A== +browserslist@^4.0.0, browserslist@^4.14.5, browserslist@^4.18.1, browserslist@^4.21.3, browserslist@^4.21.4, browserslist@^4.21.5: + version "4.21.5" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.21.5.tgz#75c5dae60063ee641f977e00edd3cfb2fb7af6a7" + integrity sha512-tUkiguQGW7S3IhB7N+c2MV/HZPSCPAAiYBZXLsBhFB/PCy6ZKKsZrmBayHV9fdGV/ARIfJ14NkxKzRDjvp7L6w== dependencies: - caniuse-lite "^1.0.30001565" - electron-to-chromium "^1.4.601" - node-releases "^2.0.14" - update-browserslist-db "^1.0.13" + caniuse-lite "^1.0.30001449" + electron-to-chromium "^1.4.284" + node-releases "^2.0.8" + update-browserslist-db "^1.0.10" buffer-from@^1.0.0: version "1.1.2" @@ -2916,14 +2867,13 @@ cacheable-request@^6.0.0: normalize-url "^4.1.0" responselike "^1.0.2" -call-bind@^1.0.0, call-bind@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.5.tgz#6fa2b7845ce0ea49bf4d8b9ef64727a2c2e2e513" - integrity sha512-C3nQxfFZxFRVoJoGKKI8y3MOEo129NQ+FgQ08iye+Mk4zNZZGdjfs06bVTr+DBSlA66Q2VEcMki/cUCP4SercQ== +call-bind@^1.0.0, call-bind@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.2.tgz#b1d4e89e688119c3c9a903ad30abb2f6a919be3c" + integrity sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA== dependencies: - function-bind "^1.1.2" - get-intrinsic "^1.2.1" - set-function-length "^1.1.1" + function-bind "^1.1.1" + get-intrinsic "^1.0.2" callsites@^3.0.0: version "3.1.0" @@ -2958,17 +2908,17 @@ caniuse-api@^3.0.0: lodash.memoize "^4.1.2" lodash.uniq "^4.5.0" -caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001565, caniuse-lite@^1.0.30001578: - version "1.0.30001579" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001579.tgz#45c065216110f46d6274311a4b3fcf6278e0852a" - integrity sha512-u5AUVkixruKHJjw/pj9wISlcMpgFWzSrczLZbrqBSxukQixmg0SJ5sZTpvaFvxU0HoQKd4yoyAogyrAz9pzJnA== +caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001426, caniuse-lite@^1.0.30001449: + version "1.0.30001525" + resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001525.tgz" + integrity sha512-/3z+wB4icFt3r0USMwxujAqRvaD/B7rvGTsKhbhSQErVrJvkZCLhgNLJxU8MevahQVH6hCU9FsHdNUFbiwmE7Q== ccount@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/ccount/-/ccount-1.1.0.tgz#246687debb6014735131be8abab2d93898f8d043" integrity sha512-vlNK021QdI7PNeiUh/lKkC/mNHHfV0m/Ad5JoI0TYtlBnJAslM/JIkm/tGC88bkLIwO6OQ5uV6ztS6kVAtCDlg== -chalk@^2.4.2: +chalk@^2.0.0: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== @@ -3056,14 +3006,14 @@ ci-info@^2.0.0: integrity sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ== ci-info@^3.2.0: - version "3.9.0" - resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.9.0.tgz#4279a62028a7b1f262f3473fc9605f5e218c59b4" - integrity sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ== + version "3.8.0" + resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.8.0.tgz#81408265a5380c929f0bc665d62256628ce9ef91" + integrity sha512-eXTggHWSooYhq49F2opQhuHWgzucfF2YgODK4e1566GQs5BIfP30B0oenwBJHfWxAs2fyPB1s7Mg949zLf61Yw== clean-css@^5.2.2, clean-css@^5.3.0: - version "5.3.3" - resolved "https://registry.yarnpkg.com/clean-css/-/clean-css-5.3.3.tgz#b330653cd3bd6b75009cc25c714cae7b93351ccd" - integrity sha512-D5J+kHaVb/wKSFcyyV75uCn8fiY4sV38XJoe4CUyGQ+mOU/fMVYUdH1hJC+CJQ5uY3EnW27SbJYS4X8BiLrAFg== + version "5.3.2" + resolved "https://registry.yarnpkg.com/clean-css/-/clean-css-5.3.2.tgz#70ecc7d4d4114921f5d298349ff86a31a9975224" + integrity sha512-JVJbM+f3d3Q704rF4bqQ5UUyTtuJ0JRKNbTKVEeujCCBoMdkEi+V+e8oktO9qGQNSvHrFTM6JZRXrUvGR1czww== dependencies: source-map "~0.6.0" @@ -3172,14 +3122,14 @@ colord@^2.9.1: integrity sha512-jeC1axXpnb0/2nn/Y1LPuLdgXBLH7aDcHu4KEKfqw3CUhX7ZpfBSlPKyqXE6btIgEzfWtrX3/tyBCaCvXvMkOw== colorette@^2.0.10: - version "2.0.20" - resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.20.tgz#9eb793e6833067f7235902fcd3b09917a000a95a" - integrity sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w== + version "2.0.19" + resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.19.tgz#cdf044f47ad41a0f4b56b3a0d5b4e6e1a2d5a798" + integrity sha512-3tlv/dIP7FWvj3BsbHrGLJ6l/oKh1O3TcgBqMn+yyCagOxc23fyzDS6HypQbgxWbkpDnf52p1LuR4eWDQ/K9WQ== combine-promises@^1.1.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/combine-promises/-/combine-promises-1.2.0.tgz#5f2e68451862acf85761ded4d9e2af7769c2ca6a" - integrity sha512-VcQB1ziGD0NXrhKxiwyNbCDmRzs/OShMs2GqW2DlU2A/Sd0nQxE1oWDAE5O0ygSx5mgQOn9eIFh7yKPgFRVkPQ== + version "1.1.0" + resolved "https://registry.yarnpkg.com/combine-promises/-/combine-promises-1.1.0.tgz#72db90743c0ca7aab7d0d8d2052fd7b0f674de71" + integrity sha512-ZI9jvcLDxqwaXEixOhArm3r7ReIivsXkpbyEWyeOhzz1QS0iSgBPnWvEqvIQtYyamGCYA88gFhmUrs9hrrQ0pg== combined-stream@^1.0.8: version "1.0.8" @@ -3244,9 +3194,9 @@ concat-map@0.0.1: integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== concurrently@^8.0.1: - version "8.2.2" - resolved "https://registry.yarnpkg.com/concurrently/-/concurrently-8.2.2.tgz#353141985c198cfa5e4a3ef90082c336b5851784" - integrity sha512-1dP4gpXFhei8IOtlXRE/T/4H88ElHgTiUzh71YUmtjTEHMSRS2Z/fgOxHSxxusGHogsRfxNq1vyAwxSC+EVyDg== + version "8.2.0" + resolved "https://registry.yarnpkg.com/concurrently/-/concurrently-8.2.0.tgz#cdc9f621a4d913366600355d68254df2c5e782f3" + integrity sha512-nnLMxO2LU492mTUj9qX/az/lESonSZu81UznYDoXtz1IQf996ixVqPAgHXwvHiHCAef/7S8HIK+fTFK7Ifk8YA== dependencies: chalk "^4.1.2" date-fns "^2.30.0" @@ -3307,11 +3257,6 @@ convert-source-map@^1.7.0: resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.9.0.tgz#7faae62353fb4213366d0ca98358d22e8368b05f" integrity sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A== -convert-source-map@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-2.0.0.tgz#4b560f649fc4e918dd0ab75cf4961e8bc882d82a" - integrity sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg== - cookie-signature@1.0.6: version "1.0.6" resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.6.tgz#e303a882b342cc3ee8ca513a79999734dab3ae2c" @@ -3323,9 +3268,9 @@ cookie@0.5.0: integrity sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw== copy-text-to-clipboard@^3.0.1: - version "3.2.0" - resolved "https://registry.yarnpkg.com/copy-text-to-clipboard/-/copy-text-to-clipboard-3.2.0.tgz#0202b2d9bdae30a49a53f898626dcc3b49ad960b" - integrity sha512-RnJFp1XR/LOBDckxTib5Qjr/PMfkatD0MUCQgdpqS8MdKiNUzBjAQBEN6oUy+jW7LI93BBG3DtMB2KOOKpGs2Q== + version "3.0.1" + resolved "https://registry.yarnpkg.com/copy-text-to-clipboard/-/copy-text-to-clipboard-3.0.1.tgz#8cbf8f90e0a47f12e4a24743736265d157bce69c" + integrity sha512-rvVsHrpFcL4F2P8ihsoLdFHmd404+CMg71S756oRSeQgqk51U3kicGdnvfkrxva0xXH92SjGS62B0XIJsbh+9Q== copy-webpack-plugin@^11.0.0: version "11.0.0" @@ -3339,22 +3284,22 @@ copy-webpack-plugin@^11.0.0: schema-utils "^4.0.0" serialize-javascript "^6.0.0" -core-js-compat@^3.31.0, core-js-compat@^3.33.1: - version "3.35.0" - resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.35.0.tgz#c149a3d1ab51e743bc1da61e39cb51f461a41873" - integrity sha512-5blwFAddknKeNgsjBzilkdQ0+YK8L1PfqPYq40NOYMYFSS38qj+hpTcLLWwpIwA2A5bje/x5jmVn2tzUMg9IVw== +core-js-compat@^3.25.1: + version "3.29.0" + resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.29.0.tgz#1b8d9eb4191ab112022e7f6364b99b65ea52f528" + integrity sha512-ScMn3uZNAFhK2DGoEfErguoiAHhV2Ju+oJo/jK08p7B3f3UhocUrCCkTvnZaiS+edl5nlIoiBXKcwMc6elv4KQ== dependencies: - browserslist "^4.22.2" + browserslist "^4.21.5" -core-js-pure@^3.30.2: - version "3.35.0" - resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.35.0.tgz#4660033304a050215ae82e476bd2513a419fbb34" - integrity sha512-f+eRYmkou59uh7BPcyJ8MC76DiGhspj1KMxVIcF24tzP8NA9HVa1uC7BTW2tgx7E1QVCzDzsgp7kArrzhlz8Ew== +core-js-pure@^3.25.1: + version "3.29.0" + resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.29.0.tgz#0e1ac889214398641ea4bb1c6cf25ff0959ec1d2" + integrity sha512-v94gUjN5UTe1n0yN/opTihJ8QBWD2O8i19RfTZR7foONPWArnjB96QA/wk5ozu1mm6ja3udQCzOzwQXTxi3xOQ== core-js@^3.23.3: - version "3.35.0" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.35.0.tgz#58e651688484f83c34196ca13f099574ee53d6b4" - integrity sha512-ntakECeqg81KqMueeGJ79Q5ZgQNR+6eaE8sxGCx62zMbAIj65q+uYvatToew3m6eAGdU4gNZwpZ34NMe4GYswg== + version "3.29.0" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.29.0.tgz#0273e142b67761058bcde5615c503c7406b572d6" + integrity sha512-VG23vuEisJNkGl6XQmFJd3rEG/so/CNatqeE+7uZAwTSwFeB/qaO0be8xZYUNWprJ/GIwL8aMt9cj1kvbpTZhg== core-util-is@~1.0.0: version "1.0.3" @@ -3386,7 +3331,7 @@ cosmiconfig@^6.0.0: path-type "^4.0.0" yaml "^1.7.2" -cosmiconfig@^7.0.1: +cosmiconfig@^7.0.0, cosmiconfig@^7.0.1: version "7.1.0" resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-7.1.0.tgz#1443b9afa596b670082ea46cbd8f6a62b84635f6" integrity sha512-AdmX6xUzdNASswsFtmwSt7Vj8po9IuqXm0UXz7QKPuEUmPB4XyjGfaAr2PSuELMwkRMVH1EpIkX5bTZGRB3eCA== @@ -3397,22 +3342,12 @@ cosmiconfig@^7.0.1: path-type "^4.0.0" yaml "^1.10.0" -cosmiconfig@^8.3.5: - version "8.3.6" - resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-8.3.6.tgz#060a2b871d66dba6c8538ea1118ba1ac16f5fae3" - integrity sha512-kcZ6+W5QzcJ3P1Mt+83OUv/oHFqZHIx8DuxG6eZ5RGMERoLqp4BuGjhHLYGK+Kf5XVkQvqBSmAy/nGWN3qDgEA== - dependencies: - import-fresh "^3.3.0" - js-yaml "^4.1.0" - parse-json "^5.2.0" - path-type "^4.0.0" - cross-fetch@^3.1.5: - version "3.1.8" - resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.8.tgz#0327eba65fd68a7d119f8fb2bf9334a1a7956f82" - integrity sha512-cvA+JwZoU0Xq+h6WkMvAUqPEYy92Obet6UdKLfW60qn99ftItKjB5T+BkyWOFWe2pUyfQ+IJHmpOTznqk1M6Kg== + version "3.1.5" + resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.5.tgz#e1389f44d9e7ba767907f7af8454787952ab534f" + integrity sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw== dependencies: - node-fetch "^2.6.12" + node-fetch "2.6.7" cross-spawn@^7.0.3: version "7.0.3" @@ -3429,23 +3364,23 @@ crypto-random-string@^2.0.0: integrity sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA== css-declaration-sorter@^6.3.1: - version "6.4.1" - resolved "https://registry.yarnpkg.com/css-declaration-sorter/-/css-declaration-sorter-6.4.1.tgz#28beac7c20bad7f1775be3a7129d7eae409a3a71" - integrity sha512-rtdthzxKuyq6IzqX6jEcIzQF/YqccluefyCYheovBOLhFT/drQA9zj/UbRAa9J7C0o6EG6u3E6g+vKkay7/k3g== + version "6.3.1" + resolved "https://registry.yarnpkg.com/css-declaration-sorter/-/css-declaration-sorter-6.3.1.tgz#be5e1d71b7a992433fb1c542c7a1b835e45682ec" + integrity sha512-fBffmak0bPAnyqc/HO8C3n2sHrp9wcqQz6ES9koRF2/mLOVAx9zIQ3Y7R29sYCteTPqMCwns4WYQoCX91Xl3+w== css-loader@^6.7.1: - version "6.9.1" - resolved "https://registry.yarnpkg.com/css-loader/-/css-loader-6.9.1.tgz#9ec9a434368f2bdfeffbf8f6901a1ce773586c6b" - integrity sha512-OzABOh0+26JKFdMzlK6PY1u5Zx8+Ck7CVRlcGNZoY9qwJjdfu2VWFuprTIpPW+Av5TZTVViYWcFQaEEQURLknQ== + version "6.7.3" + resolved "https://registry.yarnpkg.com/css-loader/-/css-loader-6.7.3.tgz#1e8799f3ccc5874fdd55461af51137fcc5befbcd" + integrity sha512-qhOH1KlBMnZP8FzRO6YCH9UHXQhVMcEGLyNdb7Hv2cpcmJbW0YrddO+tG1ab5nT41KpHIYGsbeHqxB9xPu1pKQ== dependencies: icss-utils "^5.1.0" - postcss "^8.4.33" + postcss "^8.4.19" postcss-modules-extract-imports "^3.0.0" - postcss-modules-local-by-default "^4.0.4" - postcss-modules-scope "^3.1.1" + postcss-modules-local-by-default "^4.0.0" + postcss-modules-scope "^3.0.0" postcss-modules-values "^4.0.0" postcss-value-parser "^4.2.0" - semver "^7.5.4" + semver "^7.3.8" css-minimizer-webpack-plugin@^4.0.0: version "4.2.2" @@ -3568,9 +3503,9 @@ csso@^4.2.0: css-tree "^1.1.2" csstype@^3.0.2: - version "3.1.3" - resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.3.tgz#d80ff294d114fb0e6ac500fbf85b60137d7eff81" - integrity sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw== + version "3.1.1" + resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.1.tgz#841b532c45c758ee546a11d5bd7b7b473c8c30b9" + integrity sha512-DJR/VvkAvSZW9bTouZue2sSxDwdTN92uHjqeKVm+0dAqdfNykRzQ95tay8aXMBAAPpUiq4Qcug2L7neoRh2Egw== cytoscape-cose-bilkent@^4.1.0: version "4.1.0" @@ -3587,17 +3522,17 @@ cytoscape-fcose@^2.1.0: cose-base "^2.2.0" cytoscape@^3.23.0: - version "3.28.1" - resolved "https://registry.yarnpkg.com/cytoscape/-/cytoscape-3.28.1.tgz#f32c3e009bdf32d47845a16a4cd2be2bbc01baf7" - integrity sha512-xyItz4O/4zp9/239wCcH8ZcFuuZooEeF8KHRmzjDfGdXsj3OG9MFSMA0pJE0uX3uCN/ygof6hHf4L7lst+JaDg== + version "3.23.0" + resolved "https://registry.yarnpkg.com/cytoscape/-/cytoscape-3.23.0.tgz#054ee05a6d0aa3b4f139382bbf2f4e5226df3c6d" + integrity sha512-gRZqJj/1kiAVPkrVFvz/GccxsXhF3Qwpptl32gKKypO4IlqnKBjTOu+HbXtEggSGzC5KCaHp3/F7GgENrtsFkA== dependencies: heap "^0.2.6" lodash "^4.17.21" "d3-array@2 - 3", "d3-array@2.10.0 - 3", "d3-array@2.5.0 - 3", d3-array@3, d3-array@^3.2.0: - version "3.2.4" - resolved "https://registry.yarnpkg.com/d3-array/-/d3-array-3.2.4.tgz#15fec33b237f97ac5d7c986dc77da273a8ed0bb5" - integrity sha512-tdQAmyA18i4J7wprpYq8ClcxZy3SC31QMeByyCFyRt7BVHdREQZ5lpzoe5mFEYZUWe+oq8HBvk9JjpibyEV4Jg== + version "3.2.2" + resolved "https://registry.yarnpkg.com/d3-array/-/d3-array-3.2.2.tgz#f8ac4705c5b06914a7e0025bbf8d5f1513f6a86e" + integrity sha512-yEEyEAbDrF8C6Ob2myOBLjwBLck1Z89jMGFee0oPsn95GqjerpaOA4ch+vc2l0FNFFwMD5N7OCSEN5eAlsUbgQ== dependencies: internmap "1 - 2" @@ -3637,9 +3572,9 @@ d3-contour@4: d3-array "^3.2.0" d3-delaunay@6: - version "6.0.4" - resolved "https://registry.yarnpkg.com/d3-delaunay/-/d3-delaunay-6.0.4.tgz#98169038733a0a5babbeda55054f795bb9e4a58b" - integrity sha512-mdjtIZ1XLAM8bm/hx3WwjfHt6Sggek7qH043O8KEjDXN40xi3vx/6pYSVTwLjEgiXQTbvaouWKynLBiUZ6SK6A== + version "6.0.2" + resolved "https://registry.yarnpkg.com/d3-delaunay/-/d3-delaunay-6.0.2.tgz#7fd3717ad0eade2fc9939f4260acfb503f984e92" + integrity sha512-IMLNldruDQScrcfT+MWnazhHbDJhcRJyOEBAJfwQnHle1RPh6WDuLvxNArUju2VSMSUuKlY5BGHRJ2cYyoFLQQ== dependencies: delaunator "5" @@ -3803,9 +3738,9 @@ d3-zoom@3: d3-transition "2 - 3" d3@^7.4.0, d3@^7.8.2: - version "7.8.5" - resolved "https://registry.yarnpkg.com/d3/-/d3-7.8.5.tgz#fde4b760d4486cdb6f0cc8e2cbff318af844635c" - integrity sha512-JgoahDG51ncUfJu6wX/1vWQEqOflgXyl4MaHqlcSruTez7yhaRKR9i8VjjcQGeS2en/jnFivXuaIMnseMMt0XA== + version "7.8.2" + resolved "https://registry.yarnpkg.com/d3/-/d3-7.8.2.tgz#2bdb3c178d095ae03b107a18837ae049838e372d" + integrity sha512-WXty7qOGSHb7HR7CfOzwN1Gw04MUOzN8qh9ZUsvwycIMb4DYMpY9xczZ6jUorGtO6bR9BPMPaueIKwiDxu9uiQ== dependencies: d3-array "3" d3-axis "3" @@ -3854,14 +3789,9 @@ date-fns@^2.30.0: "@babel/runtime" "^7.21.0" dayjs@^1.11.7: - version "1.11.10" - resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.10.tgz#68acea85317a6e164457d6d6947564029a6a16a0" - integrity sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ== - -debounce@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/debounce/-/debounce-1.2.1.tgz#38881d8f4166a5c5848020c11827b834bcb3e0a5" - integrity sha512-XRRe6Glud4rd/ZGQfiV1ruXSfbvfJedlV9Y6zOlP+2K04vBYiJEte6stfFkCP03aMnY5tsipamumUjL14fofug== + version "1.11.7" + resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.7.tgz#4b296922642f70999544d1144a2c25730fce63e2" + integrity sha512-+Yw9U6YO5TQohxLcIkrXBeY73WP3ejHWVvx8XCk3gxvQDCTEmS48ZrSZCKciI7Bhl/uCMyxYtE9UqRILmFphkQ== debug@2.6.9, debug@^2.6.0: version "2.6.9" @@ -3870,13 +3800,20 @@ debug@2.6.9, debug@^2.6.0: dependencies: ms "2.0.0" -debug@4, debug@^4, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1: +debug@4, debug@^4.1.0, debug@^4.1.1: version "4.3.4" resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== dependencies: ms "2.1.2" +debug@^3.2.7: + version "3.2.7" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a" + integrity sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ== + dependencies: + ms "^2.1.1" + decompress-response@^3.3.0: version "3.3.0" resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-3.3.0.tgz#80a4dd323748384bfa248083622aedec982adff3" @@ -3897,9 +3834,9 @@ deep-extend@^0.6.0: integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== deepmerge@^4.0.0, deepmerge@^4.2.2: - version "4.3.1" - resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.3.1.tgz#44b5f2147cd3b00d4b56137685966f26fd25dd4a" - integrity sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A== + version "4.3.0" + resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.3.0.tgz#65491893ec47756d44719ae520e0e2609233b59b" + integrity sha512-z2wJZXrmeHdvYJp/Ux55wIjqo81G5Bp4c+oELTW+7ar6SogWHajt5a9gO3s3IDaGSAXjDk0vlQKN3rms8ab3og== default-gateway@^6.0.3: version "6.0.3" @@ -3913,26 +3850,16 @@ defer-to-connect@^1.0.1: resolved "https://registry.yarnpkg.com/defer-to-connect/-/defer-to-connect-1.1.3.tgz#331ae050c08dcf789f8c83a7b81f0ed94f4ac591" integrity sha512-0ISdNousHvZT2EiFlZeZAHBUvSxmKswVCEf8hW7KWgG4a8MVEu/3Vb6uWYozkjylyCxe0JBIiRB1jV45S70WVQ== -define-data-property@^1.0.1, define-data-property@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/define-data-property/-/define-data-property-1.1.1.tgz#c35f7cd0ab09883480d12ac5cb213715587800b3" - integrity sha512-E7uGkTzkk1d0ByLeSc6ZsFS79Axg+m1P/VsgYsxHgiuc3tFSj+MjMIwe90FC4lOAZzNBdY7kkO2P2wKdsQ1vgQ== - dependencies: - get-intrinsic "^1.2.1" - gopd "^1.0.1" - has-property-descriptors "^1.0.0" - define-lazy-prop@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz#3f7ae421129bcaaac9bc74905c98a0009ec9ee7f" integrity sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og== -define-properties@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.2.1.tgz#10781cc616eb951a80a034bafcaa7377f6af2b6c" - integrity sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg== +define-properties@^1.1.4: + version "1.2.0" + resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.2.0.tgz#52988570670c9eacedd8064f4a990f2405849bd5" + integrity sha512-xvqAVKGfT1+UAvPwKTVw/njhdQ8ZhXK4lI0bCIuCMrp2up9nPnaDftrLtmpTazqd1o+UY4zgzU+avtMbDP+ldA== dependencies: - define-data-property "^1.0.1" has-property-descriptors "^1.0.0" object-keys "^1.1.1" @@ -3985,9 +3912,9 @@ detab@2.0.4: repeat-string "^1.5.4" detect-libc@^2.0.0, detect-libc@^2.0.1: - version "2.0.2" - resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-2.0.2.tgz#8ccf2ba9315350e1241b88d0ac3b0e1fbd99605d" - integrity sha512-UX6sGumvvqSaXgdKGUsgZWqcUyIXZ/vZTrlRT/iobiKhGL0zL4d3osHj3uqllWJK+i+sixDS/3COVEOFbupFyw== + version "2.0.1" + resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-2.0.1.tgz#e1897aa88fa6ad197862937fbc0441ef352ee0cd" + integrity sha512-463v3ZeIrcWtdgIg6vI6XUncguvr2TnGl4SzDXinkt9mSLpBJKXT3mW6xT3VQdDN11+WVs29pgvivTc4Lp8v+w== detect-node@^2.0.4: version "2.1.0" @@ -4017,10 +3944,15 @@ dir-glob@^3.0.1: dependencies: path-type "^4.0.0" +dns-equal@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/dns-equal/-/dns-equal-1.0.0.tgz#b39e7f1da6eb0a75ba9c17324b34753c47e0654d" + integrity sha512-z+paD6YUQsk+AbGCEM4PrOXSss5gd66QfcVBFTKR/HpFL9jCqikS94HYwKww6fQyO7IxrIIyUu+g0Ka9tUS2Cg== + dns-packet@^5.2.2: - version "5.6.1" - resolved "https://registry.yarnpkg.com/dns-packet/-/dns-packet-5.6.1.tgz#ae888ad425a9d1478a0674256ab866de1012cf2f" - integrity sha512-l4gcSouhcgIKRvyy99RNVOgxXiicE+2jZoNmaNmZ6JXiGajBOJAesk1OBlJuM5k2c+eudGdLxDqXuPCKIj6kpw== + version "5.4.0" + resolved "https://registry.yarnpkg.com/dns-packet/-/dns-packet-5.4.0.tgz#1f88477cf9f27e78a213fb6d118ae38e759a879b" + integrity sha512-EgqGeaBB8hLiHLZtp/IbaDQTL8pZ0+IvwzSHA6d7VyMDM+B9hgddEMa9xjK5oYnw0ci0JQ6g2XCD7/f6cafU6g== dependencies: "@leichtgewicht/ip-codec" "^2.0.1" @@ -4066,7 +3998,7 @@ domhandler@^4.0.0, domhandler@^4.2.0, domhandler@^4.3.1: dependencies: domelementtype "^2.2.0" -domhandler@^5.0.2, domhandler@^5.0.3: +domhandler@^5.0.1, domhandler@^5.0.2, domhandler@^5.0.3: version "5.0.3" resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-5.0.3.tgz#cc385f7f751f1d1fc650c21374804254538c7d31" integrity sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w== @@ -4088,13 +4020,13 @@ domutils@^2.5.2, domutils@^2.8.0: domhandler "^4.2.0" domutils@^3.0.1: - version "3.1.0" - resolved "https://registry.yarnpkg.com/domutils/-/domutils-3.1.0.tgz#c47f551278d3dc4b0b1ab8cbb42d751a6f0d824e" - integrity sha512-H78uMmQtI2AhgDJjWeQmHwJJ2bLPD3GMmO7Zja/ZZh84wkm+4ut+IUnUdRa8uCGX88DiVx1j6FRe1XfxEgjEZA== + version "3.0.1" + resolved "https://registry.yarnpkg.com/domutils/-/domutils-3.0.1.tgz#696b3875238338cb186b6c0612bd4901c89a4f1c" + integrity sha512-z08c1l761iKhDFtfXO04C7kTdPBLi41zwOZl00WS8b5eiaebNpY00HKbztwBq+e3vyqWNwWF3mP9YLUeqIrF+Q== dependencies: dom-serializer "^2.0.0" domelementtype "^2.3.0" - domhandler "^5.0.3" + domhandler "^5.0.1" dot-case@^3.0.4: version "3.0.4" @@ -4136,10 +4068,10 @@ ee-first@1.1.1: resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" integrity sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow== -electron-to-chromium@^1.4.601: - version "1.4.638" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.638.tgz#5564b750c2ceb64c0d2ef5a22b0748f63b66e0a3" - integrity sha512-gpmbAG2LbfPKcDaL5m9IKutKjUx4ZRkvGNkgL/8nKqxkXsBVYykVULboWlqCrHsh3razucgDJDuKoWJmGPdItA== +electron-to-chromium@^1.4.284: + version "1.4.325" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.325.tgz#7b97238a61192d85d055d97f3149832b3617d37b" + integrity sha512-K1C03NT4I7BuzsRdCU5RWkgZxtswnKDYM6/eMhkEXqKu4e5T+ck610x3FPzu1y7HVFSiQKZqP16gnJzPpji1TQ== elkjs@^0.8.2: version "0.8.2" @@ -4178,10 +4110,10 @@ end-of-stream@^1.1.0, end-of-stream@^1.4.1: dependencies: once "^1.4.0" -enhanced-resolve@^5.15.0: - version "5.15.0" - resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.15.0.tgz#1af946c7d93603eb88e9896cee4904dc012e9c35" - integrity sha512-LXYT42KJ7lpIKECr2mAXIaMldcNCh/7E0KBKOu4KSfkHmP+mZmSs+8V5gBAqisWBy0OO4W5Oyys0GO1Y8KtdKg== +enhanced-resolve@^5.10.0: + version "5.12.0" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.12.0.tgz#300e1c90228f5b570c4d35babf263f6da7155634" + integrity sha512-QHTXI/sZQmko1cbDoNAa3mJ5qhWUUNAq3vR0/YiD379fWQrcfuoX1+HW2S0MTt7XmoPLapdaDKUtelUSPic7hQ== dependencies: graceful-fs "^4.2.4" tapable "^2.2.0" @@ -4191,10 +4123,10 @@ entities@^2.0.0: resolved "https://registry.yarnpkg.com/entities/-/entities-2.2.0.tgz#098dc90ebb83d8dffa089d55256b351d34c4da55" integrity sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A== -entities@^4.2.0, entities@^4.4.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/entities/-/entities-4.5.0.tgz#5d268ea5e7113ec74c4d033b79ea5a35a488fb48" - integrity sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw== +entities@^4.2.0, entities@^4.3.0, entities@^4.4.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/entities/-/entities-4.4.0.tgz#97bdaba170339446495e653cfd2db78962900174" + integrity sha512-oYp7156SP8LkeGD0GF85ad1X9Ai79WtRsZ2gxJqtBuzH+98YUV6jkHEKlZkMbcrjJjIVJNIDP/3WL9wQkoPbWA== error-ex@^1.3.1: version "1.3.2" @@ -4203,10 +4135,10 @@ error-ex@^1.3.1: dependencies: is-arrayish "^0.2.1" -es-module-lexer@^1.2.1: - version "1.4.1" - resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-1.4.1.tgz#41ea21b43908fe6a287ffcbe4300f790555331f5" - integrity sha512-cXLGjP0c4T3flZJKQSuziYoq7MlT+rnvfZjfp7h+I7K9BNX54kP9nyWvdbwjQ4u1iWbOL4u96fgeZLToQlZC7w== +es-module-lexer@^0.9.0: + version "0.9.3" + resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-0.9.3.tgz#6f13db00cc38417137daf74366f535c8eb438f19" + integrity sha512-1HQ2M2sPtxwnvOvT1ZClHyQDiggdNjURWpY2we6aMKCQiUVxTmVs2UYPLIrD84sS+kMdUwfBSylbJPwNnBrnHQ== escalade@^3.1.1: version "3.1.1" @@ -4269,9 +4201,9 @@ esutils@^2.0.2: integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== eta@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/eta/-/eta-2.2.0.tgz#eb8b5f8c4e8b6306561a455e62cd7492fe3a9b8a" - integrity sha512-UVQ72Rqjy/ZKQalzV5dCCJP80GrmPrMxh6NlNf+erV6ObL0ZFkhCstWRawS85z3smdr3d2wXPsZEY7rDPfGd2g== + version "2.0.1" + resolved "https://registry.yarnpkg.com/eta/-/eta-2.0.1.tgz#199e675359cb6e19d38f29e1f405e1ba0e79a6df" + integrity sha512-46E2qDPDm7QA+usjffUWz9KfXsxVZclPOuKsXs4ZWZdI/X1wpDF7AO424pt7fdYohCzWsIkXAhNGXSlwo5naAg== etag@~1.8.1: version "1.8.1" @@ -4370,10 +4302,10 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== -fast-glob@^3.2.11, fast-glob@^3.2.9, fast-glob@^3.3.0: - version "3.3.2" - resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.2.tgz#a904501e57cfdd2ffcded45e99a54fef55e46129" - integrity sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow== +fast-glob@^3.2.11, fast-glob@^3.2.9: + version "3.2.12" + resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.12.tgz#7f39ec99c2e6ab030337142da9e0c18f37afae80" + integrity sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w== dependencies: "@nodelib/fs.stat" "^2.0.2" "@nodelib/fs.walk" "^1.2.3" @@ -4394,9 +4326,9 @@ fast-url-parser@1.1.3: punycode "^1.3.2" fastq@^1.6.0: - version "1.16.0" - resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.16.0.tgz#83b9a9375692db77a822df081edb6a9cf6839320" - integrity sha512-ifCoaXsDrsdkWTtiNJX5uzHDsrck5TzfKKDcuFFTIrrc/BS076qgEIfoIy1VeZqViznfKiysPYTh/QeHtnIsYA== + version "1.15.0" + resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.15.0.tgz#d04d07c6a2a68fe4599fea8d2e103a937fae6b3a" + integrity sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw== dependencies: reusify "^1.0.4" @@ -4420,9 +4352,9 @@ fbjs-css-vars@^1.0.0: integrity sha512-b2XGFAFdWZWg0phtAWLHCk836A1Xann+I+Dgd3Gk64MHKZO44FfoD1KxyvbSh0qZsIoXQGGlVztIY+oitJPpRQ== fbjs@^3.0.0, fbjs@^3.0.1: - version "3.0.5" - resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-3.0.5.tgz#aa0edb7d5caa6340011790bd9249dbef8a81128d" - integrity sha512-ztsSx77JBtkuMrEypfhgc3cI0+0h+svqeie7xHbh1k/IKdcydnvadp/mUaGgjAOXQmQSxsqgaRhS3q9fy+1kxg== + version "3.0.4" + resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-3.0.4.tgz#e1871c6bd3083bac71ff2da868ad5067d37716c6" + integrity sha512-ucV0tDODnGV3JCnnkmoszb5lf4bNpzjv80K41wd4k798Etq+UYD0y0TIfalLjZoKgjive6/adkRnszwapiDgBQ== dependencies: cross-fetch "^3.1.5" fbjs-css-vars "^1.0.0" @@ -4430,7 +4362,7 @@ fbjs@^3.0.0, fbjs@^3.0.1: object-assign "^4.1.0" promise "^7.1.1" setimmediate "^1.0.5" - ua-parser-js "^1.0.35" + ua-parser-js "^0.7.30" feed@^4.2.2: version "4.2.2" @@ -4504,23 +4436,18 @@ find-up@^5.0.0: locate-path "^6.0.0" path-exists "^4.0.0" -flat@^5.0.2: - version "5.0.2" - resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241" - integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ== - flux@^4.0.1: - version "4.0.4" - resolved "https://registry.yarnpkg.com/flux/-/flux-4.0.4.tgz#9661182ea81d161ee1a6a6af10d20485ef2ac572" - integrity sha512-NCj3XlayA2UsapRpM7va6wU1+9rE5FIL7qoMcmxWHRzbp0yujihMBm9BBHZ1MDIk5h5o2Bl6eGiCe8rYELAmYw== + version "4.0.3" + resolved "https://registry.yarnpkg.com/flux/-/flux-4.0.3.tgz#573b504a24982c4768fdfb59d8d2ea5637d72ee7" + integrity sha512-yKAbrp7JhZhj6uiT1FTuVMlIAT1J4jqEyBpFApi1kxpGZCvacMVc/t1pMQyotqHhAgvoE3bNvAykhCo2CLjnYw== dependencies: fbemitter "^3.0.0" fbjs "^3.0.1" -follow-redirects@^1.0.0, follow-redirects@^1.14.7, follow-redirects@^1.15.4: - version "1.15.5" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.5.tgz#54d4d6d062c0fa7d9d17feb008461550e3ba8020" - integrity sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw== +follow-redirects@^1.0.0, follow-redirects@^1.14.7, follow-redirects@^1.15.0: + version "1.15.2" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13" + integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA== fork-ts-checker-webpack-plugin@^6.5.0: version "6.5.3" @@ -4555,10 +4482,10 @@ forwarded@0.2.0: resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.2.0.tgz#2269936428aad4c15c7ebe9779a84bf0b2a81811" integrity sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow== -fraction.js@^4.3.7: - version "4.3.7" - resolved "https://registry.yarnpkg.com/fraction.js/-/fraction.js-4.3.7.tgz#06ca0085157e42fda7f9e726e79fefc4068840f7" - integrity sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew== +fraction.js@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/fraction.js/-/fraction.js-4.2.0.tgz#448e5109a313a3527f5a3ab2119ec4cf0e0e2950" + integrity sha512-MhLuK+2gUcnZe8ZHlaaINnQLl0xRIGRfcGk2yl8xoQAfHrSsL3rYu6FCmBdkdbhc9EPlwyGHewaRsvwRMJtAlA== fresh@0.5.2: version "0.5.2" @@ -4589,10 +4516,10 @@ fs-extra@^9.0.0: jsonfile "^6.0.1" universalify "^2.0.0" -fs-monkey@^1.0.4: - version "1.0.5" - resolved "https://registry.yarnpkg.com/fs-monkey/-/fs-monkey-1.0.5.tgz#fe450175f0db0d7ea758102e1d84096acb925788" - integrity sha512-8uMbBjrhzW76TYgEV27Y5E//W2f/lTFmx78P2w19FZSxarhI/798APGQyuGCwmkNxgwGRhrLfvWyLBvNtuOmew== +fs-monkey@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/fs-monkey/-/fs-monkey-1.0.3.tgz#ae3ac92d53bb328efe0e9a1d9541f6ad8d48e2d3" + integrity sha512-cybjIfiiE+pTWicSCLFHSrXZ6EilF30oh91FDP9S2B051prEa7QWfrVTQm10/dDpswBDXZugPa1Ogu8Yh+HV0Q== fs.realpath@^1.0.0: version "1.0.0" @@ -4600,14 +4527,14 @@ fs.realpath@^1.0.0: integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== fsevents@~2.3.2: - version "2.3.3" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" - integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== + version "2.3.2" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" + integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== -function-bind@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.2.tgz#2c02d864d97f3ea6c8830c464cbd11ab6eab7a1c" - integrity sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA== +function-bind@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" + integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== gensync@^1.0.0-beta.1, gensync@^1.0.0-beta.2: version "1.0.0-beta.2" @@ -4619,15 +4546,14 @@ get-caller-file@^2.0.5: resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== -get-intrinsic@^1.0.2, get-intrinsic@^1.1.3, get-intrinsic@^1.2.1, get-intrinsic@^1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.2.2.tgz#281b7622971123e1ef4b3c90fd7539306da93f3b" - integrity sha512-0gSo4ml/0j98Y3lngkFEot/zhiCeWsbYIlZ+uZOVgzLyLaUw7wxUL+nCTP0XJvJg1AXulJRI3UJi8GsbDuxdGA== +get-intrinsic@^1.0.2, get-intrinsic@^1.1.1: + version "1.2.0" + resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.2.0.tgz#7ad1dc0535f3a2904bba075772763e5051f6d05f" + integrity sha512-L049y6nFOuom5wGyRc3/gdTLO94dySVKRACj1RmJZBQXlbTMhtNIgkWkUHq+jYmZvKf14EW1EoJnnjbmoHij0Q== dependencies: - function-bind "^1.1.2" - has-proto "^1.0.1" + function-bind "^1.1.1" + has "^1.0.3" has-symbols "^1.0.3" - hasown "^2.0.0" get-own-enumerable-property-symbols@^3.0.0: version "3.0.2" @@ -4735,23 +4661,16 @@ globby@^11.0.1, globby@^11.0.4, globby@^11.1.0: slash "^3.0.0" globby@^13.1.1: - version "13.2.2" - resolved "https://registry.yarnpkg.com/globby/-/globby-13.2.2.tgz#63b90b1bf68619c2135475cbd4e71e66aa090592" - integrity sha512-Y1zNGV+pzQdh7H39l9zgB4PJqjRNqydvdYCDG4HFXM4XuvSaQQlEc91IU1yALL8gUTDomgBAfz3XJdmUS+oo0w== + version "13.1.3" + resolved "https://registry.yarnpkg.com/globby/-/globby-13.1.3.tgz#f62baf5720bcb2c1330c8d4ef222ee12318563ff" + integrity sha512-8krCNHXvlCgHDpegPzleMq07yMYTO2sXKASmZmquEYWEmCx6J5UTRbp5RwMJkTJGtcQ44YpiUYUiN0b9mzy8Bw== dependencies: dir-glob "^3.0.1" - fast-glob "^3.3.0" - ignore "^5.2.4" + fast-glob "^3.2.11" + ignore "^5.2.0" merge2 "^1.4.1" slash "^4.0.0" -gopd@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/gopd/-/gopd-1.0.1.tgz#29ff76de69dac7489b7c0918a5788e56477c332c" - integrity sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA== - dependencies: - get-intrinsic "^1.1.3" - got@^9.6.0: version "9.6.0" resolved "https://registry.yarnpkg.com/got/-/got-9.6.0.tgz#edf45e7d67f99545705de1f7bbeeeb121765ed85" @@ -4770,9 +4689,9 @@ got@^9.6.0: url-parse-lax "^3.0.0" graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.4, graceful-fs@^4.2.6, graceful-fs@^4.2.9: - version "4.2.11" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3" - integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ== + version "4.2.10" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c" + integrity sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA== gray-matter@^4.0.3: version "4.0.3" @@ -4818,17 +4737,12 @@ has-flag@^4.0.0: resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== -has-property-descriptors@^1.0.0, has-property-descriptors@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/has-property-descriptors/-/has-property-descriptors-1.0.1.tgz#52ba30b6c5ec87fd89fa574bc1c39125c6f65340" - integrity sha512-VsX8eaIewvas0xnvinAe9bw4WfIeODpGYikiWYLH+dma0Jw6KHYqWiWfhQlgOVK8D6PvjubK5Uc4P0iIhIcNVg== +has-property-descriptors@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz#610708600606d36961ed04c196193b6a607fa861" + integrity sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ== dependencies: - get-intrinsic "^1.2.2" - -has-proto@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/has-proto/-/has-proto-1.0.1.tgz#1885c1305538958aff469fef37937c22795408e0" - integrity sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg== + get-intrinsic "^1.1.1" has-symbols@^1.0.3: version "1.0.3" @@ -4840,12 +4754,12 @@ has-yarn@^2.1.0: resolved "https://registry.yarnpkg.com/has-yarn/-/has-yarn-2.1.0.tgz#137e11354a7b5bf11aa5cb649cf0c6f3ff2b2e77" integrity sha512-UqBRqi4ju7T+TqGNdqAO0PaSVGsDGJUBQvk9eUWNGRY1CFGDzYhLWoM7JQEemnlvVcv/YEmc2wNW8BC24EnUsw== -hasown@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/hasown/-/hasown-2.0.0.tgz#f4c513d454a57b7c7e1650778de226b11700546c" - integrity sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA== +has@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" + integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== dependencies: - function-bind "^1.1.2" + function-bind "^1.1.1" hast-to-hyperscript@^9.0.0: version "9.0.1" @@ -4969,14 +4883,9 @@ hpack.js@^2.1.6: wbuf "^1.1.0" html-entities@^2.3.2: - version "2.4.0" - resolved "https://registry.yarnpkg.com/html-entities/-/html-entities-2.4.0.tgz#edd0cee70402584c8c76cc2c0556db09d1f45061" - integrity sha512-igBTJcNNNhvZFRtm8uA6xMY6xYleeDwn3PeBCkDz7tHttv4F2hsDI2aPgNERWzvRcNYHNT3ymRaQzllmXj4YsQ== - -html-escaper@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/html-escaper/-/html-escaper-2.0.2.tgz#dfd60027da36a36dfcbe236262c00a5822681453" - integrity sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg== + version "2.3.3" + resolved "https://registry.yarnpkg.com/html-entities/-/html-entities-2.3.3.tgz#117d7626bece327fc8baace8868fa6f5ef856e46" + integrity sha512-DV5Ln36z34NNTDgnz0EWGBLZENelNAtkiFA4kyNOG2tDI6Mz1uSWiq1wAKdyjnJwyDiDO7Fa2SO1CTxPXL8VxA== html-minifier-terser@^6.0.2, html-minifier-terser@^6.1.0: version "6.1.0" @@ -4992,9 +4901,9 @@ html-minifier-terser@^6.0.2, html-minifier-terser@^6.1.0: terser "^5.10.0" html-tags@^3.2.0: - version "3.3.1" - resolved "https://registry.yarnpkg.com/html-tags/-/html-tags-3.3.1.tgz#a04026a18c882e4bba8a01a3d39cfe465d40b5ce" - integrity sha512-ztqyC3kLto0e9WbNp0aeP+M3kTt+nbaIveGmUxAtZa+8iFgKLUOD4YKM5j+f3QD89bra7UeumolZHKuOXnTmeQ== + version "3.2.0" + resolved "https://registry.yarnpkg.com/html-tags/-/html-tags-3.2.0.tgz#dbb3518d20b726524e4dd43de397eb0a95726961" + integrity sha512-vy7ClnArOZwCnqZgvv+ddgHgJiAFXe3Ge9ML5/mBctVJoUoYPCdxVucOywjDARn6CVoh3dRSFdPHy2sX80L0Wg== html-void-elements@^1.0.0: version "1.0.5" @@ -5002,9 +4911,9 @@ html-void-elements@^1.0.0: integrity sha512-uE/TxKuyNIcx44cIWnjr/rfIATDH7ZaOMmstu0CwhFG1Dunhlp4OC6/NMbhiwoq5BpW0ubi303qnEk/PZj614w== html-webpack-plugin@^5.5.0: - version "5.6.0" - resolved "https://registry.yarnpkg.com/html-webpack-plugin/-/html-webpack-plugin-5.6.0.tgz#50a8fa6709245608cb00e811eacecb8e0d7b7ea0" - integrity sha512-iwaY4wzbe48AfKLZ/Cc8k0L+FKG6oSNRaZ8x5A/T/IVDGyXcbHncM9TdDa93wn0FsSm82FhTKW7f3vS61thXAw== + version "5.5.0" + resolved "https://registry.yarnpkg.com/html-webpack-plugin/-/html-webpack-plugin-5.5.0.tgz#c3911936f57681c1f9f4d8b68c158cd9dfe52f50" + integrity sha512-sy88PC2cRTVxvETRgUHFrL4No3UxvcH8G1NepGhqaTT+GXN2kTamqasot0inS5hXeg1cMbFDt27zzo9p35lZVw== dependencies: "@types/html-minifier-terser" "^6.0.0" html-minifier-terser "^6.0.2" @@ -5023,14 +4932,14 @@ htmlparser2@^6.1.0: entities "^2.0.0" htmlparser2@^8.0.1: - version "8.0.2" - resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-8.0.2.tgz#f002151705b383e62433b5cf466f5b716edaec21" - integrity sha512-GYdjWKDkbRLkZ5geuHs5NY1puJ+PXwP7+fHPRz06Eirsb9ugf6d8kkXav6ADhcODhFFPMIXyxkxSuMf3D6NCFA== + version "8.0.1" + resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-8.0.1.tgz#abaa985474fcefe269bc761a779b544d7196d010" + integrity sha512-4lVbmc1diZC7GUJQtRQ5yBAeUCL1exyMwmForWkRLnwyzWBFxN633SALPMGYaWZvKe9j1pRZJpauvmxENSp/EA== dependencies: domelementtype "^2.3.0" - domhandler "^5.0.3" + domhandler "^5.0.2" domutils "^3.0.1" - entities "^4.4.0" + entities "^4.3.0" http-cache-semantics@^4.0.0: version "4.1.1" @@ -5122,22 +5031,22 @@ ignore-by-default@^1.0.1: resolved "https://registry.yarnpkg.com/ignore-by-default/-/ignore-by-default-1.0.1.tgz#48ca6d72f6c6a3af00a9ad4ae6876be3889e2b09" integrity sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA== -ignore@^5.2.0, ignore@^5.2.4: - version "5.3.0" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.3.0.tgz#67418ae40d34d6999c95ff56016759c718c82f78" - integrity sha512-g7dmpshy+gD7mh88OC9NwSGTKoc3kyLAZQRU1mt53Aw/vnvfXnbC+F/7F7QoYVKbV+KNvJx8wArewKy1vXMtlg== +ignore@^5.2.0: + version "5.2.4" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.4.tgz#a291c0c6178ff1b960befe47fcdec301674a6324" + integrity sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ== image-size@^1.0.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/image-size/-/image-size-1.1.1.tgz#ddd67d4dc340e52ac29ce5f546a09f4e29e840ac" - integrity sha512-541xKlUw6jr/6gGuk92F+mYM5zaFAc5ahphvkqvNe2bQ6gVBkd6bfrmVJ2t4KDAfikAYZyIqTnktX3i6/aQDrQ== + version "1.0.2" + resolved "https://registry.yarnpkg.com/image-size/-/image-size-1.0.2.tgz#d778b6d0ab75b2737c1556dd631652eb963bc486" + integrity sha512-xfOoWjceHntRb3qFCrh5ZFORYH8XCdYpASltMhZ/Q0KZiOwjdE/Yl2QCiWdwD+lygV5bMCvauzgu5PxBX/Yerg== dependencies: queue "6.0.2" immer@^9.0.7: - version "9.0.21" - resolved "https://registry.yarnpkg.com/immer/-/immer-9.0.21.tgz#1e025ea31a40f24fb064f1fef23e931496330176" - integrity sha512-bc4NBHqOqSfRW7POMkHd51LvClaeMXpm8dx0e8oE2GORbq5aRK7Bxl4FyzVLdGtLmvLKL7BTDBG5ACQm4HWjTA== + version "9.0.19" + resolved "https://registry.yarnpkg.com/immer/-/immer-9.0.19.tgz#67fb97310555690b5f9cd8380d38fc0aabb6b38b" + integrity sha512-eY+Y0qcsB4TZKwgQzLaE/lqYMlKhv5J9dyd2RhhtGhNo2njPXDqU9XPfcNfa3MIDsdtZt5KlkIsirlo4dHsWdQ== import-fresh@^3.1.0, import-fresh@^3.2.1, import-fresh@^3.3.0: version "3.3.0" @@ -5223,9 +5132,9 @@ ipaddr.js@1.9.1: integrity sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g== ipaddr.js@^2.0.1: - version "2.1.0" - resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-2.1.0.tgz#2119bc447ff8c257753b196fc5f1ce08a4cdf39f" - integrity sha512-LlbxQ7xKzfBusov6UMi4MFpEg0m+mAm9xyNGEduwXMEDuf4WfzB/RZwMVYEd7IKGvh4IUkEXYxtAVu9T3OelJQ== + version "2.0.1" + resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-2.0.1.tgz#eca256a7a877e917aeb368b0a7497ddf42ef81c0" + integrity sha512-1qTgH9NG+IIJ4yfKs2e6Pp1bZg8wbDbKHT21HrLIeYBTRLgMYKnMTPAuI3Lcs61nfx5h1xlXnbJtH1kX5/d/ng== is-alphabetical@1.0.4, is-alphabetical@^1.0.0: version "1.0.4" @@ -5269,12 +5178,12 @@ is-ci@^2.0.0: dependencies: ci-info "^2.0.0" -is-core-module@^2.13.0: - version "2.13.1" - resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.13.1.tgz#ad0d7532c6fea9da1ebdc82742d74525c6273384" - integrity sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw== +is-core-module@^2.9.0: + version "2.11.0" + resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.11.0.tgz#ad4cb3e3863e814523c96f3f58d26cc570ff0144" + integrity sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw== dependencies: - hasown "^2.0.0" + has "^1.0.3" is-decimal@^1.0.0: version "1.0.4" @@ -5368,11 +5277,6 @@ is-plain-object@^2.0.4: dependencies: isobject "^3.0.1" -is-plain-object@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-5.0.0.tgz#4427f50ab3429e9025ea7d52e9043a9ef4159344" - integrity sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q== - is-regexp@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-regexp/-/is-regexp-1.0.0.tgz#fd2d883545c46bac5a633e7b9a09e87fa2cb5069" @@ -5435,12 +5339,12 @@ isobject@^3.0.1: resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" integrity sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg== -jest-util@^29.7.0: - version "29.7.0" - resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-29.7.0.tgz#23c2b62bfb22be82b44de98055802ff3710fc0bc" - integrity sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA== +jest-util@^29.5.0: + version "29.5.0" + resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-29.5.0.tgz#24a4d3d92fc39ce90425311b23c27a6e0ef16b8f" + integrity sha512-RYMgG/MTadOr5t8KdhejfvUU82MxsCu5MF6KuDUHl+NuwzUt+Sm6jJWxTJVrDR1j5M/gJVCPKQEpWXY+yIQ6lQ== dependencies: - "@jest/types" "^29.6.3" + "@jest/types" "^29.5.0" "@types/node" "*" chalk "^4.0.0" ci-info "^3.2.0" @@ -5457,28 +5361,23 @@ jest-worker@^27.4.5: supports-color "^8.0.0" jest-worker@^29.1.2: - version "29.7.0" - resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-29.7.0.tgz#acad073acbbaeb7262bd5389e1bcf43e10058d4a" - integrity sha512-eIz2msL/EzL9UFTFFx7jBTkeZfku0yUAyZZZmJ93H2TYEiroIx2PQjEXcwYtYl8zXCxb+PAmA2hLIt/6ZEkPHw== + version "29.5.0" + resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-29.5.0.tgz#bdaefb06811bd3384d93f009755014d8acb4615d" + integrity sha512-NcrQnevGoSp4b5kg+akIpthoAFHxPBcb5P6mYPY0fUNT+sSvmtu6jlkEle3anczUKIKEbMxFimk9oTP/tpIPgA== dependencies: "@types/node" "*" - jest-util "^29.7.0" + jest-util "^29.5.0" merge-stream "^2.0.0" supports-color "^8.0.0" -jiti@^1.20.0: - version "1.21.0" - resolved "https://registry.yarnpkg.com/jiti/-/jiti-1.21.0.tgz#7c97f8fe045724e136a397f7340475244156105d" - integrity sha512-gFqAIbuKyyso/3G2qhiO2OM6shY6EPP/R0+mkDbyspxKazh8BXDC5FiFsUjlczgdNz/vfra0da2y+aHrusLG/Q== - joi@^17.6.0: - version "17.12.0" - resolved "https://registry.yarnpkg.com/joi/-/joi-17.12.0.tgz#a3fb5715f198beb0471cd551dd26792089c308d5" - integrity sha512-HSLsmSmXz+PV9PYoi3p7cgIbj06WnEBNT28n+bbBNcPZXZFqCzzvGqpTBPujx/Z0nh1+KNQPDrNgdmQ8dq0qYw== + version "17.8.3" + resolved "https://registry.yarnpkg.com/joi/-/joi-17.8.3.tgz#d772fe27a87a5cda21aace5cf11eee8671ca7e6f" + integrity sha512-q5Fn6Tj/jR8PfrLrx4fpGH4v9qM6o+vDUfD4/3vxxyg34OmKcNqYZ1qn2mpLza96S8tL0p0rIw2gOZX+/cTg9w== dependencies: - "@hapi/hoek" "^9.3.0" - "@hapi/topo" "^5.1.0" - "@sideway/address" "^4.1.4" + "@hapi/hoek" "^9.0.0" + "@hapi/topo" "^5.0.0" + "@sideway/address" "^4.1.3" "@sideway/formula" "^3.0.1" "@sideway/pinpoint" "^2.0.0" @@ -5532,7 +5431,7 @@ json-schema-traverse@^1.0.0: resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz#ae7bcb3656ab77a73ba5c49bf654f38e6b6860e2" integrity sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug== -json5@^2.1.2, json5@^2.2.3: +json5@^2.1.2, json5@^2.2.2: version "2.2.3" resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283" integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg== @@ -5566,9 +5465,9 @@ keyv@^3.0.0: json-buffer "3.0.0" khroma@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/khroma/-/khroma-2.1.0.tgz#45f2ce94ce231a437cf5b63c2e886e6eb42bbbb1" - integrity sha512-Ls993zuzfayK269Svk9hzpeGUKob/sIgZzyHYdjQoAdQetRKpOLj+k/QQQ/6Qi0Yz65mlROrfd+Ev+1+7dz9Kw== + version "2.0.0" + resolved "https://registry.yarnpkg.com/khroma/-/khroma-2.0.0.tgz#7577de98aed9f36c7a474c4d453d94c0d6c6588b" + integrity sha512-2J8rDNlQWbtiNYThZRvmMv5yt44ZakX+Tz5ZIp/mN1pt4snn+m030Va5Z4v8xA0cQFDXBwO/8i42xL4QPsVk3g== kind-of@^6.0.0, kind-of@^6.0.2: version "6.0.3" @@ -5580,6 +5479,11 @@ kleur@^3.0.3: resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e" integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w== +klona@^2.0.5: + version "2.0.6" + resolved "https://registry.yarnpkg.com/klona/-/klona-2.0.6.tgz#85bffbf819c03b2f53270412420a4555ef882e22" + integrity sha512-dhG34DXATL5hSxJbIexCft8FChFXtmskoZYnoPWjXQuebWYCNkVeV3KkGegCK9CP1oswI/vQibS2GY7Em/sJJA== + latest-version@^5.1.0: version "5.1.0" resolved "https://registry.yarnpkg.com/latest-version/-/latest-version-5.1.0.tgz#119dfe908fe38d15dfa43ecd13fa12ec8832face" @@ -5587,14 +5491,6 @@ latest-version@^5.1.0: dependencies: package-json "^6.3.0" -launch-editor@^2.6.0: - version "2.6.1" - resolved "https://registry.yarnpkg.com/launch-editor/-/launch-editor-2.6.1.tgz#f259c9ef95cbc9425620bbbd14b468fcdb4ffe3c" - integrity sha512-eB/uXmFVpY4zezmGp5XtU21kwo7GBbKB+EQ+UZeWtGb9yAM5xt/Evk+lYH3eRNAtId+ej4u7TYPFZ07w4s7rRw== - dependencies: - picocolors "^1.0.0" - shell-quote "^1.8.1" - layout-base@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/layout-base/-/layout-base-1.0.2.tgz#1291e296883c322a9dd4c5dd82063721b53e26e2" @@ -5810,11 +5706,11 @@ media-typer@0.3.0: integrity sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ== memfs@^3.1.2, memfs@^3.4.3: - version "3.6.0" - resolved "https://registry.yarnpkg.com/memfs/-/memfs-3.6.0.tgz#d7a2110f86f79dd950a8b6df6d57bc984aa185f6" - integrity sha512-EGowvkkgbMcIChjMTMkESFDbZeSh8xZ7kNSF0hAiAN4Jh6jgHCRS0Ga/+C8y6Au+oqpezRHCfPsmJ2+DwAgiwQ== + version "3.4.13" + resolved "https://registry.yarnpkg.com/memfs/-/memfs-3.4.13.tgz#248a8bd239b3c240175cd5ec548de5227fc4f345" + integrity sha512-omTM41g3Skpvx5dSYeZIbXKcXoAVc/AoMNwn9TKx++L/gaen/+4TTttmu8ZSch5vfVJ8uJvGbroTsIlslRg6lg== dependencies: - fs-monkey "^1.0.4" + fs-monkey "^1.0.3" memoize-one@^5.1.1: version "5.2.1" @@ -5916,9 +5812,9 @@ mimic-response@^3.1.0: integrity sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ== mini-css-extract-plugin@^2.6.1: - version "2.7.7" - resolved "https://registry.yarnpkg.com/mini-css-extract-plugin/-/mini-css-extract-plugin-2.7.7.tgz#4acf02f362c641c38fb913bfcb7ca2fc4a7cf339" - integrity sha512-+0n11YGyRavUR3IlaOzJ0/4Il1avMvJ1VJfhWfCn24ITQXhRr1gghbhhrda6tgtNcpZaWKdSuwKq20Jb7fnlyw== + version "2.7.3" + resolved "https://registry.yarnpkg.com/mini-css-extract-plugin/-/mini-css-extract-plugin-2.7.3.tgz#794aa4d598bf178a66b2a35fe287c3df3eac394e" + integrity sha512-CD9cXeKeXLcnMw8FZdtfrRrLaM7gwCl4nKuKn2YkY2Bw5wdlB8zU2cCzw+w2zS9RFvbrufTBkMCJACNPwqQA0w== dependencies: schema-utils "^4.0.0" @@ -5941,20 +5837,25 @@ minimatch@^9.0.3: dependencies: brace-expansion "^2.0.1" -minimist@^1.2.0, minimist@^1.2.3, minimist@^1.2.5: +minimist@^1.2.0, minimist@^1.2.5: version "1.2.8" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c" integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA== +minimist@^1.2.3: + version "1.2.7" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.7.tgz#daa1c4d91f507390437c6a8bc01078e7000c4d18" + integrity sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g== + mkdirp-classic@^0.5.2, mkdirp-classic@^0.5.3: version "0.5.3" resolved "https://registry.yarnpkg.com/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz#fa10c9115cc6d8865be221ba47ee9bed78601113" integrity sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A== -mrmime@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/mrmime/-/mrmime-2.0.0.tgz#151082a6e06e59a9a39b46b3e14d5cfe92b3abb4" - integrity sha512-eu38+hdgojoyq63s+yTpN4XMBdt5l8HhMhc4VKLO9KM5caLIBvUm4thi7fFaxyTmCKeNnXZ5pAlBwCUnhA09uw== +mrmime@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/mrmime/-/mrmime-1.0.1.tgz#5f90c825fad4bdd41dc914eff5d1a8cfdaf24f27" + integrity sha512-hzzEagAgDyoU1Q6yg5uI+AorQgdvMCur3FcKf7NhMKWsaYg+RnbTyHRa/9IlLF9rf455MOCtcqqrQQ83pPP7Uw== ms@2.0.0: version "2.0.0" @@ -5966,7 +5867,7 @@ ms@2.1.2: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== -ms@2.1.3: +ms@2.1.3, ms@^2.1.1: version "2.1.3" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== @@ -5979,10 +5880,10 @@ multicast-dns@^7.2.5: dns-packet "^5.2.2" thunky "^1.0.2" -nanoid@^3.3.7: - version "3.3.7" - resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.7.tgz#d0c301a691bc8d54efa0a2226ccf3fe2fd656bd8" - integrity sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g== +nanoid@^3.3.4: + version "3.3.4" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.4.tgz#730b67e3cd09e2deacf03c027c81c9d9dbc5e8ab" + integrity sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw== napi-build-utils@^1.0.1: version "1.0.2" @@ -6008,9 +5909,9 @@ no-case@^3.0.4: tslib "^2.0.3" node-abi@^3.3.0: - version "3.54.0" - resolved "https://registry.yarnpkg.com/node-abi/-/node-abi-3.54.0.tgz#f6386f7548817acac6434c6cba02999c9aebcc69" - integrity sha512-p7eGEiQil0YUV3ItH4/tBb781L5impVmmx2E9FRKF7d18XXzp4PGT2tdYMFY6wQqgxD0IwNZOiSJ0/K0fSi/OA== + version "3.31.0" + resolved "https://registry.yarnpkg.com/node-abi/-/node-abi-3.31.0.tgz#dfb2ea3d01188eb80859f69bb4a4354090c1b355" + integrity sha512-eSKV6s+APenqVh8ubJyiu/YhZgxQpGP66ntzUb3lY1xB9ukSRaGnx0AIxI+IM+1+IVYC1oWobgG5L3Lt9ARykQ== dependencies: semver "^7.3.5" @@ -6026,10 +5927,10 @@ node-emoji@^1.10.0: dependencies: lodash "^4.17.21" -node-fetch@^2.6.12: - version "2.7.0" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" - integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A== +node-fetch@2.6.7: + version "2.6.7" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" + integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== dependencies: whatwg-url "^5.0.0" @@ -6038,18 +5939,18 @@ node-forge@^1: resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-1.3.1.tgz#be8da2af243b2417d5f646a770663a92b7e9ded3" integrity sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA== -node-releases@^2.0.14: - version "2.0.14" - resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.14.tgz#2ffb053bceb8b2be8495ece1ab6ce600c4461b0b" - integrity sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw== +node-releases@^2.0.8: + version "2.0.10" + resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.10.tgz#c311ebae3b6a148c89b1813fd7c4d3c024ef537f" + integrity sha512-5GFldHPXVG/YZmFzJvKK2zDSzPKhEp0+ZR5SVaoSag9fsL5YgHbUHDfnG5494ISANDcK4KwPXAx2xqVEydmd7w== nodemon@^3.0.1: - version "3.0.3" - resolved "https://registry.yarnpkg.com/nodemon/-/nodemon-3.0.3.tgz#244a62d1c690eece3f6165c6cdb0db03ebd80b76" - integrity sha512-7jH/NXbFPxVaMwmBCC2B9F/V6X1VkEdNgx3iu9jji8WxWcvhMWkmhNWhI5077zknOnZnBzba9hZP6bCPJLSReQ== + version "3.0.1" + resolved "https://registry.yarnpkg.com/nodemon/-/nodemon-3.0.1.tgz#affe822a2c5f21354466b2fc8ae83277d27dadc7" + integrity sha512-g9AZ7HmkhQkqXkRc20w+ZfQ73cHLbE8hnPbtaFbFtCumZsjyMhKk9LajQ07U5Ux28lvFjZ5X7HvWR1xzU8jHVw== dependencies: chokidar "^3.5.2" - debug "^4" + debug "^3.2.7" ignore-by-default "^1.0.1" minimatch "^3.1.2" pstree.remy "^1.1.8" @@ -6116,9 +6017,9 @@ object-assign@^4.1.0, object-assign@^4.1.1: integrity sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg== object-inspect@^1.9.0: - version "1.13.1" - resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.13.1.tgz#b96c6109324ccfef6b12216a956ca4dc2ff94bc2" - integrity sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ== + version "1.12.3" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.12.3.tgz#ba62dffd67ee256c8c086dfae69e016cd1f198b9" + integrity sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g== object-keys@^1.1.1: version "1.1.1" @@ -6126,12 +6027,12 @@ object-keys@^1.1.1: integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== object.assign@^4.1.0: - version "4.1.5" - resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.5.tgz#3a833f9ab7fdb80fc9e8d2300c803d216d8fdbb0" - integrity sha512-byy+U7gp+FVwmyzKPYhW2h5l3crpmGsxl7X2s8y43IgxvG4g3QZ6CffDtsNQy1WsmZpQbO+ybo0AlW7TY6DcBQ== + version "4.1.4" + resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.4.tgz#9673c7c7c351ab8c4d0b516f4343ebf4dfb7799f" + integrity sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ== dependencies: - call-bind "^1.0.5" - define-properties "^1.2.1" + call-bind "^1.0.2" + define-properties "^1.1.4" has-symbols "^1.0.3" object-keys "^1.1.1" @@ -6277,7 +6178,7 @@ parse-entities@^2.0.0: is-decimal "^1.0.0" is-hexadecimal "^1.0.0" -parse-json@^5.0.0, parse-json@^5.2.0: +parse-json@^5.0.0: version "5.2.0" resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-5.2.0.tgz#c76fc66dee54231c962b22bcc8a72cf2f99753cd" integrity sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg== @@ -6455,13 +6356,13 @@ postcss-discard-unused@^5.1.0: postcss-selector-parser "^6.0.5" postcss-loader@^7.0.0: - version "7.3.4" - resolved "https://registry.yarnpkg.com/postcss-loader/-/postcss-loader-7.3.4.tgz#aed9b79ce4ed7e9e89e56199d25ad1ec8f606209" - integrity sha512-iW5WTTBSC5BfsBJ9daFMPVrLT36MrNiC6fqOZTTaHjBNX6Pfd5p+hSBqe/fEeNd7pc13QiAyGt7VdGMw4eRC4A== + version "7.0.2" + resolved "https://registry.yarnpkg.com/postcss-loader/-/postcss-loader-7.0.2.tgz#b53ff44a26fba3688eee92a048c7f2d4802e23bb" + integrity sha512-fUJzV/QH7NXUAqV8dWJ9Lg4aTkDCezpTS5HgJ2DvqznexTbSTxgi/dTECvTZ15BwKTtk8G/bqI/QTu2HPd3ZCg== dependencies: - cosmiconfig "^8.3.5" - jiti "^1.20.0" - semver "^7.5.4" + cosmiconfig "^7.0.0" + klona "^2.0.5" + semver "^7.3.8" postcss-merge-idents@^5.1.1: version "5.1.1" @@ -6526,19 +6427,19 @@ postcss-modules-extract-imports@^3.0.0: resolved "https://registry.yarnpkg.com/postcss-modules-extract-imports/-/postcss-modules-extract-imports-3.0.0.tgz#cda1f047c0ae80c97dbe28c3e76a43b88025741d" integrity sha512-bdHleFnP3kZ4NYDhuGlVK+CMrQ/pqUm8bx/oGL93K6gVwiclvX5x0n76fYMKuIGKzlABOy13zsvqjb0f92TEXw== -postcss-modules-local-by-default@^4.0.4: - version "4.0.4" - resolved "https://registry.yarnpkg.com/postcss-modules-local-by-default/-/postcss-modules-local-by-default-4.0.4.tgz#7cbed92abd312b94aaea85b68226d3dec39a14e6" - integrity sha512-L4QzMnOdVwRm1Qb8m4x8jsZzKAaPAgrUF1r/hjDR2Xj7R+8Zsf97jAlSQzWtKx5YNiNGN8QxmPFIc/sh+RQl+Q== +postcss-modules-local-by-default@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/postcss-modules-local-by-default/-/postcss-modules-local-by-default-4.0.0.tgz#ebbb54fae1598eecfdf691a02b3ff3b390a5a51c" + integrity sha512-sT7ihtmGSF9yhm6ggikHdV0hlziDTX7oFoXtuVWeDd3hHObNkcHRo9V3yg7vCAY7cONyxJC/XXCmmiHHcvX7bQ== dependencies: icss-utils "^5.0.0" postcss-selector-parser "^6.0.2" postcss-value-parser "^4.1.0" -postcss-modules-scope@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/postcss-modules-scope/-/postcss-modules-scope-3.1.1.tgz#32cfab55e84887c079a19bbb215e721d683ef134" - integrity sha512-uZgqzdTleelWjzJY+Fhti6F3C9iF1JR/dODLs/JDefozYcKTBCdD8BIl6nNPbTbcLnGrk56hzwZC2DaGNvYjzA== +postcss-modules-scope@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/postcss-modules-scope/-/postcss-modules-scope-3.0.0.tgz#9ef3151456d3bbfa120ca44898dfca6f2fa01f06" + integrity sha512-hncihwFA2yPath8oZ15PZqvWGkWf+XUfQgUGamS4LqoP1anQLOsOJw0vr7J7IwLpoY9fatA2qiGUGmuZL0Iqlg== dependencies: postcss-selector-parser "^6.0.4" @@ -6643,17 +6544,17 @@ postcss-reduce-transforms@^5.1.0: postcss-value-parser "^4.2.0" postcss-selector-parser@^6.0.2, postcss-selector-parser@^6.0.4, postcss-selector-parser@^6.0.5, postcss-selector-parser@^6.0.9: - version "6.0.15" - resolved "https://registry.yarnpkg.com/postcss-selector-parser/-/postcss-selector-parser-6.0.15.tgz#11cc2b21eebc0b99ea374ffb9887174855a01535" - integrity sha512-rEYkQOMUCEMhsKbK66tbEU9QVIxbhN18YiniAwA7XQYTVBqrBy+P2p5JcdqsHgKM2zWylp8d7J6eszocfds5Sw== + version "6.0.11" + resolved "https://registry.yarnpkg.com/postcss-selector-parser/-/postcss-selector-parser-6.0.11.tgz#2e41dc39b7ad74046e1615185185cd0b17d0c8dc" + integrity sha512-zbARubNdogI9j7WY4nQJBiNqQf3sLS3wCP4WfOidu+p28LofJqDH1tcXypGrcmMHhDk2t9wGhCsYe/+szLTy1g== dependencies: cssesc "^3.0.0" util-deprecate "^1.0.2" postcss-sort-media-queries@^4.2.1: - version "4.4.1" - resolved "https://registry.yarnpkg.com/postcss-sort-media-queries/-/postcss-sort-media-queries-4.4.1.tgz#04a5a78db3921eb78f28a1a781a2e68e65258128" - integrity sha512-QDESFzDDGKgpiIh4GYXsSy6sek2yAwQx1JASl5AxBtU1Lq2JfKBljIPNdil989NcSKRQX1ToiaKphImtBuhXWw== + version "4.3.0" + resolved "https://registry.yarnpkg.com/postcss-sort-media-queries/-/postcss-sort-media-queries-4.3.0.tgz#f48a77d6ce379e86676fc3f140cf1b10a06f6051" + integrity sha512-jAl8gJM2DvuIJiI9sL1CuiHtKM4s5aEIomkU8G3LFvbP+p8i7Sz8VV63uieTgoewGqKbi+hxBTiOKJlB35upCg== dependencies: sort-css-media-queries "2.1.0" @@ -6682,12 +6583,12 @@ postcss-zindex@^5.1.0: resolved "https://registry.yarnpkg.com/postcss-zindex/-/postcss-zindex-5.1.0.tgz#4a5c7e5ff1050bd4c01d95b1847dfdcc58a496ff" integrity sha512-fgFMf0OtVSBR1va1JNHYgMxYk73yhn/qb4uQDq1DLGYolz8gHCyr/sesEuGUaYs58E3ZJRcpoGuPVoB7Meiq9A== -postcss@^8.3.11, postcss@^8.4.14, postcss@^8.4.17, postcss@^8.4.33: - version "8.4.33" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.33.tgz#1378e859c9f69bf6f638b990a0212f43e2aaa742" - integrity sha512-Kkpbhhdjw2qQs2O2DGX+8m5OVqEcbB9HRBvuYM9pgrjEFUg30A9LmXNlTAUj4S9kgtGyrMbTzVjH7E+s5Re2yg== +postcss@^8.3.11, postcss@^8.4.14, postcss@^8.4.17, postcss@^8.4.19: + version "8.4.21" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.21.tgz#c639b719a57efc3187b13a1d765675485f4134f4" + integrity sha512-tP7u/Sn/dVxK2NnruI4H9BG+x+Wxz6oeZ1cJ8P6G/PZY0IKk4k/63TDsQf2kQq3+qoJeLm2kIBUNlZe3zgb4Zg== dependencies: - nanoid "^3.3.7" + nanoid "^3.3.4" picocolors "^1.0.0" source-map-js "^1.0.2" @@ -6805,9 +6706,9 @@ punycode@^1.3.2: integrity sha512-jmYNElW7yvO7TV33CjSmvSiE2yco3bV2czu/OzDKdMNVZQWfxCblURLhf+47syQRBntjfLdd/H0egrzIG+oaFQ== punycode@^2.1.0: - version "2.3.1" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5" - integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg== + version "2.3.0" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.0.tgz#f67fa67c94da8f4d0cfff981aee4118064199b8f" + integrity sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA== pupa@^2.1.1: version "2.1.1" @@ -6931,21 +6832,12 @@ react-error-overlay@^6.0.11: resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-6.0.11.tgz#92835de5841c5cf08ba00ddd2d677b6d17ff9adb" integrity sha512-/6UZ2qgEyH2aqzYZgQPxEnz33NJ2gNsnHA2o5+o4wW9bLM/JYQitNP9xPhsXwC08hMMovfGe/8retsdDsczPRg== -react-fast-compare@^3.0.1, react-fast-compare@^3.2.0, react-fast-compare@^3.2.2: - version "3.2.2" - resolved "https://registry.yarnpkg.com/react-fast-compare/-/react-fast-compare-3.2.2.tgz#929a97a532304ce9fee4bcae44234f1ce2c21d49" - integrity sha512-nsO+KSNgo1SbJqJEYRE9ERzo7YtYbou/OqjSQKxV7jcKox7+usiUVZOAC+XnDOABXggQTno0Y1CpVnuWEc1boQ== - -react-helmet-async@*: - version "2.0.4" - resolved "https://registry.yarnpkg.com/react-helmet-async/-/react-helmet-async-2.0.4.tgz#50a4377778f380ed1d0136303916b38eff1bf153" - integrity sha512-yxjQMWposw+akRfvpl5+8xejl4JtUlHnEBcji6u8/e6oc7ozT+P9PNTWMhCbz2y9tc5zPegw2BvKjQA+NwdEjQ== - dependencies: - invariant "^2.2.4" - react-fast-compare "^3.2.2" - shallowequal "^1.1.0" +react-fast-compare@^3.0.1, react-fast-compare@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/react-fast-compare/-/react-fast-compare-3.2.0.tgz#641a9da81b6a6320f270e89724fb45a0b39e43bb" + integrity sha512-rtGImPZ0YyLrscKI9xTpV8psd6I8VAtjKCzQDlzyDvqJA8XOW78TXYQwNRNd8g8JZnDu8q9Fu/1v4HPAVwVdHA== -react-helmet-async@^1.3.0: +react-helmet-async@*, react-helmet-async@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/react-helmet-async/-/react-helmet-async-1.3.0.tgz#7bd5bf8c5c69ea9f02f6083f14ce33ef545c222e" integrity sha512-9jZ57/dAn9t3q6hneQS0wukqC2ENOBgMNVEhb/ZG9ZSxUetzVIw4iAmEU38IaVg3QGYauQPhSeUTuIUtFglWpg== @@ -6989,9 +6881,9 @@ react-loadable-ssr-addon-v5-slorber@^1.0.1: "@babel/runtime" "^7.10.3" react-player@^2.12.0: - version "2.14.1" - resolved "https://registry.yarnpkg.com/react-player/-/react-player-2.14.1.tgz#fc434c0e1e6161e76f5d5970721596c4acec52b1" - integrity sha512-jILj7F9o+6NHzrJ1GqZIxfJgskvGmKeJ05FNhPvgiCpvMZFmFneKEkukywHcULDO2lqITm+zcEkLSq42mX0FbA== + version "2.12.0" + resolved "https://registry.yarnpkg.com/react-player/-/react-player-2.12.0.tgz#2fc05dbfec234c829292fbca563b544064bd14f0" + integrity sha512-rymLRz/2GJJD+Wc01S7S+i9pGMFYnNmQibR2gVE3KmHJCBNN8BhPAlOPTGZtn1uKpJ6p4RPLlzPQ1OLreXd8gw== dependencies: deepmerge "^4.0.0" load-script "^1.0.0" @@ -7035,11 +6927,11 @@ react-router@5.3.4, react-router@^5.3.3: tiny-warning "^1.0.0" react-textarea-autosize@^8.3.2: - version "8.5.3" - resolved "https://registry.yarnpkg.com/react-textarea-autosize/-/react-textarea-autosize-8.5.3.tgz#d1e9fe760178413891484847d3378706052dd409" - integrity sha512-XT1024o2pqCuZSuBt9FwHlaDeNtVrtCXu0Rnz88t1jUGheCLa3PhjE1GH8Ctm2axEtvdCl5SUHYschyQ0L5QHQ== + version "8.4.0" + resolved "https://registry.yarnpkg.com/react-textarea-autosize/-/react-textarea-autosize-8.4.0.tgz#4d0244d6a50caa897806b8c44abc0540a69bfc8c" + integrity sha512-YrTFaEHLgJsi8sJVYHBzYn+mkP3prGkmP2DKb/tm0t7CLJY5t1Rxix8070LAKb0wby7bl/lf2EeHkuMihMZMwQ== dependencies: - "@babel/runtime" "^7.20.13" + "@babel/runtime" "^7.10.2" use-composed-ref "^1.3.0" use-latest "^1.2.1" @@ -7074,10 +6966,19 @@ readable-stream@^2.0.1: string_decoder "~1.1.1" util-deprecate "~1.0.1" -readable-stream@^3.0.6, readable-stream@^3.1.1, readable-stream@^3.4.0: - version "3.6.2" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.2.tgz#56a9b36ea965c00c5a93ef31eb111a0f11056967" - integrity sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA== +readable-stream@^3.0.6: + version "3.6.1" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.1.tgz#f9f9b5f536920253b3d26e7660e7da4ccff9bb62" + integrity sha512-+rQmrWMYGA90yenhTYsLWAsLsqVC8osOw6PKE1HDYiO0gdPeKe/xDHNzIAIn4C91YQ6oenEhfYqqc1883qHbjQ== + dependencies: + inherits "^2.0.3" + string_decoder "^1.1.1" + util-deprecate "^1.0.1" + +readable-stream@^3.1.1, readable-stream@^3.4.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" + integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== dependencies: inherits "^2.0.3" string_decoder "^1.1.1" @@ -7110,9 +7011,9 @@ recursive-readdir@^2.2.2: minimatch "^3.0.5" regenerate-unicode-properties@^10.1.0: - version "10.1.1" - resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-10.1.1.tgz#6b0e05489d9076b04c436f318d9b067bba459480" - integrity sha512-X007RyZLsCJVVrjgEFVpLUTZwyOZk3oiL75ZcuYjlIWd6rNJtOjkBwQc5AsRrpbKVkxN6sklw/k/9m2jJYOf8Q== + version "10.1.0" + resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-10.1.0.tgz#7c3192cab6dd24e21cb4461e5ddd7dd24fa8374c" + integrity sha512-d1VudCLoIGitcU/hEg2QqvyGZQmdC0Lf8BqdOMXGFSvJP4bNV1+XqbPQeHHLD51Jh4QJJ225dlIFvY4Ly6MXmQ== dependencies: regenerate "^1.4.2" @@ -7121,22 +7022,22 @@ regenerate@^1.4.2: resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.2.tgz#b9346d8827e8f5a32f7ba29637d398b69014848a" integrity sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A== -regenerator-runtime@^0.14.0: - version "0.14.1" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz#356ade10263f685dda125100cd862c1db895327f" - integrity sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw== +regenerator-runtime@^0.13.11: + version "0.13.11" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz#f6dca3e7ceec20590d07ada785636a90cdca17f9" + integrity sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg== -regenerator-transform@^0.15.2: - version "0.15.2" - resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.15.2.tgz#5bbae58b522098ebdf09bca2f83838929001c7a4" - integrity sha512-hfMp2BoF0qOk3uc5V20ALGDS2ddjQaLrdl7xrGXvAIow7qeWRM2VA2HuCHkUKk9slq3VwEwLNK3DFBqDfPGYtg== +regenerator-transform@^0.15.1: + version "0.15.1" + resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.15.1.tgz#f6c4e99fc1b4591f780db2586328e4d9a9d8dc56" + integrity sha512-knzmNAcuyxV+gQCufkYcvOqX/qIIfHLv0u5x79kRxuGojfYVky1f15TzZEu2Avte8QGepvUNTnLskf8E6X6Vyg== dependencies: "@babel/runtime" "^7.8.4" regexpu-core@^5.3.1: - version "5.3.2" - resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-5.3.2.tgz#11a2b06884f3527aec3e93dbbf4a3b958a95546b" - integrity sha512-RAM5FlZz+Lhmo7db9L298p2vHP5ZywrVXmVXpmAD9GuL5MPH6t9ROw1iA/wfHkQ76Qe7AaPF0nGuim96/IrQMQ== + version "5.3.1" + resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-5.3.1.tgz#66900860f88def39a5cb79ebd9490e84f17bcdfb" + integrity sha512-nCOzW2V/X15XpLsK2rlgdwrysrBq+AauCn+omItIz4R1pIcmeot5zvjdmOBRLzEH/CkC6IxMJVmxDe3QcMuNVQ== dependencies: "@babel/regjsgen" "^0.8.0" regenerate "^1.4.2" @@ -7300,11 +7201,11 @@ resolve-pathname@^3.0.0: integrity sha512-C7rARubxI8bXFNB/hqcp/4iUeIXJhJZvFPFPiSPRnhU5UPxzMFIl+2E6yY6c4k9giDJAhtV+enfA+G89N6Csng== resolve@^1.1.6, resolve@^1.14.2, resolve@^1.3.2: - version "1.22.8" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.8.tgz#b6c87a9f2aa06dfab52e3d70ac8cde321fa5a48d" - integrity sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw== + version "1.22.1" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.1.tgz#27cb2ebb53f91abb49470a928bba7558066ac177" + integrity sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw== dependencies: - is-core-module "^2.13.0" + is-core-module "^2.9.0" path-parse "^1.0.7" supports-preserve-symlinks-flag "^1.0.0" @@ -7333,14 +7234,14 @@ rimraf@^3.0.2: glob "^7.1.3" robust-predicates@^3.0.0: - version "3.0.2" - resolved "https://registry.yarnpkg.com/robust-predicates/-/robust-predicates-3.0.2.tgz#d5b28528c4824d20fc48df1928d41d9efa1ad771" - integrity sha512-IXgzBWvWQwE6PrDI05OvmXUIruQTcoMDzRsOd5CDvHCVLcLHMTSYvOK5Cm46kWqlV3yAbuSpBZdJ5oP5OUoStg== + version "3.0.1" + resolved "https://registry.yarnpkg.com/robust-predicates/-/robust-predicates-3.0.1.tgz#ecde075044f7f30118682bd9fb3f123109577f9a" + integrity sha512-ndEIpszUHiG4HtDsQLeIuMvRsDnn8c8rYStabochtUeCvfuvNptb5TUbVD68LRAILPX7p9nqQGh4xJgn3EHS/g== rtl-detect@^1.0.4: - version "1.1.2" - resolved "https://registry.yarnpkg.com/rtl-detect/-/rtl-detect-1.1.2.tgz#ca7f0330af5c6bb626c15675c642ba85ad6273c6" - integrity sha512-PGMBq03+TTG/p/cRB7HCLKJ1MgDIi07+QU1faSjiYRfmY5UsAttV9Hs08jDAHVwcOwmVLcSJkpwyfXszVjWfIQ== + version "1.0.4" + resolved "https://registry.yarnpkg.com/rtl-detect/-/rtl-detect-1.0.4.tgz#40ae0ea7302a150b96bc75af7d749607392ecac6" + integrity sha512-EBR4I2VDSSYr7PkBmFy04uhycIpDKp+21p/jARYXlCSjQksTBQcJ0HFUPOO79EPPH5JS6VAhiIQbycf0O3JAxQ== rtlcss@^3.5.0: version "3.5.0" @@ -7364,7 +7265,14 @@ rw@1: resolved "https://registry.yarnpkg.com/rw/-/rw-1.3.3.tgz#3f862dfa91ab766b14885ef4d01124bfda074fb4" integrity sha512-PdhdWy89SiZogBLaw42zdeqtRJ//zFd2PgQavcICDUgJT5oW10QCRKbJ6bg4r0/UY2M6BWd5tkxuGFRvCkgfHQ== -rxjs@^7.5.4, rxjs@^7.8.1: +rxjs@^7.5.4: + version "7.8.0" + resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.8.0.tgz#90a938862a82888ff4c7359811a595e14e1e09a4" + integrity sha512-F2+gxDshqmIub1KdvZkaEfGDwLNpPvk9Fs6LD/MyQxNgMds/WH9OdDDXOmxUZpME+iSK3rQCctkL0DYyytUqMg== + dependencies: + tslib "^2.1.0" + +rxjs@^7.8.1: version "7.8.1" resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.8.1.tgz#6f6f3d99ea8044291efd92e7c7fcf562c4057543" integrity sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg== @@ -7387,9 +7295,9 @@ safe-buffer@5.2.1, safe-buffer@>=5.1.0, safe-buffer@^5.0.1, safe-buffer@^5.1.0, integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== sax@^1.2.4: - version "1.3.0" - resolved "https://registry.yarnpkg.com/sax/-/sax-1.3.0.tgz#a5dbe77db3be05c9d1ee7785dbd3ea9de51593d0" - integrity sha512-0s+oAmw9zLl1V1cS9BtZN7JAd0cW5e0QH4W3LWEK6a4LaLEA2OTpGYWDY+6XasBLtz6wkm3u1xRw95mRuJ59WA== + version "1.2.4" + resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" + integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw== scheduler@^0.20.2: version "0.20.2" @@ -7417,24 +7325,24 @@ schema-utils@^2.6.5: ajv "^6.12.4" ajv-keywords "^3.5.2" -schema-utils@^3.0.0, schema-utils@^3.1.1, schema-utils@^3.2.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-3.3.0.tgz#f50a88877c3c01652a15b622ae9e9795df7a60fe" - integrity sha512-pN/yOAvcC+5rQ5nERGuwrjLlYvLTbCibnZ1I7B1LaiAz9BRBlE9GMgE/eqV30P7aJQUf7Ddimy/RsbYO/GrVGg== +schema-utils@^3.0.0, schema-utils@^3.1.0, schema-utils@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-3.1.1.tgz#bc74c4b6b6995c1d88f76a8b77bea7219e0c8281" + integrity sha512-Y5PQxS4ITlC+EahLuXaY86TXfR7Dc5lw294alXOq86JAHCihAIZfqv8nNCWvaEJvaC51uN9hbLGeV0cFBdH+Fw== dependencies: "@types/json-schema" "^7.0.8" ajv "^6.12.5" ajv-keywords "^3.5.2" schema-utils@^4.0.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-4.2.0.tgz#70d7c93e153a273a805801882ebd3bff20d89c8b" - integrity sha512-L0jRsrPpjdckP3oPug3/VxNKt2trR8TcabrM6FOAAlvC/9Phcmm+cuAgTlxBqdBR1WJx7Naj9WHw+aOmheSVbw== + version "4.0.0" + resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-4.0.0.tgz#60331e9e3ae78ec5d16353c467c34b3a0a1d3df7" + integrity sha512-1edyXKgh6XnJsJSQ8mKWXnN/BVaIbFMLpouRUrXgVq7WYne5kw3MW7UPhO44uRXQSIpTSXoJbmrR2X0w9kUTyg== dependencies: "@types/json-schema" "^7.0.9" - ajv "^8.9.0" + ajv "^8.8.0" ajv-formats "^2.1.1" - ajv-keywords "^5.1.0" + ajv-keywords "^5.0.0" section-matter@^1.0.0: version "1.0.0" @@ -7450,11 +7358,10 @@ select-hose@^2.0.0: integrity sha512-mEugaLK+YfkijB4fx0e6kImuJdCIt2LxCRcbEYPqRGCs4F2ogyfZU5IAZRdjCP8JPq2AtdNoC/Dux63d9Kiryg== selfsigned@^2.1.1: - version "2.4.1" - resolved "https://registry.yarnpkg.com/selfsigned/-/selfsigned-2.4.1.tgz#560d90565442a3ed35b674034cec4e95dceb4ae0" - integrity sha512-th5B4L2U+eGLq1TVh7zNRGBapioSORUeymIydxgFpwww9d2qyKvtuPU2jJuHvYAwwqi2Y596QBL3eEqcPEYL8Q== + version "2.1.1" + resolved "https://registry.yarnpkg.com/selfsigned/-/selfsigned-2.1.1.tgz#18a7613d714c0cd3385c48af0075abf3f266af61" + integrity sha512-GSL3aowiF7wa/WtSFwnUrludWFoNhftq8bUkH9pkzjpN2XSPOAYEgg6e0sS9s0rZwgJzJiQRPU18A6clnoW5wQ== dependencies: - "@types/node-forge" "^1.3.0" node-forge "^1" semver-diff@^3.1.1: @@ -7465,16 +7372,23 @@ semver-diff@^3.1.1: semver "^6.3.0" semver@^5.4.1: - version "5.7.2" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8" - integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g== + version "5.7.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" + integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== -semver@^6.0.0, semver@^6.2.0, semver@^6.3.0, semver@^6.3.1: - version "6.3.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4" - integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== +semver@^6.0.0, semver@^6.1.1, semver@^6.1.2, semver@^6.2.0, semver@^6.3.0: + version "6.3.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" + integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== -semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7, semver@^7.5.3, semver@^7.5.4: +semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7, semver@^7.3.8: + version "7.3.8" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.8.tgz#07a78feafb3f7b32347d725e33de7e2a2df67798" + integrity sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A== + dependencies: + lru-cache "^6.0.0" + +semver@^7.5.3: version "7.5.4" resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e" integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA== @@ -7500,10 +7414,10 @@ send@0.18.0: range-parser "~1.2.1" statuses "2.0.1" -serialize-javascript@^6.0.0, serialize-javascript@^6.0.1: - version "6.0.2" - resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.2.tgz#defa1e055c83bf6d59ea805d8da862254eb6a6c2" - integrity sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g== +serialize-javascript@^6.0.0: + version "6.0.1" + resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.1.tgz#b206efb27c3da0b0ab6b52f48d170b7996458e5c" + integrity sha512-owoXEFjWRllis8/M1Q+Cw5k8ZH40e3zhp/ovX+Xr/vi1qj6QesbyXXViFbpNvWvPNAD62SutwEXavefrLJWj7w== dependencies: randombytes "^2.1.0" @@ -7544,17 +7458,6 @@ serve-static@1.15.0: parseurl "~1.3.3" send "0.18.0" -set-function-length@^1.1.1: - version "1.2.0" - resolved "https://registry.yarnpkg.com/set-function-length/-/set-function-length-1.2.0.tgz#2f81dc6c16c7059bda5ab7c82c11f03a515ed8e1" - integrity sha512-4DBHDoyHlM1IRPGYcoxexgh67y4ueR53FKV1yyxwFMY7aCqcN/38M1+SwZ/qJQ8iLv7+ck385ot4CcisOAPT9w== - dependencies: - define-data-property "^1.1.1" - function-bind "^1.1.2" - get-intrinsic "^1.2.2" - gopd "^1.0.1" - has-property-descriptors "^1.0.1" - setimmediate@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" @@ -7608,7 +7511,12 @@ shebang-regex@^3.0.0: resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== -shell-quote@^1.7.3, shell-quote@^1.8.1: +shell-quote@^1.7.3: + version "1.8.0" + resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.8.0.tgz#20d078d0eaf71d54f43bd2ba14a1b5b9bfa5c8ba" + integrity sha512-QHsz8GgQIGKlRi24yFc6a6lN69Idnx634w49ay6+jA5yFh7a1UY+4Rp6HPx/L/1zcEDPEij8cIsiqR6bQsE5VQ== + +shell-quote@^1.8.1: version "1.8.1" resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.8.1.tgz#6dbf4db75515ad5bac63b4f1894c3a154c766680" integrity sha512-6j1W9l1iAs/4xYBI1SYOVZyFcCis9b4KCLQ8fgAGG07QvzaRLVVRQvAy85yNmmZSjYjg4MWh4gNvlPujU/5LpA== @@ -7622,10 +7530,10 @@ shelljs@^0.8.5: interpret "^1.0.0" rechoir "^0.6.2" -shiki@^0.14.7: - version "0.14.7" - resolved "https://registry.yarnpkg.com/shiki/-/shiki-0.14.7.tgz#c3c9e1853e9737845f1d2ef81b31bcfb07056d4e" - integrity sha512-dNPAPrxSc87ua2sKJ3H5dQ/6ZaY8RNnaAqK+t0eG7p0Soi2ydiqbGOTaZCqaYvA/uZYfS1LJnemt3Q+mSfcPCg== +shiki@^0.14.1: + version "0.14.4" + resolved "https://registry.yarnpkg.com/shiki/-/shiki-0.14.4.tgz#2454969b466a5f75067d0f2fa0d7426d32881b20" + integrity sha512-IXCRip2IQzKwxArNNq1S+On4KPML3Yyn8Zzs/xRgcgOWIr8ntIK3IKzjFPfjy/7kt9ZMjc+FItfqHRBg8b6tNQ== dependencies: ansi-sequence-parser "^1.1.0" jsonc-parser "^3.2.0" @@ -7674,14 +7582,14 @@ simple-update-notifier@^2.0.0: dependencies: semver "^7.5.3" -sirv@^2.0.3: - version "2.0.4" - resolved "https://registry.yarnpkg.com/sirv/-/sirv-2.0.4.tgz#5dd9a725c578e34e449f332703eb2a74e46a29b0" - integrity sha512-94Bdh3cC2PKrbgSOUqTiGPWVZeSiXfKOVZNJniWoqrWrRkB1CJzBU3NEbiTsPcYy1lDsANA/THzS+9WBiy5nfQ== +sirv@^1.0.7: + version "1.0.19" + resolved "https://registry.yarnpkg.com/sirv/-/sirv-1.0.19.tgz#1d73979b38c7fe91fcba49c85280daa9c2363b49" + integrity sha512-JuLThK3TnZG1TAKDwNIqNq6QA2afLOCcm+iE8D1Kj3GA40pSPsxQjjJl0J8X3tsR7T+CP1GavpzLwYkgVLWrZQ== dependencies: - "@polka/url" "^1.0.0-next.24" - mrmime "^2.0.0" - totalist "^3.0.0" + "@polka/url" "^1.0.0-next.20" + mrmime "^1.0.0" + totalist "^1.0.0" sisteransi@^1.0.5: version "1.0.5" @@ -7804,9 +7712,9 @@ statuses@2.0.1: integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA== std-env@^3.0.1: - version "3.7.0" - resolved "https://registry.yarnpkg.com/std-env/-/std-env-3.7.0.tgz#c9f7386ced6ecf13360b6c6c55b8aaa4ef7481d2" - integrity sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg== + version "3.3.2" + resolved "https://registry.yarnpkg.com/std-env/-/std-env-3.3.2.tgz#af27343b001616015534292178327b202b9ee955" + integrity sha512-uUZI65yrV2Qva5gqE0+A7uVAvO40iPo6jGhs7s8keRfHCmtg+uB2X6EiLGCI9IgL1J17xGhvoOqSz79lzICPTA== string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3: version "4.2.3" @@ -7857,9 +7765,9 @@ strip-ansi@^6.0.0, strip-ansi@^6.0.1: ansi-regex "^5.0.1" strip-ansi@^7.0.1: - version "7.1.0" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" - integrity sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ== + version "7.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.0.1.tgz#61740a08ce36b61e50e65653f07060d000975fb2" + integrity sha512-cXNxvT8dFNRVfhVME3JAe98mkXDYN2O1l7jmcwMnOslDeESg1rF/OZMtK0nRAhiari1unG5cD4jG3rapUAkLbw== dependencies: ansi-regex "^6.0.1" @@ -7899,9 +7807,9 @@ stylehacks@^5.1.1: postcss-selector-parser "^6.0.4" stylis@^4.1.2: - version "4.3.1" - resolved "https://registry.yarnpkg.com/stylis/-/stylis-4.3.1.tgz#ed8a9ebf9f76fe1e12d462f5cc3c4c980b23a7eb" - integrity sha512-EQepAV+wMsIaGVGX1RECzgrcqRRU/0sYOHkeLsZ3fzHaHXZy4DaOOX0vOlGQdlsjkh3mFHAIlVimpwAs4dslyQ== + version "4.1.3" + resolved "https://registry.yarnpkg.com/stylis/-/stylis-4.1.3.tgz#fd2fbe79f5fed17c55269e16ed8da14c84d069f7" + integrity sha512-GP6WDNWf+o403jrEp9c5jibKavrtLW+/qYGhFxFrG8maXhwTBI7gLLhiBb0o7uFccWN+EOS9aMO6cGHWAO07OA== supports-color@^5.3.0, supports-color@^5.5.0: version "5.5.0" @@ -7978,24 +7886,24 @@ tar-stream@^2.1.4: inherits "^2.0.3" readable-stream "^3.1.1" -terser-webpack-plugin@^5.3.3, terser-webpack-plugin@^5.3.7: - version "5.3.10" - resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-5.3.10.tgz#904f4c9193c6fd2a03f693a2150c62a92f40d199" - integrity sha512-BKFPWlPDndPs+NGGCr1U59t0XScL5317Y0UReNrHaw9/FwhPENlq6bfgs+4yPfyP51vqC1bQ4rp1EfXW5ZSH9w== +terser-webpack-plugin@^5.1.3, terser-webpack-plugin@^5.3.3: + version "5.3.6" + resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-5.3.6.tgz#5590aec31aa3c6f771ce1b1acca60639eab3195c" + integrity sha512-kfLFk+PoLUQIbLmB1+PZDMRSZS99Mp+/MHqDNmMA6tOItzRt+Npe3E+fsMs5mfcM0wCtrrdU387UnV+vnSffXQ== dependencies: - "@jridgewell/trace-mapping" "^0.3.20" + "@jridgewell/trace-mapping" "^0.3.14" jest-worker "^27.4.5" schema-utils "^3.1.1" - serialize-javascript "^6.0.1" - terser "^5.26.0" + serialize-javascript "^6.0.0" + terser "^5.14.1" -terser@^5.10.0, terser@^5.26.0: - version "5.27.0" - resolved "https://registry.yarnpkg.com/terser/-/terser-5.27.0.tgz#70108689d9ab25fef61c4e93e808e9fd092bf20c" - integrity sha512-bi1HRwVRskAjheeYl291n3JC4GgO/Ty4z1nVs5AAsmonJulGxpSektecnNedrwK9C7vpvVtcX3cw00VSLt7U2A== +terser@^5.10.0, terser@^5.14.1: + version "5.16.5" + resolved "https://registry.yarnpkg.com/terser/-/terser-5.16.5.tgz#1c285ca0655f467f92af1bbab46ab72d1cb08e5a" + integrity sha512-qcwfg4+RZa3YvlFh0qjifnzBHjKGNbtDo9yivMqMFDy9Q6FSaQWSB/j1xKhsoUFJIqDOM3TsN6D5xbrMrFcHbg== dependencies: - "@jridgewell/source-map" "^0.3.3" - acorn "^8.8.2" + "@jridgewell/source-map" "^0.3.2" + acorn "^8.5.0" commander "^2.20.0" source-map-support "~0.5.20" @@ -8041,10 +7949,10 @@ toidentifier@1.0.1: resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35" integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA== -totalist@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/totalist/-/totalist-3.0.1.tgz#ba3a3d600c915b1a97872348f79c127475f6acf8" - integrity sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ== +totalist@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/totalist/-/totalist-1.1.0.tgz#a4d65a3e546517701e3e5c37a47a70ac97fe56df" + integrity sha512-gduQwd1rOdDMGxFG1gEvhV88Oirdo2p+KjoYFU7k2g+i7n6AFFbDQ5kMPUsW0pNbfQsB/cwXvT1i4Bue0s9g5g== touch@^3.1.0: version "3.1.0" @@ -8084,9 +7992,9 @@ ts-dedent@^2.2.0: integrity sha512-q5W7tVM71e2xjHZTlgfTDoPF/SmqKG5hddq9SzR49CH2hayqRKJtQ4mtRlSxKaJlR/+9rEM+mnBHf7I2/BQcpQ== tslib@^2.0.3, tslib@^2.1.0, tslib@^2.4.0: - version "2.6.2" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" - integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q== + version "2.5.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.5.0.tgz#42bfed86f5787aeb41d031866c8f402429e0fddf" + integrity sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg== tunnel-agent@^0.6.0: version "0.6.0" @@ -8121,31 +8029,31 @@ typedarray-to-buffer@^3.1.5: is-typedarray "^1.0.0" typedoc-plugin-markdown@^3.16.0: - version "3.17.1" - resolved "https://registry.yarnpkg.com/typedoc-plugin-markdown/-/typedoc-plugin-markdown-3.17.1.tgz#c33f42363c185adf842f4699166015f7fe0ed02b" - integrity sha512-QzdU3fj0Kzw2XSdoL15ExLASt2WPqD7FbLeaqwT70+XjKyTshBnUlQA5nNREO1C2P8Uen0CDjsBLMsCQ+zd0lw== + version "3.16.0" + resolved "https://registry.yarnpkg.com/typedoc-plugin-markdown/-/typedoc-plugin-markdown-3.16.0.tgz#98da250271aafade8b6740a8116a97cd3941abcd" + integrity sha512-eeiC78fDNGFwemPIHiwRC+mEC7W5jwt3fceUev2gJ2nFnXpVHo8eRrpC9BLWZDee6ehnz/sPmNjizbXwpfaTBw== dependencies: handlebars "^4.7.7" typedoc@^0.25.1: - version "0.25.7" - resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.25.7.tgz#11e3f527ca80ca3c029cb8e15f362e6d9f715e25" - integrity sha512-m6A6JjQRg39p2ZVRIN3NKXgrN8vzlHhOS+r9ymUYtcUP/TIQPvWSq7YgE5ZjASfv5Vd5BW5xrir6Gm2XNNcOow== + version "0.25.1" + resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.25.1.tgz#50de2d8fb93623fbfb59e2fa6407ff40e3d3f438" + integrity sha512-c2ye3YUtGIadxN2O6YwPEXgrZcvhlZ6HlhWZ8jQRNzwLPn2ylhdGqdR8HbyDRyALP8J6lmSANILCkkIdNPFxqA== dependencies: lunr "^2.3.9" marked "^4.3.0" minimatch "^9.0.3" - shiki "^0.14.7" + shiki "^0.14.1" typescript@^5.0.4: - version "5.3.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.3.3.tgz#b3ce6ba258e72e6305ba66f5c9b452aaee3ffe37" - integrity sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw== + version "5.2.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.2.2.tgz#5ebb5e5a5b75f085f22bc3f8460fba308310fa78" + integrity sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w== -ua-parser-js@^1.0.35: - version "1.0.37" - resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-1.0.37.tgz#b5dc7b163a5c1f0c510b08446aed4da92c46373f" - integrity sha512-bhTyI94tZofjo+Dn8SN6Zv8nBDvyXTymAdM3LDI/0IboIUwTu1rEhW7v2TfiVsoYWgkQ4kOVqnI8APUFbIQIFQ== +ua-parser-js@^0.7.30: + version "0.7.36" + resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.36.tgz#382c5d6fc09141b6541be2cae446ecfcec284db2" + integrity sha512-CPPLoCts2p7D8VbybttE3P2ylv0OBZEAy7a12DsulIEcAiMtWJy+PBgMXgWDI80D5UwqE8oQPHYnk13tm38M2Q== uglify-js@^3.1.4: version "3.17.4" @@ -8157,11 +8065,6 @@ undefsafe@^2.0.5: resolved "https://registry.yarnpkg.com/undefsafe/-/undefsafe-2.0.5.tgz#38733b9327bdcd226db889fb723a6efd162e6e2c" integrity sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA== -undici-types@~5.26.4: - version "5.26.5" - resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" - integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== - unherit@^1.0.4: version "1.1.3" resolved "https://registry.yarnpkg.com/unherit/-/unherit-1.1.3.tgz#6c9b503f2b41b262330c80e91c8614abdaa69c22" @@ -8290,19 +8193,19 @@ unist-util-visit@2.0.3, unist-util-visit@^2.0.0, unist-util-visit@^2.0.3: unist-util-visit-parents "^3.0.0" universalify@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.1.tgz#168efc2180964e6386d061e094df61afe239b18d" - integrity sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw== + version "2.0.0" + resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717" + integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ== unpipe@1.0.0, unpipe@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" integrity sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ== -update-browserslist-db@^1.0.13: - version "1.0.13" - resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz#3c5e4f5c083661bd38ef64b6328c26ed6c8248c4" - integrity sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg== +update-browserslist-db@^1.0.10: + version "1.0.10" + resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.0.10.tgz#0f54b876545726f17d00cd9a2561e6dade943ff3" + integrity sha512-OztqDenkfFkbSG+tRxBeAnCVPckDBcvibKd35yDONx6OU8N7sqgwc7rCbkJ/WcYtVRZ4ba68d6byhC21GFh7sQ== dependencies: escalade "^3.1.1" picocolors "^1.0.0" @@ -8383,9 +8286,9 @@ utila@~0.4: integrity sha512-Z0DbgELS9/L/75wZbro8xAnT50pBVFQZ+hUEueGDU5FN51YSCYM+jdxsfCiHjwNP/4LCDD0i/graKpeBnOXKRA== utility-types@^3.10.0: - version "3.11.0" - resolved "https://registry.yarnpkg.com/utility-types/-/utility-types-3.11.0.tgz#607c40edb4f258915e901ea7995607fdf319424c" - integrity sha512-6Z7Ma2aVEWisaL6TvBCy7P8rm2LQoPv6dJ7ecIaIixHcwfbJ0x7mWdbcwlIM5IGQxPZSFYeqRCqlOOeKoJYMkw== + version "3.10.0" + resolved "https://registry.yarnpkg.com/utility-types/-/utility-types-3.10.0.tgz#ea4148f9a741015f05ed74fd615e1d20e6bed82b" + integrity sha512-O11mqxmi7wMKCo6HKFt5AhO4BwY3VV68YU07tgxfz8zJTIxr4BpsezN49Ffwy9j3ZpwwJp4fkRwjRzq3uWE6Rg== utils-merge@1.0.1: version "1.0.1" @@ -8398,9 +8301,9 @@ uuid@^8.3.2: integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== uuid@^9.0.0: - version "9.0.1" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.1.tgz#e188d4c8853cc722220392c424cd637f32293f30" - integrity sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA== + version "9.0.0" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.0.tgz#592f550650024a38ceb0c562f2f6aa435761efb5" + integrity sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg== value-equal@^1.0.1: version "1.0.1" @@ -8477,9 +8380,9 @@ web-namespaces@^1.0.0: integrity sha512-wYxSGajtmoP4WxfejAPIr4l0fVh+jeMXZb08wNc0tMg6xsfZXj3cECqIK0G7ZAqUq0PP8WlMDtaOGVBTAWztNw== web-worker@^1.2.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/web-worker/-/web-worker-1.3.0.tgz#e5f2df5c7fe356755a5fb8f8410d4312627e6776" - integrity sha512-BSR9wyRsy/KOValMgd5kMyr3JzpdeoR9KVId8u5GVlTTAtNChlsE4yTxeY7zMdNSyOmoKBv8NH2qeRY9Tg+IaA== + version "1.2.0" + resolved "https://registry.yarnpkg.com/web-worker/-/web-worker-1.2.0.tgz#5d85a04a7fbc1e7db58f66595d7a3ac7c9c180da" + integrity sha512-PgF341avzqyx60neE9DD+XS26MMNMoUQRz9NOZwW32nPQrF6p77f1htcnjBSEV8BGMKZ16choqUG4hyI0Hx7mA== webidl-conversions@^3.0.0: version "3.0.1" @@ -8487,22 +8390,19 @@ webidl-conversions@^3.0.0: integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== webpack-bundle-analyzer@^4.5.0: - version "4.10.1" - resolved "https://registry.yarnpkg.com/webpack-bundle-analyzer/-/webpack-bundle-analyzer-4.10.1.tgz#84b7473b630a7b8c21c741f81d8fe4593208b454" - integrity sha512-s3P7pgexgT/HTUSYgxJyn28A+99mmLq4HsJepMPzu0R8ImJc52QNqaFYW1Z2z2uIb1/J3eYgaAWVpaC+v/1aAQ== + version "4.8.0" + resolved "https://registry.yarnpkg.com/webpack-bundle-analyzer/-/webpack-bundle-analyzer-4.8.0.tgz#951b8aaf491f665d2ae325d8b84da229157b1d04" + integrity sha512-ZzoSBePshOKhr+hd8u6oCkZVwpVaXgpw23ScGLFpR6SjYI7+7iIWYarjN6OEYOfRt8o7ZyZZQk0DuMizJ+LEIg== dependencies: "@discoveryjs/json-ext" "0.5.7" acorn "^8.0.4" acorn-walk "^8.0.0" + chalk "^4.1.0" commander "^7.2.0" - debounce "^1.2.1" - escape-string-regexp "^4.0.0" gzip-size "^6.0.0" - html-escaper "^2.0.2" - is-plain-object "^5.0.0" + lodash "^4.17.20" opener "^1.5.2" - picocolors "^1.0.0" - sirv "^2.0.3" + sirv "^1.0.7" ws "^7.3.1" webpack-dev-middleware@^5.3.1: @@ -8517,9 +8417,9 @@ webpack-dev-middleware@^5.3.1: schema-utils "^4.0.0" webpack-dev-server@^4.9.3: - version "4.15.1" - resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-4.15.1.tgz#8944b29c12760b3a45bdaa70799b17cb91b03df7" - integrity sha512-5hbAst3h3C3L8w6W4P96L5vaV0PxSmJhxZvWKYIdgxOQm8pNZ5dEOmmSLBVpP85ReeyRt6AS1QJNyo/oFFPeVA== + version "4.11.1" + resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-4.11.1.tgz#ae07f0d71ca0438cf88446f09029b92ce81380b5" + integrity sha512-lILVz9tAUy1zGFwieuaQtYiadImb5M3d+H+L1zDYalYoDl0cksAB1UNyuE5MMWJrG6zR1tXkCP2fitl7yoUJiw== dependencies: "@types/bonjour" "^3.5.9" "@types/connect-history-api-fallback" "^1.3.5" @@ -8527,7 +8427,7 @@ webpack-dev-server@^4.9.3: "@types/serve-index" "^1.9.1" "@types/serve-static" "^1.13.10" "@types/sockjs" "^0.3.33" - "@types/ws" "^8.5.5" + "@types/ws" "^8.5.1" ansi-html-community "^0.0.8" bonjour-service "^1.0.11" chokidar "^3.5.3" @@ -8540,7 +8440,6 @@ webpack-dev-server@^4.9.3: html-entities "^2.3.2" http-proxy-middleware "^2.0.3" ipaddr.js "^2.0.1" - launch-editor "^2.6.0" open "^8.0.9" p-retry "^4.5.0" rimraf "^3.0.2" @@ -8550,15 +8449,14 @@ webpack-dev-server@^4.9.3: sockjs "^0.3.24" spdy "^4.0.2" webpack-dev-middleware "^5.3.1" - ws "^8.13.0" + ws "^8.4.2" webpack-merge@^5.8.0: - version "5.10.0" - resolved "https://registry.yarnpkg.com/webpack-merge/-/webpack-merge-5.10.0.tgz#a3ad5d773241e9c682803abf628d4cd62b8a4177" - integrity sha512-+4zXKdx7UnO+1jaN4l2lHVD+mFvnlZQP/6ljaJVb4SZiwIKeUnrT5l0gkT8z+n4hKpC+jpOv6O9R+gLtag7pSA== + version "5.8.0" + resolved "https://registry.yarnpkg.com/webpack-merge/-/webpack-merge-5.8.0.tgz#2b39dbf22af87776ad744c390223731d30a68f61" + integrity sha512-/SaI7xY0831XwP6kzuwhKWVKDP9t1QY1h65lAFLbZqMPIuYcD9QAW4u9STIbU9kaJbPBB/geU/gLr1wDjOhQ+Q== dependencies: clone-deep "^4.0.1" - flat "^5.0.2" wildcard "^2.0.0" webpack-sources@^3.2.2, webpack-sources@^3.2.3: @@ -8567,21 +8465,21 @@ webpack-sources@^3.2.2, webpack-sources@^3.2.3: integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w== webpack@^5.73.0: - version "5.89.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.89.0.tgz#56b8bf9a34356e93a6625770006490bf3a7f32dc" - integrity sha512-qyfIC10pOr70V+jkmud8tMfajraGCZMBWJtrmuBymQKCrLTRejBI8STDp1MCyZu/QTdZSeacCQYpYNQVOzX5kw== + version "5.76.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.76.0.tgz#f9fb9fb8c4a7dbdcd0d56a98e56b8a942ee2692c" + integrity sha512-l5sOdYBDunyf72HW8dF23rFtWq/7Zgvt/9ftMof71E/yUb1YLOBmTgA2K4vQthB3kotMrSj609txVE0dnr2fjA== dependencies: "@types/eslint-scope" "^3.7.3" - "@types/estree" "^1.0.0" - "@webassemblyjs/ast" "^1.11.5" - "@webassemblyjs/wasm-edit" "^1.11.5" - "@webassemblyjs/wasm-parser" "^1.11.5" + "@types/estree" "^0.0.51" + "@webassemblyjs/ast" "1.11.1" + "@webassemblyjs/wasm-edit" "1.11.1" + "@webassemblyjs/wasm-parser" "1.11.1" acorn "^8.7.1" - acorn-import-assertions "^1.9.0" + acorn-import-assertions "^1.7.6" browserslist "^4.14.5" chrome-trace-event "^1.0.2" - enhanced-resolve "^5.15.0" - es-module-lexer "^1.2.1" + enhanced-resolve "^5.10.0" + es-module-lexer "^0.9.0" eslint-scope "5.1.1" events "^3.2.0" glob-to-regexp "^0.4.1" @@ -8590,9 +8488,9 @@ webpack@^5.73.0: loader-runner "^4.2.0" mime-types "^2.1.27" neo-async "^2.6.2" - schema-utils "^3.2.0" + schema-utils "^3.1.0" tapable "^2.1.1" - terser-webpack-plugin "^5.3.7" + terser-webpack-plugin "^5.1.3" watchpack "^2.4.0" webpack-sources "^3.2.3" @@ -8657,9 +8555,9 @@ widest-line@^4.0.1: string-width "^5.0.1" wildcard@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/wildcard/-/wildcard-2.0.1.tgz#5ab10d02487198954836b6349f74fff961e10f67" - integrity sha512-CC1bOL87PIWSBhDcTrdeLo6eGT7mCFtrg0uIJtqJUFyK+eJnzl8A1niH56uu7KMa5XFrtiV+AQuHO3n7DsHnLQ== + version "2.0.0" + resolved "https://registry.yarnpkg.com/wildcard/-/wildcard-2.0.0.tgz#a77d20e5200c6faaac979e4b3aadc7b3dd7f8fec" + integrity sha512-JcKqAHLPxcdb9KM49dufGXn2x3ssnfjbcaQdLlfZsL9rH9wgDQjUtDxbo8NE0F6SFvydeu1VhZe7hZuHsB2/pw== wordwrap@^1.0.0: version "1.0.0" @@ -8704,10 +8602,10 @@ ws@^7.3.1: resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.9.tgz#54fa7db29f4c7cec68b1ddd3a89de099942bb591" integrity sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q== -ws@^8.13.0: - version "8.16.0" - resolved "https://registry.yarnpkg.com/ws/-/ws-8.16.0.tgz#d1cd774f36fbc07165066a60e40323eab6446fd4" - integrity sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ== +ws@^8.4.2: + version "8.12.1" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.12.1.tgz#c51e583d79140b5e42e39be48c934131942d4a8f" + integrity sha512-1qo+M9Ba+xNhPB+YTWUlK6M17brTut5EXbcBaMRN5pH5dFrXz7lzz1ChFSUq3bOUl8yEvSenhHmYUNJxFzdJew== xdg-basedir@^4.0.0: version "4.0.0" diff --git a/l1-contracts/src/core/libraries/ConstantsGen.sol b/l1-contracts/src/core/libraries/ConstantsGen.sol index e8eb5f3c5c0a..4b0aecbc3ce4 100644 --- a/l1-contracts/src/core/libraries/ConstantsGen.sol +++ b/l1-contracts/src/core/libraries/ConstantsGen.sol @@ -62,7 +62,7 @@ library Constants { uint256 internal constant ARGS_HASH_CHUNK_LENGTH = 32; uint256 internal constant ARGS_HASH_CHUNK_COUNT = 16; uint256 internal constant L1_TO_L2_MESSAGE_LENGTH = 8; - uint256 internal constant L1_TO_L2_MESSAGE_ORACLE_CALL_LENGTH = 25; + uint256 internal constant L1_TO_L2_MESSAGE_ORACLE_CALL_LENGTH = 26; uint256 internal constant MAX_NOTE_FIELDS_LENGTH = 20; uint256 internal constant GET_NOTE_ORACLE_RETURN_LENGTH = 23; uint256 internal constant MAX_NOTES_PER_PAGE = 10; diff --git a/l1-contracts/test/portals/TokenPortal.sol b/l1-contracts/test/portals/TokenPortal.sol index 421199522646..ccd6661ea832 100644 --- a/l1-contracts/test/portals/TokenPortal.sol +++ b/l1-contracts/test/portals/TokenPortal.sol @@ -1,3 +1,4 @@ +// docs:start:init pragma solidity >=0.8.18; import {IERC20} from "@oz/token/ERC20/IERC20.sol"; @@ -11,7 +12,6 @@ import {DataStructures} from "../../src/core/libraries/DataStructures.sol"; import {Hash} from "../../src/core/libraries/Hash.sol"; // docs:end:content_hash_sol_import -// docs:start:init contract TokenPortal { using SafeERC20 for IERC20; diff --git a/noir/.github/actions/setup/action.yml b/noir/.github/actions/setup/action.yml index b265a63d29ab..8e24b6738a9e 100644 --- a/noir/.github/actions/setup/action.yml +++ b/noir/.github/actions/setup/action.yml @@ -4,7 +4,7 @@ description: Installs the workspace's yarn dependencies and caches them runs: using: composite steps: - - uses: actions/setup-node@v4 + - uses: actions/setup-node@v3 id: node with: node-version: 18.17.1 diff --git a/noir/.github/workflows/docs-dead-links.yml b/noir/.github/workflows/docs-dead-links.yml index 40e948fe2c17..ffb18fa0eb28 100644 --- a/noir/.github/workflows/docs-dead-links.yml +++ b/noir/.github/workflows/docs-dead-links.yml @@ -29,7 +29,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} WORKFLOW_NAME: ${{ github.workflow }} - WORKFLOW_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + WORKFLOW_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/job/${{ github.job }} with: update_existing: true filename: .github/DEAD_LINKS_IN_DOCS.md diff --git a/noir/.github/workflows/docs-pr.yml b/noir/.github/workflows/docs-pr.yml index f4a1be826a8d..a16487a49efb 100644 --- a/noir/.github/workflows/docs-pr.yml +++ b/noir/.github/workflows/docs-pr.yml @@ -11,7 +11,7 @@ jobs: steps: - name: Check if label is present id: check-labels - uses: actions/github-script@v7.0.1 + uses: actions/github-script@v3 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | @@ -21,11 +21,10 @@ jobs: } // Fetch the list of files changed in the PR - const { data: files } = await github.rest.pulls.listFiles({ + const { data: files } = await github.pulls.listFiles({ owner: context.repo.owner, repo: context.repo.repo, - pull_number: context.issue.number, - per_page: 100 + pull_number: context.issue.number }); // Check if any file is within the 'docs' folder @@ -34,13 +33,13 @@ jobs: - name: Add label if not present if: steps.check-labels.outputs.result == 'true' - uses: actions/github-script@v7.0.1 + uses: actions/github-script@v3 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | const labels = context.payload.pull_request.labels.map(label => label.name); if (!labels.includes('documentation')) { - github.rest.issues.addLabels({ + github.issues.addLabels({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, @@ -48,14 +47,20 @@ jobs: }) } - build_preview: + build_and_deploy_preview: runs-on: ubuntu-latest + permissions: + pull-requests: write + needs: add_label + if: needs.add_label.outputs.has_label == 'true' steps: - name: Checkout code uses: actions/checkout@v4 - - name: Install Yarn dependencies - uses: ./.github/actions/setup + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: '18' - name: Install wasm-bindgen-cli uses: taiki-e/install-action@v2 @@ -66,34 +71,13 @@ jobs: run: | npm i wasm-opt -g + - name: Install Yarn dependencies + uses: ./.github/actions/setup + - name: Build docs run: - yarn workspaces foreach -Rpt --from docs run build - - - name: Upload artifact - uses: actions/upload-artifact@v3 - with: - name: docs - path: ./docs/build/ - retention-days: 3 + yarn workspaces foreach -Rt run build - - deploy_preview: - needs: [build_preview, add_label] - runs-on: ubuntu-latest - permissions: - pull-requests: write - if: needs.add_label.outputs.has_label == 'true' - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Download built docs - uses: actions/download-artifact@v3 - with: - name: docs - path: ./docs/build - - name: Deploy to Netlify uses: nwtgck/actions-netlify@v2.1 with: diff --git a/noir/.github/workflows/publish-docs.yml b/noir/.github/workflows/publish-docs.yml index 231b57550c97..07b39d7627cf 100644 --- a/noir/.github/workflows/publish-docs.yml +++ b/noir/.github/workflows/publish-docs.yml @@ -15,8 +15,10 @@ jobs: - name: Checkout release branch uses: actions/checkout@v4 - - name: Install Yarn dependencies - uses: ./.github/actions/setup + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: '18' - name: Install wasm-bindgen-cli uses: taiki-e/install-action@v2 @@ -27,6 +29,9 @@ jobs: run: | npm i wasm-opt -g + - name: Install Yarn dependencies + uses: ./.github/actions/setup + - name: Build docs for deploying working-directory: docs run: diff --git a/noir/.github/workflows/release.yml b/noir/.github/workflows/release.yml index 22a733b38c58..f9f6fe2fc540 100644 --- a/noir/.github/workflows/release.yml +++ b/noir/.github/workflows/release.yml @@ -44,15 +44,6 @@ jobs: run: | cargo update --workspace - - uses: actions/setup-node@v3 - with: - node-version: 18.17.1 - cache: 'yarn' - cache-dependency-path: 'yarn.lock' - - - name: Update yarn.lock - run: yarn - - name: Configure git run: | git config user.name kevaundray @@ -77,6 +68,11 @@ jobs: ref: ${{ fromJSON(needs.release-please.outputs.release-pr).headBranchName }} token: ${{ secrets.NOIR_RELEASES_TOKEN }} + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: '18' + - name: Install Yarn dependencies uses: ./.github/actions/setup diff --git a/noir/.gitrepo b/noir/.gitrepo index 9fa4e9ae521a..5fcea33359ce 100644 --- a/noir/.gitrepo +++ b/noir/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/noir-lang/noir branch = aztec-packages - commit = 7dba0a18ad83e74f8114c6ca594ad10e5e334704 - parent = bcab9ceab62bede3bc1c105b3e639e7c64e3217a + commit = 13f93d523342daf478e08e8ccc0f00962c7fbe05 + parent = 41ae75cdee6285729551965972e8cb039ff3045a method = merge cmdver = 0.4.6 diff --git a/noir/.release-please-manifest.json b/noir/.release-please-manifest.json index f440a7a2c515..01f6fb140b1b 100644 --- a/noir/.release-please-manifest.json +++ b/noir/.release-please-manifest.json @@ -1,4 +1,4 @@ { - ".": "0.23.0", - "acvm-repo": "0.39.0" + ".": "0.22.0", + "acvm-repo": "0.38.0" } \ No newline at end of file diff --git a/noir/CHANGELOG.md b/noir/CHANGELOG.md index af7eb5b2f19e..3fc044076a0e 100644 --- a/noir/CHANGELOG.md +++ b/noir/CHANGELOG.md @@ -1,97 +1,5 @@ # Changelog -## [0.23.0](https://github.com/noir-lang/noir/compare/v0.22.0...v0.23.0) (2024-01-22) - - -### ⚠ BREAKING CHANGES - -* Ban nested slices ([#4018](https://github.com/noir-lang/noir/issues/4018)) -* Breaking changes from aztec-packages ([#3955](https://github.com/noir-lang/noir/issues/3955)) -* Rename Arithmetic opcode to AssertZero ([#3840](https://github.com/noir-lang/noir/issues/3840)) -* remove circuit methods from noir_wasm ([#3869](https://github.com/noir-lang/noir/issues/3869)) - -### Features - -* Add `assert_max_bit_size` method to `Field` ([#4016](https://github.com/noir-lang/noir/issues/4016)) ([bc9a44f](https://github.com/noir-lang/noir/commit/bc9a44f285e0569825a307b06ee8acd93461c87e)) -* Add `noir-compiler` checks to `aztec_macros` ([#4031](https://github.com/noir-lang/noir/issues/4031)) ([420a5c7](https://github.com/noir-lang/noir/commit/420a5c74a14dcfeede04337a42282093a7b5e63e)) -* Add a `--force` flag to force a full recompile ([#4054](https://github.com/noir-lang/noir/issues/4054)) ([27a8e68](https://github.com/noir-lang/noir/commit/27a8e6864643d81d96e84990e2e26cd16596a695)) -* Add dependency resolver for `noir_wasm` and implement `FileManager` for consistency with native interface ([#3891](https://github.com/noir-lang/noir/issues/3891)) ([c29c7d7](https://github.com/noir-lang/noir/commit/c29c7d7c9615b9f45c696b1bdc1c497d55469dfa)) -* Add foreign call support to `noir_codegen` functions ([#3933](https://github.com/noir-lang/noir/issues/3933)) ([e5e52a8](https://github.com/noir-lang/noir/commit/e5e52a81b31d7735b680e97a9bef89a010a99763)) -* Add MVP `nargo export` command ([#3870](https://github.com/noir-lang/noir/issues/3870)) ([fbb51ed](https://github.com/noir-lang/noir/commit/fbb51ed33e9e4d9105d8946cdfc4ea387c85258e)) -* Add support for codegenning multiple functions which use the same structs in their interface ([#3868](https://github.com/noir-lang/noir/issues/3868)) ([1dcfcc5](https://github.com/noir-lang/noir/commit/1dcfcc5265f618685a783504b1d4be213e4cda2d)) -* Added efficient field comparisons for bn254 ([#4042](https://github.com/noir-lang/noir/issues/4042)) ([1f9cad0](https://github.com/noir-lang/noir/commit/1f9cad00c57ea257f57419d2446a46938beb19f9)) -* Assert maximum bit size when creating a U128 from an integer ([#4024](https://github.com/noir-lang/noir/issues/4024)) ([8f9c7e4](https://github.com/noir-lang/noir/commit/8f9c7e4de9f2ae5b39714d8e0d26b2befcd11c4a)) -* Avoid unnecessary range checks by inspecting instructions for casts ([#4039](https://github.com/noir-lang/noir/issues/4039)) ([378c18e](https://github.com/noir-lang/noir/commit/378c18eb42d75852b97f849d05c9e3f650601339)) -* Breaking changes from aztec-packages ([#3955](https://github.com/noir-lang/noir/issues/3955)) ([5be049e](https://github.com/noir-lang/noir/commit/5be049eee6c342649462282ee04f6411e6ea392c)) -* Bubble up `Instruction::Constrain`s to be applied as early as possible. ([#4065](https://github.com/noir-lang/noir/issues/4065)) ([66f5cdd](https://github.com/noir-lang/noir/commit/66f5cddc133ba0311028eba96c0ff6ec2ecaee59)) -* Cached LSP parsing ([#4083](https://github.com/noir-lang/noir/issues/4083)) ([b4f724e](https://github.com/noir-lang/noir/commit/b4f724e848b291a733e417c394ac3fc7649c08c5)) -* Comparison for signed integers ([#3873](https://github.com/noir-lang/noir/issues/3873)) ([bcbd49b](https://github.com/noir-lang/noir/commit/bcbd49b8b44749e149f83c1240094fa2f0a19087)) -* Decompose `Instruction::Cast` to have an explicit truncation instruction ([#3946](https://github.com/noir-lang/noir/issues/3946)) ([35f18ef](https://github.com/noir-lang/noir/commit/35f18ef4d7c8041e3cf622a5643748d0793c2aa6)) -* Decompose `Instruction::Constrain` into multiple more basic constraints ([#3892](https://github.com/noir-lang/noir/issues/3892)) ([51cf9d3](https://github.com/noir-lang/noir/commit/51cf9d37c8b9fbb14bb54b178d93129a7563e131)) -* Docker testing flow ([#3895](https://github.com/noir-lang/noir/issues/3895)) ([179c90d](https://github.com/noir-lang/noir/commit/179c90dc3263c85de105c57925d9c5894427e8e1)) -* Extract parsing to its own pass and do it in parallel ([#4063](https://github.com/noir-lang/noir/issues/4063)) ([569cbbc](https://github.com/noir-lang/noir/commit/569cbbc231a242c32821cba56f3649f3228a1cc7)) -* Implement `Eq` trait on curve points ([#3944](https://github.com/noir-lang/noir/issues/3944)) ([abf751a](https://github.com/noir-lang/noir/commit/abf751ab7f57f87520be16b2bc6168efdf95a430)) -* Implement DAP protocol in Nargo ([#3627](https://github.com/noir-lang/noir/issues/3627)) ([13834d4](https://github.com/noir-lang/noir/commit/13834d43bd876909cb50494a41b42297f7e6375b)) -* Implement generic traits ([#4000](https://github.com/noir-lang/noir/issues/4000)) ([916fd15](https://github.com/noir-lang/noir/commit/916fd158aa361ac80d32767f575ad896c3462b15)) -* Implement Operator Overloading ([#3931](https://github.com/noir-lang/noir/issues/3931)) ([4b16090](https://github.com/noir-lang/noir/commit/4b16090beecd0fcdd41c9e7b8f615c4625c26a5b)) -* **lsp:** Cache definitions for goto requests ([#3930](https://github.com/noir-lang/noir/issues/3930)) ([4a2140f](https://github.com/noir-lang/noir/commit/4a2140f1f36bbe3afbc006f8db74820308ae27d5)) -* **lsp:** Goto global ([#4043](https://github.com/noir-lang/noir/issues/4043)) ([15237b3](https://github.com/noir-lang/noir/commit/15237b34dbce5ea54973a178449e67cca8ac4f9d)) -* **lsp:** Goto struct member inside Impl method ([#3918](https://github.com/noir-lang/noir/issues/3918)) ([99c2c5a](https://github.com/noir-lang/noir/commit/99c2c5a2c2c0da6bad783b60d9e3de8d9a1f4ee4)) -* **lsp:** Goto trait from trait impl ([#3956](https://github.com/noir-lang/noir/issues/3956)) ([eb566e2](https://github.com/noir-lang/noir/commit/eb566e2125e847a3e3efbd2bc15a88a1c454a7df)) -* **lsp:** Goto trait method declaration ([#3991](https://github.com/noir-lang/noir/issues/3991)) ([eb79166](https://github.com/noir-lang/noir/commit/eb79166f7d2b7aa45c9c6c0aa37db1c0a5dfa00f)) -* **lsp:** Goto type alias ([#4061](https://github.com/noir-lang/noir/issues/4061)) ([dc83385](https://github.com/noir-lang/noir/commit/dc83385e9fe5766cd8218265be38c54243cae76e)) -* **lsp:** Goto type definition ([#4029](https://github.com/noir-lang/noir/issues/4029)) ([8bb4ddf](https://github.com/noir-lang/noir/commit/8bb4ddfdd81d491ff713a056a7eae522f329d173)) -* **lsp:** Re-add code lens feature with improved performance ([#3829](https://github.com/noir-lang/noir/issues/3829)) ([8f5cd6c](https://github.com/noir-lang/noir/commit/8f5cd6c0b641b3970bf626e8910b2a4c7cc8c310)) -* Optimize array ops for arrays of structs ([#4027](https://github.com/noir-lang/noir/issues/4027)) ([c9ec0d8](https://github.com/noir-lang/noir/commit/c9ec0d811ddc8653201ed765b51585a7c1b946fb)) -* Optimize logic gate ACIR-gen ([#3897](https://github.com/noir-lang/noir/issues/3897)) ([926460a](https://github.com/noir-lang/noir/commit/926460a0c70e21e2f4720148cf424e44ab9b0678)) -* Prefer `AcirContext`-native methods for performing logic operations ([#3898](https://github.com/noir-lang/noir/issues/3898)) ([0ec39b8](https://github.com/noir-lang/noir/commit/0ec39b8396084ed1e7f20609c8ad8a5844a86674)) -* Remove range constraints from witnesses which are constrained to be constants ([#3928](https://github.com/noir-lang/noir/issues/3928)) ([afe9c7a](https://github.com/noir-lang/noir/commit/afe9c7a38bb9d4245205d3aa46d4ce23d70a5671)) -* Remove truncation from brillig casts ([#3997](https://github.com/noir-lang/noir/issues/3997)) ([857ff97](https://github.com/noir-lang/noir/commit/857ff97b196174a0999f0fe7e387bfca5c3b7cd3)) -* Remove truncations which can be seen to be noops using type information ([#3953](https://github.com/noir-lang/noir/issues/3953)) ([cc3c2c2](https://github.com/noir-lang/noir/commit/cc3c2c22644f0b5d8369bad2362ea6e9112a0713)) -* Remove unnecessary predicate from `Lt` instruction ([#3922](https://github.com/noir-lang/noir/issues/3922)) ([a63433f](https://github.com/noir-lang/noir/commit/a63433fb8747722ec3cf2c6eb85d34e5b04bc15c)) -* Simplify chains of casts to be all in terms of the original `ValueId` ([#3984](https://github.com/noir-lang/noir/issues/3984)) ([2384d3e](https://github.com/noir-lang/noir/commit/2384d3e97af24a8718fbf57f6b276a5ce1de06fe)) -* Simplify multiplications by `0` or `1` in ACIR gen ([#3924](https://github.com/noir-lang/noir/issues/3924)) ([e58844d](https://github.com/noir-lang/noir/commit/e58844daf9f040626a3a7595f8c4f831e48a4037)) -* Support for u128 ([#3913](https://github.com/noir-lang/noir/issues/3913)) ([b4911dc](https://github.com/noir-lang/noir/commit/b4911dcf676f0925ac631ba6f60fc9c4945b2fee)) -* Support printing more types ([#4071](https://github.com/noir-lang/noir/issues/4071)) ([f5c4632](https://github.com/noir-lang/noir/commit/f5c4632e174beba508e1e31d0e2ae3f6d028ae2c)) -* Sync `aztec-packages` ([#4011](https://github.com/noir-lang/noir/issues/4011)) ([fee2452](https://github.com/noir-lang/noir/commit/fee24523c427c27f0bdaf98ea09a852a2da3e94c)) -* Sync commits from `aztec-packages` ([#4068](https://github.com/noir-lang/noir/issues/4068)) ([7a8f3a3](https://github.com/noir-lang/noir/commit/7a8f3a33b57875e681e3d81e667e3570a1cdbdcc)) -* Use singleton `WasmBlackBoxFunctionSolver` in `noir_js` ([#3966](https://github.com/noir-lang/noir/issues/3966)) ([10b28de](https://github.com/noir-lang/noir/commit/10b28def4d74822b7af2c19a1cc693788272b00b)) - - -### Bug Fixes - -* Acir gen doesn't panic on unsupported BB function ([#3866](https://github.com/noir-lang/noir/issues/3866)) ([34fd978](https://github.com/noir-lang/noir/commit/34fd978d206789a9e9f5167bfd690a34386834d0)) -* Allow abi encoding arrays of structs from JS ([#3867](https://github.com/noir-lang/noir/issues/3867)) ([9b713f8](https://github.com/noir-lang/noir/commit/9b713f8cf599df262a12ec1098136c50b2b46766)) -* Allow abi encoding tuples from JS ([#3894](https://github.com/noir-lang/noir/issues/3894)) ([f7fa181](https://github.com/noir-lang/noir/commit/f7fa1811ad2591020c914976f26e2f11a91cd177)) -* Allow ast when macro errors ([#4005](https://github.com/noir-lang/noir/issues/4005)) ([efccec3](https://github.com/noir-lang/noir/commit/efccec3c24eb093fba99b1c29f01a78aae5776d0)) -* Allow lsp to run inside of a docker container ([#3876](https://github.com/noir-lang/noir/issues/3876)) ([2529977](https://github.com/noir-lang/noir/commit/2529977acd684219f57ef086415557cc07af043b)) -* Bit-shifts for signed integers ([#3890](https://github.com/noir-lang/noir/issues/3890)) ([6ddd98a](https://github.com/noir-lang/noir/commit/6ddd98ab7d3fefde491cf12b785f76bf0585609e)) -* Checks for cyclic dependencies ([#3699](https://github.com/noir-lang/noir/issues/3699)) ([642011a](https://github.com/noir-lang/noir/commit/642011ab6ebbe8f012eda1da1abbf8660500723d)) -* **debugger:** Crash when stepping through locations spanning multiple lines ([#3920](https://github.com/noir-lang/noir/issues/3920)) ([223e860](https://github.com/noir-lang/noir/commit/223e860975c2698bd5043340b937de74552ec15b)) -* Don't fail if no tests and the user didn't provide a pattern ([#3864](https://github.com/noir-lang/noir/issues/3864)) ([decbd0f](https://github.com/noir-lang/noir/commit/decbd0f0c019844cd2b235e7804d2f6ba7b23897)) -* Fix advisory issue in cargo-deny ([#4077](https://github.com/noir-lang/noir/issues/4077)) ([19baea0](https://github.com/noir-lang/noir/commit/19baea0d18e2d26bd04b649f79dd8e681488d1dc)) -* Fixing dark mode background on the CTA button ([#3882](https://github.com/noir-lang/noir/issues/3882)) ([57eae42](https://github.com/noir-lang/noir/commit/57eae42080d6a928e8010c6bc77489964a5777ef)) -* Fixup exports from `noir_wasm` ([#4022](https://github.com/noir-lang/noir/issues/4022)) ([358cdd2](https://github.com/noir-lang/noir/commit/358cdd2725444091b3322c47754e3cbd9b1d3614)) -* Handle multiple imports in the same file ([#3903](https://github.com/noir-lang/noir/issues/3903)) ([219423e](https://github.com/noir-lang/noir/commit/219423eb87fa12bd8cca2a6fd2ce4c06e308783c)) -* Hoist constraints on inputs to top of program ([#4076](https://github.com/noir-lang/noir/issues/4076)) ([447aa34](https://github.com/noir-lang/noir/commit/447aa343555cbd5a7cd735876e08f43271ecdd40)) -* Implement missing codegen for `BlackBoxFunc::EcdsaSecp256r1` in brillig ([#3943](https://github.com/noir-lang/noir/issues/3943)) ([2c5eceb](https://github.com/noir-lang/noir/commit/2c5eceb04ab6bc38e954492642121c7fe3da866f)) -* Improve `nargo test` output ([#3973](https://github.com/noir-lang/noir/issues/3973)) ([3ab5ff4](https://github.com/noir-lang/noir/commit/3ab5ff431145a1f747b698caed15caebaa145f04)) -* Make `constant_to_radix` emit a slice instead of an array ([#4049](https://github.com/noir-lang/noir/issues/4049)) ([5cdb1d0](https://github.com/noir-lang/noir/commit/5cdb1d0dabe2e38a1610f718747cc2fb4263339d)) -* Operator overloading & static trait method references resolving to generic impls ([#3967](https://github.com/noir-lang/noir/issues/3967)) ([f1de8fa](https://github.com/noir-lang/noir/commit/f1de8fa3247bcee624bcd7a0f89fe7c7cd8430f1)) -* Preserve brillig entrypoint functions without arguments ([#3951](https://github.com/noir-lang/noir/issues/3951)) ([1111465](https://github.com/noir-lang/noir/commit/1111465551557ed9e97e4b43d6eccc4b5896a39f)) -* Prevent `Instruction::Constrain`s for non-primitive types ([#3916](https://github.com/noir-lang/noir/issues/3916)) ([467948f](https://github.com/noir-lang/noir/commit/467948f9ee9ae65b4e2badaa1d15835fced3e835)) -* Remove panic for adding an invalid crate name in wasm compiler ([#3977](https://github.com/noir-lang/noir/issues/3977)) ([7a1baa5](https://github.com/noir-lang/noir/commit/7a1baa56faa2deb385ef1b6c9da9073dafd5a376)) -* Return error rather instead of panicking on invalid circuit ([#3976](https://github.com/noir-lang/noir/issues/3976)) ([67201bf](https://github.com/noir-lang/noir/commit/67201bfc21a9c8858aa86be9cd47d463fb78d925)) -* Search all levels of struct nesting before codegenning primitive types ([#3970](https://github.com/noir-lang/noir/issues/3970)) ([13ae014](https://github.com/noir-lang/noir/commit/13ae014ddcbd9eddb401c563b95053f7a1a89f1c)) -* Update generics docs to mention we have traits now ([#3980](https://github.com/noir-lang/noir/issues/3980)) ([c2acdf1](https://github.com/noir-lang/noir/commit/c2acdf1793a67abc9a074457e057a44da3b82c39)) - - -### Miscellaneous Chores - -* Ban nested slices ([#4018](https://github.com/noir-lang/noir/issues/4018)) ([f8a1fb7](https://github.com/noir-lang/noir/commit/f8a1fb7eed1ae4a9779eb16b142a64094aa603c6)) -* Remove circuit methods from noir_wasm ([#3869](https://github.com/noir-lang/noir/issues/3869)) ([12d884e](https://github.com/noir-lang/noir/commit/12d884e2b74efab7257626d8878ea1a7455ecf85)) -* Rename Arithmetic opcode to AssertZero ([#3840](https://github.com/noir-lang/noir/issues/3840)) ([836f171](https://github.com/noir-lang/noir/commit/836f17145c2901060706294461c2d282dd121b3e)) - ## [0.22.0](https://github.com/noir-lang/noir/compare/v0.21.0...v0.22.0) (2023-12-18) diff --git a/noir/Cargo.lock b/noir/Cargo.lock index 93f1d25fc76b..79f1934059f5 100644 --- a/noir/Cargo.lock +++ b/noir/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "acir" -version = "0.39.0" +version = "0.38.0" dependencies = [ "acir_field", "base64 0.21.2", @@ -23,7 +23,7 @@ dependencies = [ [[package]] name = "acir_field" -version = "0.39.0" +version = "0.38.0" dependencies = [ "ark-bls12-381", "ark-bn254", @@ -37,7 +37,7 @@ dependencies = [ [[package]] name = "acvm" -version = "0.39.0" +version = "0.38.0" dependencies = [ "acir", "acvm_blackbox_solver", @@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "acvm_blackbox_solver" -version = "0.39.0" +version = "0.38.0" dependencies = [ "acir", "blake2", @@ -68,7 +68,7 @@ dependencies = [ [[package]] name = "acvm_js" -version = "0.39.0" +version = "0.38.0" dependencies = [ "acvm", "bn254_blackbox_solver", @@ -115,15 +115,14 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.6" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" dependencies = [ "cfg-if 1.0.0", "getrandom 0.2.10", "once_cell", "version_check", - "zerocopy", ] [[package]] @@ -212,7 +211,7 @@ checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" [[package]] name = "arena" -version = "0.23.0" +version = "0.22.0" dependencies = [ "generational-arena", ] @@ -416,7 +415,7 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "aztec_macros" -version = "0.23.0" +version = "0.22.0" dependencies = [ "iter-extended", "noirc_frontend", @@ -580,7 +579,7 @@ dependencies = [ [[package]] name = "bn254_blackbox_solver" -version = "0.39.0" +version = "0.38.0" dependencies = [ "acir", "acvm_blackbox_solver", @@ -602,7 +601,7 @@ dependencies = [ [[package]] name = "brillig" -version = "0.39.0" +version = "0.38.0" dependencies = [ "acir_field", "serde", @@ -610,7 +609,7 @@ dependencies = [ [[package]] name = "brillig_vm" -version = "0.39.0" +version = "0.38.0" dependencies = [ "acir", "acvm_blackbox_solver", @@ -846,7 +845,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.26", ] [[package]] @@ -1296,7 +1295,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.32", + "syn 2.0.26", ] [[package]] @@ -1307,7 +1306,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core", "quote", - "syn 2.0.32", + "syn 2.0.26", ] [[package]] @@ -1557,7 +1556,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.26", ] [[package]] @@ -1683,7 +1682,7 @@ dependencies = [ [[package]] name = "fm" -version = "0.23.0" +version = "0.22.0" dependencies = [ "codespan-reporting", "iter-extended", @@ -1775,7 +1774,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.26", ] [[package]] @@ -1945,9 +1944,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.24" +version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" +checksum = "97ec8491ebaf99c8eaa73058b045fe58073cd6be7f596ac993ced0b0a0c01049" dependencies = [ "bytes", "fnv", @@ -1955,7 +1954,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 2.0.0", + "indexmap 1.9.3", "slab", "tokio", "tokio-util 0.7.8", @@ -1992,7 +1991,7 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ - "ahash 0.8.6", + "ahash 0.8.3", ] [[package]] @@ -2255,7 +2254,7 @@ version = "0.11.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fb7c1b80a1dfa604bb4a649a5c5aeef3d913f7c520cb42b40e534e8a61bcdfc" dependencies = [ - "ahash 0.8.6", + "ahash 0.8.3", "indexmap 1.9.3", "is-terminal", "itoa", @@ -2295,7 +2294,7 @@ dependencies = [ [[package]] name = "iter-extended" -version = "0.23.0" +version = "0.22.0" [[package]] name = "itertools" @@ -2648,7 +2647,7 @@ checksum = "7843ec2de400bcbc6a6328c958dc38e5359da6e93e72e37bc5246bf1ae776389" [[package]] name = "nargo" -version = "0.23.0" +version = "0.22.0" dependencies = [ "acvm", "codespan-reporting", @@ -2676,7 +2675,7 @@ dependencies = [ [[package]] name = "nargo_cli" -version = "0.23.0" +version = "0.22.0" dependencies = [ "acvm", "assert_cmd", @@ -2727,7 +2726,7 @@ dependencies = [ [[package]] name = "nargo_fmt" -version = "0.23.0" +version = "0.22.0" dependencies = [ "bytecount", "noirc_frontend", @@ -2739,7 +2738,7 @@ dependencies = [ [[package]] name = "nargo_toml" -version = "0.23.0" +version = "0.22.0" dependencies = [ "dirs", "fm", @@ -2812,7 +2811,7 @@ dependencies = [ [[package]] name = "noir_debugger" -version = "0.23.0" +version = "0.22.0" dependencies = [ "acvm", "assert_cmd", @@ -2835,13 +2834,12 @@ dependencies = [ [[package]] name = "noir_lsp" -version = "0.23.0" +version = "0.22.0" dependencies = [ "acvm", "async-lsp", "codespan-lsp", "fm", - "fxhash", "lsp-types 0.94.1", "nargo", "nargo_fmt", @@ -2849,7 +2847,6 @@ dependencies = [ "noirc_driver", "noirc_errors", "noirc_frontend", - "rayon", "serde", "serde_json", "serde_with", @@ -2861,7 +2858,7 @@ dependencies = [ [[package]] name = "noir_wasm" -version = "0.23.0" +version = "0.22.0" dependencies = [ "acvm", "build-data", @@ -2884,7 +2881,7 @@ dependencies = [ [[package]] name = "noirc_abi" -version = "0.23.0" +version = "0.22.0" dependencies = [ "acvm", "iter-extended", @@ -2901,7 +2898,7 @@ dependencies = [ [[package]] name = "noirc_abi_wasm" -version = "0.23.0" +version = "0.22.0" dependencies = [ "acvm", "build-data", @@ -2918,7 +2915,7 @@ dependencies = [ [[package]] name = "noirc_driver" -version = "0.23.0" +version = "0.22.0" dependencies = [ "acvm", "aztec_macros", @@ -2938,7 +2935,7 @@ dependencies = [ [[package]] name = "noirc_errors" -version = "0.23.0" +version = "0.22.0" dependencies = [ "acvm", "base64 0.21.2", @@ -2955,7 +2952,7 @@ dependencies = [ [[package]] name = "noirc_evaluator" -version = "0.23.0" +version = "0.22.0" dependencies = [ "acvm", "fxhash", @@ -2971,7 +2968,7 @@ dependencies = [ [[package]] name = "noirc_frontend" -version = "0.23.0" +version = "0.22.0" dependencies = [ "acvm", "arena", @@ -2995,7 +2992,7 @@ dependencies = [ [[package]] name = "noirc_printable_type" -version = "0.23.0" +version = "0.22.0" dependencies = [ "acvm", "iter-extended", @@ -3847,7 +3844,7 @@ dependencies = [ "quote", "rust-embed-utils", "shellexpand", - "syn 2.0.32", + "syn 2.0.26", "walkdir", ] @@ -4157,7 +4154,7 @@ checksum = "741e124f5485c7e60c03b043f79f320bff3527f4bbf12cf3831750dc46a0ec2c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.26", ] [[package]] @@ -4179,7 +4176,7 @@ checksum = "1d89a8107374290037607734c0b73a85db7ed80cae314b3c5791f192a496e731" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.26", ] [[package]] @@ -4229,7 +4226,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.26", ] [[package]] @@ -4254,7 +4251,7 @@ checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.26", ] [[package]] @@ -4530,9 +4527,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.32" +version = "2.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "239814284fd6f1a4ffe4ca893952cdd93c224b6a1571c9a9eadd670295c0c9e2" +checksum = "45c3457aacde3c65315de5031ec191ce46604304d2446e803d71ade03308d970" dependencies = [ "proc-macro2", "quote", @@ -4603,9 +4600,9 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "test-binary" -version = "3.0.2" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c7cb854285c40b61c0fade358bf63a2bb1226688a1ea11432ea65349209e6e3" +checksum = "bb28771e7854f02e5705f2a1b09451d932a273f5a4ec1c9fa4c65882b8b7b6ca" dependencies = [ "camino", "cargo_metadata", @@ -4652,7 +4649,7 @@ checksum = "463fe12d7993d3b327787537ce8dd4dfa058de32fc2b195ef3cde03dc4771e8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.26", ] [[package]] @@ -4743,7 +4740,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.26", ] [[package]] @@ -4894,7 +4891,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.26", ] [[package]] @@ -5166,7 +5163,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.26", "wasm-bindgen-shared", ] @@ -5200,7 +5197,7 @@ checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.26", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5681,26 +5678,6 @@ dependencies = [ "libc", ] -[[package]] -name = "zerocopy" -version = "0.7.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.32", -] - [[package]] name = "zeroize" version = "1.6.0" @@ -5718,5 +5695,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.32", + "syn 2.0.26", ] diff --git a/noir/Cargo.toml b/noir/Cargo.toml index 8a827cacfcd2..f0fc7249efc0 100644 --- a/noir/Cargo.toml +++ b/noir/Cargo.toml @@ -38,7 +38,7 @@ resolver = "2" [workspace.package] # x-release-please-start-version -version = "0.23.0" +version = "0.22.0" # x-release-please-end authors = ["The Noir Team "] edition = "2021" @@ -49,14 +49,14 @@ repository = "https://github.com/noir-lang/noir/" [workspace.dependencies] # ACVM workspace dependencies -acir_field = { version = "0.39.0", path = "acvm-repo/acir_field", default-features = false } -acir = { version = "0.39.0", path = "acvm-repo/acir", default-features = false } -acvm = { version = "0.39.0", path = "acvm-repo/acvm" } +acir_field = { version = "0.38.0", path = "acvm-repo/acir_field", default-features = false } +acir = { version = "0.38.0", path = "acvm-repo/acir", default-features = false } +acvm = { version = "0.38.0", path = "acvm-repo/acvm" } stdlib = { version = "0.37.1", package = "acvm_stdlib", path = "acvm-repo/stdlib", default-features = false } -brillig = { version = "0.39.0", path = "acvm-repo/brillig", default-features = false } -brillig_vm = { version = "0.39.0", path = "acvm-repo/brillig_vm", default-features = false } -acvm_blackbox_solver = { version = "0.39.0", path = "acvm-repo/blackbox_solver", default-features = false } -bn254_blackbox_solver = { version = "0.39.0", path = "acvm-repo/bn254_blackbox_solver", default-features = false } +brillig = { version = "0.38.0", path = "acvm-repo/brillig", default-features = false } +brillig_vm = { version = "0.38.0", path = "acvm-repo/brillig_vm", default-features = false } +acvm_blackbox_solver = { version = "0.38.0", path = "acvm-repo/blackbox_solver", default-features = false } +bn254_blackbox_solver = { version = "0.38.0", path = "acvm-repo/bn254_blackbox_solver", default-features = false } # Noir compiler workspace dependencies arena = { path = "compiler/utils/arena" } diff --git a/noir/acvm-repo/CHANGELOG.md b/noir/acvm-repo/CHANGELOG.md index 7f68244a7eb9..d413bd390c40 100644 --- a/noir/acvm-repo/CHANGELOG.md +++ b/noir/acvm-repo/CHANGELOG.md @@ -5,38 +5,6 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.39.0](https://github.com/noir-lang/noir/compare/v0.38.0...v0.39.0) (2024-01-22) - - -### ⚠ BREAKING CHANGES - -* Breaking changes from aztec-packages ([#3955](https://github.com/noir-lang/noir/issues/3955)) -* Rename Arithmetic opcode to AssertZero ([#3840](https://github.com/noir-lang/noir/issues/3840)) -* Remove unused methods on ACIR opcodes ([#3841](https://github.com/noir-lang/noir/issues/3841)) -* Remove partial backend feature ([#3805](https://github.com/noir-lang/noir/issues/3805)) - -### Features - -* Aztec-packages ([#3754](https://github.com/noir-lang/noir/issues/3754)) ([c043265](https://github.com/noir-lang/noir/commit/c043265e550b59bd4296504826fe15d3ce3e9ad2)) -* Breaking changes from aztec-packages ([#3955](https://github.com/noir-lang/noir/issues/3955)) ([5be049e](https://github.com/noir-lang/noir/commit/5be049eee6c342649462282ee04f6411e6ea392c)) -* Remove range constraints from witnesses which are constrained to be constants ([#3928](https://github.com/noir-lang/noir/issues/3928)) ([afe9c7a](https://github.com/noir-lang/noir/commit/afe9c7a38bb9d4245205d3aa46d4ce23d70a5671)) -* Speed up transformation of debug messages ([#3815](https://github.com/noir-lang/noir/issues/3815)) ([2a8af1e](https://github.com/noir-lang/noir/commit/2a8af1e4141ffff61547ee1c2837a6392bd5db48)) -* Sync `aztec-packages` ([#4011](https://github.com/noir-lang/noir/issues/4011)) ([fee2452](https://github.com/noir-lang/noir/commit/fee24523c427c27f0bdaf98ea09a852a2da3e94c)) -* Sync commits from `aztec-packages` ([#4068](https://github.com/noir-lang/noir/issues/4068)) ([7a8f3a3](https://github.com/noir-lang/noir/commit/7a8f3a33b57875e681e3d81e667e3570a1cdbdcc)) - - -### Bug Fixes - -* Deserialize odd length hex literals ([#3747](https://github.com/noir-lang/noir/issues/3747)) ([4000fb2](https://github.com/noir-lang/noir/commit/4000fb279221eb07187d657bfaa7f1c7b311abf2)) -* Return error rather instead of panicking on invalid circuit ([#3976](https://github.com/noir-lang/noir/issues/3976)) ([67201bf](https://github.com/noir-lang/noir/commit/67201bfc21a9c8858aa86be9cd47d463fb78d925)) - - -### Miscellaneous Chores - -* Remove partial backend feature ([#3805](https://github.com/noir-lang/noir/issues/3805)) ([0383100](https://github.com/noir-lang/noir/commit/0383100853a80a5b28b797cdfeae0d271f1b7805)) -* Remove unused methods on ACIR opcodes ([#3841](https://github.com/noir-lang/noir/issues/3841)) ([9e5d0e8](https://github.com/noir-lang/noir/commit/9e5d0e813d61a0bfb5ee68174ed287c5a20f1579)) -* Rename Arithmetic opcode to AssertZero ([#3840](https://github.com/noir-lang/noir/issues/3840)) ([836f171](https://github.com/noir-lang/noir/commit/836f17145c2901060706294461c2d282dd121b3e)) - ## [0.38.0](https://github.com/noir-lang/noir/compare/v0.37.1...v0.38.0) (2023-12-18) diff --git a/noir/acvm-repo/acir/Cargo.toml b/noir/acvm-repo/acir/Cargo.toml index 49b10c57cc8c..b44c64dd8383 100644 --- a/noir/acvm-repo/acir/Cargo.toml +++ b/noir/acvm-repo/acir/Cargo.toml @@ -2,7 +2,7 @@ name = "acir" description = "ACIR is the IR that the VM processes, it is analogous to LLVM IR" # x-release-please-start-version -version = "0.39.0" +version = "0.38.0" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/noir/acvm-repo/acir/codegen/acir.cpp b/noir/acvm-repo/acir/codegen/acir.cpp index 07bcd5f9f972..9b74a8ea6310 100644 --- a/noir/acvm-repo/acir/codegen/acir.cpp +++ b/noir/acvm-repo/acir/codegen/acir.cpp @@ -206,66 +206,7 @@ namespace Circuit { static RecursiveAggregation bincodeDeserialize(std::vector); }; - struct BigIntAdd { - uint32_t lhs; - uint32_t rhs; - uint32_t output; - - friend bool operator==(const BigIntAdd&, const BigIntAdd&); - std::vector bincodeSerialize() const; - static BigIntAdd bincodeDeserialize(std::vector); - }; - - struct BigIntNeg { - uint32_t lhs; - uint32_t rhs; - uint32_t output; - - friend bool operator==(const BigIntNeg&, const BigIntNeg&); - std::vector bincodeSerialize() const; - static BigIntNeg bincodeDeserialize(std::vector); - }; - - struct BigIntMul { - uint32_t lhs; - uint32_t rhs; - uint32_t output; - - friend bool operator==(const BigIntMul&, const BigIntMul&); - std::vector bincodeSerialize() const; - static BigIntMul bincodeDeserialize(std::vector); - }; - - struct BigIntDiv { - uint32_t lhs; - uint32_t rhs; - uint32_t output; - - friend bool operator==(const BigIntDiv&, const BigIntDiv&); - std::vector bincodeSerialize() const; - static BigIntDiv bincodeDeserialize(std::vector); - }; - - struct BigIntFromLeBytes { - std::vector inputs; - std::vector modulus; - uint32_t output; - - friend bool operator==(const BigIntFromLeBytes&, const BigIntFromLeBytes&); - std::vector bincodeSerialize() const; - static BigIntFromLeBytes bincodeDeserialize(std::vector); - }; - - struct BigIntToLeBytes { - uint32_t input; - std::vector outputs; - - friend bool operator==(const BigIntToLeBytes&, const BigIntToLeBytes&); - std::vector bincodeSerialize() const; - static BigIntToLeBytes bincodeDeserialize(std::vector); - }; - - std::variant value; + std::variant value; friend bool operator==(const BlackBoxFuncCall&, const BlackBoxFuncCall&); std::vector bincodeSerialize() const; @@ -602,66 +543,7 @@ namespace Circuit { static EmbeddedCurveDouble bincodeDeserialize(std::vector); }; - struct BigIntAdd { - Circuit::RegisterIndex lhs; - Circuit::RegisterIndex rhs; - Circuit::RegisterIndex output; - - friend bool operator==(const BigIntAdd&, const BigIntAdd&); - std::vector bincodeSerialize() const; - static BigIntAdd bincodeDeserialize(std::vector); - }; - - struct BigIntNeg { - Circuit::RegisterIndex lhs; - Circuit::RegisterIndex rhs; - Circuit::RegisterIndex output; - - friend bool operator==(const BigIntNeg&, const BigIntNeg&); - std::vector bincodeSerialize() const; - static BigIntNeg bincodeDeserialize(std::vector); - }; - - struct BigIntMul { - Circuit::RegisterIndex lhs; - Circuit::RegisterIndex rhs; - Circuit::RegisterIndex output; - - friend bool operator==(const BigIntMul&, const BigIntMul&); - std::vector bincodeSerialize() const; - static BigIntMul bincodeDeserialize(std::vector); - }; - - struct BigIntDiv { - Circuit::RegisterIndex lhs; - Circuit::RegisterIndex rhs; - Circuit::RegisterIndex output; - - friend bool operator==(const BigIntDiv&, const BigIntDiv&); - std::vector bincodeSerialize() const; - static BigIntDiv bincodeDeserialize(std::vector); - }; - - struct BigIntFromLeBytes { - Circuit::HeapVector inputs; - Circuit::HeapVector modulus; - Circuit::RegisterIndex output; - - friend bool operator==(const BigIntFromLeBytes&, const BigIntFromLeBytes&); - std::vector bincodeSerialize() const; - static BigIntFromLeBytes bincodeDeserialize(std::vector); - }; - - struct BigIntToLeBytes { - Circuit::RegisterIndex input; - Circuit::HeapVector output; - - friend bool operator==(const BigIntToLeBytes&, const BigIntToLeBytes&); - std::vector bincodeSerialize() const; - static BigIntToLeBytes bincodeDeserialize(std::vector); - }; - - std::variant value; + std::variant value; friend bool operator==(const BlackBoxOp&, const BlackBoxOp&); std::vector bincodeSerialize() const; @@ -2587,267 +2469,6 @@ Circuit::BlackBoxFuncCall::RecursiveAggregation serde::Deserializable BlackBoxFuncCall::BigIntAdd::bincodeSerialize() const { - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); - } - - inline BlackBoxFuncCall::BigIntAdd BlackBoxFuncCall::BigIntAdd::bincodeDeserialize(std::vector input) { - auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); - if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); - } - return value; - } - -} // end of namespace Circuit - -template <> -template -void serde::Serializable::serialize(const Circuit::BlackBoxFuncCall::BigIntAdd &obj, Serializer &serializer) { - serde::Serializable::serialize(obj.lhs, serializer); - serde::Serializable::serialize(obj.rhs, serializer); - serde::Serializable::serialize(obj.output, serializer); -} - -template <> -template -Circuit::BlackBoxFuncCall::BigIntAdd serde::Deserializable::deserialize(Deserializer &deserializer) { - Circuit::BlackBoxFuncCall::BigIntAdd obj; - obj.lhs = serde::Deserializable::deserialize(deserializer); - obj.rhs = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); - return obj; -} - -namespace Circuit { - - inline bool operator==(const BlackBoxFuncCall::BigIntNeg &lhs, const BlackBoxFuncCall::BigIntNeg &rhs) { - if (!(lhs.lhs == rhs.lhs)) { return false; } - if (!(lhs.rhs == rhs.rhs)) { return false; } - if (!(lhs.output == rhs.output)) { return false; } - return true; - } - - inline std::vector BlackBoxFuncCall::BigIntNeg::bincodeSerialize() const { - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); - } - - inline BlackBoxFuncCall::BigIntNeg BlackBoxFuncCall::BigIntNeg::bincodeDeserialize(std::vector input) { - auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); - if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); - } - return value; - } - -} // end of namespace Circuit - -template <> -template -void serde::Serializable::serialize(const Circuit::BlackBoxFuncCall::BigIntNeg &obj, Serializer &serializer) { - serde::Serializable::serialize(obj.lhs, serializer); - serde::Serializable::serialize(obj.rhs, serializer); - serde::Serializable::serialize(obj.output, serializer); -} - -template <> -template -Circuit::BlackBoxFuncCall::BigIntNeg serde::Deserializable::deserialize(Deserializer &deserializer) { - Circuit::BlackBoxFuncCall::BigIntNeg obj; - obj.lhs = serde::Deserializable::deserialize(deserializer); - obj.rhs = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); - return obj; -} - -namespace Circuit { - - inline bool operator==(const BlackBoxFuncCall::BigIntMul &lhs, const BlackBoxFuncCall::BigIntMul &rhs) { - if (!(lhs.lhs == rhs.lhs)) { return false; } - if (!(lhs.rhs == rhs.rhs)) { return false; } - if (!(lhs.output == rhs.output)) { return false; } - return true; - } - - inline std::vector BlackBoxFuncCall::BigIntMul::bincodeSerialize() const { - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); - } - - inline BlackBoxFuncCall::BigIntMul BlackBoxFuncCall::BigIntMul::bincodeDeserialize(std::vector input) { - auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); - if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); - } - return value; - } - -} // end of namespace Circuit - -template <> -template -void serde::Serializable::serialize(const Circuit::BlackBoxFuncCall::BigIntMul &obj, Serializer &serializer) { - serde::Serializable::serialize(obj.lhs, serializer); - serde::Serializable::serialize(obj.rhs, serializer); - serde::Serializable::serialize(obj.output, serializer); -} - -template <> -template -Circuit::BlackBoxFuncCall::BigIntMul serde::Deserializable::deserialize(Deserializer &deserializer) { - Circuit::BlackBoxFuncCall::BigIntMul obj; - obj.lhs = serde::Deserializable::deserialize(deserializer); - obj.rhs = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); - return obj; -} - -namespace Circuit { - - inline bool operator==(const BlackBoxFuncCall::BigIntDiv &lhs, const BlackBoxFuncCall::BigIntDiv &rhs) { - if (!(lhs.lhs == rhs.lhs)) { return false; } - if (!(lhs.rhs == rhs.rhs)) { return false; } - if (!(lhs.output == rhs.output)) { return false; } - return true; - } - - inline std::vector BlackBoxFuncCall::BigIntDiv::bincodeSerialize() const { - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); - } - - inline BlackBoxFuncCall::BigIntDiv BlackBoxFuncCall::BigIntDiv::bincodeDeserialize(std::vector input) { - auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); - if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); - } - return value; - } - -} // end of namespace Circuit - -template <> -template -void serde::Serializable::serialize(const Circuit::BlackBoxFuncCall::BigIntDiv &obj, Serializer &serializer) { - serde::Serializable::serialize(obj.lhs, serializer); - serde::Serializable::serialize(obj.rhs, serializer); - serde::Serializable::serialize(obj.output, serializer); -} - -template <> -template -Circuit::BlackBoxFuncCall::BigIntDiv serde::Deserializable::deserialize(Deserializer &deserializer) { - Circuit::BlackBoxFuncCall::BigIntDiv obj; - obj.lhs = serde::Deserializable::deserialize(deserializer); - obj.rhs = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); - return obj; -} - -namespace Circuit { - - inline bool operator==(const BlackBoxFuncCall::BigIntFromLeBytes &lhs, const BlackBoxFuncCall::BigIntFromLeBytes &rhs) { - if (!(lhs.inputs == rhs.inputs)) { return false; } - if (!(lhs.modulus == rhs.modulus)) { return false; } - if (!(lhs.output == rhs.output)) { return false; } - return true; - } - - inline std::vector BlackBoxFuncCall::BigIntFromLeBytes::bincodeSerialize() const { - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); - } - - inline BlackBoxFuncCall::BigIntFromLeBytes BlackBoxFuncCall::BigIntFromLeBytes::bincodeDeserialize(std::vector input) { - auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); - if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); - } - return value; - } - -} // end of namespace Circuit - -template <> -template -void serde::Serializable::serialize(const Circuit::BlackBoxFuncCall::BigIntFromLeBytes &obj, Serializer &serializer) { - serde::Serializable::serialize(obj.inputs, serializer); - serde::Serializable::serialize(obj.modulus, serializer); - serde::Serializable::serialize(obj.output, serializer); -} - -template <> -template -Circuit::BlackBoxFuncCall::BigIntFromLeBytes serde::Deserializable::deserialize(Deserializer &deserializer) { - Circuit::BlackBoxFuncCall::BigIntFromLeBytes obj; - obj.inputs = serde::Deserializable::deserialize(deserializer); - obj.modulus = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); - return obj; -} - -namespace Circuit { - - inline bool operator==(const BlackBoxFuncCall::BigIntToLeBytes &lhs, const BlackBoxFuncCall::BigIntToLeBytes &rhs) { - if (!(lhs.input == rhs.input)) { return false; } - if (!(lhs.outputs == rhs.outputs)) { return false; } - return true; - } - - inline std::vector BlackBoxFuncCall::BigIntToLeBytes::bincodeSerialize() const { - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); - } - - inline BlackBoxFuncCall::BigIntToLeBytes BlackBoxFuncCall::BigIntToLeBytes::bincodeDeserialize(std::vector input) { - auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); - if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); - } - return value; - } - -} // end of namespace Circuit - -template <> -template -void serde::Serializable::serialize(const Circuit::BlackBoxFuncCall::BigIntToLeBytes &obj, Serializer &serializer) { - serde::Serializable::serialize(obj.input, serializer); - serde::Serializable::serialize(obj.outputs, serializer); -} - -template <> -template -Circuit::BlackBoxFuncCall::BigIntToLeBytes serde::Deserializable::deserialize(Deserializer &deserializer) { - Circuit::BlackBoxFuncCall::BigIntToLeBytes obj; - obj.input = serde::Deserializable::deserialize(deserializer); - obj.outputs = serde::Deserializable::deserialize(deserializer); - return obj; -} - namespace Circuit { inline bool operator==(const BlackBoxOp &lhs, const BlackBoxOp &rhs) { @@ -3471,267 +3092,6 @@ Circuit::BlackBoxOp::EmbeddedCurveDouble serde::Deserializable BlackBoxOp::BigIntAdd::bincodeSerialize() const { - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); - } - - inline BlackBoxOp::BigIntAdd BlackBoxOp::BigIntAdd::bincodeDeserialize(std::vector input) { - auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); - if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); - } - return value; - } - -} // end of namespace Circuit - -template <> -template -void serde::Serializable::serialize(const Circuit::BlackBoxOp::BigIntAdd &obj, Serializer &serializer) { - serde::Serializable::serialize(obj.lhs, serializer); - serde::Serializable::serialize(obj.rhs, serializer); - serde::Serializable::serialize(obj.output, serializer); -} - -template <> -template -Circuit::BlackBoxOp::BigIntAdd serde::Deserializable::deserialize(Deserializer &deserializer) { - Circuit::BlackBoxOp::BigIntAdd obj; - obj.lhs = serde::Deserializable::deserialize(deserializer); - obj.rhs = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); - return obj; -} - -namespace Circuit { - - inline bool operator==(const BlackBoxOp::BigIntNeg &lhs, const BlackBoxOp::BigIntNeg &rhs) { - if (!(lhs.lhs == rhs.lhs)) { return false; } - if (!(lhs.rhs == rhs.rhs)) { return false; } - if (!(lhs.output == rhs.output)) { return false; } - return true; - } - - inline std::vector BlackBoxOp::BigIntNeg::bincodeSerialize() const { - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); - } - - inline BlackBoxOp::BigIntNeg BlackBoxOp::BigIntNeg::bincodeDeserialize(std::vector input) { - auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); - if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); - } - return value; - } - -} // end of namespace Circuit - -template <> -template -void serde::Serializable::serialize(const Circuit::BlackBoxOp::BigIntNeg &obj, Serializer &serializer) { - serde::Serializable::serialize(obj.lhs, serializer); - serde::Serializable::serialize(obj.rhs, serializer); - serde::Serializable::serialize(obj.output, serializer); -} - -template <> -template -Circuit::BlackBoxOp::BigIntNeg serde::Deserializable::deserialize(Deserializer &deserializer) { - Circuit::BlackBoxOp::BigIntNeg obj; - obj.lhs = serde::Deserializable::deserialize(deserializer); - obj.rhs = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); - return obj; -} - -namespace Circuit { - - inline bool operator==(const BlackBoxOp::BigIntMul &lhs, const BlackBoxOp::BigIntMul &rhs) { - if (!(lhs.lhs == rhs.lhs)) { return false; } - if (!(lhs.rhs == rhs.rhs)) { return false; } - if (!(lhs.output == rhs.output)) { return false; } - return true; - } - - inline std::vector BlackBoxOp::BigIntMul::bincodeSerialize() const { - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); - } - - inline BlackBoxOp::BigIntMul BlackBoxOp::BigIntMul::bincodeDeserialize(std::vector input) { - auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); - if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); - } - return value; - } - -} // end of namespace Circuit - -template <> -template -void serde::Serializable::serialize(const Circuit::BlackBoxOp::BigIntMul &obj, Serializer &serializer) { - serde::Serializable::serialize(obj.lhs, serializer); - serde::Serializable::serialize(obj.rhs, serializer); - serde::Serializable::serialize(obj.output, serializer); -} - -template <> -template -Circuit::BlackBoxOp::BigIntMul serde::Deserializable::deserialize(Deserializer &deserializer) { - Circuit::BlackBoxOp::BigIntMul obj; - obj.lhs = serde::Deserializable::deserialize(deserializer); - obj.rhs = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); - return obj; -} - -namespace Circuit { - - inline bool operator==(const BlackBoxOp::BigIntDiv &lhs, const BlackBoxOp::BigIntDiv &rhs) { - if (!(lhs.lhs == rhs.lhs)) { return false; } - if (!(lhs.rhs == rhs.rhs)) { return false; } - if (!(lhs.output == rhs.output)) { return false; } - return true; - } - - inline std::vector BlackBoxOp::BigIntDiv::bincodeSerialize() const { - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); - } - - inline BlackBoxOp::BigIntDiv BlackBoxOp::BigIntDiv::bincodeDeserialize(std::vector input) { - auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); - if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); - } - return value; - } - -} // end of namespace Circuit - -template <> -template -void serde::Serializable::serialize(const Circuit::BlackBoxOp::BigIntDiv &obj, Serializer &serializer) { - serde::Serializable::serialize(obj.lhs, serializer); - serde::Serializable::serialize(obj.rhs, serializer); - serde::Serializable::serialize(obj.output, serializer); -} - -template <> -template -Circuit::BlackBoxOp::BigIntDiv serde::Deserializable::deserialize(Deserializer &deserializer) { - Circuit::BlackBoxOp::BigIntDiv obj; - obj.lhs = serde::Deserializable::deserialize(deserializer); - obj.rhs = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); - return obj; -} - -namespace Circuit { - - inline bool operator==(const BlackBoxOp::BigIntFromLeBytes &lhs, const BlackBoxOp::BigIntFromLeBytes &rhs) { - if (!(lhs.inputs == rhs.inputs)) { return false; } - if (!(lhs.modulus == rhs.modulus)) { return false; } - if (!(lhs.output == rhs.output)) { return false; } - return true; - } - - inline std::vector BlackBoxOp::BigIntFromLeBytes::bincodeSerialize() const { - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); - } - - inline BlackBoxOp::BigIntFromLeBytes BlackBoxOp::BigIntFromLeBytes::bincodeDeserialize(std::vector input) { - auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); - if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); - } - return value; - } - -} // end of namespace Circuit - -template <> -template -void serde::Serializable::serialize(const Circuit::BlackBoxOp::BigIntFromLeBytes &obj, Serializer &serializer) { - serde::Serializable::serialize(obj.inputs, serializer); - serde::Serializable::serialize(obj.modulus, serializer); - serde::Serializable::serialize(obj.output, serializer); -} - -template <> -template -Circuit::BlackBoxOp::BigIntFromLeBytes serde::Deserializable::deserialize(Deserializer &deserializer) { - Circuit::BlackBoxOp::BigIntFromLeBytes obj; - obj.inputs = serde::Deserializable::deserialize(deserializer); - obj.modulus = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); - return obj; -} - -namespace Circuit { - - inline bool operator==(const BlackBoxOp::BigIntToLeBytes &lhs, const BlackBoxOp::BigIntToLeBytes &rhs) { - if (!(lhs.input == rhs.input)) { return false; } - if (!(lhs.output == rhs.output)) { return false; } - return true; - } - - inline std::vector BlackBoxOp::BigIntToLeBytes::bincodeSerialize() const { - auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); - return std::move(serializer).bytes(); - } - - inline BlackBoxOp::BigIntToLeBytes BlackBoxOp::BigIntToLeBytes::bincodeDeserialize(std::vector input) { - auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); - if (deserializer.get_buffer_offset() < input.size()) { - throw serde::deserialization_error("Some input bytes were not read"); - } - return value; - } - -} // end of namespace Circuit - -template <> -template -void serde::Serializable::serialize(const Circuit::BlackBoxOp::BigIntToLeBytes &obj, Serializer &serializer) { - serde::Serializable::serialize(obj.input, serializer); - serde::Serializable::serialize(obj.output, serializer); -} - -template <> -template -Circuit::BlackBoxOp::BigIntToLeBytes serde::Deserializable::deserialize(Deserializer &deserializer) { - Circuit::BlackBoxOp::BigIntToLeBytes obj; - obj.input = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); - return obj; -} - namespace Circuit { inline bool operator==(const BlockId &lhs, const BlockId &rhs) { diff --git a/noir/acvm-repo/acir/src/circuit/black_box_functions.rs b/noir/acvm-repo/acir/src/circuit/black_box_functions.rs index 41b8923a8c9f..d1f5560313b4 100644 --- a/noir/acvm-repo/acir/src/circuit/black_box_functions.rs +++ b/noir/acvm-repo/acir/src/circuit/black_box_functions.rs @@ -49,18 +49,6 @@ pub enum BlackBoxFunc { EmbeddedCurveAdd, /// Point doubling over the embedded curve on which [`FieldElement`][acir_field::FieldElement] is defined. EmbeddedCurveDouble, - /// BigInt addition - BigIntAdd, - /// BigInt subtraction - BigIntNeg, - /// BigInt multiplication - BigIntMul, - /// BigInt division - BigIntDiv, - /// BigInt from le bytes - BigIntFromLeBytes, - /// BigInt to le bytes - BigIntToLeBytes, } impl std::fmt::Display for BlackBoxFunc { @@ -89,15 +77,8 @@ impl BlackBoxFunc { BlackBoxFunc::Keccakf1600 => "keccakf1600", BlackBoxFunc::RecursiveAggregation => "recursive_aggregation", BlackBoxFunc::EcdsaSecp256r1 => "ecdsa_secp256r1", - BlackBoxFunc::BigIntAdd => "bigint_add", - BlackBoxFunc::BigIntNeg => "bigint_neg", - BlackBoxFunc::BigIntMul => "bigint_mul", - BlackBoxFunc::BigIntDiv => "bigint_div", - BlackBoxFunc::BigIntFromLeBytes => "bigint_from_le_bytes", - BlackBoxFunc::BigIntToLeBytes => "bigint_to_le_bytes", } } - pub fn lookup(op_name: &str) -> Option { match op_name { "sha256" => Some(BlackBoxFunc::SHA256), @@ -117,12 +98,6 @@ impl BlackBoxFunc { "keccak256" => Some(BlackBoxFunc::Keccak256), "keccakf1600" => Some(BlackBoxFunc::Keccakf1600), "recursive_aggregation" => Some(BlackBoxFunc::RecursiveAggregation), - "bigint_add" => Some(BlackBoxFunc::BigIntAdd), - "bigint_neg" => Some(BlackBoxFunc::BigIntNeg), - "bigint_mul" => Some(BlackBoxFunc::BigIntMul), - "bigint_div" => Some(BlackBoxFunc::BigIntDiv), - "bigint_from_le_bytes" => Some(BlackBoxFunc::BigIntFromLeBytes), - "bigint_to_le_bytes" => Some(BlackBoxFunc::BigIntToLeBytes), _ => None, } } diff --git a/noir/acvm-repo/acir/src/circuit/opcodes/black_box_function_call.rs b/noir/acvm-repo/acir/src/circuit/opcodes/black_box_function_call.rs index 1fdc02653771..7ee4e2498a5f 100644 --- a/noir/acvm-repo/acir/src/circuit/opcodes/black_box_function_call.rs +++ b/noir/acvm-repo/acir/src/circuit/opcodes/black_box_function_call.rs @@ -120,35 +120,6 @@ pub enum BlackBoxFuncCall { /// key provided to the circuit matches the key produced by the circuit creator key_hash: FunctionInput, }, - BigIntAdd { - lhs: u32, - rhs: u32, - output: u32, - }, - BigIntNeg { - lhs: u32, - rhs: u32, - output: u32, - }, - BigIntMul { - lhs: u32, - rhs: u32, - output: u32, - }, - BigIntDiv { - lhs: u32, - rhs: u32, - output: u32, - }, - BigIntFromLeBytes { - inputs: Vec, - modulus: Vec, - output: u32, - }, - BigIntToLeBytes { - input: u32, - outputs: Vec, - }, } impl BlackBoxFuncCall { @@ -172,12 +143,6 @@ impl BlackBoxFuncCall { BlackBoxFuncCall::Keccak256VariableLength { .. } => BlackBoxFunc::Keccak256, BlackBoxFuncCall::Keccakf1600 { .. } => BlackBoxFunc::Keccakf1600, BlackBoxFuncCall::RecursiveAggregation { .. } => BlackBoxFunc::RecursiveAggregation, - BlackBoxFuncCall::BigIntAdd { .. } => BlackBoxFunc::BigIntAdd, - BlackBoxFuncCall::BigIntNeg { .. } => BlackBoxFunc::BigIntNeg, - BlackBoxFuncCall::BigIntMul { .. } => BlackBoxFunc::BigIntMul, - BlackBoxFuncCall::BigIntDiv { .. } => BlackBoxFunc::BigIntDiv, - BlackBoxFuncCall::BigIntFromLeBytes { .. } => BlackBoxFunc::BigIntFromLeBytes, - &BlackBoxFuncCall::BigIntToLeBytes { .. } => BlackBoxFunc::BigIntToLeBytes, } } @@ -193,16 +158,10 @@ impl BlackBoxFuncCall { | BlackBoxFuncCall::Keccak256 { inputs, .. } | BlackBoxFuncCall::Keccakf1600 { inputs, .. } | BlackBoxFuncCall::PedersenCommitment { inputs, .. } - | BlackBoxFuncCall::PedersenHash { inputs, .. } - | BlackBoxFuncCall::BigIntFromLeBytes { inputs, .. } => inputs.to_vec(), + | BlackBoxFuncCall::PedersenHash { inputs, .. } => inputs.to_vec(), BlackBoxFuncCall::AND { lhs, rhs, .. } | BlackBoxFuncCall::XOR { lhs, rhs, .. } => { vec![*lhs, *rhs] } - BlackBoxFuncCall::BigIntAdd { .. } - | BlackBoxFuncCall::BigIntNeg { .. } - | BlackBoxFuncCall::BigIntMul { .. } - | BlackBoxFuncCall::BigIntDiv { .. } - | BlackBoxFuncCall::BigIntToLeBytes { .. } => Vec::new(), BlackBoxFuncCall::FixedBaseScalarMul { low, high, .. } => vec![*low, *high], BlackBoxFuncCall::EmbeddedCurveAdd { input1_x, input1_y, input2_x, input2_y, .. @@ -290,8 +249,7 @@ impl BlackBoxFuncCall { | BlackBoxFuncCall::Blake2s { outputs, .. } | BlackBoxFuncCall::Blake3 { outputs, .. } | BlackBoxFuncCall::Keccak256 { outputs, .. } - | BlackBoxFuncCall::Keccakf1600 { outputs, .. } - | BlackBoxFuncCall::Keccak256VariableLength { outputs, .. } => outputs.to_vec(), + | BlackBoxFuncCall::Keccakf1600 { outputs, .. } => outputs.to_vec(), BlackBoxFuncCall::AND { output, .. } | BlackBoxFuncCall::XOR { output, .. } | BlackBoxFuncCall::SchnorrVerify { output, .. } @@ -302,16 +260,10 @@ impl BlackBoxFuncCall { | BlackBoxFuncCall::PedersenCommitment { outputs, .. } | BlackBoxFuncCall::EmbeddedCurveAdd { outputs, .. } | BlackBoxFuncCall::EmbeddedCurveDouble { outputs, .. } => vec![outputs.0, outputs.1], - BlackBoxFuncCall::RANGE { .. } - | BlackBoxFuncCall::RecursiveAggregation { .. } - | BlackBoxFuncCall::BigIntFromLeBytes { .. } - | BlackBoxFuncCall::BigIntAdd { .. } - | BlackBoxFuncCall::BigIntNeg { .. } - | BlackBoxFuncCall::BigIntMul { .. } - | BlackBoxFuncCall::BigIntDiv { .. } => { + BlackBoxFuncCall::RANGE { .. } | BlackBoxFuncCall::RecursiveAggregation { .. } => { vec![] } - BlackBoxFuncCall::BigIntToLeBytes { outputs, .. } => outputs.to_vec(), + BlackBoxFuncCall::Keccak256VariableLength { outputs, .. } => outputs.to_vec(), } } } diff --git a/noir/acvm-repo/acir_field/Cargo.toml b/noir/acvm-repo/acir_field/Cargo.toml index dde121f40291..cedfc66e7349 100644 --- a/noir/acvm-repo/acir_field/Cargo.toml +++ b/noir/acvm-repo/acir_field/Cargo.toml @@ -2,7 +2,7 @@ name = "acir_field" description = "The field implementation being used by ACIR." # x-release-please-start-version -version = "0.39.0" +version = "0.38.0" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/noir/acvm-repo/acvm/Cargo.toml b/noir/acvm-repo/acvm/Cargo.toml index a40148a01efd..be2391a3216f 100644 --- a/noir/acvm-repo/acvm/Cargo.toml +++ b/noir/acvm-repo/acvm/Cargo.toml @@ -2,7 +2,7 @@ name = "acvm" description = "The virtual machine that processes ACIR given a backend/proof system." # x-release-please-start-version -version = "0.39.0" +version = "0.38.0" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/noir/acvm-repo/acvm/src/compiler/transformers/mod.rs b/noir/acvm-repo/acvm/src/compiler/transformers/mod.rs index effe1128d36f..306ea1b7c126 100644 --- a/noir/acvm-repo/acvm/src/compiler/transformers/mod.rs +++ b/noir/acvm-repo/acvm/src/compiler/transformers/mod.rs @@ -105,12 +105,7 @@ pub(super) fn transform_internal( transformer.mark_solvable(*output); } acir::circuit::opcodes::BlackBoxFuncCall::RANGE { .. } - | acir::circuit::opcodes::BlackBoxFuncCall::RecursiveAggregation { .. } - | acir::circuit::opcodes::BlackBoxFuncCall::BigIntFromLeBytes { .. } - | acir::circuit::opcodes::BlackBoxFuncCall::BigIntAdd { .. } - | acir::circuit::opcodes::BlackBoxFuncCall::BigIntNeg { .. } - | acir::circuit::opcodes::BlackBoxFuncCall::BigIntMul { .. } - | acir::circuit::opcodes::BlackBoxFuncCall::BigIntDiv { .. } => (), + | acir::circuit::opcodes::BlackBoxFuncCall::RecursiveAggregation { .. } => (), acir::circuit::opcodes::BlackBoxFuncCall::SHA256 { outputs, .. } | acir::circuit::opcodes::BlackBoxFuncCall::Keccak256 { outputs, .. } | acir::circuit::opcodes::BlackBoxFuncCall::Keccak256VariableLength { @@ -119,10 +114,7 @@ pub(super) fn transform_internal( } | acir::circuit::opcodes::BlackBoxFuncCall::Keccakf1600 { outputs, .. } | acir::circuit::opcodes::BlackBoxFuncCall::Blake2s { outputs, .. } - | acir::circuit::opcodes::BlackBoxFuncCall::Blake3 { outputs, .. } - | acir::circuit::opcodes::BlackBoxFuncCall::BigIntToLeBytes { - outputs, .. - } => { + | acir::circuit::opcodes::BlackBoxFuncCall::Blake3 { outputs, .. } => { for witness in outputs { transformer.mark_solvable(*witness); } diff --git a/noir/acvm-repo/acvm/src/pwg/blackbox/mod.rs b/noir/acvm-repo/acvm/src/pwg/blackbox/mod.rs index a56b24b86f3d..5eea234885c5 100644 --- a/noir/acvm-repo/acvm/src/pwg/blackbox/mod.rs +++ b/noir/acvm-repo/acvm/src/pwg/blackbox/mod.rs @@ -185,11 +185,5 @@ pub(crate) fn solve( } // Recursive aggregation will be entirely handled by the backend and is not solved by the ACVM BlackBoxFuncCall::RecursiveAggregation { .. } => Ok(()), - BlackBoxFuncCall::BigIntAdd { .. } => todo!(), - BlackBoxFuncCall::BigIntNeg { .. } => todo!(), - BlackBoxFuncCall::BigIntMul { .. } => todo!(), - BlackBoxFuncCall::BigIntDiv { .. } => todo!(), - BlackBoxFuncCall::BigIntFromLeBytes { .. } => todo!(), - BlackBoxFuncCall::BigIntToLeBytes { .. } => todo!(), } } diff --git a/noir/acvm-repo/acvm_js/Cargo.toml b/noir/acvm-repo/acvm_js/Cargo.toml index 226e273c3064..e8d46b9717e1 100644 --- a/noir/acvm-repo/acvm_js/Cargo.toml +++ b/noir/acvm-repo/acvm_js/Cargo.toml @@ -2,7 +2,7 @@ name = "acvm_js" description = "Typescript wrapper around the ACVM allowing execution of ACIR code" # x-release-please-start-version -version = "0.39.0" +version = "0.38.0" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/noir/acvm-repo/acvm_js/package.json b/noir/acvm-repo/acvm_js/package.json index 4ec9b1a2da38..2d878e961da9 100644 --- a/noir/acvm-repo/acvm_js/package.json +++ b/noir/acvm-repo/acvm_js/package.json @@ -1,6 +1,6 @@ { "name": "@noir-lang/acvm_js", - "version": "0.39.0", + "version": "0.38.0", "publishConfig": { "access": "public" }, diff --git a/noir/acvm-repo/blackbox_solver/Cargo.toml b/noir/acvm-repo/blackbox_solver/Cargo.toml index 7359cf307e4b..749ef8f289a3 100644 --- a/noir/acvm-repo/blackbox_solver/Cargo.toml +++ b/noir/acvm-repo/blackbox_solver/Cargo.toml @@ -2,7 +2,7 @@ name = "acvm_blackbox_solver" description = "A solver for the blackbox functions found in ACIR and Brillig" # x-release-please-start-version -version = "0.39.0" +version = "0.38.0" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/noir/acvm-repo/bn254_blackbox_solver/Cargo.toml b/noir/acvm-repo/bn254_blackbox_solver/Cargo.toml index a73aded231f2..b98bb370f748 100644 --- a/noir/acvm-repo/bn254_blackbox_solver/Cargo.toml +++ b/noir/acvm-repo/bn254_blackbox_solver/Cargo.toml @@ -2,7 +2,7 @@ name = "bn254_blackbox_solver" description = "Solvers for black box functions which are specific for the bn254 curve" # x-release-please-start-version -version = "0.39.0" +version = "0.38.0" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/noir/acvm-repo/brillig/Cargo.toml b/noir/acvm-repo/brillig/Cargo.toml index b9cedfe8d603..ee8651faeece 100644 --- a/noir/acvm-repo/brillig/Cargo.toml +++ b/noir/acvm-repo/brillig/Cargo.toml @@ -2,7 +2,7 @@ name = "brillig" description = "Brillig is the bytecode ACIR uses for non-determinism." # x-release-please-start-version -version = "0.39.0" +version = "0.38.0" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/noir/acvm-repo/brillig/src/black_box.rs b/noir/acvm-repo/brillig/src/black_box.rs index 5893758ce9ec..c007e78b785d 100644 --- a/noir/acvm-repo/brillig/src/black_box.rs +++ b/noir/acvm-repo/brillig/src/black_box.rs @@ -6,30 +6,15 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] pub enum BlackBoxOp { /// Calculates the SHA256 hash of the inputs. - Sha256 { - message: HeapVector, - output: HeapArray, - }, + Sha256 { message: HeapVector, output: HeapArray }, /// Calculates the Blake2s hash of the inputs. - Blake2s { - message: HeapVector, - output: HeapArray, - }, + Blake2s { message: HeapVector, output: HeapArray }, /// Calculates the Blake3 hash of the inputs. - Blake3 { - message: HeapVector, - output: HeapArray, - }, + Blake3 { message: HeapVector, output: HeapArray }, /// Calculates the Keccak256 hash of the inputs. - Keccak256 { - message: HeapVector, - output: HeapArray, - }, + Keccak256 { message: HeapVector, output: HeapArray }, /// Keccak Permutation function of 1600 width - Keccakf1600 { - message: HeapVector, - output: HeapArray, - }, + Keccakf1600 { message: HeapVector, output: HeapArray }, /// Verifies a ECDSA signature over the secp256k1 curve. EcdsaSecp256k1 { hashed_msg: HeapVector, @@ -55,23 +40,11 @@ pub enum BlackBoxOp { result: RegisterIndex, }, /// Calculates a Pedersen commitment to the inputs. - PedersenCommitment { - inputs: HeapVector, - domain_separator: RegisterIndex, - output: HeapArray, - }, + PedersenCommitment { inputs: HeapVector, domain_separator: RegisterIndex, output: HeapArray }, /// Calculates a Pedersen hash to the inputs. - PedersenHash { - inputs: HeapVector, - domain_separator: RegisterIndex, - output: RegisterIndex, - }, + PedersenHash { inputs: HeapVector, domain_separator: RegisterIndex, output: RegisterIndex }, /// Performs scalar multiplication over the embedded curve. - FixedBaseScalarMul { - low: RegisterIndex, - high: RegisterIndex, - result: HeapArray, - }, + FixedBaseScalarMul { low: RegisterIndex, high: RegisterIndex, result: HeapArray }, /// Performs addition over the embedded curve. EmbeddedCurveAdd { input1_x: RegisterIndex, @@ -81,39 +54,5 @@ pub enum BlackBoxOp { result: HeapArray, }, /// Performs point doubling over the embedded curve. - EmbeddedCurveDouble { - input1_x: RegisterIndex, - input1_y: RegisterIndex, - result: HeapArray, - }, - - BigIntAdd { - lhs: RegisterIndex, - rhs: RegisterIndex, - output: RegisterIndex, - }, - BigIntNeg { - lhs: RegisterIndex, - rhs: RegisterIndex, - output: RegisterIndex, - }, - BigIntMul { - lhs: RegisterIndex, - rhs: RegisterIndex, - output: RegisterIndex, - }, - BigIntDiv { - lhs: RegisterIndex, - rhs: RegisterIndex, - output: RegisterIndex, - }, - BigIntFromLeBytes { - inputs: HeapVector, - modulus: HeapVector, - output: RegisterIndex, - }, - BigIntToLeBytes { - input: RegisterIndex, - output: HeapVector, - }, + EmbeddedCurveDouble { input1_x: RegisterIndex, input1_y: RegisterIndex, result: HeapArray }, } diff --git a/noir/acvm-repo/brillig_vm/Cargo.toml b/noir/acvm-repo/brillig_vm/Cargo.toml index 5a8a34be881c..91bef2572bb3 100644 --- a/noir/acvm-repo/brillig_vm/Cargo.toml +++ b/noir/acvm-repo/brillig_vm/Cargo.toml @@ -2,7 +2,7 @@ name = "brillig_vm" description = "The virtual machine that processes Brillig bytecode, used to introduce non-determinism to the ACVM" # x-release-please-start-version -version = "0.39.0" +version = "0.38.0" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/noir/acvm-repo/brillig_vm/src/black_box.rs b/noir/acvm-repo/brillig_vm/src/black_box.rs index edbebb61eced..463038509e13 100644 --- a/noir/acvm-repo/brillig_vm/src/black_box.rs +++ b/noir/acvm-repo/brillig_vm/src/black_box.rs @@ -200,12 +200,6 @@ pub(crate) fn evaluate_black_box( registers.set(*output, hash.into()); Ok(()) } - BlackBoxOp::BigIntAdd { .. } => todo!(), - BlackBoxOp::BigIntNeg { .. } => todo!(), - BlackBoxOp::BigIntMul { .. } => todo!(), - BlackBoxOp::BigIntDiv { .. } => todo!(), - BlackBoxOp::BigIntFromLeBytes { .. } => todo!(), - BlackBoxOp::BigIntToLeBytes { .. } => todo!(), } } @@ -224,12 +218,6 @@ fn black_box_function_from_op(op: &BlackBoxOp) -> BlackBoxFunc { BlackBoxOp::FixedBaseScalarMul { .. } => BlackBoxFunc::FixedBaseScalarMul, BlackBoxOp::EmbeddedCurveAdd { .. } => BlackBoxFunc::EmbeddedCurveAdd, BlackBoxOp::EmbeddedCurveDouble { .. } => BlackBoxFunc::EmbeddedCurveDouble, - BlackBoxOp::BigIntAdd { .. } => BlackBoxFunc::BigIntAdd, - BlackBoxOp::BigIntNeg { .. } => BlackBoxFunc::BigIntNeg, - BlackBoxOp::BigIntMul { .. } => BlackBoxFunc::BigIntMul, - BlackBoxOp::BigIntDiv { .. } => BlackBoxFunc::BigIntDiv, - BlackBoxOp::BigIntFromLeBytes { .. } => BlackBoxFunc::BigIntFromLeBytes, - BlackBoxOp::BigIntToLeBytes { .. } => BlackBoxFunc::BigIntToLeBytes, } } diff --git a/noir/aztec_macros/src/lib.rs b/noir/aztec_macros/src/lib.rs index 7c62f8f81692..c985bbc367a2 100644 --- a/noir/aztec_macros/src/lib.rs +++ b/noir/aztec_macros/src/lib.rs @@ -40,7 +40,6 @@ pub enum AztecMacroError { AztecComputeNoteHashAndNullifierNotFound { span: Span }, AztecContractHasTooManyFunctions { span: Span }, AztecContractConstructorMissing { span: Span }, - UnsupportedFunctionArgumentType { span: Span, typ: UnresolvedTypeData }, } impl From for MacroError { @@ -66,11 +65,6 @@ impl From for MacroError { secondary_message: None, span: Some(span), }, - AztecMacroError::UnsupportedFunctionArgumentType { span, typ } => MacroError { - primary_message: format!("Provided parameter type `{typ:?}` is not supported in Aztec contract interface"), - secondary_message: None, - span: Some(span), - }, } } } @@ -347,14 +341,11 @@ fn transform_module( for func in module.functions.iter_mut() { for secondary_attribute in func.def.attributes.secondary.clone() { - let crate_graph = &context.crate_graph[crate_id]; if is_custom_attribute(&secondary_attribute, "aztec(private)") { - transform_function("Private", func, storage_defined) - .map_err(|err| (err.into(), crate_graph.root_file_id))?; + transform_function("Private", func, storage_defined); has_transformed_module = true; } else if is_custom_attribute(&secondary_attribute, "aztec(public)") { - transform_function("Public", func, storage_defined) - .map_err(|err| (err.into(), crate_graph.root_file_id))?; + transform_function("Public", func, storage_defined); has_transformed_module = true; } } @@ -393,11 +384,7 @@ fn transform_module( /// - A new Input that is provided for a kernel app circuit, named: {Public/Private}ContextInputs /// - Hashes all of the function input variables /// - This instantiates a helper function -fn transform_function( - ty: &str, - func: &mut NoirFunction, - storage_defined: bool, -) -> Result<(), AztecMacroError> { +fn transform_function(ty: &str, func: &mut NoirFunction, storage_defined: bool) { let context_name = format!("{}Context", ty); let inputs_name = format!("{}ContextInputs", ty); let return_type_name = format!("{}CircuitPublicInputs", ty); @@ -409,7 +396,7 @@ fn transform_function( } // Insert the context creation as the first action - let create_context = create_context(&context_name, &func.def.parameters)?; + let create_context = create_context(&context_name, &func.def.parameters); func.def.body.0.splice(0..0, (create_context).iter().cloned()); // Add the inputs to the params @@ -436,8 +423,6 @@ fn transform_function( "Public" => func.def.is_open = true, _ => (), } - - Ok(()) } /// Transform Unconstrained @@ -636,7 +621,7 @@ fn create_inputs(ty: &str) -> Param { /// let mut context = PrivateContext::new(inputs, hasher.hash()); /// } /// ``` -fn create_context(ty: &str, params: &[Param]) -> Result, AztecMacroError> { +fn create_context(ty: &str, params: &[Param]) -> Vec { let mut injected_expressions: Vec = vec![]; // `let mut hasher = Hasher::new();` @@ -652,7 +637,7 @@ fn create_context(ty: &str, params: &[Param]) -> Result, AztecMac injected_expressions.push(let_hasher); // Iterate over each of the function parameters, adding to them to the hasher - for Param { pattern, typ, span, .. } in params { + params.iter().for_each(|Param { pattern, typ, span: _, visibility: _ }| { match pattern { Pattern::Identifier(identifier) => { // Match the type to determine the padding to do @@ -681,18 +666,16 @@ fn create_context(ty: &str, params: &[Param]) -> Result, AztecMac }, ) } - _ => { - return Err(AztecMacroError::UnsupportedFunctionArgumentType { - typ: unresolved_type.clone(), - span: *span, - }) - } + _ => panic!( + "[Aztec Noir] Provided parameter type: {:?} is not supported", + unresolved_type + ), }; injected_expressions.push(expression); } _ => todo!(), // Maybe unreachable? } - } + }); // Create the inputs to the context let inputs_expression = variable("inputs"); @@ -714,7 +697,7 @@ fn create_context(ty: &str, params: &[Param]) -> Result, AztecMac injected_expressions.push(let_context); // Return all expressions that will be injected by the hasher - Ok(injected_expressions) + injected_expressions } /// Abstract Return Type diff --git a/noir/bootstrap_cache.sh b/noir/bootstrap_cache.sh index 672702416bd4..ac919f3ca658 100755 --- a/noir/bootstrap_cache.sh +++ b/noir/bootstrap_cache.sh @@ -8,4 +8,3 @@ echo -e "\033[1mRetrieving noir packages from remote cache...\033[0m" extract_repo noir-packages /usr/src/noir/packages ./ echo -e "\033[1mRetrieving nargo from remote cache...\033[0m" extract_repo noir /usr/src/noir/target/release ./target/ - diff --git a/noir/compiler/fm/src/file_map.rs b/noir/compiler/fm/src/file_map.rs index 50412d352ec4..c4d7002a0820 100644 --- a/noir/compiler/fm/src/file_map.rs +++ b/noir/compiler/fm/src/file_map.rs @@ -75,10 +75,6 @@ impl FileMap { pub fn get_file_id(&self, file_name: &PathString) -> Option { self.name_to_id.get(file_name).cloned() } - - pub fn all_file_ids(&self) -> impl Iterator { - self.name_to_id.values() - } } impl Default for FileMap { fn default() -> Self { diff --git a/noir/compiler/noirc_driver/tests/stdlib_warnings.rs b/noir/compiler/noirc_driver/tests/stdlib_warnings.rs index 6f4376211237..e9153ec2f99f 100644 --- a/noir/compiler/noirc_driver/tests/stdlib_warnings.rs +++ b/noir/compiler/noirc_driver/tests/stdlib_warnings.rs @@ -1,7 +1,7 @@ use std::path::Path; use noirc_driver::{file_manager_with_stdlib, prepare_crate, ErrorsAndWarnings}; -use noirc_frontend::hir::{def_map::parse_file, Context}; +use noirc_frontend::hir::Context; #[test] fn stdlib_does_not_produce_constant_warnings() -> Result<(), ErrorsAndWarnings> { @@ -15,13 +15,8 @@ fn stdlib_does_not_produce_constant_warnings() -> Result<(), ErrorsAndWarnings> file_manager.add_file_with_source(file_name, source.to_owned()).expect( "Adding source buffer to file manager should never fail when file manager is empty", ); - let parsed_files = file_manager - .as_file_map() - .all_file_ids() - .map(|&file_id| (file_id, parse_file(&file_manager, file_id))) - .collect(); - let mut context = Context::new(file_manager, parsed_files); + let mut context = Context::new(file_manager); let root_crate_id = prepare_crate(&mut context, file_name); let ((), warnings) = noirc_driver::check_crate(&mut context, root_crate_id, false, false)?; diff --git a/noir/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_black_box.rs b/noir/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_black_box.rs index c7b6f39279ba..c081806f4a73 100644 --- a/noir/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_black_box.rs +++ b/noir/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_black_box.rs @@ -244,107 +244,6 @@ pub(crate) fn convert_black_box_call( BlackBoxFunc::RecursiveAggregation => unimplemented!( "ICE: `BlackBoxFunc::RecursiveAggregation` is not implemented by the Brillig VM" ), - BlackBoxFunc::BigIntAdd => { - if let ( - [BrilligVariable::Simple(lhs), BrilligVariable::Simple(rhs)], - [BrilligVariable::Simple(output)], - ) = (function_arguments, function_results) - { - brillig_context.black_box_op_instruction(BlackBoxOp::BigIntAdd { - lhs: *lhs, - rhs: *rhs, - output: *output, - }); - } else { - unreachable!( - "ICE: EmbeddedCurveAdd expects two register arguments and one array result" - ) - } - } - BlackBoxFunc::BigIntNeg => { - if let ( - [BrilligVariable::Simple(lhs), BrilligVariable::Simple(rhs)], - [BrilligVariable::Simple(output)], - ) = (function_arguments, function_results) - { - brillig_context.black_box_op_instruction(BlackBoxOp::BigIntNeg { - lhs: *lhs, - rhs: *rhs, - output: *output, - }); - } else { - unreachable!( - "ICE: EmbeddedCurveAdd expects two register arguments and one array result" - ) - } - } - BlackBoxFunc::BigIntMul => { - if let ( - [BrilligVariable::Simple(lhs), BrilligVariable::Simple(rhs)], - [BrilligVariable::Simple(output)], - ) = (function_arguments, function_results) - { - brillig_context.black_box_op_instruction(BlackBoxOp::BigIntMul { - lhs: *lhs, - rhs: *rhs, - output: *output, - }); - } else { - unreachable!( - "ICE: EmbeddedCurveAdd expects two register arguments and one array result" - ) - } - } - BlackBoxFunc::BigIntDiv => { - if let ( - [BrilligVariable::Simple(lhs), BrilligVariable::Simple(rhs)], - [BrilligVariable::Simple(output)], - ) = (function_arguments, function_results) - { - brillig_context.black_box_op_instruction(BlackBoxOp::BigIntDiv { - lhs: *lhs, - rhs: *rhs, - output: *output, - }); - } else { - unreachable!( - "ICE: EmbeddedCurveAdd expects two register arguments and one array result" - ) - } - } - BlackBoxFunc::BigIntFromLeBytes => { - if let ([inputs, modulus], [BrilligVariable::Simple(output)]) = - (function_arguments, function_results) - { - let inputs_vector = convert_array_or_vector(brillig_context, inputs, bb_func); - let modulus_vector = convert_array_or_vector(brillig_context, modulus, bb_func); - brillig_context.black_box_op_instruction(BlackBoxOp::BigIntFromLeBytes { - inputs: inputs_vector.to_heap_vector(), - modulus: modulus_vector.to_heap_vector(), - output: *output, - }); - } else { - unreachable!( - "ICE: EmbeddedCurveAdd expects two register arguments and one array result" - ) - } - } - BlackBoxFunc::BigIntToLeBytes => { - if let ( - [BrilligVariable::Simple(input)], - [BrilligVariable::BrilligVector(result_vector)], - ) = (function_arguments, function_results) - { - brillig_context.black_box_op_instruction(BlackBoxOp::BigIntToLeBytes { - input: *input, - output: result_vector.to_heap_vector(), - }); - } else { - unreachable!( - "ICE: EmbeddedCurveAdd expects two register arguments and one array result" - ) - } - } } } diff --git a/noir/compiler/noirc_evaluator/src/brillig/brillig_ir/debug_show.rs b/noir/compiler/noirc_evaluator/src/brillig/brillig_ir/debug_show.rs index 5709b0a1aa25..dc8c6b6694cf 100644 --- a/noir/compiler/noirc_evaluator/src/brillig/brillig_ir/debug_show.rs +++ b/noir/compiler/noirc_evaluator/src/brillig/brillig_ir/debug_show.rs @@ -457,59 +457,6 @@ impl DebugShow { result ); } - BlackBoxOp::BigIntAdd { lhs, rhs, output } => { - debug_println!( - self.enable_debug_trace, - " BIGINT_ADD {} {} -> {}", - lhs, - rhs, - output - ); - } - BlackBoxOp::BigIntNeg { lhs, rhs, output } => { - debug_println!( - self.enable_debug_trace, - " BIGINT_NEG {} {} -> {}", - lhs, - rhs, - output - ); - } - BlackBoxOp::BigIntMul { lhs, rhs, output } => { - debug_println!( - self.enable_debug_trace, - " BIGINT_MUL {} {} -> {}", - lhs, - rhs, - output - ); - } - BlackBoxOp::BigIntDiv { lhs, rhs, output } => { - debug_println!( - self.enable_debug_trace, - " BIGINT_DIV {} {} -> {}", - lhs, - rhs, - output - ); - } - BlackBoxOp::BigIntFromLeBytes { inputs, modulus, output } => { - debug_println!( - self.enable_debug_trace, - " BIGINT_FROM_LE_BYTES {} {} -> {}", - inputs, - modulus, - output - ); - } - BlackBoxOp::BigIntToLeBytes { input, output } => { - debug_println!( - self.enable_debug_trace, - " BIGINT_TO_LE_BYTES {} -> {}", - input, - output - ); - } } } diff --git a/noir/compiler/noirc_evaluator/src/ssa.rs b/noir/compiler/noirc_evaluator/src/ssa.rs index e2da5652faf6..f11c077d49a5 100644 --- a/noir/compiler/noirc_evaluator/src/ssa.rs +++ b/noir/compiler/noirc_evaluator/src/ssa.rs @@ -45,7 +45,7 @@ pub(crate) fn optimize_into_acir( let ssa_gen_span = span!(Level::TRACE, "ssa_generation"); let ssa_gen_span_guard = ssa_gen_span.enter(); - let ssa = SsaBuilder::new(program, print_ssa_passes)? + let ssa_builder = SsaBuilder::new(program, print_ssa_passes)? .run_pass(Ssa::defunctionalize, "After Defunctionalization:") .run_pass(Ssa::inline_functions, "After Inlining:") // Run mem2reg with the CFG separated into blocks @@ -62,12 +62,16 @@ pub(crate) fn optimize_into_acir( // Run mem2reg once more with the flattened CFG to catch any remaining loads/stores .run_pass(Ssa::mem2reg, "After Mem2Reg:") .run_pass(Ssa::fold_constants, "After Constant Folding:") - .run_pass(Ssa::dead_instruction_elimination, "After Dead Instruction Elimination:") - .run_pass(Ssa::bubble_up_constrains, "After Constraint Bubbling:") - .finish(); + .run_pass(Ssa::dead_instruction_elimination, "After Dead Instruction Elimination:"); - let brillig = ssa.to_brillig(print_brillig_trace); + let brillig = ssa_builder.to_brillig(print_brillig_trace); + // Split off any passes the are not necessary for Brillig generation but are necessary for ACIR generation. + // We only need to fill out nested slices as we need to have a known length when dealing with memory operations + // in ACIR gen while this is not necessary in the Brillig IR. + let ssa = ssa_builder + .run_pass(Ssa::fill_internal_slices, "After Fill Internal Slice Dummy Data:") + .finish(); drop(ssa_gen_span_guard); let last_array_uses = ssa.find_last_array_uses(); diff --git a/noir/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/generated_acir.rs b/noir/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/generated_acir.rs index 4572cf1dd083..efc64c5286e3 100644 --- a/noir/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/generated_acir.rs +++ b/noir/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/generated_acir.rs @@ -251,34 +251,6 @@ impl GeneratedAcir { public_inputs: inputs[2].clone(), key_hash: inputs[3][0], }, - BlackBoxFunc::BigIntAdd => BlackBoxFuncCall::BigIntAdd { - lhs: constants[0].to_u128() as u32, - rhs: constants[1].to_u128() as u32, - output: constants[2].to_u128() as u32, - }, - BlackBoxFunc::BigIntNeg => BlackBoxFuncCall::BigIntNeg { - lhs: constants[0].to_u128() as u32, - rhs: constants[1].to_u128() as u32, - output: constants[2].to_u128() as u32, - }, - BlackBoxFunc::BigIntMul => BlackBoxFuncCall::BigIntMul { - lhs: constants[0].to_u128() as u32, - rhs: constants[1].to_u128() as u32, - output: constants[2].to_u128() as u32, - }, - BlackBoxFunc::BigIntDiv => BlackBoxFuncCall::BigIntDiv { - lhs: constants[0].to_u128() as u32, - rhs: constants[1].to_u128() as u32, - output: constants[2].to_u128() as u32, - }, - BlackBoxFunc::BigIntFromLeBytes => BlackBoxFuncCall::BigIntFromLeBytes { - inputs: inputs[0].clone(), - modulus: vecmap(constants, |c| c.to_u128() as u8), - output: todo!(), - }, - BlackBoxFunc::BigIntToLeBytes => { - BlackBoxFuncCall::BigIntToLeBytes { input: constants[0].to_u128() as u32, outputs } - } }; self.push_opcode(AcirOpcode::BlackBoxFuncCall(black_box_func_call)); @@ -601,7 +573,6 @@ fn black_box_func_expected_input_size(name: BlackBoxFunc) -> Option { match name { // Bitwise opcodes will take in 2 parameters BlackBoxFunc::AND | BlackBoxFunc::XOR => Some(2), - // All of the hash/cipher methods will take in a // variable number of inputs. BlackBoxFunc::Keccak256 @@ -622,30 +593,15 @@ fn black_box_func_expected_input_size(name: BlackBoxFunc) -> Option { BlackBoxFunc::SchnorrVerify | BlackBoxFunc::EcdsaSecp256k1 | BlackBoxFunc::EcdsaSecp256r1 => None, - // Inputs for fixed based scalar multiplication // is the low and high limbs of the scalar BlackBoxFunc::FixedBaseScalarMul => Some(2), - // Recursive aggregation has a variable number of inputs BlackBoxFunc::RecursiveAggregation => None, - // Addition over the embedded curve: input are coordinates (x1,y1) and (x2,y2) of the Grumpkin points BlackBoxFunc::EmbeddedCurveAdd => Some(4), - // Doubling over the embedded curve: input is (x,y) coordinate of the point. BlackBoxFunc::EmbeddedCurveDouble => Some(2), - - // Big integer operations take in 2 inputs - BlackBoxFunc::BigIntAdd - | BlackBoxFunc::BigIntNeg - | BlackBoxFunc::BigIntMul - | BlackBoxFunc::BigIntDiv => Some(2), - - // FromLeBytes takes a variable array of bytes as input - BlackBoxFunc::BigIntFromLeBytes => None, - // ToLeBytes takes a single big integer as input - BlackBoxFunc::BigIntToLeBytes => Some(1), } } @@ -656,46 +612,28 @@ fn black_box_expected_output_size(name: BlackBoxFunc) -> Option { // Bitwise opcodes will return 1 parameter which is the output // or the operation. BlackBoxFunc::AND | BlackBoxFunc::XOR => Some(1), - // 32 byte hash algorithms BlackBoxFunc::Keccak256 | BlackBoxFunc::SHA256 | BlackBoxFunc::Blake2s | BlackBoxFunc::Blake3 => Some(32), - BlackBoxFunc::Keccakf1600 => Some(25), - // Pedersen commitment returns a point BlackBoxFunc::PedersenCommitment => Some(2), - // Pedersen hash returns a field BlackBoxFunc::PedersenHash => Some(1), - // Can only apply a range constraint to one // witness at a time. BlackBoxFunc::RANGE => Some(0), - // Signature verification algorithms will return a boolean BlackBoxFunc::SchnorrVerify | BlackBoxFunc::EcdsaSecp256k1 | BlackBoxFunc::EcdsaSecp256r1 => Some(1), - // Output of operations over the embedded curve // will be 2 field elements representing the point. BlackBoxFunc::FixedBaseScalarMul | BlackBoxFunc::EmbeddedCurveAdd | BlackBoxFunc::EmbeddedCurveDouble => Some(2), - - // Big integer operations return a big integer - BlackBoxFunc::BigIntAdd - | BlackBoxFunc::BigIntNeg - | BlackBoxFunc::BigIntMul - | BlackBoxFunc::BigIntDiv - | BlackBoxFunc::BigIntFromLeBytes => Some(1), - - // ToLeBytes returns a variable array of bytes - BlackBoxFunc::BigIntToLeBytes => None, - // Recursive aggregation has a variable number of outputs BlackBoxFunc::RecursiveAggregation => None, } diff --git a/noir/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs b/noir/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs index d832b8d0fbb6..c0e3ed1ff661 100644 --- a/noir/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs +++ b/noir/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs @@ -88,6 +88,10 @@ struct Context { /// a new BlockId max_block_id: u32, + /// Maps SSA array values to their slice size and any nested slices internal to the parent slice. + /// This enables us to maintain the slice structure of a slice when performing an array get. + slice_sizes: HashMap, Vec>, + data_bus: DataBus, } @@ -198,6 +202,7 @@ impl Context { internal_memory_blocks: HashMap::default(), internal_mem_block_lengths: HashMap::default(), max_block_id: 0, + slice_sizes: HashMap::default(), data_bus: DataBus::default(), } } @@ -410,10 +415,62 @@ impl Context { self.define_result_var(dfg, instruction_id, result_acir_var); } Instruction::Constrain(lhs, rhs, assert_message) => { - let lhs = self.convert_numeric_value(*lhs, dfg)?; - let rhs = self.convert_numeric_value(*rhs, dfg)?; + let lhs = self.convert_value(*lhs, dfg); + let rhs = self.convert_value(*rhs, dfg); + + fn get_var_equality_assertions( + lhs: AcirValue, + rhs: AcirValue, + read_from_index: &mut impl FnMut(BlockId, usize) -> Result, + ) -> Result, InternalError> { + match (lhs, rhs) { + (AcirValue::Var(lhs, _), AcirValue::Var(rhs, _)) => Ok(vec![(lhs, rhs)]), + (AcirValue::Array(lhs_values), AcirValue::Array(rhs_values)) => { + let var_equality_assertions = lhs_values + .into_iter() + .zip(rhs_values) + .map(|(lhs, rhs)| { + get_var_equality_assertions(lhs, rhs, read_from_index) + }) + .collect::, _>>()? + .into_iter() + .flatten() + .collect(); + Ok(var_equality_assertions) + } + ( + AcirValue::DynamicArray(AcirDynamicArray { + block_id: lhs_block_id, + len, + .. + }), + AcirValue::DynamicArray(AcirDynamicArray { + block_id: rhs_block_id, + .. + }), + ) => try_vecmap(0..len, |i| { + let lhs_var = read_from_index(lhs_block_id, i)?; + let rhs_var = read_from_index(rhs_block_id, i)?; + Ok((lhs_var, rhs_var)) + }), + _ => { + unreachable!("ICE: lhs and rhs should be of the same type") + } + } + } + + let mut read_dynamic_array_index = + |block_id: BlockId, array_index: usize| -> Result { + let index_var = self.acir_context.add_constant(array_index); - self.acir_context.assert_eq_var(lhs, rhs, assert_message.clone())?; + self.acir_context.read_from_memory(block_id, &index_var) + }; + + for (lhs, rhs) in + get_var_equality_assertions(lhs, rhs, &mut read_dynamic_array_index)? + { + self.acir_context.assert_eq_var(lhs, rhs, assert_message.clone())?; + } } Instruction::Cast(value_id, _) => { let acir_var = self.convert_numeric_value(*value_id, dfg)?; @@ -626,15 +683,21 @@ impl Context { ) -> Result { let index_const = dfg.get_numeric_constant(index); let value_type = dfg.type_of_value(array); - // Compiler sanity checks - assert!( - !value_type.is_nested_slice(), - "ICE: Nested slice type has reached ACIR generation" - ); - let (Type::Array(_, _) | Type::Slice(_)) = &value_type else { + let (Type::Array(element_types, _) | Type::Slice(element_types)) = &value_type else { unreachable!("ICE: expected array or slice type"); + }; + // TODO(#3188): Need to be able to handle constant index for slices to seriously reduce + // constraint sizes of nested slices + // This can only be done if we accurately flatten nested slices as otherwise we will reach + // index out of bounds errors. If the slice is already flat then we can treat them similarly to arrays. + if matches!(value_type, Type::Slice(_)) + && element_types.iter().any(|element| element.contains_slice_element()) + { + return Ok(false); + } + match self.convert_value(array, dfg) { AcirValue::Var(acir_var, _) => { return Err(RuntimeError::InternalError(InternalError::Unexpected { @@ -725,8 +788,24 @@ impl Context { let mut dummy_predicate_index = predicate_index; // We must setup the dummy value to match the type of the value we wish to store - let dummy = - self.array_get_value(&store_type, block_id, &mut dummy_predicate_index)?; + let slice_sizes = if store_type.contains_slice_element() { + self.compute_slice_sizes(store, None, dfg); + self.slice_sizes.get(&store).cloned().ok_or_else(|| { + InternalError::Unexpected { + expected: "Store value should have slice sizes computed".to_owned(), + found: "Missing key in slice sizes map".to_owned(), + call_stack: self.acir_context.get_call_stack(), + } + })? + } else { + vec![] + }; + let dummy = self.array_get_value( + &store_type, + block_id, + &mut dummy_predicate_index, + &slice_sizes, + )?; Some(self.convert_array_set_store_value(&store_value, &dummy)?) } @@ -843,12 +922,26 @@ impl Context { } } - // Compiler sanity check - assert!( - !res_typ.contains_slice_element(), - "ICE: Nested slice result found during ACIR generation" - ); - let value = self.array_get_value(&res_typ, block_id, &mut var_index)?; + let value = if !res_typ.contains_slice_element() { + self.array_get_value(&res_typ, block_id, &mut var_index, &[])? + } else { + let slice_sizes = self + .slice_sizes + .get(&array_id) + .expect("ICE: Array with slices should have associated slice sizes"); + + // The first max size is going to be the length of the parent slice + // As we are fetching from the parent slice we just want its internal + // slice sizes. + let slice_sizes = slice_sizes[1..].to_vec(); + + let value = self.array_get_value(&res_typ, block_id, &mut var_index, &slice_sizes)?; + + // Insert the resulting slice sizes + self.slice_sizes.insert(results[0], slice_sizes); + + value + }; self.define_result(dfg, instruction, value.clone()); @@ -860,6 +953,7 @@ impl Context { ssa_type: &Type, block_id: BlockId, var_index: &mut AcirVar, + slice_sizes: &[usize], ) -> Result { let one = self.acir_context.add_constant(FieldElement::one()); match ssa_type.clone() { @@ -877,12 +971,33 @@ impl Context { let mut values = Vector::new(); for _ in 0..len { for typ in element_types.as_ref() { - values.push_back(self.array_get_value(typ, block_id, var_index)?); + values.push_back(self.array_get_value( + typ, + block_id, + var_index, + slice_sizes, + )?); } } Ok(AcirValue::Array(values)) } - _ => unreachable!("ICE: Expected an array or numeric but got {ssa_type:?}"), + Type::Slice(element_types) => { + // It is not enough to execute this loop and simply pass the size from the parent definition. + // We need the internal sizes of each type in case of a nested slice. + let mut values = Vector::new(); + + let (current_size, new_sizes) = + slice_sizes.split_first().expect("should be able to split"); + + for _ in 0..*current_size { + for typ in element_types.as_ref() { + values + .push_back(self.array_get_value(typ, block_id, var_index, new_sizes)?); + } + } + Ok(AcirValue::Array(values)) + } + _ => unreachable!("ICE - expected an array or slice"), } } @@ -944,6 +1059,23 @@ impl Context { self.array_set_value(&store_value, result_block_id, &mut var_index)?; + // Set new resulting array to have the same slice sizes as the instruction input + if let Type::Slice(element_types) = &array_typ { + let has_internal_slices = + element_types.as_ref().iter().any(|typ| typ.contains_slice_element()); + if has_internal_slices { + let slice_sizes = self + .slice_sizes + .get(&array_id) + .expect( + "ICE: Expected array with internal slices to have associated slice sizes", + ) + .clone(); + let results = dfg.instruction_results(instruction); + self.slice_sizes.insert(results[0], slice_sizes); + } + } + let element_type_sizes = if !can_omit_element_sizes_array(&array_typ) { Some(self.init_element_type_sizes_array(&array_typ, array_id, None, dfg)?) } else { @@ -1052,6 +1184,8 @@ impl Context { Type::Array(_, _) | Type::Slice(_) => { match &dfg[array_id] { Value::Array { array, .. } => { + self.compute_slice_sizes(array_id, None, dfg); + for (i, value) in array.iter().enumerate() { flat_elem_type_sizes.push( self.flattened_slice_size(*value, dfg) + flat_elem_type_sizes[i], @@ -1151,6 +1285,41 @@ impl Context { Ok(element_type_sizes) } + fn compute_slice_sizes( + &mut self, + current_array_id: ValueId, + parent_array: Option, + dfg: &DataFlowGraph, + ) { + let (array, typ) = match &dfg[current_array_id] { + Value::Array { array, typ } => (array, typ.clone()), + _ => return, + }; + + if !matches!(typ, Type::Slice(_)) { + return; + } + + let element_size = typ.element_size(); + let true_len = array.len() / element_size; + if let Some(parent_array) = parent_array { + let sizes_list = + self.slice_sizes.get_mut(&parent_array).expect("ICE: expected size list"); + sizes_list.push(true_len); + for value in array { + self.compute_slice_sizes(*value, Some(parent_array), dfg); + } + } else { + // This means the current_array_id is the parent array + // The slice sizes should follow the parent array's type structure + // thus we start our sizes list with the parent array size. + self.slice_sizes.insert(current_array_id, vec![true_len]); + for value in array { + self.compute_slice_sizes(*value, Some(current_array_id), dfg); + } + } + } + fn copy_dynamic_array( &mut self, source: BlockId, @@ -1603,21 +1772,23 @@ impl Context { let slice_length = self.convert_value(arguments[0], dfg).into_var()?; let (slice_contents, slice_typ, _) = self.check_array_is_initialized(arguments[1], dfg)?; - assert!(!slice_typ.is_nested_slice(), "ICE: Nested slice used in ACIR generation"); - let slice = self.convert_value(slice_contents, dfg); + let mut new_elem_size = Self::flattened_value_size(&slice); let mut new_slice = Vector::new(); self.slice_intrinsic_input(&mut new_slice, slice)?; let elements_to_push = &arguments[2..]; - // We must directly push back elements for non-nested slices - for elem in elements_to_push { - let element = self.convert_value(*elem, dfg); - - new_elem_size += Self::flattened_value_size(&element); - new_slice.push_back(element); + // We only fill internal slices for nested slices (a slice inside of a slice). + // So we must directly push back elements for slices which are not a nested slice. + if !slice_typ.is_nested_slice() { + for elem in elements_to_push { + let element = self.convert_value(*elem, dfg); + + new_elem_size += Self::flattened_value_size(&element); + new_slice.push_back(element); + } } // Increase the slice length by one to enable accessing more elements in the slice. @@ -1629,6 +1800,20 @@ impl Context { self.initialize_array(result_block_id, new_elem_size, Some(new_slice_val.clone()))?; // The previous slice length represents the index we want to write into. let mut var_index = slice_length; + // Dynamic arrays are represented as flat memory. We must flatten the user facing index + // to a flattened index that matches the complex slice structure. + if slice_typ.is_nested_slice() { + let element_size = slice_typ.element_size(); + + // Multiply the element size against the var index before fetching the flattened index + // This operation makes sure our user-facing slice index matches the strategy for indexing in SSA, + // which is how `get_flattened_index` expects its index input. + let element_size_var = self.acir_context.add_constant(element_size); + var_index = self.acir_context.mul_var(slice_length, element_size_var)?; + var_index = + self.get_flattened_index(&slice_typ, slice_contents, var_index, dfg)?; + } + // Write the elements we wish to push back directly. // The slice's underlying array value should already be filled with dummy data // to enable this write to be within bounds. @@ -1662,9 +1847,8 @@ impl Context { let (slice_contents, slice_typ, _) = self.check_array_is_initialized(arguments[1], dfg)?; - assert!(!slice_typ.is_nested_slice(), "ICE: Nested slice used in ACIR generation"); - let slice: AcirValue = self.convert_value(slice_contents, dfg); + let mut new_slice_size = Self::flattened_value_size(&slice); // Increase the slice length by one to enable accessing more elements in the slice. @@ -1676,14 +1860,33 @@ impl Context { let elements_to_push = &arguments[2..]; let mut elem_size = 0; - // We must directly push front elements for non-nested slices - for elem in elements_to_push.iter().rev() { - let element = self.convert_value(*elem, dfg); - - elem_size += Self::flattened_value_size(&element); - new_slice.push_front(element); + // We only fill internal slices for nested slices (a slice inside of a slice). + // So we must directly push front elements for slices which are not a nested slice. + if !slice_typ.is_nested_slice() { + for elem in elements_to_push.iter().rev() { + let element = self.convert_value(*elem, dfg); + + elem_size += Self::flattened_value_size(&element); + new_slice.push_front(element); + } + new_slice_size += elem_size; + } else { + // We have already filled the appropriate dummy values for nested slice during SSA gen. + // We need to account for that we do not go out of bounds by removing dummy data as we + // push elements to the front of our slice. + // Using this strategy we are able to avoid dynamic writes like we do for a SlicePushBack. + for elem in elements_to_push.iter().rev() { + let element = self.convert_value(*elem, dfg); + + let elem_size = Self::flattened_value_size(&element); + // Have to pop based off of the flattened value size as we read the + // slice intrinsic as a flat list of AcirValue::Var + for _ in 0..elem_size { + new_slice.pop_back(); + } + new_slice.push_front(element); + } } - new_slice_size += elem_size; let new_slice_val = AcirValue::Array(new_slice.clone()); @@ -1725,16 +1928,55 @@ impl Context { let (slice_contents, slice_typ, block_id) = self.check_array_is_initialized(arguments[1], dfg)?; - assert!(!slice_typ.is_nested_slice(), "ICE: Nested slice used in ACIR generation"); + let slice = self.convert_value(slice_contents, dfg); + + let element_size = slice_typ.element_size(); let mut popped_elements = Vec::new(); - for res in &result_ids[2..] { - let elem = - self.array_get_value(&dfg.type_of_value(*res), block_id, &mut var_index)?; - popped_elements.push(elem); + // Fetch the values we are popping off of the slice. + // In the case of non-nested slice the logic is simple as we do not + // need to account for the internal slice sizes or flattening the index. + // + // The pop back operation results are of the format [slice length, slice contents, popped elements]. + // Thus, we look at the result ids at index 2 and onwards to determine the type of each popped element. + if !slice_typ.is_nested_slice() { + for res in &result_ids[2..] { + let elem = self.array_get_value( + &dfg.type_of_value(*res), + block_id, + &mut var_index, + &[], + )?; + popped_elements.push(elem); + } + } else { + // Fetch the slice sizes of the nested slice. + let slice_sizes = self.slice_sizes.get(&slice_contents); + let mut slice_sizes = + slice_sizes.expect("ICE: should have slice sizes").clone(); + // We want to remove the parent size as we are fetching the child + slice_sizes.remove(0); + + // Multiply the element size against the var index before fetching the flattened index + // This operation makes sure our user-facing slice index matches the strategy for indexing in SSA, + // which is how `get_flattened_index` expects its index input. + let element_size_var = self.acir_context.add_constant(element_size); + // We want to use an index one less than the slice length + var_index = self.acir_context.mul_var(var_index, element_size_var)?; + var_index = + self.get_flattened_index(&slice_typ, slice_contents, var_index, dfg)?; + + for res in &result_ids[2..] { + let elem = self.array_get_value( + &dfg.type_of_value(*res), + block_id, + &mut var_index, + &slice_sizes, + )?; + popped_elements.push(elem); + } } - let slice = self.convert_value(slice_contents, dfg); let mut new_slice = Vector::new(); self.slice_intrinsic_input(&mut new_slice, slice)?; @@ -1752,13 +1994,11 @@ impl Context { let (slice_contents, slice_typ, block_id) = self.check_array_is_initialized(arguments[1], dfg)?; - assert!(!slice_typ.is_nested_slice(), "ICE: Nested slice used in ACIR generation"); + let slice = self.convert_value(slice_contents, dfg); let one = self.acir_context.add_constant(FieldElement::one()); let new_slice_length = self.acir_context.sub_var(slice_length, one)?; - let slice = self.convert_value(slice_contents, dfg); - let mut new_slice = Vector::new(); self.slice_intrinsic_input(&mut new_slice, slice)?; @@ -1770,14 +2010,40 @@ impl Context { // Fetch the values we are popping off of the slice. // In the case of non-nested slice the logic is simple as we do not // need to account for the internal slice sizes or flattening the index. - for res in &result_ids[..element_size] { - let element = - self.array_get_value(&dfg.type_of_value(*res), block_id, &mut var_index)?; - let elem_size = Self::flattened_value_size(&element); - popped_elements_size += elem_size; - popped_elements.push(element); + // + // The pop front operation results are of the format [popped elements, slice length, slice contents]. + // Thus, we look at the result ids up to the element size to determine the type of each popped element. + if !slice_typ.is_nested_slice() { + for res in &result_ids[..element_size] { + let element = self.array_get_value( + &dfg.type_of_value(*res), + block_id, + &mut var_index, + &[], + )?; + let elem_size = Self::flattened_value_size(&element); + popped_elements_size += elem_size; + popped_elements.push(element); + } + } else { + let slice_sizes = self.slice_sizes.get(&slice_contents); + let mut slice_sizes = + slice_sizes.expect("ICE: should have slice sizes").clone(); + // We want to remove the parent size as we are fetching the child + slice_sizes.remove(0); + + for res in &result_ids[..element_size] { + let element = self.array_get_value( + &dfg.type_of_value(*res), + block_id, + &mut var_index, + &slice_sizes, + )?; + let elem_size = Self::flattened_value_size(&element); + popped_elements_size += elem_size; + popped_elements.push(element); + } } - // It is expected that the `popped_elements_size` is the flattened size of the elements, // as the input slice should be a dynamic array which is represented by flat memory. new_slice = new_slice.slice(popped_elements_size..); @@ -1793,7 +2059,6 @@ impl Context { let (slice_contents, slice_typ, block_id) = self.check_array_is_initialized(arguments[1], dfg)?; - assert!(!slice_typ.is_nested_slice(), "ICE: Nested slice used in ACIR generation"); let slice = self.convert_value(slice_contents, dfg); let insert_index = self.convert_value(arguments[2], dfg).into_var()?; @@ -1899,6 +2164,7 @@ impl Context { } } + // let new_slice_val = AcirValue::Array(new_slice); let element_type_sizes = if !can_omit_element_sizes_array(&slice_typ) { Some(self.init_element_type_sizes_array( &slice_typ, @@ -1923,7 +2189,6 @@ impl Context { let (slice_contents, slice_typ, block_id) = self.check_array_is_initialized(arguments[1], dfg)?; - assert!(!slice_typ.is_nested_slice(), "ICE: Nested slice used in ACIR generation"); let slice = self.convert_value(slice_contents, dfg); let remove_index = self.convert_value(arguments[2], dfg).into_var()?; @@ -1952,6 +2217,8 @@ impl Context { self.get_flattened_index(&slice_typ, slice_contents, flat_remove_index, dfg)?; // Fetch the values we are remove from the slice. + // In the case of non-nested slice the logic is simple as we do not + // need to account for the internal slice sizes or flattening the index. // As we fetch the values we can determine the size of the removed values // which we will later use for writing the correct resulting slice. let mut popped_elements = Vec::new(); @@ -1959,12 +2226,36 @@ impl Context { // Set a temp index just for fetching from the original slice as `array_get_value` mutates // the index internally. let mut temp_index = flat_user_index; - for res in &result_ids[2..(2 + element_size)] { - let element = - self.array_get_value(&dfg.type_of_value(*res), block_id, &mut temp_index)?; - let elem_size = Self::flattened_value_size(&element); - popped_elements_size += elem_size; - popped_elements.push(element); + if !slice_typ.is_nested_slice() { + for res in &result_ids[2..(2 + element_size)] { + let element = self.array_get_value( + &dfg.type_of_value(*res), + block_id, + &mut temp_index, + &[], + )?; + let elem_size = Self::flattened_value_size(&element); + popped_elements_size += elem_size; + popped_elements.push(element); + } + } else { + let slice_sizes = self.slice_sizes.get(&slice_contents); + let mut slice_sizes = + slice_sizes.expect("ICE: should have slice sizes").clone(); + // We want to remove the parent size as we are fetching the child + slice_sizes.remove(0); + + for res in &result_ids[2..(2 + element_size)] { + let element = self.array_get_value( + &dfg.type_of_value(*res), + block_id, + &mut temp_index, + &slice_sizes, + )?; + let elem_size = Self::flattened_value_size(&element); + popped_elements_size += elem_size; + popped_elements.push(element); + } } // Go through the entire slice argument and determine what value should be written to the new slice. diff --git a/noir/compiler/noirc_evaluator/src/ssa/function_builder/mod.rs b/noir/compiler/noirc_evaluator/src/ssa/function_builder/mod.rs index 44be423be101..852848afb81e 100644 --- a/noir/compiler/noirc_evaluator/src/ssa/function_builder/mod.rs +++ b/noir/compiler/noirc_evaluator/src/ssa/function_builder/mod.rs @@ -367,12 +367,10 @@ impl FunctionBuilder { let r_squared = self.insert_binary(r, BinaryOp::Mul, r); let a = self.insert_binary(r_squared, BinaryOp::Mul, lhs); let idx = self.field_constant(FieldElement::from((bit_size - i) as i128)); - let b = self.insert_array_get(rhs_bits, idx, Type::bool()); - let not_b = self.insert_not(b); - let b = self.insert_cast(b, Type::field()); - let not_b = self.insert_cast(not_b, Type::field()); + let b = self.insert_array_get(rhs_bits, idx, Type::field()); let r1 = self.insert_binary(a, BinaryOp::Mul, b); - let r2 = self.insert_binary(r_squared, BinaryOp::Mul, not_b); + let c = self.insert_binary(one, BinaryOp::Sub, b); + let r2 = self.insert_binary(c, BinaryOp::Mul, r_squared); r = self.insert_binary(r1, BinaryOp::Add, r2); } r diff --git a/noir/compiler/noirc_evaluator/src/ssa/ir/instruction/call.rs b/noir/compiler/noirc_evaluator/src/ssa/ir/instruction/call.rs index ff9dc4f345ec..d1991abab377 100644 --- a/noir/compiler/noirc_evaluator/src/ssa/ir/instruction/call.rs +++ b/noir/compiler/noirc_evaluator/src/ssa/ir/instruction/call.rs @@ -434,13 +434,8 @@ fn simplify_black_box_func( // Currently unsolvable here as we rely on an implementation in the backend. SimplifyResult::None } - BlackBoxFunc::BigIntAdd - | BlackBoxFunc::BigIntNeg - | BlackBoxFunc::BigIntMul - | BlackBoxFunc::BigIntDiv - | BlackBoxFunc::RecursiveAggregation - | BlackBoxFunc::BigIntFromLeBytes - | BlackBoxFunc::BigIntToLeBytes => SimplifyResult::None, + + BlackBoxFunc::RecursiveAggregation => SimplifyResult::None, BlackBoxFunc::AND => { unreachable!("ICE: `BlackBoxFunc::AND` calls should be transformed into a `BinaryOp`") diff --git a/noir/compiler/noirc_evaluator/src/ssa/ir/types.rs b/noir/compiler/noirc_evaluator/src/ssa/ir/types.rs index f412def1e760..ae53c7705c25 100644 --- a/noir/compiler/noirc_evaluator/src/ssa/ir/types.rs +++ b/noir/compiler/noirc_evaluator/src/ssa/ir/types.rs @@ -139,7 +139,7 @@ impl Type { } pub(crate) fn is_nested_slice(&self) -> bool { - if let Type::Slice(element_types) | Type::Array(element_types, _) = self { + if let Type::Slice(element_types) = self { element_types.as_ref().iter().any(|typ| typ.contains_slice_element()) } else { false diff --git a/noir/compiler/noirc_evaluator/src/ssa/opt/bubble_up_constrains.rs b/noir/compiler/noirc_evaluator/src/ssa/opt/bubble_up_constrains.rs deleted file mode 100644 index 8a903cbd87b3..000000000000 --- a/noir/compiler/noirc_evaluator/src/ssa/opt/bubble_up_constrains.rs +++ /dev/null @@ -1,153 +0,0 @@ -use std::collections::HashMap; - -use crate::ssa::{ - ir::instruction::{Instruction, InstructionId}, - ssa_gen::Ssa, -}; - -impl Ssa { - /// A simple SSA pass to go through each instruction and move every `Instruction::Constrain` to immediately - /// after when all of its inputs are available. - #[tracing::instrument(level = "trace", skip(self))] - pub(crate) fn bubble_up_constrains(mut self) -> Ssa { - for function in self.functions.values_mut() { - for block in function.reachable_blocks() { - let instructions = function.dfg[block].take_instructions(); - let mut filtered_instructions = Vec::with_capacity(instructions.len()); - - // Multiple constrains can bubble up to sit under a single instruction. We want to maintain the ordering of these constraints, - // so we need to keep track of how many constraints are attached to a given instruction. - // Some assertions don't operate on instruction results, so we use Option so we also track the None case - let mut inserted_at_instruction: HashMap, usize> = - HashMap::with_capacity(instructions.len()); - - let dfg = &function.dfg; - for instruction in instructions { - let (lhs, rhs) = match dfg[instruction] { - Instruction::Constrain(lhs, rhs, ..) => (lhs, rhs), - _ => { - filtered_instructions.push(instruction); - continue; - } - }; - - let last_instruction_that_creates_inputs = filtered_instructions - .iter() - .rev() - .position(|&instruction_id| { - let results = dfg.instruction_results(instruction_id).to_vec(); - results.contains(&lhs) || results.contains(&rhs) - }) - // We iterate through the previous instructions in reverse order so the index is from the - // back of the vector - .map(|reversed_index| filtered_instructions.len() - reversed_index - 1); - - let insertion_index = last_instruction_that_creates_inputs - .map(|index| { - // We want to insert just after the last instruction that creates the inputs - index + 1 - }) - // If it doesn't depend from the previous instructions, then we insert at the start - .unwrap_or_default(); - - let already_inserted_for_this_instruction = inserted_at_instruction - .entry( - last_instruction_that_creates_inputs - .map(|index| filtered_instructions[index]), - ) - .or_default(); - - filtered_instructions.insert( - insertion_index + *already_inserted_for_this_instruction, - instruction, - ); - - *already_inserted_for_this_instruction += 1; - } - - *function.dfg[block].instructions_mut() = filtered_instructions; - } - } - self - } -} - -#[cfg(test)] -mod test { - use crate::ssa::{ - function_builder::FunctionBuilder, - ir::{ - function::RuntimeType, - instruction::{Binary, BinaryOp, Instruction}, - map::Id, - types::Type, - }, - }; - - #[test] - fn check_bubble_up_constrains() { - // fn main f0 { - // b0(v0: Field): - // v1 = add v0, Field 1 - // v2 = add v1, Field 1 - // constrain v0 == Field 1 'With message' - // constrain v2 == Field 3 - // constrain v0 == Field 1 - // constrain v1 == Field 2 - // constrain v1 == Field 2 'With message' - // } - // - let main_id = Id::test_new(0); - - // Compiling main - let mut builder = FunctionBuilder::new("main".into(), main_id, RuntimeType::Acir); - let v0 = builder.add_parameter(Type::field()); - - let one = builder.field_constant(1u128); - let two = builder.field_constant(2u128); - let three = builder.field_constant(3u128); - - let v1 = builder.insert_binary(v0, BinaryOp::Add, one); - let v2 = builder.insert_binary(v1, BinaryOp::Add, one); - builder.insert_constrain(v0, one, Some("With message".to_string())); - builder.insert_constrain(v2, three, None); - builder.insert_constrain(v0, one, None); - builder.insert_constrain(v1, two, None); - builder.insert_constrain(v1, two, Some("With message".to_string())); - builder.terminate_with_return(vec![]); - - let ssa = builder.finish(); - - // Expected output: - // - // fn main f0 { - // b0(v0: Field): - // constrain v0 == Field 1 'With message' - // constrain v0 == Field 1 - // v1 = add v0, Field 1 - // constrain v1 == Field 2 - // constrain v1 == Field 2 'With message' - // v2 = add v1, Field 1 - // constrain v2 == Field 3 - // } - // - let ssa = ssa.bubble_up_constrains(); - let main = ssa.main(); - let block = &main.dfg[main.entry_block()]; - assert_eq!(block.instructions().len(), 7); - - let expected_instructions = vec![ - Instruction::Constrain(v0, one, Some("With message".to_string())), - Instruction::Constrain(v0, one, None), - Instruction::Binary(Binary { lhs: v0, rhs: one, operator: BinaryOp::Add }), - Instruction::Constrain(v1, two, None), - Instruction::Constrain(v1, two, Some("With message".to_string())), - Instruction::Binary(Binary { lhs: v1, rhs: one, operator: BinaryOp::Add }), - Instruction::Constrain(v2, three, None), - ]; - - for (index, instruction) in block.instructions().iter().enumerate() { - assert_eq!(&main.dfg[*instruction], &expected_instructions[index]); - } - } -} diff --git a/noir/compiler/noirc_evaluator/src/ssa/opt/fill_internal_slices.rs b/noir/compiler/noirc_evaluator/src/ssa/opt/fill_internal_slices.rs new file mode 100644 index 000000000000..5ee8e42fe3ac --- /dev/null +++ b/noir/compiler/noirc_evaluator/src/ssa/opt/fill_internal_slices.rs @@ -0,0 +1,765 @@ +//! This module defines the internal slices data fill pass. +//! The purpose of this pass is to fill out nested slice values represented by SSA array values. +//! "Filling out" a nested slice specifically refers to making a nested slice's internal slice types +//! match up in their size. This pass is necessary for dynamic array operations to work in ACIR gen +//! as we need to have a known size for any memory operations. As slice types do not carry a size we +//! need to make sure all nested internal slices have the same size in order to accurately +//! read from or write to a nested slice. This pass ultimately attaches dummy data to any smaller internal slice types. +//! +//! A simple example: +//! If we have a slice of the type [[Field]] which is of length 2. The internal slices themselves +//! could be of different sizes, such as 3 and 4. An array operation on this nested slice would look +//! something like below: +//! array_get [Field 3, [Field 1, Field 1, Field 1], Field 4, [Field 2, Field 2, Field 2, Field 2]], index Field v0 +//! Will get translated into a new instruction like such: +//! array_get [Field 3, [Field 1, Field 1, Field 1, Field 0], Field 4, [Field 2, Field 2, Field 2, Field 2]], index Field v0 +//! +//! +//! TODO(#3188): Currently the pass only works on a single flattened block. This should be updated in followup work. +//! The steps of the pass are as follows: +//! - Process each instruction of the block to collect relevant slice size information. We want to find the maximum size that a nested slice +//! potentially could be. Slices can potentially be set to larger array values or used in intrinsics that increase or shorten their size. +//! - Track all array constants and compute an initial map of their nested slice sizes. The slice sizes map is simply a map of an SSA array value +//! to its array size and then any child slice values that may exist. +//! - We also track a map to resolve a starting array constant to its final possible array value. This map is updated on the appropriate instructions +//! such as ArraySet or any slice intrinsics. +//! - On an ArrayGet operation add the resulting value as a possible child of the original slice. In SSA we will reuse the same memory block +//! for the nested slice and must account for an internal slice being fetched and set to a larger value, otherwise we may have an out of bounds error. +//! Also set the resulting fetched value to have the same internal slice size map as the children of the original array used in the operation. +//! - On an ArraySet operation we set the resulting value to have the same slice sizes map as the original array used in the operation. Like the result of +//! an ArrayGet we need to also add the `value` for an ArraySet as a possible child slice of the original array. +//! - For slice intrinsics we set the resulting value to have the same slice sizes map as the original array the same way as we do in an ArraySet. +//! However, with a slice intrinsic we also increase the size for the respective slice intrinsics. +//! We do not decrement the size on intrinsics that could remove values from a slice. This is because we could potentially go back to the smaller slice size, +//! not fill in the appropriate dummies and then get an out of bounds error later when executing the ACIR. We always want to compute +//! what a slice maximum size could be. +//! - Now we need to add each instruction back except with the updated original array values. +//! - Resolve the original slice value to what its final value would be using the previously computed map. +//! - Find the max size as each layer of the recursive nested slice type. +//! For instance in the example above we have a slice of depth 2 with the max sizes of [2, 4]. +//! - Follow the slice type to check whether the SSA value is under the specified max size. If a slice value +//! is under the max size we then attach dummy data. +//! - Construct a final nested slice with the now attached dummy data and replace the original array in the previously +//! saved ArrayGet and ArraySet instructions. + +use crate::ssa::{ + ir::{ + basic_block::BasicBlockId, + dfg::CallStack, + function::{Function, RuntimeType}, + function_inserter::FunctionInserter, + instruction::{Instruction, InstructionId, Intrinsic}, + post_order::PostOrder, + types::Type, + value::{Value, ValueId}, + }, + ssa_gen::Ssa, +}; + +use acvm::FieldElement; +use fxhash::FxHashMap as HashMap; + +impl Ssa { + #[tracing::instrument(level = "trace", skip(self))] + pub(crate) fn fill_internal_slices(mut self) -> Ssa { + for function in self.functions.values_mut() { + // This pass is only necessary for generating ACIR and thus we should not + // process Brillig functions. + // The pass is also currently only setup to handle a function with a single flattened block. + // For complex Brillig functions we can expect this pass to panic. + if function.runtime() == RuntimeType::Acir { + let databus = function.dfg.data_bus.clone(); + let mut context = Context::new(function); + context.process_blocks(); + // update the databus with the new array instructions + function.dfg.data_bus = databus.map_values(|t| context.inserter.resolve(t)); + } + } + self + } +} + +struct Context<'f> { + post_order: PostOrder, + inserter: FunctionInserter<'f>, + + /// Maps SSA array values representing a slice's contents to its updated array value + /// after an array set or a slice intrinsic operation. + /// Maps original value -> result + mapped_slice_values: HashMap, + + /// Maps an updated array value following an array operation to its previous value. + /// When used in conjunction with `mapped_slice_values` we form a two way map of all array + /// values being used in array operations. + /// Maps result -> original value + slice_parents: HashMap, +} + +impl<'f> Context<'f> { + fn new(function: &'f mut Function) -> Self { + let post_order = PostOrder::with_function(function); + let inserter = FunctionInserter::new(function); + + Context { + post_order, + inserter, + mapped_slice_values: HashMap::default(), + slice_parents: HashMap::default(), + } + } + + fn process_blocks(&mut self) { + let mut block_order = PostOrder::with_function(self.inserter.function).into_vec(); + block_order.reverse(); + for block in block_order { + self.process_block(block); + } + } + + fn process_block(&mut self, block: BasicBlockId) { + // Fetch SSA values potentially with internal slices + let instructions = self.inserter.function.dfg[block].take_instructions(); + + // Values containing nested slices to be replaced + let mut slice_values = Vec::new(); + // Maps SSA array ID representing slice contents to its length and a list of its potential internal slices + // This map is constructed once for an array constant and is then updated + // according to the rules in `collect_slice_information`. + let mut slice_sizes: HashMap)> = HashMap::default(); + + // Update the slice sizes map to help find the potential max size of each nested slice. + for instruction in instructions.iter() { + self.collect_slice_information(*instruction, &mut slice_values, &mut slice_sizes); + } + + // Add back every instruction with the updated nested slices. + for instruction in instructions { + self.push_updated_instruction(instruction, &slice_values, &slice_sizes, block); + } + + self.inserter.map_terminator_in_place(block); + } + + /// Determine how the slice sizes map needs to be updated according to the provided instruction. + fn collect_slice_information( + &mut self, + instruction: InstructionId, + slice_values: &mut Vec, + slice_sizes: &mut HashMap)>, + ) { + let results = self.inserter.function.dfg.instruction_results(instruction); + match &self.inserter.function.dfg[instruction] { + Instruction::ArrayGet { array, .. } => { + let array_typ = self.inserter.function.dfg.type_of_value(*array); + let array_value = &self.inserter.function.dfg[*array]; + // If we have an SSA value containing nested slices we should mark it + // as a slice that potentially requires to be filled with dummy data. + if matches!(array_value, Value::Array { .. }) && array_typ.contains_slice_element() + { + slice_values.push(*array); + // Initial insertion into the slice sizes map + // Any other insertions should only occur if the value is already + // a part of the map. + self.compute_slice_sizes(*array, slice_sizes); + } + + let res_typ = self.inserter.function.dfg.type_of_value(results[0]); + if res_typ.contains_slice_element() { + if let Some(inner_sizes) = slice_sizes.get_mut(array) { + // Include the result in the parent array potential children + // If the result has internal slices and is called in an array set + // we could potentially have a new larger slice which we need to account for + inner_sizes.1.push(results[0]); + self.slice_parents.insert(results[0], *array); + + let inner_sizes_iter = inner_sizes.1.clone(); + for slice_value in inner_sizes_iter { + let inner_slice = slice_sizes.get(&slice_value).unwrap_or_else(|| { + panic!("ICE: should have inner slice set for {slice_value}") + }); + slice_sizes.insert(results[0], inner_slice.clone()); + if slice_value != results[0] { + self.mapped_slice_values.insert(slice_value, results[0]); + } + } + } + } + } + Instruction::ArraySet { array, value, .. } => { + let array_typ = self.inserter.function.dfg.type_of_value(*array); + let array_value = &self.inserter.function.dfg[*array]; + // If we have an SSA value containing nested slices we should mark it + // as a slice that potentially requires to be filled with dummy data. + if matches!(array_value, Value::Array { .. }) && array_typ.contains_slice_element() + { + slice_values.push(*array); + // Initial insertion into the slice sizes map + // Any other insertions should only occur if the value is already + // a part of the map. + self.compute_slice_sizes(*array, slice_sizes); + } + + let value_typ = self.inserter.function.dfg.type_of_value(*value); + if value_typ.contains_slice_element() { + self.compute_slice_sizes(*value, slice_sizes); + + let inner_sizes = slice_sizes.get_mut(array).expect("ICE expected slice sizes"); + inner_sizes.1.push(*value); + } + + if let Some(inner_sizes) = slice_sizes.get_mut(array) { + let inner_sizes = inner_sizes.clone(); + + slice_sizes.insert(results[0], inner_sizes); + + self.mapped_slice_values.insert(*array, results[0]); + self.slice_parents.insert(results[0], *array); + } + } + Instruction::Call { func, arguments } => { + let func = &self.inserter.function.dfg[*func]; + if let Value::Intrinsic(intrinsic) = func { + let (argument_index, result_index) = match intrinsic { + Intrinsic::SlicePushBack + | Intrinsic::SlicePushFront + | Intrinsic::SlicePopBack + | Intrinsic::SliceInsert + | Intrinsic::SliceRemove => (1, 1), + // `pop_front` returns the popped element, and then the respective slice. + // This means in the case of a slice with structs, the result index of the popped slice + // will change depending on the number of elements in the struct. + // For example, a slice with four elements will look as such in SSA: + // v3, v4, v5, v6, v7, v8 = call slice_pop_front(v1, v2) + // where v7 is the slice length and v8 is the popped slice itself. + Intrinsic::SlicePopFront => (1, results.len() - 1), + _ => return, + }; + let slice_contents = arguments[argument_index]; + match intrinsic { + Intrinsic::SlicePushBack + | Intrinsic::SlicePushFront + | Intrinsic::SliceInsert => { + for arg in &arguments[(argument_index + 1)..] { + let element_typ = self.inserter.function.dfg.type_of_value(*arg); + if element_typ.contains_slice_element() { + slice_values.push(*arg); + self.compute_slice_sizes(*arg, slice_sizes); + } + } + if let Some(inner_sizes) = slice_sizes.get_mut(&slice_contents) { + inner_sizes.0 += 1; + + let inner_sizes = inner_sizes.clone(); + slice_sizes.insert(results[result_index], inner_sizes); + + self.mapped_slice_values + .insert(slice_contents, results[result_index]); + self.slice_parents.insert(results[result_index], slice_contents); + } + } + Intrinsic::SlicePopBack + | Intrinsic::SliceRemove + | Intrinsic::SlicePopFront => { + // We do not decrement the size on intrinsics that could remove values from a slice. + // This is because we could potentially go back to the smaller slice and not fill in dummies. + // This pass should be tracking the potential max that a slice ***could be*** + if let Some(inner_sizes) = slice_sizes.get(&slice_contents) { + let inner_sizes = inner_sizes.clone(); + slice_sizes.insert(results[result_index], inner_sizes); + + self.mapped_slice_values + .insert(slice_contents, results[result_index]); + self.slice_parents.insert(results[result_index], slice_contents); + } + } + _ => {} + } + } + } + _ => {} + } + } + + fn push_updated_instruction( + &mut self, + instruction: InstructionId, + slice_values: &[ValueId], + slice_sizes: &HashMap)>, + block: BasicBlockId, + ) { + match &self.inserter.function.dfg[instruction] { + Instruction::ArrayGet { array, .. } | Instruction::ArraySet { array, .. } => { + if slice_values.contains(array) { + let (new_array_op_instr, call_stack) = + self.get_updated_array_op_instr(*array, slice_sizes, instruction); + self.inserter.push_instruction_value( + new_array_op_instr, + instruction, + block, + call_stack, + ); + } else { + self.inserter.push_instruction(instruction, block); + } + } + Instruction::Call { func: _, arguments } => { + let mut args_to_replace = Vec::new(); + for (i, arg) in arguments.iter().enumerate() { + let element_typ = self.inserter.function.dfg.type_of_value(*arg); + if slice_values.contains(arg) && element_typ.contains_slice_element() { + args_to_replace.push((i, *arg)); + } + } + if args_to_replace.is_empty() { + self.inserter.push_instruction(instruction, block); + } else { + // Using the original slice is ok to do as during collection of slice information + // we guarantee that only the arguments to slice intrinsic calls can be replaced. + let slice_contents = arguments[1]; + + let element_typ = self.inserter.function.dfg.type_of_value(arguments[1]); + let elem_depth = Self::compute_nested_slice_depth(&element_typ); + + let mut max_sizes = Vec::new(); + max_sizes.resize(elem_depth, 0); + // We want the max for the parent of the argument + let parent = self.resolve_slice_parent(slice_contents); + self.compute_slice_max_sizes(parent, slice_sizes, &mut max_sizes, 0); + + for (index, arg) in args_to_replace { + let element_typ = self.inserter.function.dfg.type_of_value(arg); + max_sizes.remove(0); + let new_array = + self.attach_slice_dummies(&element_typ, Some(arg), false, &max_sizes); + + let instruction_id = instruction; + let (instruction, call_stack) = + self.inserter.map_instruction(instruction_id); + let new_call_instr = match instruction { + Instruction::Call { func, mut arguments } => { + arguments[index] = new_array; + Instruction::Call { func, arguments } + } + _ => panic!("Expected call instruction"), + }; + self.inserter.push_instruction_value( + new_call_instr, + instruction_id, + block, + call_stack, + ); + } + } + } + _ => { + self.inserter.push_instruction(instruction, block); + } + } + } + + /// Construct an updated ArrayGet or ArraySet instruction where the array value + /// has been replaced by a newly filled in array according to the max internal + /// slice sizes. + fn get_updated_array_op_instr( + &mut self, + array_id: ValueId, + slice_sizes: &HashMap)>, + instruction: InstructionId, + ) -> (Instruction, CallStack) { + let mapped_slice_value = self.resolve_slice_value(array_id); + + let (current_size, _) = slice_sizes + .get(&mapped_slice_value) + .unwrap_or_else(|| panic!("should have slice sizes: {mapped_slice_value}")); + + let mut max_sizes = Vec::new(); + + let typ = self.inserter.function.dfg.type_of_value(array_id); + let depth = Self::compute_nested_slice_depth(&typ); + max_sizes.resize(depth, 0); + + max_sizes[0] = *current_size; + self.compute_slice_max_sizes(array_id, slice_sizes, &mut max_sizes, 1); + + let new_array = self.attach_slice_dummies(&typ, Some(array_id), true, &max_sizes); + + let instruction_id = instruction; + let (instruction, call_stack) = self.inserter.map_instruction(instruction_id); + let new_array_op_instr = match instruction { + Instruction::ArrayGet { index, .. } => { + Instruction::ArrayGet { array: new_array, index } + } + Instruction::ArraySet { index, value, .. } => { + Instruction::ArraySet { array: new_array, index, value } + } + _ => panic!("Expected array set"), + }; + + (new_array_op_instr, call_stack) + } + + fn attach_slice_dummies( + &mut self, + typ: &Type, + value: Option, + is_parent_slice: bool, + max_sizes: &[usize], + ) -> ValueId { + match typ { + Type::Numeric(_) => { + if let Some(value) = value { + self.inserter.resolve(value) + } else { + let zero = FieldElement::zero(); + self.inserter.function.dfg.make_constant(zero, Type::field()) + } + } + Type::Array(element_types, len) => { + if let Some(value) = value { + self.inserter.resolve(value) + } else { + let mut array = im::Vector::new(); + for _ in 0..*len { + for typ in element_types.iter() { + array.push_back(self.attach_slice_dummies(typ, None, false, max_sizes)); + } + } + self.inserter.function.dfg.make_array(array, typ.clone()) + } + } + Type::Slice(element_types) => { + let (current_size, max_sizes) = + max_sizes.split_first().expect("ICE: Missing internal slice max size"); + let mut max_size = *current_size; + if let Some(value) = value { + let mut slice = im::Vector::new(); + + let value = self.inserter.function.dfg[value].clone(); + let array = match value { + Value::Array { array, .. } => array, + _ => { + panic!("Expected an array value"); + } + }; + + if is_parent_slice { + max_size = array.len() / element_types.len(); + } + for i in 0..max_size { + for (element_index, element_type) in element_types.iter().enumerate() { + let index_usize = i * element_types.len() + element_index; + let valid_index = index_usize < array.len(); + let maybe_value = + if valid_index { Some(array[index_usize]) } else { None }; + slice.push_back(self.attach_slice_dummies( + element_type, + maybe_value, + false, + max_sizes, + )); + } + } + + self.inserter.function.dfg.make_array(slice, typ.clone()) + } else { + let mut slice = im::Vector::new(); + for _ in 0..max_size { + for typ in element_types.iter() { + slice.push_back(self.attach_slice_dummies(typ, None, false, max_sizes)); + } + } + self.inserter.function.dfg.make_array(slice, typ.clone()) + } + } + Type::Reference(_) => { + unreachable!("ICE: Generating dummy data for references is unsupported") + } + Type::Function => { + unreachable!("ICE: Generating dummy data for functions is unsupported") + } + } + } + + // This methods computes a map representing a nested slice. + // The method also automatically computes the given max slice size + // at each depth of the recursive type. + // For example if we had a next slice + fn compute_slice_sizes( + &self, + array_id: ValueId, + slice_sizes: &mut HashMap)>, + ) { + if let Value::Array { array, typ } = &self.inserter.function.dfg[array_id].clone() { + if let Type::Slice(_) = typ { + let element_size = typ.element_size(); + let len = array.len() / element_size; + let mut slice_value = (len, vec![]); + for value in array { + let typ = self.inserter.function.dfg.type_of_value(*value); + if let Type::Slice(_) = typ { + slice_value.1.push(*value); + self.compute_slice_sizes(*value, slice_sizes); + } + } + // Mark the correct max size based upon an array values internal structure + let mut max_size = 0; + for inner_value in slice_value.1.iter() { + let inner_slice = + slice_sizes.get(inner_value).expect("ICE: should have inner slice set"); + if inner_slice.0 > max_size { + max_size = inner_slice.0; + } + } + for inner_value in slice_value.1.iter() { + let inner_slice = + slice_sizes.get_mut(inner_value).expect("ICE: should have inner slice set"); + if inner_slice.0 < max_size { + inner_slice.0 = max_size; + } + } + slice_sizes.insert(array_id, slice_value); + } + } + } + + /// Determine the maximum possible size of an internal slice at each + /// layer of a nested slice. + /// + /// If the slice map is incorrectly formed the function will exceed + /// the type's nested slice depth and panic. + fn compute_slice_max_sizes( + &self, + array_id: ValueId, + slice_sizes: &HashMap)>, + max_sizes: &mut Vec, + depth: usize, + ) { + let array_id = self.resolve_slice_value(array_id); + let (current_size, inner_slices) = slice_sizes + .get(&array_id) + .unwrap_or_else(|| panic!("should have slice sizes: {array_id}")); + + if inner_slices.is_empty() { + return; + } + + let mut max = *current_size; + for inner_slice in inner_slices.iter() { + let inner_slice = &self.resolve_slice_value(*inner_slice); + + let (inner_size, _) = slice_sizes[inner_slice]; + if inner_size > max { + max = inner_size; + } + self.compute_slice_max_sizes(*inner_slice, slice_sizes, max_sizes, depth + 1); + } + + if max > max_sizes[depth] { + max_sizes[depth] = max; + } + } + + /// Compute the depth of nested slices in a given Type. + /// The depth follows the recursive type structure of a slice. + fn compute_nested_slice_depth(typ: &Type) -> usize { + let mut depth = 0; + if let Type::Slice(element_types) = typ { + depth += 1; + for typ in element_types.as_ref() { + depth += Self::compute_nested_slice_depth(typ); + } + } + depth + } + + /// Resolves a ValueId representing a slice's contents to its updated value. + /// If there is no resolved value for the supplied value, the value which + /// was passed to the method is returned. + fn resolve_slice_value(&self, array_id: ValueId) -> ValueId { + match self.mapped_slice_values.get(&array_id) { + Some(value) => self.resolve_slice_value(*value), + None => array_id, + } + } + + /// Resolves a ValueId representing a slice's contents to its previous value. + /// If there is no resolved parent value it means we have the original slice value + /// and the value which was passed to the method is returned. + fn resolve_slice_parent(&self, array_id: ValueId) -> ValueId { + match self.slice_parents.get(&array_id) { + Some(value) => self.resolve_slice_parent(*value), + None => array_id, + } + } +} + +#[cfg(test)] +mod tests { + + use std::rc::Rc; + + use acvm::FieldElement; + use im::vector; + + use crate::ssa::{ + function_builder::FunctionBuilder, + ir::{ + dfg::DataFlowGraph, + function::RuntimeType, + instruction::{BinaryOp, Instruction}, + map::Id, + types::Type, + value::ValueId, + }, + }; + + #[test] + fn test_simple_nested_slice() { + // We want to test that a nested slice with two internal slices of primitive types + // fills the smaller internal slice with dummy data to match the length of the + // larger internal slice. + + // Note that slices are a represented by a tuple of (length, contents). + // The type of the nested slice in this test is [[Field]]. + // + // This is the original SSA: + // acir fn main f0 { + // b0(v0: Field): + // v2 = lt v0, Field 2 + // constrain v2 == Field 1 'Index out of bounds' + // v11 = array_get [[Field 3, [Field 1, Field 1, Field 1]], [Field 4, [Field 2, Field 2, Field 2, Field 2]]], index Field v0 + // constrain v11 == Field 4 + // return + // } + + let main_id = Id::test_new(0); + let mut builder = FunctionBuilder::new("main".into(), main_id, RuntimeType::Acir); + + let main_v0 = builder.add_parameter(Type::field()); + + let two = builder.field_constant(2_u128); + // Every slice access checks against the dynamic slice length + let slice_access_check = builder.insert_binary(main_v0, BinaryOp::Lt, two); + let one = builder.field_constant(1_u128); + builder.insert_constrain(slice_access_check, one, Some("Index out of bounds".to_owned())); + + let field_element_type = Rc::new(vec![Type::field()]); + let inner_slice_contents_type = Type::Slice(field_element_type); + + let inner_slice_small_len = builder.field_constant(3_u128); + let inner_slice_small_contents = + builder.array_constant(vector![one, one, one], inner_slice_contents_type.clone()); + + let inner_slice_big_len = builder.field_constant(4_u128); + let inner_slice_big_contents = + builder.array_constant(vector![two, two, two, two], inner_slice_contents_type.clone()); + + let outer_slice_element_type = Rc::new(vec![Type::field(), inner_slice_contents_type]); + let outer_slice_type = Type::Slice(outer_slice_element_type); + + let outer_slice_contents = builder.array_constant( + vector![ + inner_slice_small_len, + inner_slice_small_contents, + inner_slice_big_len, + inner_slice_big_contents + ], + outer_slice_type, + ); + // Fetching the length of the second nested slice + // We must use a parameter to main as we do not want the array operation to be simplified out during SSA gen. The filling of internal slices + // is necessary for dynamic nested slices and thus we want to generate the SSA that ACIR gen would be converting. + let array_get_res = builder.insert_array_get(outer_slice_contents, main_v0, Type::field()); + + let four = builder.field_constant(4_u128); + builder.insert_constrain(array_get_res, four, None); + builder.terminate_with_return(vec![]); + + // Note that now the smaller internal slice should have extra dummy data that matches the larger internal slice's size. + // + // Expected SSA: + // acir fn main f0 { + // b0(v0: Field): + // v10 = lt v0, Field 2 + // constrain v10 == Field 1 'Index out of bounds' + // v18 = array_get [Field 3, [Field 1, Field 1, Field 1, Field 0], Field 4, [Field 2, Field 2, Field 2, Field 2]], index v0 + // constrain v18 == Field 4 + // return + // } + + let ssa = builder.finish().fill_internal_slices(); + + let func = ssa.main(); + let block_id = func.entry_block(); + + // Check the array get expression has replaced its nested slice with a new slice + // where the internal slice has dummy data attached to it. + let instructions = func.dfg[block_id].instructions(); + let array_id = instructions + .iter() + .find_map(|instruction| { + if let Instruction::ArrayGet { array, .. } = func.dfg[*instruction] { + Some(array) + } else { + None + } + }) + .expect("Should find array_get instruction"); + + let (array_constant, _) = + func.dfg.get_array_constant(array_id).expect("should have an array constant"); + + let inner_slice_small_len = func + .dfg + .get_numeric_constant(array_constant[0]) + .expect("should have a numeric constant"); + assert_eq!( + inner_slice_small_len, + FieldElement::from(3u128), + "The length of the smaller internal slice should be unchanged" + ); + + let (inner_slice_small_contents, _) = + func.dfg.get_array_constant(array_constant[1]).expect("should have an array constant"); + let small_capacity = inner_slice_small_contents.len(); + assert_eq!(small_capacity, 4, "The inner slice contents should contain dummy element"); + + compare_array_constants(&inner_slice_small_contents, &[1, 1, 1, 0], &func.dfg); + + let inner_slice_big_len = func + .dfg + .get_numeric_constant(array_constant[2]) + .expect("should have a numeric constant"); + assert_eq!( + inner_slice_big_len, + FieldElement::from(4u128), + "The length of the larger internal slice should be unchanged" + ); + + let (inner_slice_big_contents, _) = + func.dfg.get_array_constant(array_constant[3]).expect("should have an array constant"); + let big_capacity = inner_slice_big_contents.len(); + assert_eq!( + small_capacity, big_capacity, + "The length of both internal slice contents should be the same" + ); + + compare_array_constants(&inner_slice_big_contents, &[2u128; 4], &func.dfg); + } + + fn compare_array_constants( + got_list: &im::Vector, + expected_list: &[u128], + dfg: &DataFlowGraph, + ) { + for i in 0..got_list.len() { + let got_value = + dfg.get_numeric_constant(got_list[i]).expect("should have a numeric constant"); + assert_eq!( + got_value, + FieldElement::from(expected_list[i]), + "Value is different than expected" + ); + } + } +} diff --git a/noir/compiler/noirc_evaluator/src/ssa/opt/mod.rs b/noir/compiler/noirc_evaluator/src/ssa/opt/mod.rs index 71725422a7a9..95784194d284 100644 --- a/noir/compiler/noirc_evaluator/src/ssa/opt/mod.rs +++ b/noir/compiler/noirc_evaluator/src/ssa/opt/mod.rs @@ -5,10 +5,10 @@ //! Generally, these passes are also expected to minimize the final amount of instructions. mod array_use; mod assert_constant; -mod bubble_up_constrains; mod constant_folding; mod defunctionalize; mod die; +mod fill_internal_slices; pub(crate) mod flatten_cfg; mod inlining; mod mem2reg; diff --git a/noir/compiler/noirc_evaluator/src/ssa/ssa_gen/context.rs b/noir/compiler/noirc_evaluator/src/ssa/ssa_gen/context.rs index 0e155776545e..f1a2154d3a89 100644 --- a/noir/compiler/noirc_evaluator/src/ssa/ssa_gen/context.rs +++ b/noir/compiler/noirc_evaluator/src/ssa/ssa_gen/context.rs @@ -270,12 +270,11 @@ impl<'a> FunctionContext<'a> { /// helper function which add instructions to the block computing the absolute value of the /// given signed integer input. When the input is negative, we return its two complement, and itself when it is positive. fn absolute_value_helper(&mut self, input: ValueId, sign: ValueId, bit_size: u32) -> ValueId { - assert_eq!(self.builder.type_of_value(sign), Type::bool()); - // We compute the absolute value of lhs + let one = self.builder.numeric_constant(FieldElement::one(), Type::bool()); let bit_width = self.builder.numeric_constant(FieldElement::from(2_i128.pow(bit_size)), Type::field()); - let sign_not = self.builder.insert_not(sign); + let sign_not = self.builder.insert_binary(one, BinaryOp::Sub, sign); // We use unsafe casts here, this is fine as we're casting to a `field` type. let as_field = self.builder.insert_cast(input, Type::field()); @@ -473,6 +472,7 @@ impl<'a> FunctionContext<'a> { location: Location, ) { let is_sub = operator == BinaryOpKind::Subtract; + let one = self.builder.numeric_constant(FieldElement::one(), Type::bool()); let half_width = self.builder.numeric_constant( FieldElement::from(2_i128.pow(bit_size - 1)), Type::unsigned(bit_size), @@ -484,7 +484,7 @@ impl<'a> FunctionContext<'a> { let mut rhs_sign = self.builder.insert_binary(rhs_as_unsigned, BinaryOp::Lt, half_width); let message = if is_sub { // lhs - rhs = lhs + (-rhs) - rhs_sign = self.builder.insert_not(rhs_sign); + rhs_sign = self.builder.insert_binary(one, BinaryOp::Sub, rhs_sign); "attempt to subtract with overflow".to_string() } else { "attempt to add with overflow".to_string() @@ -518,15 +518,13 @@ impl<'a> FunctionContext<'a> { let product = self.builder.insert_cast(product_field, Type::unsigned(bit_size)); // Then we check the signed product fits in a signed integer of bit_size-bits - let not_same = self.builder.insert_not(same_sign); + let not_same = self.builder.insert_binary(one, BinaryOp::Sub, same_sign); let not_same_sign_field = self.insert_safe_cast(not_same, Type::unsigned(bit_size), location); let positive_maximum_with_offset = self.builder.insert_binary(half_width, BinaryOp::Add, not_same_sign_field); let product_overflow_check = self.builder.insert_binary(product, BinaryOp::Lt, positive_maximum_with_offset); - - let one = self.builder.numeric_constant(FieldElement::one(), Type::bool()); self.builder.set_location(location).insert_constrain( product_overflow_check, one, diff --git a/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs b/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs index c768ea96f8f3..f0fc482cae0c 100644 --- a/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs +++ b/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs @@ -491,7 +491,7 @@ pub(crate) fn check_methods_signatures( } // We also need to bind the traits generics to the trait's generics on the impl - for (generic, binding) in the_trait.generics.iter().zip(trait_generics) { + for ((_, generic), binding) in the_trait.generics.iter().zip(trait_generics) { generic.bind(binding); } @@ -599,7 +599,7 @@ pub(crate) fn check_methods_signatures( the_trait.set_methods(trait_methods); the_trait.self_type_typevar.unbind(the_trait.self_type_typevar_id); - for generic in &the_trait.generics { - generic.unbind(generic.id()); + for (old_id, generic) in &the_trait.generics { + generic.unbind(*old_id); } } diff --git a/noir/compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs b/noir/compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs index 3cd60c33b8b0..2e6eb3992ff4 100644 --- a/noir/compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs +++ b/noir/compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs @@ -20,7 +20,7 @@ use super::{ }, errors::{DefCollectorErrorKind, DuplicateType}, }; -use crate::hir::def_map::{LocalModuleId, ModuleData, ModuleId}; +use crate::hir::def_map::{parse_file, LocalModuleId, ModuleData, ModuleId}; use crate::hir::resolution::import::ImportDirective; use crate::hir::Context; @@ -555,7 +555,7 @@ impl<'a> ModCollector<'a> { context.visited_files.insert(child_file_id, location); // Parse the AST for the module we just found and then recursively look for it's defs - let (ast, parsing_errors) = context.parsed_file_results(child_file_id); + let (ast, parsing_errors) = parse_file(&context.file_manager, child_file_id); let ast = ast.into_sorted(); errors.extend( diff --git a/noir/compiler/noirc_frontend/src/hir/def_map/mod.rs b/noir/compiler/noirc_frontend/src/hir/def_map/mod.rs index 8c985e88e0b5..d60ceffa9af0 100644 --- a/noir/compiler/noirc_frontend/src/hir/def_map/mod.rs +++ b/noir/compiler/noirc_frontend/src/hir/def_map/mod.rs @@ -87,7 +87,7 @@ impl CrateDefMap { // First parse the root file. let root_file_id = context.crate_graph[crate_id].root_file_id; - let (ast, parsing_errors) = context.parsed_file_results(root_file_id); + let (ast, parsing_errors) = parse_file(&context.file_manager, root_file_id); let mut ast = ast.into_sorted(); for macro_processor in ¯o_processors { diff --git a/noir/compiler/noirc_frontend/src/hir/mod.rs b/noir/compiler/noirc_frontend/src/hir/mod.rs index 2124b5281f4f..c62f357167f0 100644 --- a/noir/compiler/noirc_frontend/src/hir/mod.rs +++ b/noir/compiler/noirc_frontend/src/hir/mod.rs @@ -7,22 +7,18 @@ pub mod type_check; use crate::graph::{CrateGraph, CrateId}; use crate::hir_def::function::FuncMeta; use crate::node_interner::{FuncId, NodeInterner, StructId}; -use crate::parser::ParserError; -use crate::ParsedModule; use def_map::{Contract, CrateDefMap}; use fm::FileManager; use noirc_errors::Location; use std::borrow::Cow; -use std::collections::{BTreeMap, HashMap}; +use std::collections::BTreeMap; use self::def_map::TestFunction; -pub type ParsedFiles = HashMap)>; - /// Helper object which groups together several useful context objects used /// during name resolution. Once name resolution is finished, only the /// def_interner is required for type inference and monomorphization. -pub struct Context<'file_manager, 'parsed_files> { +pub struct Context<'file_manager> { pub def_interner: NodeInterner, pub crate_graph: CrateGraph, pub(crate) def_maps: BTreeMap, @@ -34,11 +30,6 @@ pub struct Context<'file_manager, 'parsed_files> { /// A map of each file that already has been visited from a prior `mod foo;` declaration. /// This is used to issue an error if a second `mod foo;` is declared to the same file. pub visited_files: BTreeMap, - - // A map of all parsed files. - // Same as the file manager, we take ownership of the parsed files in the WASM context. - // Parsed files is also read only. - pub parsed_files: Cow<'parsed_files, ParsedFiles>, } #[derive(Debug, Copy, Clone)] @@ -48,36 +39,27 @@ pub enum FunctionNameMatch<'a> { Contains(&'a str), } -impl Context<'_, '_> { - pub fn new(file_manager: FileManager, parsed_files: ParsedFiles) -> Context<'static, 'static> { +impl Context<'_> { + pub fn new(file_manager: FileManager) -> Context<'static> { Context { def_interner: NodeInterner::default(), def_maps: BTreeMap::new(), visited_files: BTreeMap::new(), crate_graph: CrateGraph::default(), file_manager: Cow::Owned(file_manager), - parsed_files: Cow::Owned(parsed_files), } } - pub fn from_ref_file_manager<'file_manager, 'parsed_files>( - file_manager: &'file_manager FileManager, - parsed_files: &'parsed_files ParsedFiles, - ) -> Context<'file_manager, 'parsed_files> { + pub fn from_ref_file_manager(file_manager: &FileManager) -> Context<'_> { Context { def_interner: NodeInterner::default(), def_maps: BTreeMap::new(), visited_files: BTreeMap::new(), crate_graph: CrateGraph::default(), file_manager: Cow::Borrowed(file_manager), - parsed_files: Cow::Borrowed(parsed_files), } } - pub fn parsed_file_results(&self, file_id: fm::FileId) -> (ParsedModule, Vec) { - self.parsed_files.get(&file_id).expect("noir file wasn't parsed").clone() - } - /// Returns the CrateDefMap for a given CrateId. /// It is perfectly valid for the compiler to look /// up a CrateDefMap and it is not available. diff --git a/noir/compiler/noirc_frontend/src/hir/resolution/resolver.rs b/noir/compiler/noirc_frontend/src/hir/resolution/resolver.rs index 1d4f60ffd516..bb7acf1037b1 100644 --- a/noir/compiler/noirc_frontend/src/hir/resolution/resolver.rs +++ b/noir/compiler/noirc_frontend/src/hir/resolution/resolver.rs @@ -39,7 +39,7 @@ use crate::{ use crate::{ ArrayLiteral, ContractFunctionType, Distinctness, ForRange, FunctionDefinition, FunctionReturnType, FunctionVisibility, Generics, LValue, NoirStruct, NoirTypeAlias, Param, - Path, PathKind, Pattern, Shared, StructType, Type, TypeAliasType, TypeVariable, + Path, PathKind, Pattern, Shared, StructType, Type, TypeAliasType, TypeBinding, TypeVariable, TypeVariableKind, UnaryOp, UnresolvedGenerics, UnresolvedTraitConstraint, UnresolvedType, UnresolvedTypeData, UnresolvedTypeExpression, Visibility, ERROR_IDENT, }; @@ -558,10 +558,6 @@ impl<'a> Resolver<'a> { let result = self.interner.get_type_alias(id).get_type(&args); - // Collecting Type Alias references [Location]s to be used by LSP in order - // to resolve the definition of the type alias - self.interner.add_type_alias_ref(id, Location::new(span, self.file)); - // Because there is no ordering to when type aliases (and other globals) are resolved, // it is possible for one to refer to an Error type and issue no error if it is set // equal to another type alias. Fixing this fully requires an analysis to create a DFG @@ -647,7 +643,7 @@ impl<'a> Resolver<'a> { None => { let id = self.interner.next_type_variable_id(); let typevar = TypeVariable::unbound(id); - new_variables.push(typevar.clone()); + new_variables.push((id, typevar.clone())); // 'Named'Generic is a bit of a misnomer here, we want a type variable that // wont be bound over but this one has no name since we do not currently @@ -777,7 +773,7 @@ impl<'a> Resolver<'a> { self.generics.push((name, typevar.clone(), span)); } - typevar + (id, typevar) }) } @@ -787,7 +783,7 @@ impl<'a> Resolver<'a> { pub fn add_existing_generics(&mut self, names: &UnresolvedGenerics, generics: &Generics) { assert_eq!(names.len(), generics.len()); - for (name, typevar) in names.iter().zip(generics) { + for (name, (_id, typevar)) in names.iter().zip(generics) { self.add_existing_generic(&name.0.contents, name.0.span(), typevar.clone()); } } @@ -855,7 +851,14 @@ impl<'a> Resolver<'a> { let attributes = func.attributes().clone(); - let mut generics = vecmap(&self.generics, |(_, typevar, _)| typevar.clone()); + let mut generics = + vecmap(self.generics.clone(), |(name, typevar, _)| match &*typevar.borrow() { + TypeBinding::Unbound(id) => (*id, typevar.clone()), + TypeBinding::Bound(binding) => { + unreachable!("Expected {} to be unbound, but it is bound to {}", name, binding) + } + }); + let mut parameters = vec![]; let mut parameter_types = vec![]; diff --git a/noir/compiler/noirc_frontend/src/hir/resolution/traits.rs b/noir/compiler/noirc_frontend/src/hir/resolution/traits.rs index 8f966be312ba..f08d9c50c847 100644 --- a/noir/compiler/noirc_frontend/src/hir/resolution/traits.rs +++ b/noir/compiler/noirc_frontend/src/hir/resolution/traits.rs @@ -18,7 +18,7 @@ use crate::{ }, hir_def::traits::{TraitConstant, TraitFunction, TraitImpl, TraitType}, node_interner::{FuncId, NodeInterner, TraitId}, - Generics, Path, Shared, TraitItem, Type, TypeVariable, TypeVariableKind, + Generics, Path, Shared, TraitItem, Type, TypeBinding, TypeVariable, TypeVariableKind, }; use super::{ @@ -42,7 +42,8 @@ pub(crate) fn resolve_traits( for (trait_id, unresolved_trait) in traits { let generics = vecmap(&unresolved_trait.trait_def.generics, |_| { - TypeVariable::unbound(context.def_interner.next_type_variable_id()) + let id = context.def_interner.next_type_variable_id(); + (id, TypeVariable::unbound(id)) }); // Resolve order @@ -141,7 +142,17 @@ fn resolve_trait_methods( let arguments = vecmap(parameters, |param| resolver.resolve_type(param.1.clone())); let return_type = resolver.resolve_type(return_type.get_type().into_owned()); - let generics = vecmap(resolver.get_generics(), |(_, type_var, _)| type_var.clone()); + let generics = + vecmap(resolver.get_generics(), |(_, type_var, _)| match &*type_var.borrow() { + TypeBinding::Unbound(id) => (*id, type_var.clone()), + TypeBinding::Bound(binding) => { + unreachable!("Trait generic was bound to {binding}") + } + }); + + // Ensure the trait is generic over the Self type as well + // let the_trait = resolver.interner.get_trait(trait_id); + // generics.push((the_trait.self_type_typevar_id, the_trait.self_type_typevar.clone())); let default_impl_list: Vec<_> = unresolved_trait .fns_with_default_impl @@ -454,7 +465,8 @@ pub(crate) fn resolve_trait_impls( methods: vecmap(&impl_methods, |(_, func_id)| *func_id), }); - let impl_generics = vecmap(impl_generics, |(_, type_variable, _)| type_variable); + let impl_generics = + vecmap(impl_generics, |(_, type_variable, _)| (type_variable.id(), type_variable)); if let Err((prev_span, prev_file)) = interner.add_trait_implementation( self_type.clone(), diff --git a/noir/compiler/noirc_frontend/src/hir/type_check/expr.rs b/noir/compiler/noirc_frontend/src/hir/type_check/expr.rs index 58cf4e7b289f..b583959bfb1a 100644 --- a/noir/compiler/noirc_frontend/src/hir/type_check/expr.rs +++ b/noir/compiler/noirc_frontend/src/hir/type_check/expr.rs @@ -595,7 +595,7 @@ impl<'interner> TypeChecker<'interner> { .generics .iter() .zip(generics) - .map(|(var, arg)| (var.id(), (var.clone(), arg))) + .map(|((id, var), arg)| (*id, (var.clone(), arg))) .collect(); (method.typ.clone(), method.arguments().len(), generic_bindings) diff --git a/noir/compiler/noirc_frontend/src/hir_def/traits.rs b/noir/compiler/noirc_frontend/src/hir_def/traits.rs index 16b9899039f9..85c292ac5f3b 100644 --- a/noir/compiler/noirc_frontend/src/hir_def/traits.rs +++ b/noir/compiler/noirc_frontend/src/hir_def/traits.rs @@ -147,7 +147,7 @@ impl TraitFunction { } } - pub fn generics(&self) -> &[TypeVariable] { + pub fn generics(&self) -> &[(TypeVariableId, TypeVariable)] { match &self.typ { Type::Function(..) => &[], Type::Forall(generics, _) => generics, diff --git a/noir/compiler/noirc_frontend/src/hir_def/types.rs b/noir/compiler/noirc_frontend/src/hir_def/types.rs index 8979d60c0055..f59341e5b1ca 100644 --- a/noir/compiler/noirc_frontend/src/hir_def/types.rs +++ b/noir/compiler/noirc_frontend/src/hir_def/types.rs @@ -207,8 +207,11 @@ pub struct StructType { pub location: Location, } -/// Corresponds to generic lists such as `` in the source program. -pub type Generics = Vec; +/// Corresponds to generic lists such as `` in the source +/// program. The `TypeVariableId` portion is used to match two +/// type variables to check for equality, while the `TypeVariable` is +/// the actual part that can be mutated to bind it to another type. +pub type Generics = Vec<(TypeVariableId, TypeVariable)>; impl std::hash::Hash for StructType { fn hash(&self, state: &mut H) { @@ -257,7 +260,7 @@ impl StructType { .generics .iter() .zip(generic_args) - .map(|(old, new)| (old.id(), (old.clone(), new.clone()))) + .map(|((old_id, old_var), new)| (*old_id, (old_var.clone(), new.clone()))) .collect(); (typ.substitute(&substitutions), i) @@ -273,7 +276,7 @@ impl StructType { .generics .iter() .zip(generic_args) - .map(|(old, new)| (old.id(), (old.clone(), new.clone()))) + .map(|((old_id, old_var), new)| (*old_id, (old_var.clone(), new.clone()))) .collect(); vecmap(&self.fields, |(name, typ)| { @@ -314,7 +317,7 @@ pub struct TypeAliasType { pub id: TypeAliasId, pub typ: Type, pub generics: Generics, - pub location: Location, + pub span: Span, } impl std::hash::Hash for TypeAliasType { @@ -334,7 +337,7 @@ impl std::fmt::Display for TypeAliasType { write!(f, "{}", self.name)?; if !self.generics.is_empty() { - let generics = vecmap(&self.generics, |binding| binding.borrow().to_string()); + let generics = vecmap(&self.generics, |(_, binding)| binding.borrow().to_string()); write!(f, "{}", generics.join(", "))?; } @@ -346,11 +349,11 @@ impl TypeAliasType { pub fn new( id: TypeAliasId, name: Ident, - location: Location, + span: Span, typ: Type, generics: Generics, ) -> TypeAliasType { - TypeAliasType { id, typ, name, location, generics } + TypeAliasType { id, typ, name, span, generics } } pub fn set_type_and_generics(&mut self, new_typ: Type, new_generics: Generics) { @@ -366,7 +369,7 @@ impl TypeAliasType { .generics .iter() .zip(generic_args) - .map(|(old, new)| (old.id(), (old.clone(), new.clone()))) + .map(|((old_id, old_var), new)| (*old_id, (old_var.clone(), new.clone()))) .collect(); self.typ.substitute(&substitutions) @@ -704,7 +707,7 @@ impl Type { /// Takes a monomorphic type and generalizes it over each of the type variables in the /// given type bindings, ignoring what each type variable is bound to in the TypeBindings. pub(crate) fn generalize_from_substitutions(self, type_bindings: TypeBindings) -> Type { - let polymorphic_type_vars = vecmap(type_bindings, |(_, (type_var, _))| type_var); + let polymorphic_type_vars = vecmap(type_bindings, |(id, (type_var, _))| (id, type_var)); Type::Forall(polymorphic_type_vars, Box::new(self)) } @@ -798,7 +801,7 @@ impl std::fmt::Display for Type { }, Type::Constant(x) => x.fmt(f), Type::Forall(typevars, typ) => { - let typevars = vecmap(typevars, |var| var.id().to_string()); + let typevars = vecmap(typevars, |(var, _)| var.to_string()); write!(f, "forall {}. {}", typevars.join(" "), typ) } Type::Function(args, ret, env) => { @@ -1304,9 +1307,9 @@ impl Type { ) -> (Type, TypeBindings) { match self { Type::Forall(typevars, typ) => { - for var in typevars { + for (id, var) in typevars { bindings - .entry(var.id()) + .entry(*id) .or_insert_with(|| (var.clone(), interner.next_type_variable())); } @@ -1325,9 +1328,9 @@ impl Type { Type::Forall(typevars, typ) => { let replacements = typevars .iter() - .map(|var| { + .map(|(id, var)| { let new = interner.next_type_variable(); - (var.id(), (var.clone(), new)) + (*id, (var.clone(), new)) }) .collect(); @@ -1425,8 +1428,8 @@ impl Type { Type::Forall(typevars, typ) => { // Trying to substitute_helper a variable de, substitute_bound_typevarsfined within a nested Forall // is usually impossible and indicative of an error in the type checker somewhere. - for var in typevars { - assert!(!type_bindings.contains_key(&var.id())); + for (var, _) in typevars { + assert!(!type_bindings.contains_key(var)); } let typ = Box::new(typ.substitute_helper(type_bindings, substitute_bound_typevars)); Type::Forall(typevars.clone(), typ) @@ -1473,7 +1476,7 @@ impl Type { } } Type::Forall(typevars, typ) => { - !typevars.iter().any(|var| var.id() == target_id) && typ.occurs(target_id) + !typevars.iter().any(|(id, _)| *id == target_id) && typ.occurs(target_id) } Type::Function(args, ret, env) => { args.iter().any(|arg| arg.occurs(target_id)) @@ -1546,7 +1549,7 @@ impl Type { } pub fn from_generics(generics: &Generics) -> Vec { - vecmap(generics, |var| Type::TypeVariable(var.clone(), TypeVariableKind::Normal)) + vecmap(generics, |(_, var)| Type::TypeVariable(var.clone(), TypeVariableKind::Normal)) } } @@ -1617,7 +1620,7 @@ impl From<&Type> for PrintableType { match value { Type::FieldElement => PrintableType::Field, Type::Array(size, typ) => { - let length = size.evaluate_to_u64(); + let length = size.evaluate_to_u64().expect("Cannot print variable sized arrays"); let typ = typ.as_ref(); PrintableType::Array { length, typ: Box::new(typ.into()) } } @@ -1638,7 +1641,7 @@ impl From<&Type> for PrintableType { } Type::FmtString(_, _) => unreachable!("format strings cannot be printed"), Type::Error => unreachable!(), - Type::Unit => PrintableType::Unit, + Type::Unit => unreachable!(), Type::Constant(_) => unreachable!(), Type::Struct(def, ref args) => { let struct_type = def.borrow(); @@ -1646,17 +1649,13 @@ impl From<&Type> for PrintableType { let fields = vecmap(fields, |(name, typ)| (name, typ.into())); PrintableType::Struct { fields, name: struct_type.name.to_string() } } - Type::TraitAsType(_, _, _) => unreachable!(), - Type::Tuple(types) => PrintableType::Tuple { types: vecmap(types, |typ| typ.into()) }, + Type::TraitAsType(..) => unreachable!(), + Type::Tuple(_) => todo!("printing tuple types is not yet implemented"), Type::TypeVariable(_, _) => unreachable!(), Type::NamedGeneric(..) => unreachable!(), Type::Forall(..) => unreachable!(), - Type::Function(_, _, env) => { - PrintableType::Function { env: Box::new(env.as_ref().into()) } - } - Type::MutableReference(typ) => { - PrintableType::MutableReference { typ: Box::new(typ.as_ref().into()) } - } + Type::Function(_, _, _) => unreachable!(), + Type::MutableReference(_) => unreachable!("cannot print &mut"), Type::NotConstant => unreachable!(), } } diff --git a/noir/compiler/noirc_frontend/src/monomorphization/mod.rs b/noir/compiler/noirc_frontend/src/monomorphization/mod.rs index 67b246a02ce0..ac11e00ad201 100644 --- a/noir/compiler/noirc_frontend/src/monomorphization/mod.rs +++ b/noir/compiler/noirc_frontend/src/monomorphization/mod.rs @@ -27,7 +27,7 @@ use crate::{ node_interner::{self, DefinitionKind, NodeInterner, StmtId, TraitImplKind, TraitMethodId}, token::FunctionAttribute, ContractFunctionType, FunctionKind, Type, TypeBinding, TypeBindings, TypeVariable, - TypeVariableKind, UnaryOp, Visibility, + TypeVariableId, TypeVariableKind, UnaryOp, Visibility, }; use self::ast::{Definition, FuncId, Function, LocalId, Program}; @@ -1029,16 +1029,11 @@ impl<'interner> Monomorphizer<'interner> { } fn append_printable_type_info_inner(typ: &Type, arguments: &mut Vec) { - // Disallow printing slices and mutable references for consistency, - // since they cannot be passed from ACIR into Brillig if let HirType::Array(size, _) = typ { if let HirType::NotConstant = **size { unreachable!("println does not support slices. Convert the slice to an array before passing it to println"); } - } else if matches!(typ, HirType::MutableReference(_)) { - unreachable!("println does not support mutable references."); } - let printable_type: PrintableType = typ.into(); let abi_as_string = serde_json::to_string(&printable_type) .expect("ICE: expected PrintableType to serialize"); @@ -1538,8 +1533,8 @@ impl<'interner> Monomorphizer<'interner> { let (generics, impl_method_type) = self.interner.function_meta(&impl_method).typ.unwrap_forall(); - let replace_type_variable = |var: &TypeVariable| { - (var.id(), (var.clone(), Type::TypeVariable(var.clone(), TypeVariableKind::Normal))) + let replace_type_variable = |(id, var): &(TypeVariableId, TypeVariable)| { + (*id, (var.clone(), Type::TypeVariable(var.clone(), TypeVariableKind::Normal))) }; // Replace each NamedGeneric with a TypeVariable containing the same internal type variable diff --git a/noir/compiler/noirc_frontend/src/node_interner.rs b/noir/compiler/noirc_frontend/src/node_interner.rs index e734161e360e..173bac958771 100644 --- a/noir/compiler/noirc_frontend/src/node_interner.rs +++ b/noir/compiler/noirc_frontend/src/node_interner.rs @@ -78,7 +78,7 @@ pub struct NodeInterner { // // Map type aliases to the actual type. // When resolving types, check against this map to see if a type alias is defined. - pub(crate) type_aliases: Vec, + type_aliases: Vec, // Trait map. // @@ -142,10 +142,6 @@ pub struct NodeInterner { // For trait implementation functions, this is their self type and trait they belong to func_id_to_trait: HashMap, - - /// A list of all type aliases that are referenced in the program. - /// Searched by LSP to resolve [Location]s of [TypeAliasType]s - pub(crate) type_alias_ref: Vec<(TypeAliasId, Location)>, } /// A trait implementation is either a normal implementation that is present in the source @@ -454,7 +450,6 @@ impl Default for NodeInterner { globals: HashMap::new(), struct_methods: HashMap::new(), primitive_methods: HashMap::new(), - type_alias_ref: Vec::new(), }; // An empty block expression is used often, we add this into the `node` on startup @@ -504,7 +499,8 @@ impl NodeInterner { // This lets us record how many arguments the type expects so that other types // can refer to it with generic arguments before the generic parameters themselves // are resolved. - TypeVariable::unbound(TypeVariableId(0)) + let id = TypeVariableId(0); + (id, TypeVariable::unbound(id)) }), self_type_typevar_id, self_type_typevar: TypeVariable::unbound(self_type_typevar_id), @@ -534,7 +530,8 @@ impl NodeInterner { // This lets us record how many arguments the type expects so that other types // can refer to it with generic arguments before the generic parameters themselves // are resolved. - TypeVariable::unbound(TypeVariableId(0)) + let id = TypeVariableId(0); + (id, TypeVariable::unbound(id)) }); let location = Location::new(typ.struct_def.span, file_id); @@ -550,19 +547,17 @@ impl NodeInterner { self.type_aliases.push(TypeAliasType::new( type_id, typ.type_alias_def.name.clone(), - Location::new(typ.type_alias_def.span, typ.file_id), + typ.type_alias_def.span, Type::Error, - vecmap(&typ.type_alias_def.generics, |_| TypeVariable::unbound(TypeVariableId(0))), + vecmap(&typ.type_alias_def.generics, |_| { + let id = TypeVariableId(0); + (id, TypeVariable::unbound(id)) + }), )); type_id } - /// Adds [TypeLiasId] and [Location] to the type_alias_ref vector - /// So that we can later resolve [Location]s type aliases from the LSP requests - pub fn add_type_alias_ref(&mut self, type_id: TypeAliasId, location: Location) { - self.type_alias_ref.push((type_id, location)); - } pub fn update_struct(&mut self, type_id: StructId, f: impl FnOnce(&mut StructType)) { let mut value = self.structs.get_mut(&type_id).unwrap().borrow_mut(); f(&mut value); @@ -1200,18 +1195,19 @@ impl NodeInterner { self.trait_implementations.push(trait_impl.clone()); + // Ignoring overlapping TraitImplKind::Assumed impls here is perfectly fine. + // It should never happen since impls are defined at global scope, but even + // if they were, we should never prevent defining a new impl because a where + // clause already assumes it exists. + // Replace each generic with a fresh type variable let substitutions = impl_generics .into_iter() - .map(|typevar| (typevar.id(), (typevar, self.next_type_variable()))) + .map(|(id, typevar)| (id, (typevar, self.next_type_variable()))) .collect(); let instantiated_object_type = object_type.substitute(&substitutions); - // Ignoring overlapping `TraitImplKind::Assumed` impls here is perfectly fine. - // It should never happen since impls are defined at global scope, but even - // if they were, we should never prevent defining a new impl because a 'where' - // clause already assumes it exists. if let Ok((TraitImplKind::Normal(existing), _)) = self.try_lookup_trait_implementation( &instantiated_object_type, trait_id, diff --git a/noir/compiler/noirc_frontend/src/resolve_locations.rs b/noir/compiler/noirc_frontend/src/resolve_locations.rs index 02325de4da82..95ced906984e 100644 --- a/noir/compiler/noirc_frontend/src/resolve_locations.rs +++ b/noir/compiler/noirc_frontend/src/resolve_locations.rs @@ -33,22 +33,17 @@ impl NodeInterner { /// Returns the [Location] of the definition of the given Ident found at [Span] of the given [FileId]. /// Returns [None] when definition is not found. - pub fn get_definition_location_from( - &self, - location: Location, - return_type_location_instead: bool, - ) -> Option { + pub fn get_definition_location_from(&self, location: Location) -> Option { self.find_location_index(location) - .and_then(|index| self.resolve_location(index, return_type_location_instead)) + .and_then(|index| self.resolve_location(index)) .or_else(|| self.try_resolve_trait_impl_location(location)) .or_else(|| self.try_resolve_trait_method_declaration(location)) - .or_else(|| self.try_resolve_type_alias(location)) } pub fn get_declaration_location_from(&self, location: Location) -> Option { self.try_resolve_trait_method_declaration(location).or_else(|| { self.find_location_index(location) - .and_then(|index| self.resolve_location(index, false)) + .and_then(|index| self.resolve_location(index)) .and_then(|found_impl_location| { self.try_resolve_trait_method_declaration(found_impl_location) }) @@ -58,31 +53,12 @@ impl NodeInterner { /// For a given [Index] we return [Location] to which we resolved to /// We currently return None for features not yet implemented /// TODO(#3659): LSP goto def should error when Ident at Location could not resolve - fn resolve_location( - &self, - index: impl Into, - return_type_location_instead: bool, - ) -> Option { - if return_type_location_instead { - return self.get_type_location_from_index(index); - } - + fn resolve_location(&self, index: impl Into) -> Option { let node = self.nodes.get(index.into())?; match node { - Node::Function(func) => { - self.resolve_location(func.as_expr(), return_type_location_instead) - } - Node::Expression(expression) => { - self.resolve_expression_location(expression, return_type_location_instead) - } - _ => None, - } - } - - fn get_type_location_from_index(&self, index: impl Into) -> Option { - match self.id_type(index.into()) { - Type::Struct(struct_type, _) => Some(struct_type.borrow().location), + Node::Function(func) => self.resolve_location(func.as_expr()), + Node::Expression(expression) => self.resolve_expression_location(expression), _ => None, } } @@ -90,11 +66,7 @@ impl NodeInterner { /// Resolves the [Location] of the definition for a given [HirExpression] /// /// Note: current the code returns None because some expressions are not yet implemented. - fn resolve_expression_location( - &self, - expression: &HirExpression, - return_type_location_instead: bool, - ) -> Option { + fn resolve_expression_location(&self, expression: &HirExpression) -> Option { match expression { HirExpression::Ident(ident) => { let definition_info = self.definition(ident.id); @@ -116,7 +88,7 @@ impl NodeInterner { } HirExpression::Call(expr_call) => { let func = expr_call.func; - self.resolve_location(func, return_type_location_instead) + self.resolve_location(func) } _ => None, @@ -195,12 +167,4 @@ impl NodeInterner { method.map(|method| method.location) }) } - - #[tracing::instrument(skip(self), ret)] - fn try_resolve_type_alias(&self, location: Location) -> Option { - self.type_alias_ref - .iter() - .find(|(_, named_type_location)| named_type_location.span.contains(&location.span)) - .map(|(type_alias_id, _found_location)| self.get_type_alias(*type_alias_id).location) - } } diff --git a/noir/compiler/noirc_frontend/src/tests.rs b/noir/compiler/noirc_frontend/src/tests.rs index 9ccbddab9eca..a56c3a7755f6 100644 --- a/noir/compiler/noirc_frontend/src/tests.rs +++ b/noir/compiler/noirc_frontend/src/tests.rs @@ -52,7 +52,7 @@ mod test { ) -> (ParsedModule, Context, Vec<(CompilationError, FileId)>) { let root = std::path::Path::new("/"); let fm = FileManager::new(root); - let mut context = Context::new(fm, Default::default()); + let mut context = Context::new(fm); context.def_interner.populate_dummy_operator_traits(); let root_file_id = FileId::dummy(); let root_crate_id = context.crate_graph.add_crate_root(root_file_id); diff --git a/noir/compiler/noirc_printable_type/src/lib.rs b/noir/compiler/noirc_printable_type/src/lib.rs index 18f2fe0a873e..273e2d512ea8 100644 --- a/noir/compiler/noirc_printable_type/src/lib.rs +++ b/noir/compiler/noirc_printable_type/src/lib.rs @@ -11,13 +11,10 @@ use thiserror::Error; pub enum PrintableType { Field, Array { - length: Option, + length: u64, #[serde(rename = "type")] typ: Box, }, - Tuple { - types: Vec, - }, SignedInteger { width: u32, }, @@ -32,13 +29,23 @@ pub enum PrintableType { String { length: u64, }, - Function { - env: Box, - }, - MutableReference { - typ: Box, - }, - Unit, +} + +impl PrintableType { + /// Returns the number of field elements required to represent the type once encoded. + fn field_count(&self) -> u32 { + match self { + Self::Field + | Self::SignedInteger { .. } + | Self::UnsignedInteger { .. } + | Self::Boolean => 1, + Self::Array { length, typ } => typ.field_count() * (*length as u32), + Self::Struct { fields, .. } => { + fields.iter().fold(0, |acc, (_, field_type)| acc + field_type.field_count()) + } + Self::String { length } => *length as u32, + } + } } /// This is what all formats eventually transform into @@ -107,26 +114,43 @@ fn convert_string_inputs( fn convert_fmt_string_inputs( foreign_call_inputs: &[ForeignCallParam], ) -> Result { - let (message, input_and_printable_types) = + let (message, input_and_printable_values) = foreign_call_inputs.split_first().ok_or(ForeignCallError::MissingForeignCallInputs)?; let message_as_fields = vecmap(message.values(), |value| value.to_field()); let message_as_string = decode_string_value(&message_as_fields); - let (num_values, input_and_printable_types) = input_and_printable_types + let (num_values, input_and_printable_values) = input_and_printable_values .split_first() .ok_or(ForeignCallError::MissingForeignCallInputs)?; let mut output = Vec::new(); let num_values = num_values.unwrap_value().to_field().to_u128() as usize; - let types_start_at = input_and_printable_types.len() - num_values; - let mut input_iter = input_and_printable_types[0..types_start_at] + for (i, printable_value) in input_and_printable_values .iter() - .flat_map(|param| vecmap(param.values(), |value| value.to_field())); - for printable_type in input_and_printable_types.iter().skip(types_start_at) { - let printable_type = fetch_printable_type(printable_type)?; - let value = decode_value(&mut input_iter, &printable_type); + .skip(input_and_printable_values.len() - num_values) + .enumerate() + { + let printable_type = fetch_printable_type(printable_value)?; + let type_size = printable_type.field_count() as usize; + let value = match printable_type { + PrintableType::Array { .. } | PrintableType::String { .. } => { + // Arrays and strings are represented in a single value vector rather than multiple separate input values + let mut input_values_as_fields = input_and_printable_values[i] + .values() + .into_iter() + .map(|value| value.to_field()); + decode_value(&mut input_values_as_fields, &printable_type) + } + _ => { + // We must use a flat map here as each value in a struct will be in a separate input value + let mut input_values_as_fields = input_and_printable_values[i..(i + type_size)] + .iter() + .flat_map(|param| vecmap(param.values(), |value| value.to_field())); + decode_value(&mut input_values_as_fields, &printable_type) + } + }; output.push((value, printable_type)); } @@ -172,12 +196,6 @@ fn to_string(value: &PrintableValue, typ: &PrintableType) -> Option { output.push_str("false"); } } - (PrintableValue::Field(_), PrintableType::Function { .. }) => { - output.push_str("<>"); - } - (_, PrintableType::MutableReference { .. }) => { - output.push_str("<>"); - } (PrintableValue::Vec(vector), PrintableType::Array { typ, .. }) => { output.push('['); let mut values = vector.iter().peekable(); @@ -215,22 +233,6 @@ fn to_string(value: &PrintableValue, typ: &PrintableType) -> Option { output.push_str(" }"); } - (PrintableValue::Vec(values), PrintableType::Tuple { types }) => { - output.push('('); - let mut elems = values.iter().zip(types).peekable(); - while let Some((value, typ)) = elems.next() { - output.push_str( - &PrintableValueDisplay::Plain(value.clone(), typ.clone()).to_string(), - ); - if elems.peek().is_some() { - output.push_str(", "); - } - } - output.push(')'); - } - - (_, PrintableType::Unit) => output.push_str("()"), - _ => return None, }; @@ -306,19 +308,7 @@ fn decode_value( PrintableValue::Field(field_element) } - PrintableType::Array { length: None, typ } => { - let length = field_iterator - .next() - .expect("not enough data to decode variable array length") - .to_u128() as usize; - let mut array_elements = Vec::with_capacity(length); - for _ in 0..length { - array_elements.push(decode_value(field_iterator, typ)); - } - - PrintableValue::Vec(array_elements) - } - PrintableType::Array { length: Some(length), typ } => { + PrintableType::Array { length, typ } => { let length = *length as usize; let mut array_elements = Vec::with_capacity(length); for _ in 0..length { @@ -327,9 +317,6 @@ fn decode_value( PrintableValue::Vec(array_elements) } - PrintableType::Tuple { types } => { - PrintableValue::Vec(vecmap(types, |typ| decode_value(field_iterator, typ))) - } PrintableType::String { length } => { let field_elements: Vec = field_iterator.take(*length as usize).collect(); @@ -346,18 +333,6 @@ fn decode_value( PrintableValue::Struct(struct_map) } - PrintableType::Function { env } => { - let field_element = field_iterator.next().unwrap(); - let func_ref = PrintableValue::Field(field_element); - // we want to consume the fields from the environment, but for now they are not actually printed - decode_value(field_iterator, env); - func_ref - } - PrintableType::MutableReference { typ } => { - // we decode the reference, but it's not really used for printing - decode_value(field_iterator, typ) - } - PrintableType::Unit => PrintableValue::Field(FieldElement::zero()), } } diff --git a/noir/compiler/wasm/package.json b/noir/compiler/wasm/package.json index 2aaf4a494df6..412e9c82f9a5 100644 --- a/noir/compiler/wasm/package.json +++ b/noir/compiler/wasm/package.json @@ -3,7 +3,7 @@ "contributors": [ "The Noir Team " ], - "version": "0.23.0", + "version": "0.22.0", "license": "(MIT OR Apache-2.0)", "main": "dist/main.js", "types": "./dist/types/src/index.d.cts", diff --git a/noir/compiler/wasm/src/compile.rs b/noir/compiler/wasm/src/compile.rs index 498ffe447cef..351f9ae8a86c 100644 --- a/noir/compiler/wasm/src/compile.rs +++ b/noir/compiler/wasm/src/compile.rs @@ -13,7 +13,7 @@ use noirc_driver::{ use noirc_evaluator::errors::SsaReport; use noirc_frontend::{ graph::{CrateId, CrateName}, - hir::{def_map::parse_file, Context, ParsedFiles}, + hir::Context, }; use serde::Deserialize; use std::{collections::HashMap, path::Path}; @@ -140,10 +140,6 @@ impl PathToFileSourceMap { } } -pub(crate) fn parse_all(fm: &FileManager) -> ParsedFiles { - fm.as_file_map().all_file_ids().map(|&file_id| (file_id, parse_file(fm, file_id))).collect() -} - pub enum CompileResult { Contract { contract: ContractArtifact, warnings: Vec }, Program { program: ProgramArtifact, warnings: Vec }, @@ -166,8 +162,8 @@ pub fn compile( }; let fm = file_manager_with_source_map(file_source_map); - let parsed_files = parse_all(&fm); - let mut context = Context::new(fm, parsed_files); + + let mut context = Context::new(fm); let path = Path::new(&entry_point); let crate_id = prepare_crate(&mut context, path); @@ -295,18 +291,15 @@ mod test { use crate::compile::PathToFileSourceMap; - use super::{ - file_manager_with_source_map, parse_all, process_dependency_graph, DependencyGraph, - }; + use super::{file_manager_with_source_map, process_dependency_graph, DependencyGraph}; use std::{collections::HashMap, path::Path}; - fn setup_test_context(source_map: PathToFileSourceMap) -> Context<'static, 'static> { + fn setup_test_context(source_map: PathToFileSourceMap) -> Context<'static> { let mut fm = file_manager_with_source_map(source_map); // Add this due to us calling prepare_crate on "/main.nr" below fm.add_file_with_source(Path::new("/main.nr"), "fn foo() {}".to_string()); - let parsed_files = parse_all(&fm); - let mut context = Context::new(fm, parsed_files); + let mut context = Context::new(fm); prepare_crate(&mut context, Path::new("/main.nr")); context diff --git a/noir/compiler/wasm/src/compile_new.rs b/noir/compiler/wasm/src/compile_new.rs index 6476f6d29bc9..3cb20bd0b5c9 100644 --- a/noir/compiler/wasm/src/compile_new.rs +++ b/noir/compiler/wasm/src/compile_new.rs @@ -1,5 +1,5 @@ use crate::compile::{ - file_manager_with_source_map, generate_contract_artifact, generate_program_artifact, parse_all, + file_manager_with_source_map, generate_contract_artifact, generate_program_artifact, JsCompileResult, PathToFileSourceMap, }; use crate::errors::{CompileError, JsCompileError}; @@ -20,7 +20,7 @@ use wasm_bindgen::prelude::wasm_bindgen; pub struct CompilerContext { // `wasm_bindgen` currently doesn't allow lifetime parameters on structs so we must use a `'static` lifetime. // `Context` must then own the `FileManager` to satisfy this lifetime. - context: Context<'static, 'static>, + context: Context<'static>, } #[wasm_bindgen(js_name = "CrateId")] @@ -34,9 +34,7 @@ impl CompilerContext { console_error_panic_hook::set_once(); let fm = file_manager_with_source_map(source_map); - let parsed_files = parse_all(&fm); - - CompilerContext { context: Context::new(fm, parsed_files) } + CompilerContext { context: Context::new(fm) } } #[cfg(test)] @@ -233,7 +231,7 @@ mod test { use noirc_driver::prepare_crate; use noirc_frontend::hir::Context; - use crate::compile::{file_manager_with_source_map, parse_all, PathToFileSourceMap}; + use crate::compile::{file_manager_with_source_map, PathToFileSourceMap}; use std::path::Path; @@ -243,9 +241,8 @@ mod test { let mut fm = file_manager_with_source_map(source_map); // Add this due to us calling prepare_crate on "/main.nr" below fm.add_file_with_source(Path::new("/main.nr"), "fn foo() {}".to_string()); - let parsed_files = parse_all(&fm); - let mut context = Context::new(fm, parsed_files); + let mut context = Context::new(fm); prepare_crate(&mut context, Path::new("/main.nr")); CompilerContext { context } diff --git a/noir/docs/versioned_docs/version-v0.22.0/explainers/explainer-oracle.md b/noir/docs/versioned_docs/version-v0.22.0/explainers/explainer-oracle.md new file mode 100644 index 000000000000..76dd0e36d6c8 --- /dev/null +++ b/noir/docs/versioned_docs/version-v0.22.0/explainers/explainer-oracle.md @@ -0,0 +1,57 @@ +--- +title: Oracles +description: This guide provides an in-depth understanding of how Oracles work in Noir programming. Learn how to use outside calculations in your programs, constrain oracles, and understand their uses and limitations. +keywords: + - Noir Programming + - Oracles + - JSON-RPC + - Foreign Call Handlers + - Constrained Functions + - Blockchain Programming +sidebar_position: 1 +--- + +If you've seen "The Matrix" you may recall "The Oracle" as Gloria Foster smoking cigarettes and baking cookies. While she appears to "know things", she is actually providing a calculation of a pre-determined future. Noir Oracles are similar, in a way. They don't calculate the future (yet), but they allow you to use outside calculations in your programs. + +![matrix oracle prediction](@site/static/img/memes/matrix_oracle.jpeg) + +A Noir program is usually self-contained. You can pass certain inputs to it, and it will generate a deterministic output for those inputs. But what if you wanted to defer some calculation to an outside process or source? + +Oracles are functions that provide this feature. + +## Use cases + +An example usage for Oracles is proving something on-chain. For example, proving that the ETH-USDC quote was below a certain target at a certain block time. Or even making more complex proofs like proving the ownership of an NFT as an anonymous login method. + +Another interesting use case is to defer expensive calculations to be made outside of the Noir program, and then constraining the result; similar to the use of [unconstrained functions](../noir/syntax/unconstrained.md). + +In short, anything that can be constrained in a Noir program but needs to be fetched from an external source is a great candidate to be used in oracles. + +## Constraining oracles + +Just like in The Matrix, Oracles are powerful. But with great power, comes great responsibility. Just because you're using them in a Noir program doesn't mean they're true. Noir has no superpowers. If you want to prove that Portugal won the Euro Cup 2016, you're still relying on potentially untrusted information. + +To give a concrete example, Alice wants to login to the [NounsDAO](https://nouns.wtf/) forum with her username "noir_nouner" by proving she owns a noun without revealing her ethereum address. Her Noir program could have a oracle call like this: + +```rust +#[oracle(getNoun)] +unconstrained fn get_noun(address: Field) -> Field +``` + +This oracle could naively resolve with the number of Nouns she possesses. However, it is useless as a trusted source, as the oracle could resolve to anything Alice wants. In order to make this oracle call actually useful, Alice would need to constrain the response from the oracle, by proving her address and the noun count belongs to the state tree of the contract. + +In short, **Oracles don't prove anything. Your Noir program does.** + +:::danger + +If you don't constrain the return of your oracle, you could be clearly opening an attack vector on your Noir program. Make double-triple sure that the return of an oracle call is constrained! + +::: + +## How to use Oracles + +On CLI, Nargo resolves oracles by making JSON RPC calls, which means it would require an RPC node to be running. + +In JavaScript, NoirJS accepts and resolves arbitrary call handlers (that is, not limited to JSON) as long as they matches the expected types the developer defines. Refer to [Foreign Call Handler](../reference/NoirJS/noir_js/type-aliases/ForeignCallHandler.md) to learn more about NoirJS's call handling. + +If you want to build using oracles, follow through to the [oracle guide](../how_to/how-to-oracles.md) for a simple example on how to do that. diff --git a/noir/docs/versioned_docs/version-v0.22.0/how_to/how-to-oracles.md b/noir/docs/versioned_docs/version-v0.22.0/how_to/how-to-oracles.md new file mode 100644 index 000000000000..61cabe586e6b --- /dev/null +++ b/noir/docs/versioned_docs/version-v0.22.0/how_to/how-to-oracles.md @@ -0,0 +1,280 @@ +--- +title: How to use Oracles +description: Learn how to use oracles in your Noir program with examples in both Nargo and NoirJS. This guide also covers writing a JSON RPC server and providing custom foreign call handlers for NoirJS. +keywords: + - Noir Programming + - Oracles + - Nargo + - NoirJS + - JSON RPC Server + - Foreign Call Handlers +sidebar_position: 1 +--- + +This guide shows you how to use oracles in your Noir program. For the sake of clarity, it assumes that: + +- You have read the [explainer on Oracles](../explainers/explainer-oracle.md) and are comfortable with the concept. +- You have a Noir program to add oracles to. You can create one using the [vite-hardhat starter](https://github.com/noir-lang/noir-starter/tree/main/vite-hardhat) as a boilerplate. +- You understand the concept of a JSON-RPC server. Visit the [JSON-RPC website](https://www.jsonrpc.org/) if you need a refresher. +- You are comfortable with server-side JavaScript (e.g. Node.js, managing packages, etc.). + +For reference, you can find the snippets used in this tutorial on the [Aztec DevRel Repository](https://github.com/AztecProtocol/dev-rel/tree/main/how_to_oracles/code-snippets/how-to-oracles). + +## Rundown + +This guide has 3 major steps: + +1. How to modify our Noir program to make use of oracle calls as unconstrained functions +2. How to write a JSON RPC Server to resolve these oracle calls with Nargo +3. How to use them in Nargo and how to provide a custom resolver in NoirJS + +## Step 1 - Modify your Noir program + +An oracle is defined in a Noir program by defining two methods: + +- An unconstrained method - This tells the compiler that it is executing an [unconstrained functions](../noir/syntax/unconstrained.md). +- A decorated oracle method - This tells the compiler that this method is an RPC call. + +An example of an oracle that returns a `Field` would be: + +```rust +#[oracle(getSqrt)] +unconstrained fn sqrt(number: Field) -> Field { } + +unconstrained fn get_sqrt(number: Field) -> Field { + sqrt(number) +} +``` + +In this example, we're wrapping our oracle function in a unconstrained method, and decorating it with `oracle(getSqrt)`. We can then call the unconstrained function as we would call any other function: + +```rust +fn main(input: Field) { + let sqrt = get_sqrt(input); +} +``` + +In the next section, we will make this `getSqrt` (defined on the `sqrt` decorator) be a method of the RPC server Noir will use. + +:::danger + +As explained in the [Oracle Explainer](../explainers/explainer-oracle.md), this `main` function is unsafe unless you constrain its return value. For example: + +```rust +fn main(input: Field) { + let sqrt = get_sqrt(input); + assert(sqrt[0].pow_32(2) as u64 == input as u64); // <---- constrain the return of an oracle! +} +``` + +::: + +:::info + +Currently, oracles only work with single params or array params. For example: + +```rust +#[oracle(getSqrt)] +unconstrained fn sqrt([Field; 2]) -> [Field; 2] { } +``` + +::: + +## Step 2 - Write an RPC server + +Brillig will call *one* RPC server. Most likely you will have to write your own, and you can do it in whatever language you prefer. In this guide, we will do it in Javascript. + +Let's use the above example of an oracle that consumes an array with two `Field` and returns their square roots: + +```rust +#[oracle(getSqrt)] +unconstrained fn sqrt(input: [Field; 2]) -> [Field; 2] { } + +unconstrained fn get_sqrt(input: [Field; 2]) -> [Field; 2] { + sqrt(input) +} + +fn main(input: [Field; 2]) { + let sqrt = get_sqrt(input); + assert(sqrt[0].pow_32(2) as u64 == input[0] as u64); + assert(sqrt[1].pow_32(2) as u64 == input[1] as u64); +} +``` + +:::info + +Why square root? + +In general, computing square roots is computationally more expensive than multiplications, which takes a toll when speaking about ZK applications. In this case, instead of calculating the square root in Noir, we are using our oracle to offload that computation to be made in plain. In our circuit we can simply multiply the two values. + +::: + +Now, we should write the correspondent RPC server, starting with the [default JSON-RPC 2.0 boilerplate](https://www.npmjs.com/package/json-rpc-2.0#example): + +```js +import { JSONRPCServer } from "json-rpc-2.0"; +import express from "express"; +import bodyParser from "body-parser"; + +const app = express(); +app.use(bodyParser.json()); + +const server = new JSONRPCServer(); +app.post("/", (req, res) => { + const jsonRPCRequest = req.body; + server.receive(jsonRPCRequest).then((jsonRPCResponse) => { + if (jsonRPCResponse) { + res.json(jsonRPCResponse); + } else { + res.sendStatus(204); + } + }); +}); + +app.listen(5555); +``` + +Now, we will add our `getSqrt` method, as expected by the `#[oracle(getSqrt)]` decorator in our Noir code. It maps through the params array and returns their square roots: + +```js +server.addMethod("getSqrt", async (params) => { + const values = params[0].Array.map(({ inner }) => { + return { inner: `${Math.sqrt(parseInt(inner, 16))}` }; + }); + return { values: [{ Array: values }] }; +}); +``` + +:::tip + +Brillig expects an object with an array of values. Each value is an object declaring to be `Single` or `Array` and returning a `inner` property *as a string*. For example: + +```json +{ "values": [{ "Array": [{ "inner": "1" }, { "inner": "2"}]}]} +{ "values": [{ "Single": { "inner": "1" }}]} +{ "values": [{ "Single": { "inner": "1" }}, { "Array": [{ "inner": "1", { "inner": "2" }}]}]} +``` + +If you're using Typescript, the following types may be helpful in understanding the expected return value and making sure they're easy to follow: + +```js +interface Value { + inner: string, +} + +interface SingleForeignCallParam { + Single: Value, +} + +interface ArrayForeignCallParam { + Array: Value[], +} + +type ForeignCallParam = SingleForeignCallParam | ArrayForeignCallParam; + +interface ForeignCallResult { + values: ForeignCallParam[], +} +``` + +::: + +## Step 3 - Usage with Nargo + +Using the [`nargo` CLI tool](../getting_started/installation/index.md), you can use oracles in the `nargo test`, `nargo execute` and `nargo prove` commands by passing a value to `--oracle-resolver`. For example: + +```bash +nargo test --oracle-resolver http://localhost:5555 +``` + +This tells `nargo` to use your RPC Server URL whenever it finds an oracle decorator. + +## Step 4 - Usage with NoirJS + +In a JS environment, an RPC server is not strictly necessary, as you may want to resolve your oracles without needing any JSON call at all. NoirJS simply expects that you pass a callback function when you generate proofs, and that callback function can be anything. + +For example, if your Noir program expects the host machine to provide CPU pseudo-randomness, you could simply pass it as the `foreignCallHandler`. You don't strictly need to create an RPC server to serve pseudo-randomness, as you may as well get it directly in your app: + +```js +const foreignCallHandler = (name, inputs) => crypto.randomBytes(16) // etc + +await noir.generateFinalProof(inputs, foreignCallHandler) +``` + +As one can see, in NoirJS, the [`foreignCallHandler`](../reference/NoirJS/noir_js/type-aliases/ForeignCallHandler.md) function simply means "a callback function that returns a value of type [`ForeignCallOutput`](../reference/NoirJS/noir_js/type-aliases/ForeignCallOutput.md). It doesn't have to be an RPC call like in the case for Nargo. + +:::tip + +Does this mean you don't have to write an RPC server like in [Step #2](#step-2---write-an-rpc-server)? + +You don't technically have to, but then how would you run `nargo test` or `nargo prove`? To use both `Nargo` and `NoirJS` in your development flow, you will have to write a JSON RPC server. + +::: + +In this case, let's make `foreignCallHandler` call the JSON RPC Server we created in [Step #2](#step-2---write-an-rpc-server), by making it a JSON RPC Client. + +For example, using the same `getSqrt` program in [Step #1](#step-1---modify-your-noir-program) (comments in the code): + +```js +import { JSONRPCClient } from "json-rpc-2.0"; + +// declaring the JSONRPCClient +const client = new JSONRPCClient((jsonRPCRequest) => { +// hitting the same JSON RPC Server we coded above + return fetch("http://localhost:5555", { + method: "POST", + headers: { + "content-type": "application/json", + }, + body: JSON.stringify(jsonRPCRequest), + }).then((response) => { + if (response.status === 200) { + return response + .json() + .then((jsonRPCResponse) => client.receive(jsonRPCResponse)); + } else if (jsonRPCRequest.id !== undefined) { + return Promise.reject(new Error(response.statusText)); + } + }); +}); + +// declaring a function that takes the name of the foreign call (getSqrt) and the inputs +const foreignCallHandler = async (name, input) => { + // notice that the "inputs" parameter contains *all* the inputs + // in this case we to make the RPC request with the first parameter "numbers", which would be input[0] + const oracleReturn = await client.request(name, [ + { Array: input[0].map((i) => ({ inner: i.toString("hex") })) }, + ]); + return [oracleReturn.values[0].Array.map((x) => x.inner)]; +}; + +// the rest of your NoirJS code +const input = { input: [4, 16] }; +const { witness } = await noir.execute(numbers, foreignCallHandler); +``` + +:::tip + +If you're in a NoirJS environment running your RPC server together with a frontend app, you'll probably hit a familiar problem in full-stack development: requests being blocked by [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) policy. For development only, you can simply install and use the [`cors` npm package](https://www.npmjs.com/package/cors) to get around the problem: + +```bash +yarn add cors +``` + +and use it as a middleware: + +```js +import cors from "cors"; + +const app = express(); +app.use(cors()) +``` + +::: + +## Conclusion + +Hopefully by the end of this guide, you should be able to: + +- Write your own logic around Oracles and how to write a JSON RPC server to make them work with your Nargo commands. +- Provide custom foreign call handlers for NoirJS. diff --git a/noir/docs/versioned_docs/version-v0.22.0/noir/syntax/oracles.md b/noir/docs/versioned_docs/version-v0.22.0/noir/syntax/oracles.md new file mode 100644 index 000000000000..2e6a6818d48c --- /dev/null +++ b/noir/docs/versioned_docs/version-v0.22.0/noir/syntax/oracles.md @@ -0,0 +1,23 @@ +--- +title: Oracles +description: Dive into how Noir supports Oracles via RPC calls, and learn how to declare an Oracle in Noir with our comprehensive guide. +keywords: + - Noir + - Oracles + - RPC Calls + - Unconstrained Functions + - Programming + - Blockchain +sidebar_position: 6 +--- + +Noir has support for Oracles via RPC calls. This means Noir will make an RPC call and use the return value for proof generation. + +Since Oracles are not resolved by Noir, they are [`unconstrained` functions](./unconstrained.md) + +You can declare an Oracle through the `#[oracle()]` flag. Example: + +```rust +#[oracle(get_number_sequence)] +unconstrained fn get_number_sequence(_size: Field) -> [Field] {} +``` diff --git a/noir/flake.nix b/noir/flake.nix index 6849dc0a0ada..2300d0091147 100644 --- a/noir/flake.nix +++ b/noir/flake.nix @@ -73,7 +73,7 @@ # Configuration shared between builds config = { # x-release-please-start-version - version = "0.23.0"; + version = "0.22.0"; # x-release-please-end src = pkgs.lib.cleanSourceWith { diff --git a/noir/test_programs/execution_success/bit_and/Prover.toml b/noir/test_programs/execution_success/bit_and/Prover.toml index 34a5b63e5b16..40ce2b0bc273 100644 --- a/noir/test_programs/execution_success/bit_and/Prover.toml +++ b/noir/test_programs/execution_success/bit_and/Prover.toml @@ -1,4 +1,2 @@ x = "0x00" y = "0x10" -a = "0x00" -b = "0x10" diff --git a/noir/test_programs/execution_success/bit_and/src/main.nr b/noir/test_programs/execution_success/bit_and/src/main.nr index 5a0aa17e3ede..0bc1d9a49bde 100644 --- a/noir/test_programs/execution_success/bit_and/src/main.nr +++ b/noir/test_programs/execution_success/bit_and/src/main.nr @@ -1,6 +1,6 @@ // You can only do bit operations with integers. // (Kobi/Daira/Circom/#37) https://github.com/iden3/circom/issues/37 -fn main(x: Field, y: Field, a: Field, b: Field) { +fn main(x: Field, y: Field) { let x_as_u8 = x as u8; let y_as_u8 = y as u8; @@ -9,8 +9,8 @@ fn main(x: Field, y: Field, a: Field, b: Field) { let flag = (x == 0) & (y == 16); assert(flag); //bitwise and with odd bits: - let a_as_u8 = a as u8; - let b_as_u8 = b as u8; - assert((a_as_u8 & b_as_u8) == a_as_u8); + let x_as_u11 = x as u11; + let y_as_u11 = y as u11; + assert((x_as_u11 & y_as_u11) == x_as_u11); } diff --git a/noir/test_programs/execution_success/debug_logs/src/main.nr b/noir/test_programs/execution_success/debug_logs/src/main.nr index 52c910065c17..6accdf725d92 100644 --- a/noir/test_programs/execution_success/debug_logs/src/main.nr +++ b/noir/test_programs/execution_success/debug_logs/src/main.nr @@ -39,26 +39,7 @@ fn main(x: Field, y: pub Field) { let struct_string = if x != 5 { f"{foo}" } else { f"{bar}" }; std::println(struct_string); - let one_tuple = (1, 2, 3); - let another_tuple = (4, 5, 6); - std::println(f"one_tuple: {one_tuple}, another_tuple: {another_tuple}"); - std::println(one_tuple); - - let tuples_nested = (one_tuple, another_tuple); - std::println(f"tuples_nested: {tuples_nested}"); - std::println(tuples_nested); - regression_2906(); - - let free_lambda = |x| x + 1; - let sentinel: u32 = 8888; - std::println(f"free_lambda: {free_lambda}, sentinel: {sentinel}"); - std::println(free_lambda); - - let one = 1; - let closured_lambda = |x| x + one; - std::println(f"closured_lambda: {closured_lambda}, sentinel: {sentinel}"); - std::println(closured_lambda); } fn string_identity(string: fmtstr<14, (Field, Field)>) -> fmtstr<14, (Field, Field)> { @@ -98,4 +79,3 @@ fn regression_2906() { dep::std::println(f"array_five_vals: {array_five_vals}, label_five_vals: {label_five_vals}"); } - diff --git a/noir/test_programs/execution_success/nested_array_in_slice/Nargo.toml b/noir/test_programs/execution_success/nested_slice_dynamic/Nargo.toml similarity index 62% rename from noir/test_programs/execution_success/nested_array_in_slice/Nargo.toml rename to noir/test_programs/execution_success/nested_slice_dynamic/Nargo.toml index 4f0748f79be3..c8925ed97b4d 100644 --- a/noir/test_programs/execution_success/nested_array_in_slice/Nargo.toml +++ b/noir/test_programs/execution_success/nested_slice_dynamic/Nargo.toml @@ -1,5 +1,5 @@ [package] -name = "nested_array_in_slice" +name = "nested_slice_dynamic" type = "bin" authors = [""] [dependencies] \ No newline at end of file diff --git a/noir/test_programs/execution_success/nested_array_in_slice/Prover.toml b/noir/test_programs/execution_success/nested_slice_dynamic/Prover.toml similarity index 100% rename from noir/test_programs/execution_success/nested_array_in_slice/Prover.toml rename to noir/test_programs/execution_success/nested_slice_dynamic/Prover.toml diff --git a/noir/test_programs/execution_success/nested_array_in_slice/src/main.nr b/noir/test_programs/execution_success/nested_slice_dynamic/src/main.nr similarity index 100% rename from noir/test_programs/execution_success/nested_array_in_slice/src/main.nr rename to noir/test_programs/execution_success/nested_slice_dynamic/src/main.nr diff --git a/noir/tooling/backend_interface/test-binaries/mock_backend/Cargo.lock b/noir/tooling/backend_interface/test-binaries/mock_backend/Cargo.lock index 3c14a9369070..c43d1b849153 100644 --- a/noir/tooling/backend_interface/test-binaries/mock_backend/Cargo.lock +++ b/noir/tooling/backend_interface/test-binaries/mock_backend/Cargo.lock @@ -4,67 +4,81 @@ version = 3 [[package]] name = "anstream" -version = "0.6.11" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e2e1ebcb11de5c03c67de28a7df593d32191b44939c482e97702baaaa6ab6a5" +checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", + "is-terminal", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.4" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" +checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" [[package]] name = "anstyle-parse" -version = "0.2.3" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.2" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" dependencies = [ "windows-sys", ] [[package]] name = "anstyle-wincon" -version = "3.0.2" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" dependencies = [ "anstyle", "windows-sys", ] +[[package]] +name = "bitflags" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" + +[[package]] +name = "cc" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" + [[package]] name = "clap" -version = "4.4.18" +version = "4.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c" +checksum = "5fd304a20bff958a57f04c4e96a2e7594cc4490a0e809cbd48bb6437edaa452d" dependencies = [ "clap_builder", "clap_derive", + "once_cell", ] [[package]] name = "clap_builder" -version = "4.4.18" +version = "4.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7" +checksum = "01c6a3f08f1fe5662a35cfe393aec09c4df95f60ee93b7556505260f75eee9e1" dependencies = [ "anstream", "anstyle", @@ -74,9 +88,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.4.7" +version = "4.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" +checksum = "54a9bb5758fc5dfe728d1019941681eccaf0cf8a4189b692a0ee2f2ecf90a050" dependencies = [ "heck", "proc-macro2", @@ -86,9 +100,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.6.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" +checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" [[package]] name = "colorchoice" @@ -96,12 +110,62 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +[[package]] +name = "errno" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" +dependencies = [ + "errno-dragonfly", + "libc", + "windows-sys", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "heck" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +[[package]] +name = "hermit-abi" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" + +[[package]] +name = "is-terminal" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" +dependencies = [ + "hermit-abi", + "rustix", + "windows-sys", +] + +[[package]] +name = "libc" +version = "0.2.147" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" + +[[package]] +name = "linux-raw-sys" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09fc20d2ca12cb9f044c93e3bd6d32d523e6e2ec3db4f7b2939cd99026ecd3f0" + [[package]] name = "mock_backend" version = "0.1.0" @@ -109,24 +173,43 @@ dependencies = [ "clap", ] +[[package]] +name = "once_cell" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" + [[package]] name = "proc-macro2" -version = "1.0.76" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.35" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "5fe8a65d69dd0808184ebb5f836ab526bb259db23c657efa38711b1072ee47f0" dependencies = [ "proc-macro2", ] +[[package]] +name = "rustix" +version = "0.38.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a962918ea88d644592894bc6dc55acc6c0956488adcebbfb6e273506b7fd6e5" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + [[package]] name = "strsim" version = "0.10.0" @@ -135,9 +218,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "2.0.48" +version = "2.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "45c3457aacde3c65315de5031ec191ce46604304d2446e803d71ade03308d970" dependencies = [ "proc-macro2", "quote", @@ -146,9 +229,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" [[package]] name = "utf8parse" @@ -158,18 +241,18 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "windows-sys" -version = "0.52.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ "windows-targets", ] [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -182,42 +265,42 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" [[package]] name = "windows_i686_msvc" -version = "0.52.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" diff --git a/noir/tooling/lsp/Cargo.toml b/noir/tooling/lsp/Cargo.toml index 750e85694e2d..6371bcbac192 100644 --- a/noir/tooling/lsp/Cargo.toml +++ b/noir/tooling/lsp/Cargo.toml @@ -25,8 +25,6 @@ async-lsp = { workspace = true, features = ["omni-trait"] } serde_with = "3.2.0" thiserror.workspace = true fm.workspace = true -rayon = "1.8.0" -fxhash.workspace = true [target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi")))'.dependencies] wasm-bindgen.workspace = true diff --git a/noir/tooling/lsp/src/lib.rs b/noir/tooling/lsp/src/lib.rs index b64fc474b0b4..1099ad602699 100644 --- a/noir/tooling/lsp/src/lib.rs +++ b/noir/tooling/lsp/src/lib.rs @@ -17,20 +17,16 @@ use async_lsp::{ router::Router, AnyEvent, AnyNotification, AnyRequest, ClientSocket, Error, LspService, ResponseError, }; -use fm::{codespan_files as files, FileManager}; -use fxhash::FxHashSet; +use fm::codespan_files as files; use lsp_types::CodeLens; -use nargo::{parse_all, workspace::Workspace}; +use nargo::workspace::Workspace; use nargo_toml::{find_file_manifest, resolve_workspace_from_toml, PackageSelection}; use noirc_driver::{file_manager_with_stdlib, prepare_crate, NOIR_ARTIFACT_VERSION_STRING}; use noirc_frontend::{ graph::{CrateId, CrateName}, - hir::{def_map::parse_file, Context, FunctionNameMatch, ParsedFiles}, + hir::{Context, FunctionNameMatch}, node_interner::NodeInterner, - parser::ParserError, - ParsedModule, }; -use rayon::prelude::*; use notifications::{ on_did_change_configuration, on_did_change_text_document, on_did_close_text_document, @@ -38,8 +34,7 @@ use notifications::{ }; use requests::{ on_code_lens_request, on_formatting, on_goto_declaration_request, on_goto_definition_request, - on_goto_type_definition_request, on_initialize, on_profile_run_request, on_shutdown, - on_test_run_request, on_tests_request, + on_initialize, on_profile_run_request, on_shutdown, on_test_run_request, on_tests_request, }; use serde_json::Value as JsonValue; use thiserror::Error; @@ -69,8 +64,6 @@ pub struct LspState { input_files: HashMap, cached_lenses: HashMap>, cached_definitions: HashMap, - cached_parsed_files: HashMap))>, - parsing_cache_enabled: bool, } impl LspState { @@ -83,8 +76,6 @@ impl LspState { cached_lenses: HashMap::new(), cached_definitions: HashMap::new(), open_documents_count: 0, - cached_parsed_files: HashMap::new(), - parsing_cache_enabled: true, } } } @@ -107,7 +98,6 @@ impl NargoLspService { .request::(on_profile_run_request) .request::(on_goto_definition_request) .request::(on_goto_declaration_request) - .request::(on_goto_type_definition_request) .notification::(on_initialized) .notification::(on_did_change_configuration) .notification::(on_did_open_text_document) @@ -235,78 +225,20 @@ pub(crate) fn resolve_workspace_for_source_path(file_path: &Path) -> Result (Context<'static, 'static>, CrateId) { +fn prepare_source(source: String) -> (Context<'static>, CrateId) { let root = Path::new(""); let file_name = Path::new("main.nr"); let mut file_manager = file_manager_with_stdlib(root); file_manager.add_file_with_source(file_name, source).expect( "Adding source buffer to file manager should never fail when file manager is empty", ); - let parsed_files = parse_diff(&file_manager, state); - let mut context = Context::new(file_manager, parsed_files); + let mut context = Context::new(file_manager); let root_crate_id = prepare_crate(&mut context, file_name); (context, root_crate_id) } -fn parse_diff(file_manager: &FileManager, state: &mut LspState) -> ParsedFiles { - if state.parsing_cache_enabled { - let noir_file_hashes: Vec<_> = file_manager - .as_file_map() - .all_file_ids() - .par_bridge() - .filter_map(|&file_id| { - let file_path = file_manager.path(file_id).expect("expected file to exist"); - let file_extension = - file_path.extension().expect("expected all file paths to have an extension"); - if file_extension == "nr" { - Some(( - file_id, - file_path.to_path_buf(), - fxhash::hash(file_manager.fetch_file(file_id).expect("file must exist")), - )) - } else { - None - } - }) - .collect(); - - let cache_hits: Vec<_> = noir_file_hashes - .par_iter() - .filter_map(|(file_id, file_path, current_hash)| { - let cached_version = state.cached_parsed_files.get(file_path); - if let Some((hash, cached_parsing)) = cached_version { - if hash == current_hash { - return Some((*file_id, cached_parsing.clone())); - } - } - None - }) - .collect(); - - let cache_hits_ids: FxHashSet<_> = cache_hits.iter().map(|(file_id, _)| *file_id).collect(); - - let cache_misses: Vec<_> = noir_file_hashes - .into_par_iter() - .filter(|(id, _, _)| !cache_hits_ids.contains(id)) - .map(|(file_id, path, hash)| (file_id, path, hash, parse_file(file_manager, file_id))) - .collect(); - - cache_misses.iter().for_each(|(_, path, hash, parse_results)| { - state.cached_parsed_files.insert(path.clone(), (*hash, parse_results.clone())); - }); - - cache_misses - .into_iter() - .map(|(id, _, _, parse_results)| (id, parse_results)) - .chain(cache_hits.into_iter()) - .collect() - } else { - parse_all(file_manager) - } -} - #[test] fn prepare_package_from_source_string() { let source = r#" @@ -317,10 +249,7 @@ fn prepare_package_from_source_string() { } "#; - let client = ClientSocket::new_closed(); - let mut state = LspState::new(&client, acvm::blackbox_solver::StubbedBlackBoxSolver); - - let (mut context, crate_id) = crate::prepare_source(source.to_string(), &mut state); + let (mut context, crate_id) = crate::prepare_source(source.to_string()); let _check_result = noirc_driver::check_crate(&mut context, crate_id, false, false); let main_func_id = context.get_main_function(&crate_id); assert!(main_func_id.is_some()); diff --git a/noir/tooling/lsp/src/notifications/mod.rs b/noir/tooling/lsp/src/notifications/mod.rs index 355bb7832c4f..0cd86803efad 100644 --- a/noir/tooling/lsp/src/notifications/mod.rs +++ b/noir/tooling/lsp/src/notifications/mod.rs @@ -13,7 +13,7 @@ use crate::types::{ }; use crate::{ - byte_span_to_range, get_package_tests_in_crate, parse_diff, prepare_source, + byte_span_to_range, get_package_tests_in_crate, prepare_source, resolve_workspace_for_source_path, LspState, }; @@ -55,7 +55,7 @@ pub(super) fn on_did_change_text_document( let text = params.content_changes.into_iter().next().unwrap().text; state.input_files.insert(params.text_document.uri.to_string(), text.clone()); - let (mut context, crate_id) = prepare_source(text, state); + let (mut context, crate_id) = prepare_source(text); let _ = check_crate(&mut context, crate_id, false, false); let workspace = match resolve_workspace_for_source_path( @@ -131,13 +131,10 @@ fn process_noir_document( let mut workspace_file_manager = file_manager_with_stdlib(&workspace.root_dir); insert_all_files_for_workspace_into_file_manager(&workspace, &mut workspace_file_manager); - let parsed_files = parse_diff(&workspace_file_manager, state); - let diagnostics: Vec<_> = workspace .into_iter() .flat_map(|package| -> Vec { - let (mut context, crate_id) = - prepare_package(&workspace_file_manager, &parsed_files, package); + let (mut context, crate_id) = prepare_package(&workspace_file_manager, package); let file_diagnostics = match check_crate(&mut context, crate_id, false, false) { Ok(((), warnings)) => warnings, diff --git a/noir/tooling/lsp/src/requests/code_lens_request.rs b/noir/tooling/lsp/src/requests/code_lens_request.rs index 893ba33d8456..b16c19457f0e 100644 --- a/noir/tooling/lsp/src/requests/code_lens_request.rs +++ b/noir/tooling/lsp/src/requests/code_lens_request.rs @@ -64,7 +64,7 @@ fn on_code_lens_request_inner( let workspace = resolve_workspace_for_source_path(file_path.as_path()).unwrap(); let package = workspace.members.first().unwrap(); - let (mut context, crate_id) = prepare_source(source_string, state); + let (mut context, crate_id) = prepare_source(source_string); // We ignore the warnings and errors produced by compilation for producing code lenses // because we can still get the test functions even if compilation fails let _ = check_crate(&mut context, crate_id, false, false); diff --git a/noir/tooling/lsp/src/requests/goto_declaration.rs b/noir/tooling/lsp/src/requests/goto_declaration.rs index 8e6d519b8959..6e3664804f6a 100644 --- a/noir/tooling/lsp/src/requests/goto_declaration.rs +++ b/noir/tooling/lsp/src/requests/goto_declaration.rs @@ -1,8 +1,8 @@ use std::future::{self, Future}; +use crate::resolve_workspace_for_source_path; use crate::types::GotoDeclarationResult; use crate::LspState; -use crate::{parse_diff, resolve_workspace_for_source_path}; use async_lsp::{ErrorCode, ResponseError}; use lsp_types::request::{GotoDeclarationParams, GotoDeclarationResponse}; @@ -21,7 +21,7 @@ pub(crate) fn on_goto_declaration_request( } fn on_goto_definition_inner( - state: &mut LspState, + _state: &mut LspState, params: GotoDeclarationParams, ) -> Result { let file_path = @@ -36,13 +36,11 @@ fn on_goto_definition_inner( let mut workspace_file_manager = file_manager_with_stdlib(&workspace.root_dir); insert_all_files_for_workspace_into_file_manager(&workspace, &mut workspace_file_manager); - let parsed_files = parse_diff(&workspace_file_manager, state); - let (mut context, crate_id) = - nargo::prepare_package(&workspace_file_manager, &parsed_files, package); + let (mut context, crate_id) = nargo::prepare_package(&workspace_file_manager, package); let interner; - if let Some(def_interner) = state.cached_definitions.get(&package_root_path) { + if let Some(def_interner) = _state.cached_definitions.get(&package_root_path) { interner = def_interner; } else { // We ignore the warnings and errors produced by compilation while resolving the definition diff --git a/noir/tooling/lsp/src/requests/goto_definition.rs b/noir/tooling/lsp/src/requests/goto_definition.rs index 88bb667f2e8b..277bbf013f97 100644 --- a/noir/tooling/lsp/src/requests/goto_definition.rs +++ b/noir/tooling/lsp/src/requests/goto_definition.rs @@ -1,10 +1,9 @@ use std::future::{self, Future}; -use crate::{parse_diff, resolve_workspace_for_source_path}; +use crate::resolve_workspace_for_source_path; use crate::{types::GotoDefinitionResult, LspState}; use async_lsp::{ErrorCode, ResponseError}; -use lsp_types::request::GotoTypeDefinitionParams; use lsp_types::{GotoDefinitionParams, GotoDefinitionResponse}; use nargo::insert_all_files_for_workspace_into_file_manager; use noirc_driver::file_manager_with_stdlib; @@ -15,22 +14,13 @@ pub(crate) fn on_goto_definition_request( state: &mut LspState, params: GotoDefinitionParams, ) -> impl Future> { - let result = on_goto_definition_inner(state, params, false); - future::ready(result) -} - -pub(crate) fn on_goto_type_definition_request( - state: &mut LspState, - params: GotoTypeDefinitionParams, -) -> impl Future> { - let result = on_goto_definition_inner(state, params, true); + let result = on_goto_definition_inner(state, params); future::ready(result) } fn on_goto_definition_inner( - state: &mut LspState, + _state: &mut LspState, params: GotoDefinitionParams, - return_type_location_instead: bool, ) -> Result { let file_path = params.text_document_position_params.text_document.uri.to_file_path().map_err(|_| { @@ -44,13 +34,11 @@ fn on_goto_definition_inner( let mut workspace_file_manager = file_manager_with_stdlib(&workspace.root_dir); insert_all_files_for_workspace_into_file_manager(&workspace, &mut workspace_file_manager); - let parsed_files = parse_diff(&workspace_file_manager, state); - let (mut context, crate_id) = - nargo::prepare_package(&workspace_file_manager, &parsed_files, package); + let (mut context, crate_id) = nargo::prepare_package(&workspace_file_manager, package); let interner; - if let Some(def_interner) = state.cached_definitions.get(&package_root_path) { + if let Some(def_interner) = _state.cached_definitions.get(&package_root_path) { interner = def_interner; } else { // We ignore the warnings and errors produced by compilation while resolving the definition @@ -77,9 +65,8 @@ fn on_goto_definition_inner( span: noirc_errors::Span::single_char(byte_index as u32), }; - let goto_definition_response = interner - .get_definition_location_from(search_for_location, return_type_location_instead) - .and_then(|found_location| { + let goto_definition_response = + interner.get_definition_location_from(search_for_location).and_then(|found_location| { let file_id = found_location.file; let definition_position = to_lsp_location(files, file_id, found_location.span)?; let response: GotoDefinitionResponse = diff --git a/noir/tooling/lsp/src/requests/mod.rs b/noir/tooling/lsp/src/requests/mod.rs index ec56cf5045a7..9a4738e1985c 100644 --- a/noir/tooling/lsp/src/requests/mod.rs +++ b/noir/tooling/lsp/src/requests/mod.rs @@ -5,7 +5,7 @@ use async_lsp::ResponseError; use fm::codespan_files::Error; use lsp_types::{ DeclarationCapability, Location, Position, TextDocumentSyncCapability, TextDocumentSyncKind, - TypeDefinitionProviderCapability, Url, + Url, }; use nargo_fmt::Config; use serde::{Deserialize, Serialize}; @@ -35,8 +35,7 @@ mod tests; pub(crate) use { code_lens_request::collect_lenses_for_package, code_lens_request::on_code_lens_request, goto_declaration::on_goto_declaration_request, goto_definition::on_goto_definition_request, - goto_definition::on_goto_type_definition_request, profile_run::on_profile_run_request, - test_run::on_test_run_request, tests::on_tests_request, + profile_run::on_profile_run_request, test_run::on_test_run_request, tests::on_tests_request, }; /// LSP client will send initialization request after the server has started. @@ -47,25 +46,15 @@ struct LspInitializationOptions { /// By default this will be set to true (enabled). #[serde(rename = "enableCodeLens", default = "default_enable_code_lens")] enable_code_lens: bool, - - #[serde(rename = "enableParsingCache", default = "default_enable_parsing_cache")] - enable_parsing_cache: bool, } fn default_enable_code_lens() -> bool { true } -fn default_enable_parsing_cache() -> bool { - true -} - impl Default for LspInitializationOptions { fn default() -> Self { - Self { - enable_code_lens: default_enable_code_lens(), - enable_parsing_cache: default_enable_parsing_cache(), - } + Self { enable_code_lens: default_enable_code_lens() } } } @@ -74,11 +63,11 @@ pub(crate) fn on_initialize( params: InitializeParams, ) -> impl Future> { state.root_path = params.root_uri.and_then(|root_uri| root_uri.to_file_path().ok()); + let initialization_options: LspInitializationOptions = params .initialization_options .and_then(|value| serde_json::from_value(value).ok()) .unwrap_or_default(); - state.parsing_cache_enabled = initialization_options.enable_parsing_cache; async move { let text_document_sync = TextDocumentSyncCapability::Kind(TextDocumentSyncKind::FULL); @@ -105,7 +94,6 @@ pub(crate) fn on_initialize( nargo: Some(nargo), definition_provider: Some(lsp_types::OneOf::Left(true)), declaration_provider: Some(DeclarationCapability::Simple(true)), - type_definition_provider: Some(TypeDefinitionProviderCapability::Simple(true)), }, server_info: None, }) diff --git a/noir/tooling/lsp/src/requests/profile_run.rs b/noir/tooling/lsp/src/requests/profile_run.rs index 8ba91338f557..6664475a68c4 100644 --- a/noir/tooling/lsp/src/requests/profile_run.rs +++ b/noir/tooling/lsp/src/requests/profile_run.rs @@ -13,7 +13,6 @@ use noirc_driver::{ use noirc_errors::{debug_info::OpCodesCount, Location}; use crate::{ - parse_diff, types::{NargoProfileRunParams, NargoProfileRunResult}, LspState, }; @@ -27,7 +26,7 @@ pub(crate) fn on_profile_run_request( } fn on_profile_run_request_inner( - state: &mut LspState, + state: &LspState, params: NargoProfileRunParams, ) -> Result { let root_path = state.root_path.as_deref().ok_or_else(|| { @@ -53,17 +52,23 @@ fn on_profile_run_request_inner( let mut workspace_file_manager = file_manager_with_stdlib(&workspace.root_dir); insert_all_files_for_workspace_into_file_manager(&workspace, &mut workspace_file_manager); - let parsed_files = parse_diff(&workspace_file_manager, state); // Since we filtered on crate name, this should be the only item in the iterator match workspace.into_iter().next() { Some(_package) => { + let (binary_packages, contract_packages): (Vec<_>, Vec<_>) = workspace + .into_iter() + .filter(|package| !package.is_library()) + .cloned() + .partition(|package| package.is_binary()); + let expression_width = ExpressionWidth::Bounded { width: 3 }; let (compiled_programs, compiled_contracts) = nargo::ops::compile_workspace( &workspace_file_manager, - &parsed_files, &workspace, + &binary_packages, + &contract_packages, expression_width, &CompileOptions::default(), ) diff --git a/noir/tooling/lsp/src/requests/test_run.rs b/noir/tooling/lsp/src/requests/test_run.rs index 135090d7ed98..c2181d7839d0 100644 --- a/noir/tooling/lsp/src/requests/test_run.rs +++ b/noir/tooling/lsp/src/requests/test_run.rs @@ -13,7 +13,6 @@ use noirc_driver::{ use noirc_frontend::hir::FunctionNameMatch; use crate::{ - parse_diff, types::{NargoTestRunParams, NargoTestRunResult}, LspState, }; @@ -26,7 +25,7 @@ pub(crate) fn on_test_run_request( } fn on_test_run_request_inner( - state: &mut LspState, + state: &LspState, params: NargoTestRunParams, ) -> Result { let root_path = state.root_path.as_deref().ok_or_else(|| { @@ -53,13 +52,11 @@ fn on_test_run_request_inner( let mut workspace_file_manager = file_manager_with_stdlib(&workspace.root_dir); insert_all_files_for_workspace_into_file_manager(&workspace, &mut workspace_file_manager); - let parsed_files = parse_diff(&workspace_file_manager, state); // Since we filtered on crate name, this should be the only item in the iterator match workspace.into_iter().next() { Some(package) => { - let (mut context, crate_id) = - prepare_package(&workspace_file_manager, &parsed_files, package); + let (mut context, crate_id) = prepare_package(&workspace_file_manager, package); if check_crate(&mut context, crate_id, false, false).is_err() { let result = NargoTestRunResult { id: params.id.clone(), diff --git a/noir/tooling/lsp/src/requests/tests.rs b/noir/tooling/lsp/src/requests/tests.rs index 5b78fcc65c33..0f717b9fb9ee 100644 --- a/noir/tooling/lsp/src/requests/tests.rs +++ b/noir/tooling/lsp/src/requests/tests.rs @@ -7,7 +7,7 @@ use nargo_toml::{find_package_manifest, resolve_workspace_from_toml, PackageSele use noirc_driver::{check_crate, file_manager_with_stdlib, NOIR_ARTIFACT_VERSION_STRING}; use crate::{ - get_package_tests_in_crate, parse_diff, + get_package_tests_in_crate, types::{NargoPackageTests, NargoTestsParams, NargoTestsResult}, LspState, }; @@ -52,13 +52,11 @@ fn on_tests_request_inner( let mut workspace_file_manager = file_manager_with_stdlib(&workspace.root_dir); insert_all_files_for_workspace_into_file_manager(&workspace, &mut workspace_file_manager); - let parsed_files = parse_diff(&workspace_file_manager, state); let package_tests: Vec<_> = workspace .into_iter() .filter_map(|package| { - let (mut context, crate_id) = - prepare_package(&workspace_file_manager, &parsed_files, package); + let (mut context, crate_id) = prepare_package(&workspace_file_manager, package); // We ignore the warnings and errors produced by compilation for producing tests // because we can still get the test functions even if compilation fails let _ = check_crate(&mut context, crate_id, false, false); diff --git a/noir/tooling/lsp/src/types.rs b/noir/tooling/lsp/src/types.rs index e3492f21346d..8dbc51ec83c5 100644 --- a/noir/tooling/lsp/src/types.rs +++ b/noir/tooling/lsp/src/types.rs @@ -1,7 +1,5 @@ use fm::FileId; -use lsp_types::{ - DeclarationCapability, DefinitionOptions, OneOf, TypeDefinitionProviderCapability, -}; +use lsp_types::{DeclarationCapability, DefinitionOptions, OneOf}; use noirc_driver::DebugFile; use noirc_errors::{debug_info::OpCodesCount, Location}; use noirc_frontend::graph::CrateName; @@ -27,8 +25,7 @@ pub(crate) mod request { // Re-providing lsp_types that we don't need to override pub(crate) use lsp_types::request::{ - CodeLensRequest as CodeLens, Formatting, GotoDeclaration, GotoDefinition, - GotoTypeDefinition, Shutdown, + CodeLensRequest as CodeLens, Formatting, GotoDeclaration, GotoDefinition, Shutdown, }; #[derive(Debug)] @@ -121,10 +118,6 @@ pub(crate) struct ServerCapabilities { #[serde(skip_serializing_if = "Option::is_none")] pub(crate) definition_provider: Option>, - /// The server provides goto type definition support. - #[serde(skip_serializing_if = "Option::is_none")] - pub(crate) type_definition_provider: Option, - /// The server provides code lens. #[serde(skip_serializing_if = "Option::is_none")] pub(crate) code_lens_provider: Option, diff --git a/noir/tooling/nargo/src/lib.rs b/noir/tooling/nargo/src/lib.rs index 0fdff8b202f8..62ff4325a230 100644 --- a/noir/tooling/nargo/src/lib.rs +++ b/noir/tooling/nargo/src/lib.rs @@ -20,10 +20,9 @@ use fm::FileManager; use noirc_driver::{add_dep, prepare_crate, prepare_dependency}; use noirc_frontend::{ graph::{CrateId, CrateName}, - hir::{def_map::parse_file, Context, ParsedFiles}, + hir::Context, }; use package::{Dependency, Package}; -use rayon::prelude::*; pub use self::errors::NargoError; @@ -96,27 +95,11 @@ fn insert_all_files_for_packages_dependencies_into_file_manager( } } -pub fn parse_all(file_manager: &FileManager) -> ParsedFiles { - file_manager - .as_file_map() - .all_file_ids() - .par_bridge() - .filter(|&&file_id| { - let file_path = file_manager.path(file_id).expect("expected file to exist"); - let file_extension = - file_path.extension().expect("expected all file paths to have an extension"); - file_extension == "nr" - }) - .map(|&file_id| (file_id, parse_file(file_manager, file_id))) - .collect() -} - -pub fn prepare_package<'file_manager, 'parsed_files>( +pub fn prepare_package<'file_manager>( file_manager: &'file_manager FileManager, - parsed_files: &'parsed_files ParsedFiles, package: &Package, -) -> (Context<'file_manager, 'parsed_files>, CrateId) { - let mut context = Context::from_ref_file_manager(file_manager, parsed_files); +) -> (Context<'file_manager>, CrateId) { + let mut context = Context::from_ref_file_manager(file_manager); let crate_id = prepare_crate(&mut context, &package.entry_path); diff --git a/noir/tooling/nargo/src/ops/compile.rs b/noir/tooling/nargo/src/ops/compile.rs index 866bfe39d7b8..043e2a367a5b 100644 --- a/noir/tooling/nargo/src/ops/compile.rs +++ b/noir/tooling/nargo/src/ops/compile.rs @@ -1,7 +1,6 @@ use acvm::ExpressionWidth; use fm::FileManager; use noirc_driver::{CompilationResult, CompileOptions, CompiledContract, CompiledProgram}; -use noirc_frontend::hir::ParsedFiles; use crate::errors::CompileError; use crate::prepare_package; @@ -16,36 +15,22 @@ use rayon::prelude::*; /// This function will return an error if there are any compilations errors reported. pub fn compile_workspace( file_manager: &FileManager, - parsed_files: &ParsedFiles, workspace: &Workspace, + binary_packages: &[Package], + contract_packages: &[Package], expression_width: ExpressionWidth, compile_options: &CompileOptions, ) -> Result<(Vec, Vec), CompileError> { - let (binary_packages, contract_packages): (Vec<_>, Vec<_>) = workspace - .into_iter() - .filter(|package| !package.is_library()) - .cloned() - .partition(|package| package.is_binary()); - // Compile all of the packages in parallel. let program_results: Vec> = binary_packages .par_iter() .map(|package| { - compile_program( - file_manager, - parsed_files, - package, - compile_options, - expression_width, - None, - ) + compile_program(file_manager, workspace, package, compile_options, expression_width) }) .collect(); let contract_results: Vec> = contract_packages .par_iter() - .map(|package| { - compile_contract(file_manager, parsed_files, package, compile_options, expression_width) - }) + .map(|package| compile_contract(file_manager, package, compile_options, expression_width)) .collect(); // Report any warnings/errors which were encountered during compilation. @@ -77,16 +62,19 @@ pub fn compile_workspace( pub fn compile_program( file_manager: &FileManager, - parsed_files: &ParsedFiles, + workspace: &Workspace, package: &Package, compile_options: &CompileOptions, expression_width: ExpressionWidth, - cached_program: Option, ) -> CompilationResult { - let (mut context, crate_id) = prepare_package(file_manager, parsed_files, package); + let (mut context, crate_id) = prepare_package(file_manager, package); + + let program_artifact_path = workspace.package_build_path(package); + let mut debug_artifact_path = program_artifact_path.clone(); + debug_artifact_path.set_file_name(format!("debug_{}.json", package.name)); let (program, warnings) = - noirc_driver::compile_main(&mut context, crate_id, compile_options, cached_program)?; + noirc_driver::compile_main(&mut context, crate_id, compile_options, None)?; // Apply backend specific optimizations. let optimized_program = crate::ops::optimize_program(program, expression_width); @@ -94,16 +82,20 @@ pub fn compile_program( Ok((optimized_program, warnings)) } -pub fn compile_contract( +fn compile_contract( file_manager: &FileManager, - parsed_files: &ParsedFiles, package: &Package, compile_options: &CompileOptions, expression_width: ExpressionWidth, ) -> CompilationResult { - let (mut context, crate_id) = prepare_package(file_manager, parsed_files, package); + let (mut context, crate_id) = prepare_package(file_manager, package); let (contract, warnings) = - noirc_driver::compile_contract(&mut context, crate_id, compile_options)?; + match noirc_driver::compile_contract(&mut context, crate_id, compile_options) { + Ok(contracts_and_warnings) => contracts_and_warnings, + Err(errors) => { + return Err(errors); + } + }; let optimized_contract = crate::ops::optimize_contract(contract, expression_width); diff --git a/noir/tooling/nargo/src/ops/mod.rs b/noir/tooling/nargo/src/ops/mod.rs index 4912c84839e8..34487ed97703 100644 --- a/noir/tooling/nargo/src/ops/mod.rs +++ b/noir/tooling/nargo/src/ops/mod.rs @@ -1,4 +1,4 @@ -pub use self::compile::{compile_contract, compile_program, compile_workspace}; +pub use self::compile::{compile_program, compile_workspace}; pub use self::execute::execute_circuit; pub use self::foreign_calls::{DefaultForeignCallExecutor, ForeignCallExecutor}; pub use self::optimize::{optimize_contract, optimize_program}; diff --git a/noir/tooling/nargo_cli/Cargo.toml b/noir/tooling/nargo_cli/Cargo.toml index 6e022f090f09..2652adaf3277 100644 --- a/noir/tooling/nargo_cli/Cargo.toml +++ b/noir/tooling/nargo_cli/Cargo.toml @@ -74,7 +74,7 @@ pprof = { version = "0.12", features = [ "criterion", ] } iai = "0.1.1" -test-binary = "3.0.2" +test-binary = "3.0.1" [[bench]] name = "criterion" diff --git a/noir/tooling/nargo_cli/build.rs b/noir/tooling/nargo_cli/build.rs index 57aa487f66af..9a0492c99adb 100644 --- a/noir/tooling/nargo_cli/build.rs +++ b/noir/tooling/nargo_cli/build.rs @@ -75,7 +75,7 @@ fn execution_success_{test_name}() {{ let mut cmd = Command::cargo_bin("nargo").unwrap(); cmd.env("NARGO_BACKEND_PATH", path_to_mock_backend()); cmd.arg("--program-dir").arg(test_program_dir); - cmd.arg("execute").arg("--force"); + cmd.arg("execute"); cmd.assert().success(); }} @@ -194,12 +194,11 @@ fn compile_success_empty_{test_name}() {{ cmd.arg("--program-dir").arg(test_program_dir); cmd.arg("info"); cmd.arg("--json"); - cmd.arg("--force"); let output = cmd.output().expect("Failed to execute command"); if !output.status.success() {{ - panic!("`nargo info` failed with: {{}}", String::from_utf8(output.stderr).unwrap_or_default()); + panic!("`nargo info` failed with: {{}}", String::from_utf8(output.stderr).unwrap()); }} // `compile_success_empty` tests should be able to compile down to an empty circuit. @@ -207,7 +206,7 @@ fn compile_success_empty_{test_name}() {{ panic!("JSON was not well-formatted {{:?}}",output.stdout) }}); let num_opcodes = &json["programs"][0]["acir_opcodes"]; - assert_eq!(num_opcodes.as_u64().expect("number of opcodes should fit in a u64"), 0); + assert_eq!(num_opcodes.as_u64().unwrap(), 0); }} "#, test_dir = test_dir.display(), @@ -243,7 +242,7 @@ fn compile_success_contract_{test_name}() {{ let mut cmd = Command::cargo_bin("nargo").unwrap(); cmd.env("NARGO_BACKEND_PATH", path_to_mock_backend()); cmd.arg("--program-dir").arg(test_program_dir); - cmd.arg("compile").arg("--force"); + cmd.arg("compile"); cmd.assert().success(); }} @@ -281,7 +280,7 @@ fn compile_failure_{test_name}() {{ let mut cmd = Command::cargo_bin("nargo").unwrap(); cmd.env("NARGO_BACKEND_PATH", path_to_mock_backend()); cmd.arg("--program-dir").arg(test_program_dir); - cmd.arg("execute").arg("--force"); + cmd.arg("execute"); cmd.assert().failure().stderr(predicate::str::contains("The application panicked (crashed).").not()); }} diff --git a/noir/tooling/nargo_cli/src/cli/check_cmd.rs b/noir/tooling/nargo_cli/src/cli/check_cmd.rs index a8b9dbdeeb26..e2db492fe9c1 100644 --- a/noir/tooling/nargo_cli/src/cli/check_cmd.rs +++ b/noir/tooling/nargo_cli/src/cli/check_cmd.rs @@ -6,7 +6,7 @@ use fm::FileManager; use iter_extended::btree_map; use nargo::{ errors::CompileError, insert_all_files_for_workspace_into_file_manager, package::Package, - parse_all, prepare_package, + prepare_package, }; use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection}; use noirc_abi::{AbiParameter, AbiType, MAIN_RETURN_NAME}; @@ -16,7 +16,7 @@ use noirc_driver::{ }; use noirc_frontend::{ graph::{CrateId, CrateName}, - hir::{Context, ParsedFiles}, + hir::Context, }; use super::fs::write_to_file; @@ -54,10 +54,9 @@ pub(crate) fn run( let mut workspace_file_manager = file_manager_with_stdlib(&workspace.root_dir); insert_all_files_for_workspace_into_file_manager(&workspace, &mut workspace_file_manager); - let parsed_files = parse_all(&workspace_file_manager); for package in &workspace { - check_package(&workspace_file_manager, &parsed_files, package, &args.compile_options)?; + check_package(&workspace_file_manager, package, &args.compile_options)?; println!("[{}] Constraint system successfully built!", package.name); } Ok(()) @@ -65,11 +64,10 @@ pub(crate) fn run( fn check_package( file_manager: &FileManager, - parsed_files: &ParsedFiles, package: &Package, compile_options: &CompileOptions, ) -> Result<(), CompileError> { - let (mut context, crate_id) = prepare_package(file_manager, parsed_files, package); + let (mut context, crate_id) = prepare_package(file_manager, package); check_crate_and_report_errors( &mut context, crate_id, diff --git a/noir/tooling/nargo_cli/src/cli/codegen_verifier_cmd.rs b/noir/tooling/nargo_cli/src/cli/codegen_verifier_cmd.rs index 8bf12ee4100b..1eb8153ce9bb 100644 --- a/noir/tooling/nargo_cli/src/cli/codegen_verifier_cmd.rs +++ b/noir/tooling/nargo_cli/src/cli/codegen_verifier_cmd.rs @@ -6,8 +6,12 @@ use super::{ use crate::backends::Backend; use crate::errors::CliError; +use acvm::ExpressionWidth; use clap::Args; -use nargo::{insert_all_files_for_workspace_into_file_manager, parse_all}; +use fm::FileManager; +use nargo::insert_all_files_for_workspace_into_file_manager; +use nargo::package::Package; +use nargo::workspace::Workspace; use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection}; use noirc_driver::{file_manager_with_stdlib, CompileOptions, NOIR_ARTIFACT_VERSION_STRING}; use noirc_frontend::graph::CrateName; @@ -44,20 +48,18 @@ pub(crate) fn run( let mut workspace_file_manager = file_manager_with_stdlib(&workspace.root_dir); insert_all_files_for_workspace_into_file_manager(&workspace, &mut workspace_file_manager); - let parsed_files = parse_all(&workspace_file_manager); let expression_width = backend.get_backend_info()?; for package in &workspace { - let program = compile_bin_package( + let smart_contract_string = smart_contract_for_package( &workspace_file_manager, - &parsed_files, + &workspace, + backend, package, &args.compile_options, expression_width, )?; - let smart_contract_string = backend.eth_contract(&program.circuit)?; - let contract_dir = workspace.contracts_directory_path(package); create_named_dir(&contract_dir, "contract"); let contract_path = contract_dir.join("plonk_vk").with_extension("sol"); @@ -68,3 +70,17 @@ pub(crate) fn run( Ok(()) } + +fn smart_contract_for_package( + file_manager: &FileManager, + workspace: &Workspace, + backend: &Backend, + package: &Package, + compile_options: &CompileOptions, + expression_width: ExpressionWidth, +) -> Result { + let program = + compile_bin_package(file_manager, workspace, package, compile_options, expression_width)?; + + Ok(backend.eth_contract(&program.circuit)?) +} diff --git a/noir/tooling/nargo_cli/src/cli/compile_cmd.rs b/noir/tooling/nargo_cli/src/cli/compile_cmd.rs index aa9a46f39ef5..9e739f5c818c 100644 --- a/noir/tooling/nargo_cli/src/cli/compile_cmd.rs +++ b/noir/tooling/nargo_cli/src/cli/compile_cmd.rs @@ -5,10 +5,10 @@ use acvm::ExpressionWidth; use fm::FileManager; use nargo::artifacts::program::ProgramArtifact; use nargo::errors::CompileError; -use nargo::ops::{compile_contract, compile_program}; +use nargo::insert_all_files_for_workspace_into_file_manager; use nargo::package::Package; +use nargo::prepare_package; use nargo::workspace::Workspace; -use nargo::{insert_all_files_for_workspace_into_file_manager, parse_all}; use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection}; use noirc_driver::file_manager_with_stdlib; use noirc_driver::NOIR_ARTIFACT_VERSION_STRING; @@ -17,7 +17,6 @@ use noirc_driver::{CompilationResult, CompileOptions, CompiledContract, Compiled use noirc_frontend::graph::CrateName; use clap::Args; -use noirc_frontend::hir::ParsedFiles; use crate::backends::Backend; use crate::errors::CliError; @@ -61,28 +60,24 @@ pub(crate) fn run( let mut workspace_file_manager = file_manager_with_stdlib(&workspace.root_dir); insert_all_files_for_workspace_into_file_manager(&workspace, &mut workspace_file_manager); - let parsed_files = parse_all(&workspace_file_manager); + + let (binary_packages, contract_packages): (Vec<_>, Vec<_>) = workspace + .into_iter() + .filter(|package| !package.is_library()) + .cloned() + .partition(|package| package.is_binary()); let expression_width = backend.get_backend_info_or_default(); - let (compiled_program, compiled_contracts) = compile_workspace( + let (_, compiled_contracts) = compile_workspace( &workspace_file_manager, - &parsed_files, &workspace, + &binary_packages, + &contract_packages, expression_width, &args.compile_options, )?; - let (binary_packages, contract_packages): (Vec<_>, Vec<_>) = workspace - .into_iter() - .filter(|package| !package.is_library()) - .cloned() - .partition(|package| package.is_binary()); - // Save build artifacts to disk. - let only_acir = args.compile_options.only_acir; - for (package, program) in binary_packages.into_iter().zip(compiled_program) { - save_program(program.clone(), &package, &workspace.target_directory_path(), only_acir); - } for (package, contract) in contract_packages.into_iter().zip(compiled_contracts) { save_contract(contract, &package, &circuit_dir); } @@ -92,43 +87,22 @@ pub(crate) fn run( pub(super) fn compile_workspace( file_manager: &FileManager, - parsed_files: &ParsedFiles, workspace: &Workspace, + binary_packages: &[Package], + contract_packages: &[Package], expression_width: ExpressionWidth, compile_options: &CompileOptions, ) -> Result<(Vec, Vec), CliError> { - let (binary_packages, contract_packages): (Vec<_>, Vec<_>) = workspace - .into_iter() - .filter(|package| !package.is_library()) - .cloned() - .partition(|package| package.is_binary()); - // Compile all of the packages in parallel. let program_results: Vec> = binary_packages .par_iter() .map(|package| { - let program_artifact_path = workspace.package_build_path(package); - let cached_program: Option = - read_program_from_file(program_artifact_path) - .ok() - .filter(|p| p.noir_version == NOIR_ARTIFACT_VERSION_STRING) - .map(|p| p.into()); - - compile_program( - file_manager, - parsed_files, - package, - compile_options, - expression_width, - cached_program, - ) + compile_program(file_manager, workspace, package, compile_options, expression_width) }) .collect(); let contract_results: Vec> = contract_packages .par_iter() - .map(|package| { - compile_contract(file_manager, parsed_files, package, compile_options, expression_width) - }) + .map(|package| compile_contract(file_manager, package, compile_options, expression_width)) .collect(); // Report any warnings/errors which were encountered during compilation. @@ -160,7 +134,7 @@ pub(super) fn compile_workspace( pub(crate) fn compile_bin_package( file_manager: &FileManager, - parsed_files: &ParsedFiles, + workspace: &Workspace, package: &Package, compile_options: &CompileOptions, expression_width: ExpressionWidth, @@ -169,14 +143,8 @@ pub(crate) fn compile_bin_package( return Err(CompileError::LibraryCrate(package.name.clone()).into()); } - let compilation_result = compile_program( - file_manager, - parsed_files, - package, - compile_options, - expression_width, - None, - ); + let compilation_result = + compile_program(file_manager, workspace, package, compile_options, expression_width); let program = report_errors( compilation_result, @@ -188,6 +156,53 @@ pub(crate) fn compile_bin_package( Ok(program) } +fn compile_program( + file_manager: &FileManager, + workspace: &Workspace, + package: &Package, + compile_options: &CompileOptions, + expression_width: ExpressionWidth, +) -> CompilationResult { + let (mut context, crate_id) = prepare_package(file_manager, package); + + let program_artifact_path = workspace.package_build_path(package); + let cached_program: Option = + read_program_from_file(program_artifact_path) + .ok() + .filter(|p| p.noir_version == NOIR_ARTIFACT_VERSION_STRING) + .map(|p| p.into()); + + let (program, warnings) = + noirc_driver::compile_main(&mut context, crate_id, compile_options, cached_program)?; + + // Apply backend specific optimizations. + let optimized_program = nargo::ops::optimize_program(program, expression_width); + let only_acir = compile_options.only_acir; + save_program(optimized_program.clone(), package, &workspace.target_directory_path(), only_acir); + + Ok((optimized_program, warnings)) +} + +fn compile_contract( + file_manager: &FileManager, + package: &Package, + compile_options: &CompileOptions, + expression_width: ExpressionWidth, +) -> CompilationResult { + let (mut context, crate_id) = prepare_package(file_manager, package); + let (contract, warnings) = + match noirc_driver::compile_contract(&mut context, crate_id, compile_options) { + Ok(contracts_and_warnings) => contracts_and_warnings, + Err(errors) => { + return Err(errors); + } + }; + + let optimized_contract = nargo::ops::optimize_contract(contract, expression_width); + + Ok((optimized_contract, warnings)) +} + pub(super) fn save_program( program: CompiledProgram, package: &Package, diff --git a/noir/tooling/nargo_cli/src/cli/dap_cmd.rs b/noir/tooling/nargo_cli/src/cli/dap_cmd.rs index 9798cbedfeb1..29e696ea6086 100644 --- a/noir/tooling/nargo_cli/src/cli/dap_cmd.rs +++ b/noir/tooling/nargo_cli/src/cli/dap_cmd.rs @@ -2,8 +2,8 @@ use acvm::acir::native_types::WitnessMap; use backend_interface::Backend; use clap::Args; use nargo::constants::PROVER_INPUT_FILE; +use nargo::insert_all_files_for_workspace_into_file_manager; use nargo::workspace::Workspace; -use nargo::{insert_all_files_for_workspace_into_file_manager, parse_all}; use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection}; use noirc_abi::input_parser::Format; use noirc_driver::{ @@ -70,11 +70,10 @@ fn load_and_compile_project( let mut workspace_file_manager = file_manager_with_stdlib(std::path::Path::new("")); insert_all_files_for_workspace_into_file_manager(&workspace, &mut workspace_file_manager); - let parsed_files = parse_all(&workspace_file_manager); let compiled_program = compile_bin_package( &workspace_file_manager, - &parsed_files, + &workspace, package, &CompileOptions::default(), expression_width, diff --git a/noir/tooling/nargo_cli/src/cli/debug_cmd.rs b/noir/tooling/nargo_cli/src/cli/debug_cmd.rs index e62cbc11ec87..f78a683aa8f9 100644 --- a/noir/tooling/nargo_cli/src/cli/debug_cmd.rs +++ b/noir/tooling/nargo_cli/src/cli/debug_cmd.rs @@ -6,8 +6,8 @@ use clap::Args; use nargo::artifacts::debug::DebugArtifact; use nargo::constants::PROVER_INPUT_FILE; +use nargo::insert_all_files_for_workspace_into_file_manager; use nargo::package::Package; -use nargo::{insert_all_files_for_workspace_into_file_manager, parse_all}; use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection}; use noirc_abi::input_parser::{Format, InputValue}; use noirc_abi::InputMap; @@ -57,7 +57,6 @@ pub(crate) fn run( let mut workspace_file_manager = file_manager_with_stdlib(std::path::Path::new("")); insert_all_files_for_workspace_into_file_manager(&workspace, &mut workspace_file_manager); - let parsed_files = parse_all(&workspace_file_manager); let Some(package) = workspace.into_iter().find(|p| p.is_binary()) else { println!( @@ -68,7 +67,7 @@ pub(crate) fn run( let compiled_program = compile_bin_package( &workspace_file_manager, - &parsed_files, + &workspace, package, &args.compile_options, expression_width, diff --git a/noir/tooling/nargo_cli/src/cli/execute_cmd.rs b/noir/tooling/nargo_cli/src/cli/execute_cmd.rs index cf0d46a0718b..7f695c42fa4c 100644 --- a/noir/tooling/nargo_cli/src/cli/execute_cmd.rs +++ b/noir/tooling/nargo_cli/src/cli/execute_cmd.rs @@ -5,9 +5,9 @@ use clap::Args; use nargo::artifacts::debug::DebugArtifact; use nargo::constants::PROVER_INPUT_FILE; use nargo::errors::try_to_diagnose_runtime_error; +use nargo::insert_all_files_for_workspace_into_file_manager; use nargo::ops::DefaultForeignCallExecutor; use nargo::package::Package; -use nargo::{insert_all_files_for_workspace_into_file_manager, parse_all}; use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection}; use noirc_abi::input_parser::{Format, InputValue}; use noirc_abi::InputMap; @@ -66,13 +66,12 @@ pub(crate) fn run( let mut workspace_file_manager = file_manager_with_stdlib(&workspace.root_dir); insert_all_files_for_workspace_into_file_manager(&workspace, &mut workspace_file_manager); - let parsed_files = parse_all(&workspace_file_manager); let expression_width = backend.get_backend_info_or_default(); for package in &workspace { let compiled_program = compile_bin_package( &workspace_file_manager, - &parsed_files, + &workspace, package, &args.compile_options, expression_width, diff --git a/noir/tooling/nargo_cli/src/cli/export_cmd.rs b/noir/tooling/nargo_cli/src/cli/export_cmd.rs index feaa55857e56..ac3e93e09b7f 100644 --- a/noir/tooling/nargo_cli/src/cli/export_cmd.rs +++ b/noir/tooling/nargo_cli/src/cli/export_cmd.rs @@ -1,14 +1,13 @@ use nargo::errors::CompileError; use noirc_errors::FileDiagnostic; -use noirc_frontend::hir::ParsedFiles; use rayon::prelude::*; use fm::FileManager; use iter_extended::try_vecmap; +use nargo::insert_all_files_for_workspace_into_file_manager; use nargo::package::Package; use nargo::prepare_package; use nargo::workspace::Workspace; -use nargo::{insert_all_files_for_workspace_into_file_manager, parse_all}; use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection}; use noirc_driver::{ compile_no_check, file_manager_with_stdlib, CompileOptions, CompiledProgram, @@ -61,7 +60,6 @@ pub(crate) fn run( let mut workspace_file_manager = file_manager_with_stdlib(&workspace.root_dir); insert_all_files_for_workspace_into_file_manager(&workspace, &mut workspace_file_manager); - let parsed_files = parse_all(&workspace_file_manager); let library_packages: Vec<_> = workspace.into_iter().filter(|package| package.is_library()).collect(); @@ -71,7 +69,6 @@ pub(crate) fn run( .map(|package| { compile_exported_functions( &workspace_file_manager, - &parsed_files, &workspace, package, &args.compile_options, @@ -82,12 +79,11 @@ pub(crate) fn run( fn compile_exported_functions( file_manager: &FileManager, - parsed_files: &ParsedFiles, workspace: &Workspace, package: &Package, compile_options: &CompileOptions, ) -> Result<(), CliError> { - let (mut context, crate_id) = prepare_package(file_manager, parsed_files, package); + let (mut context, crate_id) = prepare_package(file_manager, package); check_crate_and_report_errors( &mut context, crate_id, diff --git a/noir/tooling/nargo_cli/src/cli/info_cmd.rs b/noir/tooling/nargo_cli/src/cli/info_cmd.rs index 8dfff67b47fd..f983a19c0fdb 100644 --- a/noir/tooling/nargo_cli/src/cli/info_cmd.rs +++ b/noir/tooling/nargo_cli/src/cli/info_cmd.rs @@ -6,7 +6,7 @@ use clap::Args; use iter_extended::vecmap; use nargo::{ artifacts::debug::DebugArtifact, insert_all_files_for_workspace_into_file_manager, - package::Package, parse_all, + package::Package, }; use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection}; use noirc_driver::{ @@ -67,13 +67,19 @@ pub(crate) fn run( let mut workspace_file_manager = file_manager_with_stdlib(&workspace.root_dir); insert_all_files_for_workspace_into_file_manager(&workspace, &mut workspace_file_manager); - let parsed_files = parse_all(&workspace_file_manager); + + let (binary_packages, contract_packages): (Vec<_>, Vec<_>) = workspace + .into_iter() + .filter(|package| !package.is_library()) + .cloned() + .partition(|package| package.is_binary()); let expression_width = backend.get_backend_info_or_default(); let (compiled_programs, compiled_contracts) = compile_workspace( &workspace_file_manager, - &parsed_files, &workspace, + &binary_packages, + &contract_packages, expression_width, &args.compile_options, )?; @@ -95,12 +101,11 @@ pub(crate) fn run( } } - let binary_packages = - workspace.into_iter().filter(|package| package.is_binary()).zip(compiled_programs); let program_info = binary_packages - .par_bridge() + .into_par_iter() + .zip(compiled_programs) .map(|(package, program)| { - count_opcodes_and_gates_in_program(backend, program, package, expression_width) + count_opcodes_and_gates_in_program(backend, program, &package, expression_width) }) .collect::>()?; diff --git a/noir/tooling/nargo_cli/src/cli/prove_cmd.rs b/noir/tooling/nargo_cli/src/cli/prove_cmd.rs index d02464fd6dfb..167ab541bc5f 100644 --- a/noir/tooling/nargo_cli/src/cli/prove_cmd.rs +++ b/noir/tooling/nargo_cli/src/cli/prove_cmd.rs @@ -1,8 +1,8 @@ use clap::Args; use nargo::constants::{PROVER_INPUT_FILE, VERIFIER_INPUT_FILE}; +use nargo::insert_all_files_for_workspace_into_file_manager; use nargo::package::Package; use nargo::workspace::Workspace; -use nargo::{insert_all_files_for_workspace_into_file_manager, parse_all}; use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection}; use noirc_abi::input_parser::Format; use noirc_driver::{ @@ -66,13 +66,12 @@ pub(crate) fn run( let mut workspace_file_manager = file_manager_with_stdlib(&workspace.root_dir); insert_all_files_for_workspace_into_file_manager(&workspace, &mut workspace_file_manager); - let parsed_files = parse_all(&workspace_file_manager); let expression_width = backend.get_backend_info()?; for package in &workspace { let program = compile_bin_package( &workspace_file_manager, - &parsed_files, + &workspace, package, &args.compile_options, expression_width, diff --git a/noir/tooling/nargo_cli/src/cli/test_cmd.rs b/noir/tooling/nargo_cli/src/cli/test_cmd.rs index 5db842609e58..69f03b49cbde 100644 --- a/noir/tooling/nargo_cli/src/cli/test_cmd.rs +++ b/noir/tooling/nargo_cli/src/cli/test_cmd.rs @@ -8,14 +8,11 @@ use nargo::{ insert_all_files_for_workspace_into_file_manager, ops::{run_test, TestStatus}, package::Package, - parse_all, prepare_package, + prepare_package, }; use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection}; use noirc_driver::{file_manager_with_stdlib, CompileOptions, NOIR_ARTIFACT_VERSION_STRING}; -use noirc_frontend::{ - graph::CrateName, - hir::{FunctionNameMatch, ParsedFiles}, -}; +use noirc_frontend::{graph::CrateName, hir::FunctionNameMatch}; use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor}; use crate::{backends::Backend, cli::check_cmd::check_crate_and_report_errors, errors::CliError}; @@ -69,7 +66,6 @@ pub(crate) fn run( let mut workspace_file_manager = file_manager_with_stdlib(&workspace.root_dir); insert_all_files_for_workspace_into_file_manager(&workspace, &mut workspace_file_manager); - let parsed_files = parse_all(&workspace_file_manager); let pattern = match &args.test_name { Some(name) => { @@ -88,7 +84,6 @@ pub(crate) fn run( // TODO: We should run the whole suite even if there are failures in a package run_tests( &workspace_file_manager, - &parsed_files, &blackbox_solver, package, pattern, @@ -101,10 +96,8 @@ pub(crate) fn run( Ok(()) } -#[allow(clippy::too_many_arguments)] fn run_tests( file_manager: &FileManager, - parsed_files: &ParsedFiles, blackbox_solver: &S, package: &Package, fn_name: FunctionNameMatch, @@ -112,7 +105,7 @@ fn run_tests( foreign_call_resolver_url: Option<&str>, compile_options: &CompileOptions, ) -> Result<(), CliError> { - let (mut context, crate_id) = prepare_package(file_manager, parsed_files, package); + let (mut context, crate_id) = prepare_package(file_manager, package); check_crate_and_report_errors( &mut context, crate_id, diff --git a/noir/tooling/nargo_cli/src/cli/verify_cmd.rs b/noir/tooling/nargo_cli/src/cli/verify_cmd.rs index 1701b9e063c8..86d5e774cbe9 100644 --- a/noir/tooling/nargo_cli/src/cli/verify_cmd.rs +++ b/noir/tooling/nargo_cli/src/cli/verify_cmd.rs @@ -7,9 +7,9 @@ use crate::{backends::Backend, errors::CliError}; use clap::Args; use nargo::constants::{PROOF_EXT, VERIFIER_INPUT_FILE}; +use nargo::insert_all_files_for_workspace_into_file_manager; use nargo::package::Package; use nargo::workspace::Workspace; -use nargo::{insert_all_files_for_workspace_into_file_manager, parse_all}; use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection}; use noirc_abi::input_parser::Format; use noirc_driver::{ @@ -53,13 +53,12 @@ pub(crate) fn run( let mut workspace_file_manager = file_manager_with_stdlib(&workspace.root_dir); insert_all_files_for_workspace_into_file_manager(&workspace, &mut workspace_file_manager); - let parsed_files = parse_all(&workspace_file_manager); let expression_width = backend.get_backend_info()?; for package in &workspace { let program = compile_bin_package( &workspace_file_manager, - &parsed_files, + &workspace, package, &args.compile_options, expression_width, diff --git a/noir/tooling/noir_codegen/package.json b/noir/tooling/noir_codegen/package.json index 60ccf5ec2a5b..7d76b1a91381 100644 --- a/noir/tooling/noir_codegen/package.json +++ b/noir/tooling/noir_codegen/package.json @@ -3,7 +3,7 @@ "contributors": [ "The Noir Team " ], - "version": "0.23.0", + "version": "0.22.0", "packageManager": "yarn@3.5.1", "license": "(MIT OR Apache-2.0)", "type": "module", diff --git a/noir/tooling/noir_js/package.json b/noir/tooling/noir_js/package.json index 356909a1e35b..ed2fd2258100 100644 --- a/noir/tooling/noir_js/package.json +++ b/noir/tooling/noir_js/package.json @@ -3,7 +3,7 @@ "contributors": [ "The Noir Team " ], - "version": "0.23.0", + "version": "0.22.0", "packageManager": "yarn@3.5.1", "license": "(MIT OR Apache-2.0)", "type": "module", diff --git a/noir/tooling/noir_js_backend_barretenberg/package.json b/noir/tooling/noir_js_backend_barretenberg/package.json index cd2a6354ac4b..e22ea2ff49d5 100644 --- a/noir/tooling/noir_js_backend_barretenberg/package.json +++ b/noir/tooling/noir_js_backend_barretenberg/package.json @@ -3,7 +3,7 @@ "contributors": [ "The Noir Team " ], - "version": "0.23.0", + "version": "0.22.0", "packageManager": "yarn@3.5.1", "license": "(MIT OR Apache-2.0)", "type": "module", diff --git a/noir/tooling/noir_js_types/package.json b/noir/tooling/noir_js_types/package.json index ef75f3d2fb38..0276b8d087cd 100644 --- a/noir/tooling/noir_js_types/package.json +++ b/noir/tooling/noir_js_types/package.json @@ -4,7 +4,7 @@ "The Noir Team " ], "packageManager": "yarn@3.5.1", - "version": "0.23.0", + "version": "0.22.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://noir-lang.org/", "repository": { diff --git a/noir/tooling/noirc_abi_wasm/package.json b/noir/tooling/noirc_abi_wasm/package.json index db0f6c291530..d023e1e43910 100644 --- a/noir/tooling/noirc_abi_wasm/package.json +++ b/noir/tooling/noirc_abi_wasm/package.json @@ -3,7 +3,7 @@ "contributors": [ "The Noir Team " ], - "version": "0.23.0", + "version": "0.22.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://noir-lang.org/", "repository": { diff --git a/noir/yarn.lock b/noir/yarn.lock index db3f493bc62d..e7822f59bdc3 100644 --- a/noir/yarn.lock +++ b/noir/yarn.lock @@ -221,20 +221,6 @@ __metadata: languageName: node linkType: hard -"@aztec/bb.js@npm:0.16.0": - version: 0.16.0 - resolution: "@aztec/bb.js@npm:0.16.0" - dependencies: - comlink: ^4.4.1 - commander: ^10.0.1 - debug: ^4.3.4 - tslib: ^2.4.0 - bin: - bb.js: dest/node/main.js - checksum: 5f68b4ad16284a3a871e0ad21fea05aed670383bc639c9d07ab3bf9b7a9d15cc8a4e5cda404a9290775ad5023924739543a8aac37d602892dd1fb5087521970b - languageName: node - linkType: hard - "@aztec/bb.js@npm:0.19.0": version: 0.19.0 resolution: "@aztec/bb.js@npm:0.19.0" @@ -4395,13 +4381,6 @@ __metadata: languageName: node linkType: hard -"@noir-lang/acvm_js@npm:0.38.0": - version: 0.38.0 - resolution: "@noir-lang/acvm_js@npm:0.38.0" - checksum: 42a5bba45135d1df0d0eb3f7b65439733e016580bad610e859e140638d42200d6b856ff11c4b30417b74ce011da7c39861aafb1c5b8c7211de2172aea449c635 - languageName: node - linkType: hard - "@noir-lang/acvm_js@workspace:*, @noir-lang/acvm_js@workspace:acvm-repo/acvm_js": version: 0.0.0-use.local resolution: "@noir-lang/acvm_js@workspace:acvm-repo/acvm_js" @@ -4420,18 +4399,7 @@ __metadata: languageName: unknown linkType: soft -"@noir-lang/backend_barretenberg@npm:^0.22.0": - version: 0.22.0 - resolution: "@noir-lang/backend_barretenberg@npm:0.22.0" - dependencies: - "@aztec/bb.js": 0.16.0 - "@noir-lang/types": 0.22.0 - fflate: ^0.8.0 - checksum: ead456218ba61d925e0fc5b47d1b94272e980b44a220f1262fb6cdc73cff7cd4232ddc69dd67bb21e50f0b43e7696d4a96fde15e3eadc0bf223ec6d59e014e23 - languageName: node - linkType: hard - -"@noir-lang/backend_barretenberg@workspace:*, @noir-lang/backend_barretenberg@workspace:tooling/noir_js_backend_barretenberg": +"@noir-lang/backend_barretenberg@^0.22.0, @noir-lang/backend_barretenberg@workspace:*, @noir-lang/backend_barretenberg@workspace:tooling/noir_js_backend_barretenberg": version: 0.0.0-use.local resolution: "@noir-lang/backend_barretenberg@workspace:tooling/noir_js_backend_barretenberg" dependencies: @@ -4475,18 +4443,7 @@ __metadata: languageName: unknown linkType: soft -"@noir-lang/noir_js@npm:^0.22.0": - version: 0.22.0 - resolution: "@noir-lang/noir_js@npm:0.22.0" - dependencies: - "@noir-lang/acvm_js": 0.38.0 - "@noir-lang/noirc_abi": 0.22.0 - "@noir-lang/types": 0.22.0 - checksum: 3b0873ad87521415af11208bebe5690191d03fa06dcd515789f0a63f7641146cdcb01d292b208452856ea3967e196c8332cb2618e013f9e7e5ce7d6e09de043d - languageName: node - linkType: hard - -"@noir-lang/noir_js@workspace:*, @noir-lang/noir_js@workspace:tooling/noir_js": +"@noir-lang/noir_js@^0.22.0, @noir-lang/noir_js@workspace:*, @noir-lang/noir_js@workspace:tooling/noir_js": version: 0.0.0-use.local resolution: "@noir-lang/noir_js@workspace:tooling/noir_js" dependencies: @@ -4509,14 +4466,7 @@ __metadata: languageName: unknown linkType: soft -"@noir-lang/noir_wasm@npm:^0.22.0": - version: 0.22.0 - resolution: "@noir-lang/noir_wasm@npm:0.22.0" - checksum: 7ac0ca170bf312df761d7ccfd32a67a27f88f15ad4eed1807864295d761d3b2176ffb82f4c6931e1bc06b225d6f738519962c79ffbce9a33d5ef8a6a2bdea82c - languageName: node - linkType: hard - -"@noir-lang/noir_wasm@workspace:*, @noir-lang/noir_wasm@workspace:compiler/wasm": +"@noir-lang/noir_wasm@^0.22.0, @noir-lang/noir_wasm@workspace:*, @noir-lang/noir_wasm@workspace:compiler/wasm": version: 0.0.0-use.local resolution: "@noir-lang/noir_wasm@workspace:compiler/wasm" dependencies: @@ -4560,13 +4510,6 @@ __metadata: languageName: unknown linkType: soft -"@noir-lang/noirc_abi@npm:0.22.0": - version: 0.22.0 - resolution: "@noir-lang/noirc_abi@npm:0.22.0" - checksum: a250c6cc5ca37fcf02663f8d6b027776f0e58920fb8f8a84efcf74f079f235bb11bbad682ba332211d9b9a79b6a3eb7faede7701cd88582b682971a41ca6212d - languageName: node - linkType: hard - "@noir-lang/noirc_abi@workspace:*, @noir-lang/noirc_abi@workspace:tooling/noirc_abi_wasm": version: 0.0.0-use.local resolution: "@noir-lang/noirc_abi@workspace:tooling/noirc_abi_wasm" @@ -4597,16 +4540,7 @@ __metadata: languageName: unknown linkType: soft -"@noir-lang/types@npm:0.22.0, @noir-lang/types@npm:^0.22.0": - version: 0.22.0 - resolution: "@noir-lang/types@npm:0.22.0" - dependencies: - "@noir-lang/noirc_abi": 0.22.0 - checksum: 5dd1badf0449c518e755172de1d2f2c1b95bfaf7b7328b7de00b8ce9ba68bd447ca65e827185da7d737e7e88dcaf296b29687ffe2e1f5b4d5cc31ce3e3b4f208 - languageName: node - linkType: hard - -"@noir-lang/types@workspace:*, @noir-lang/types@workspace:tooling/noir_js_types": +"@noir-lang/types@^0.22.0, @noir-lang/types@workspace:*, @noir-lang/types@workspace:tooling/noir_js_types": version: 0.0.0-use.local resolution: "@noir-lang/types@workspace:tooling/noir_js_types" dependencies: diff --git a/yarn-project/accounts/.eslintrc.cjs b/yarn-project/accounts/.eslintrc.cjs index ec1dd3e14de0..e659927475c0 100644 --- a/yarn-project/accounts/.eslintrc.cjs +++ b/yarn-project/accounts/.eslintrc.cjs @@ -1 +1 @@ -module.exports = require('@aztec/foundation/eslint.docs'); +module.exports = require('@aztec/foundation/eslint'); diff --git a/yarn-project/acir-simulator/src/acvm/oracle/oracle.ts b/yarn-project/acir-simulator/src/acvm/oracle/oracle.ts index 020e1738776b..49449ffcbcb8 100644 --- a/yarn-project/acir-simulator/src/acvm/oracle/oracle.ts +++ b/yarn-project/acir-simulator/src/acvm/oracle/oracle.ts @@ -33,14 +33,10 @@ export class Oracle { return toACVMField(packed); } - async getNullifierKeyPair([accountAddress]: ACVMField[]): Promise { - const { publicKey, secretKey } = await this.typedOracle.getNullifierKeyPair(fromACVMField(accountAddress)); - return [ - toACVMField(publicKey.x), - toACVMField(publicKey.y), - toACVMField(secretKey.high), - toACVMField(secretKey.low), - ]; + async getSecretKey([publicKeyX]: ACVMField[], [publicKeyY]: ACVMField[]): Promise { + const publicKey = new Point(fromACVMField(publicKeyX), fromACVMField(publicKeyY)); + const secretKey = await this.typedOracle.getSecretKey(publicKey); + return [toACVMField(secretKey.low), toACVMField(secretKey.high)]; } async getPublicKeyAndPartialAddress([address]: ACVMField[]) { @@ -232,8 +228,8 @@ export class Oracle { } async getL1ToL2Message([msgKey]: ACVMField[]): Promise { - const { ...message } = await this.typedOracle.getL1ToL2Message(fromACVMField(msgKey)); - return toAcvmL1ToL2MessageLoadOracleInputs(message); + const { root, ...message } = await this.typedOracle.getL1ToL2Message(fromACVMField(msgKey)); + return toAcvmL1ToL2MessageLoadOracleInputs(message, root); } async getPortalContractAddress([aztecAddress]: ACVMField[]): Promise { diff --git a/yarn-project/acir-simulator/src/acvm/oracle/typed_oracle.ts b/yarn-project/acir-simulator/src/acvm/oracle/typed_oracle.ts index 27d9f8d5f307..995a285b7b1a 100644 --- a/yarn-project/acir-simulator/src/acvm/oracle/typed_oracle.ts +++ b/yarn-project/acir-simulator/src/acvm/oracle/typed_oracle.ts @@ -7,25 +7,11 @@ import { PublicKey, UnencryptedL2Log, } from '@aztec/circuit-types'; -import { BlockHeader, GrumpkinPrivateKey, PrivateCallStackItem, PublicCallRequest } from '@aztec/circuits.js'; +import { BlockHeader, PrivateCallStackItem, PublicCallRequest } from '@aztec/circuits.js'; import { FunctionSelector } from '@aztec/foundation/abi'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { EthAddress } from '@aztec/foundation/eth-address'; -import { Fr } from '@aztec/foundation/fields'; - -/** - * A pair of public key and secret key. - */ -export interface KeyPair { - /** - * Public key. - */ - publicKey: PublicKey; - /** - * Secret Key. - */ - secretKey: GrumpkinPrivateKey; -} +import { Fr, GrumpkinScalar } from '@aztec/foundation/fields'; /** * Information about a note needed during execution. @@ -48,7 +34,7 @@ export interface NoteData { } /** - * The data for L1 to L2 Messages provided by other data sources. + * The partial data for L1 to L2 Messages provided by other data sources. */ export interface MessageLoadOracleInputs { /** @@ -66,6 +52,16 @@ export interface MessageLoadOracleInputs { index: bigint; } +/** + * The data required by Aztec.nr to validate L1 to L2 Messages. + */ +export interface L1ToL2MessageOracleReturnData extends MessageLoadOracleInputs { + /** + * The current root of the l1 to l2 message tree. + */ + root: Fr; +} + /** * Oracle with typed parameters and typed return values. * Methods that require read and/or write will have to be implemented based on the context (public, private, or view) @@ -80,7 +76,7 @@ export abstract class TypedOracle { throw new Error('Not available.'); } - getNullifierKeyPair(_accountAddress: AztecAddress): Promise { + getSecretKey(_owner: PublicKey): Promise { throw new Error('Not available.'); } @@ -157,7 +153,7 @@ export abstract class TypedOracle { throw new Error('Not available.'); } - getL1ToL2Message(_msgKey: Fr): Promise { + getL1ToL2Message(_msgKey: Fr): Promise { throw new Error('Not available.'); } diff --git a/yarn-project/acir-simulator/src/acvm/serialize.ts b/yarn-project/acir-simulator/src/acvm/serialize.ts index 5e844ff8a7cd..1877bf264d98 100644 --- a/yarn-project/acir-simulator/src/acvm/serialize.ts +++ b/yarn-project/acir-simulator/src/acvm/serialize.ts @@ -199,13 +199,18 @@ export function toAcvmEnqueuePublicFunctionResult(item: PublicCallRequest): ACVM /** * Converts the result of loading messages to ACVM fields. * @param messageLoadOracleInputs - The result of loading messages to convert. + * @param l1ToL2MessageTreeRoot - The L1 to L2 message tree root * @returns The Message Oracle Fields. */ -export function toAcvmL1ToL2MessageLoadOracleInputs(messageLoadOracleInputs: MessageLoadOracleInputs): ACVMField[] { +export function toAcvmL1ToL2MessageLoadOracleInputs( + messageLoadOracleInputs: MessageLoadOracleInputs, + l1ToL2MessageTreeRoot: Fr, +): ACVMField[] { return [ ...messageLoadOracleInputs.message.map(f => toACVMField(f)), toACVMField(messageLoadOracleInputs.index), ...messageLoadOracleInputs.siblingPath.map(f => toACVMField(f)), + toACVMField(l1ToL2MessageTreeRoot), ]; } diff --git a/yarn-project/acir-simulator/src/avm/avm_message_call_result.ts b/yarn-project/acir-simulator/src/avm/avm_message_call_result.ts index e2290e4fa6d1..ec258dff1126 100644 --- a/yarn-project/acir-simulator/src/avm/avm_message_call_result.ts +++ b/yarn-project/acir-simulator/src/avm/avm_message_call_result.ts @@ -6,15 +6,12 @@ import { Fr } from '@aztec/foundation/fields'; export class AvmMessageCallResult { /** - */ public readonly reverted: boolean; - /** - */ - public readonly revertReason: Error | undefined; /** .- */ public readonly output: Fr[]; - private constructor(reverted: boolean, output: Fr[], revertReason?: Error) { + constructor(reverted: boolean, output: Fr[]) { this.reverted = reverted; this.output = output; - this.revertReason = revertReason; } /** @@ -29,10 +26,9 @@ export class AvmMessageCallResult { /** * Terminate a call as a revert * @param output - Return data ( revert message ) - * @param reason - Optional reason for revert * @returns instance of AvmMessageCallResult */ - public static revert(output: Fr[], reason?: Error): AvmMessageCallResult { - return new AvmMessageCallResult(true, output, reason); + public static revert(output: Fr[]): AvmMessageCallResult { + return new AvmMessageCallResult(true, output); } } diff --git a/yarn-project/acir-simulator/src/avm/interpreter/interpreter.test.ts b/yarn-project/acir-simulator/src/avm/interpreter/interpreter.test.ts index 7f252ec739c8..a52a2c13222e 100644 --- a/yarn-project/acir-simulator/src/avm/interpreter/interpreter.test.ts +++ b/yarn-project/acir-simulator/src/avm/interpreter/interpreter.test.ts @@ -8,7 +8,7 @@ import { Add } from '../opcodes/arithmetic.js'; import { Jump, Return } from '../opcodes/control_flow.js'; import { Instruction } from '../opcodes/instruction.js'; import { CalldataCopy } from '../opcodes/memory.js'; -import { AvmInterpreter, InvalidProgramCounterError } from './interpreter.js'; +import { AvmInterpreter } from './interpreter.js'; describe('interpreter', () => { it('Should execute a series of instructions', () => { @@ -16,9 +16,12 @@ describe('interpreter', () => { const stateManager = mock(); const instructions: Instruction[] = [ - new CalldataCopy(/*cdOffset=*/ 0, /*copySize=*/ 2, /*destOffset=*/ 0), - new Add(/*aOffset=*/ 0, /*bOffset=*/ 1, /*destOffset=*/ 2), - new Return(/*returnOffset=*/ 2, /*copySize=*/ 1), + // Copy the first two elements of the calldata to memory regions 0 and 1 + new CalldataCopy(0, 2, 0), + // Add the two together and store the result in memory region 2 + new Add(0, 1, 2), // 1 + 2 + // Return the result + new Return(2, 1), // [3] ]; const context = new AvmMachineState(calldata); @@ -26,8 +29,10 @@ describe('interpreter', () => { const avmReturnData = interpreter.run(); expect(avmReturnData.reverted).toBe(false); - expect(avmReturnData.revertReason).toBeUndefined(); - expect(avmReturnData.output).toEqual([new Fr(3)]); + + const returnData = avmReturnData.output; + expect(returnData.length).toBe(1); + expect(returnData).toEqual([new Fr(3)]); }); it('Should revert with an invalid jump', () => { @@ -44,7 +49,5 @@ describe('interpreter', () => { const avmReturnData = interpreter.run(); expect(avmReturnData.reverted).toBe(true); - expect(avmReturnData.revertReason).toBeInstanceOf(InvalidProgramCounterError); - expect(avmReturnData.output).toHaveLength(0); }); }); diff --git a/yarn-project/acir-simulator/src/avm/interpreter/interpreter.ts b/yarn-project/acir-simulator/src/avm/interpreter/interpreter.ts index f3970ade43f6..9bbd511c2d37 100644 --- a/yarn-project/acir-simulator/src/avm/interpreter/interpreter.ts +++ b/yarn-project/acir-simulator/src/avm/interpreter/interpreter.ts @@ -1,7 +1,6 @@ +// import { AvmContext } from "../avm_machineState.js"; import { Fr } from '@aztec/foundation/fields'; -import { strict as assert } from 'assert'; - import { AvmMachineState } from '../avm_machine_state.js'; import { AvmMessageCallResult } from '../avm_message_call_result.js'; import { AvmStateManager } from '../avm_state_manager.js'; @@ -17,10 +16,10 @@ export class AvmInterpreter { private machineState: AvmMachineState; private stateManager: AvmStateManager; - constructor(machineState: AvmMachineState, stateManager: AvmStateManager, instructions: Instruction[]) { + constructor(machineState: AvmMachineState, stateManager: AvmStateManager, bytecode: Instruction[]) { this.machineState = machineState; this.stateManager = stateManager; - this.instructions = instructions; + this.instructions = bytecode; } /** @@ -30,30 +29,27 @@ export class AvmInterpreter { * - any other panic will throw */ run(): AvmMessageCallResult { - assert(this.instructions.length > 0); - try { - while (!this.machineState.halted) { + while (!this.machineState.halted && this.machineState.pc < this.instructions.length) { const instruction = this.instructions[this.machineState.pc]; - assert(!!instruction); // This should never happen + + if (!instruction) { + throw new InvalidInstructionError(this.machineState.pc); + } instruction.execute(this.machineState, this.stateManager); if (this.machineState.pc >= this.instructions.length) { - throw new InvalidProgramCounterError(this.machineState.pc, /*max=*/ this.instructions.length); + throw new InvalidProgramCounterError(this.machineState.pc, this.instructions.length); } } const returnData = this.machineState.getReturnData(); return AvmMessageCallResult.success(returnData); - } catch (_e) { - if (!(_e instanceof AvmInterpreterError)) { - throw _e; - } - - const revertReason: AvmInterpreterError = _e; + } catch (e) { + // TODO: This should only accept AVM defined errors, anything else SHOULD be thrown upstream const revertData = this.machineState.getReturnData(); - return AvmMessageCallResult.revert(revertData, revertReason); + return AvmMessageCallResult.revert(revertData); } } @@ -68,22 +64,20 @@ export class AvmInterpreter { } /** - * Avm-specific errors should derive from this + * Error is thrown when the program counter goes to an invalid location. + * There is no instruction at the provided pc */ -export abstract class AvmInterpreterError extends Error { - constructor(message: string) { - super(message); - this.name = 'AvmInterpreterError'; +class InvalidProgramCounterError extends Error { + constructor(pc: number, max: number) { + super(`Invalid program counter ${pc}, max is ${max}`); } } /** - * Error is thrown when the program counter goes to an invalid location. - * There is no instruction at the provided pc + * This assertion should never be hit - there should always be a valid instruction */ -export class InvalidProgramCounterError extends AvmInterpreterError { - constructor(pc: number, max: number) { - super(`Invalid program counter ${pc}, max is ${max}`); - this.name = 'InvalidProgramCounterError'; +class InvalidInstructionError extends Error { + constructor(pc: number) { + super(`Invalid instruction at ${pc}`); } } diff --git a/yarn-project/acir-simulator/src/avm/opcodes/bitwise.test.ts b/yarn-project/acir-simulator/src/avm/opcodes/bitwise.test.ts deleted file mode 100644 index e1de73560412..000000000000 --- a/yarn-project/acir-simulator/src/avm/opcodes/bitwise.test.ts +++ /dev/null @@ -1,166 +0,0 @@ -import { Fr } from '@aztec/foundation/fields'; - -import { mock } from 'jest-mock-extended'; - -import { AvmMachineState } from '../avm_machine_state.js'; -import { AvmStateManager } from '../avm_state_manager.js'; -import { - And, - /*Not,*/ - Or, - Shl, - Shr, - Xor, -} from './bitwise.js'; - -describe('Bitwise instructions', () => { - let machineState: AvmMachineState; - let stateManager = mock(); - - beforeEach(() => { - machineState = new AvmMachineState([]); - stateManager = mock(); - }); - - it('Should AND correctly over Fr type', () => { - const a = new Fr(0b11111110010011100100n); - const b = new Fr(0b11100100111001001111n); - - machineState.writeMemory(0, a); - machineState.writeMemory(1, b); - - new And(0, 1, 2).execute(machineState, stateManager); - - const expected = new Fr(0b11100100010001000100n); - const actual = machineState.readMemory(2); - expect(actual).toEqual(expected); - }); - - it('Should OR correctly over Fr type', () => { - const a = new Fr(0b11111110010011100100n); - const b = new Fr(0b11100100111001001111n); - - machineState.writeMemory(0, a); - machineState.writeMemory(1, b); - - new Or(0, 1, 2).execute(machineState, stateManager); - - const expected = new Fr(0b11111110111011101111n); - const actual = machineState.readMemory(2); - expect(actual).toEqual(expected); - }); - - it('Should XOR correctly over Fr type', () => { - const a = new Fr(0b11111110010011100100n); - const b = new Fr(0b11100100111001001111n); - - machineState.writeMemory(0, a); - machineState.writeMemory(1, b); - - new Xor(0, 1, 2).execute(machineState, stateManager); - - const expected = new Fr(0b00011010101010101011n); - const actual = machineState.readMemory(2); - expect(actual).toEqual(expected); - }); - - describe('SHR', () => { - it('Should shift correctly 0 positions over Fr type', () => { - const a = new Fr(0b11111110010011100100n); - const b = new Fr(0n); - - machineState.writeMemory(0, a); - machineState.writeMemory(1, b); - - new Shr(0, 1, 2).execute(machineState, stateManager); - - const expected = a; - const actual = machineState.readMemory(2); - expect(actual).toEqual(expected); - }); - - it('Should shift correctly 2 positions over Fr type', () => { - const a = new Fr(0b11111110010011100100n); - const b = new Fr(2n); - - machineState.writeMemory(0, a); - machineState.writeMemory(1, b); - - new Shr(0, 1, 2).execute(machineState, stateManager); - - const expected = new Fr(0b00111111100100111001n); - const actual = machineState.readMemory(2); - expect(actual).toEqual(expected); - }); - - it('Should shift correctly 19 positions over Fr type', () => { - const a = new Fr(0b11111110010011100100n); - const b = new Fr(19n); - - machineState.writeMemory(0, a); - machineState.writeMemory(1, b); - - new Shr(0, 1, 2).execute(machineState, stateManager); - - const expected = new Fr(0b01n); - const actual = machineState.readMemory(2); - expect(actual).toEqual(expected); - }); - }); - - describe('SHL', () => { - it('Should shift correctly 0 positions over Fr type', () => { - const a = new Fr(0b11111110010011100100n); - const b = new Fr(0n); - - machineState.writeMemory(0, a); - machineState.writeMemory(1, b); - - new Shl(0, 1, 2).execute(machineState, stateManager); - - const expected = a; - const actual = machineState.readMemory(2); - expect(actual).toEqual(expected); - }); - - it('Should shift correctly 2 positions over Fr type', () => { - const a = new Fr(0b11111110010011100100n); - const b = new Fr(2n); - - machineState.writeMemory(0, a); - machineState.writeMemory(1, b); - - new Shl(0, 1, 2).execute(machineState, stateManager); - - const expected = new Fr(0b1111111001001110010000n); - const actual = machineState.readMemory(2); - expect(actual).toEqual(expected); - }); - - // it('Should shift correctly over bit limit over Fr type', () => { - // const a = new Fr(0b11111110010011100100n); - // const b = new Fr(19n); - - // machineState.writeMemory(0, a); - // machineState.writeMemory(1, b); - - // new Shl(0, 1, 2).execute(machineState, stateManager); - - // const expected = new Fr(0b01n); - // const actual = machineState.readMemory(2); - // expect(actual).toEqual(expected); - // }); - }); - - // it('Should NOT correctly over Fr type', () => { - // const a = new Fr(0b11111110010011100100n); - - // machineState.writeMemory(0, a); - - // new Not(0, 1).execute(machineState, stateManager); - - // const expected = new Fr(0b00000001101100011011n); // high bits! - // const actual = machineState.readMemory(1); - // expect(actual).toEqual(expected); - // }); -}); diff --git a/yarn-project/acir-simulator/src/avm/opcodes/bitwise.ts b/yarn-project/acir-simulator/src/avm/opcodes/bitwise.ts index ff7802aac614..4950c771f7c6 100644 --- a/yarn-project/acir-simulator/src/avm/opcodes/bitwise.ts +++ b/yarn-project/acir-simulator/src/avm/opcodes/bitwise.ts @@ -120,9 +120,6 @@ export class Shr extends Instruction { const a: Fr = machineState.readMemory(this.aOffset); const b: Fr = machineState.readMemory(this.bOffset); - // Here we are assuming that the field element maps to a positive number. - // The >> operator is *signed* in JS (and it sign extends). - // E.g.: -1n >> 3n == -1n. const dest = new Fr(a.toBigInt() >> b.toBigInt()); machineState.writeMemory(this.destOffset, dest); diff --git a/yarn-project/acir-simulator/src/avm/opcodes/control_flow.test.ts b/yarn-project/acir-simulator/src/avm/opcodes/control_flow.test.ts index 906584b3493d..864ee0d0b425 100644 --- a/yarn-project/acir-simulator/src/avm/opcodes/control_flow.test.ts +++ b/yarn-project/acir-simulator/src/avm/opcodes/control_flow.test.ts @@ -8,7 +8,7 @@ import { Add, Mul, Sub } from './arithmetic.js'; import { And, Not, Or, Shl, Shr, Xor } from './bitwise.js'; import { Eq, Lt, Lte } from './comparators.js'; import { InternalCall, InternalCallStackEmptyError, InternalReturn, Jump, JumpI } from './control_flow.js'; -import { CMov, CalldataCopy, Cast, Mov, Set } from './memory.js'; +import { CalldataCopy, Cast, Mov, Set } from './memory.js'; describe('Control Flow Opcodes', () => { let stateManager = mock(); @@ -132,7 +132,6 @@ describe('Control Flow Opcodes', () => { new CalldataCopy(0, 1, 2), new Set(0n, 1), new Mov(0, 1), - new CMov(0, 1, 2, 3), new Cast(0, 1), ]; diff --git a/yarn-project/acir-simulator/src/avm/opcodes/instruction_set.ts b/yarn-project/acir-simulator/src/avm/opcodes/instruction_set.ts index 664467f887dd..4395ba46d534 100644 --- a/yarn-project/acir-simulator/src/avm/opcodes/instruction_set.ts +++ b/yarn-project/acir-simulator/src/avm/opcodes/instruction_set.ts @@ -1,9 +1,12 @@ import { Add, Div, Mul, Sub } from './arithmetic.js'; -import { And, Not, Or, Shl, Shr, Xor } from './bitwise.js'; +//import { And, Not, Or, Shl, Shr, Xor } from './bitwise.js'; //import { Eq, Lt, Lte } from './comparators.js'; import { InternalCall, InternalReturn, Jump, JumpI, Return } from './control_flow.js'; import { Instruction } from './instruction.js'; -import { CMov, CalldataCopy, Cast, Mov, Set } from './memory.js'; +import { + CalldataCopy, + /*Cast, Mov*/ +} from './memory.js'; import { Opcode } from './opcodes.js'; /** - */ @@ -27,14 +30,14 @@ export const INSTRUCTION_SET: Map = ne //[Opcode.LT, Lt], //[Opcode.LTE, Lte], //// Compute - Bitwise - [Opcode.AND, And], - [Opcode.OR, Or], - [Opcode.XOR, Xor], - [Opcode.NOT, Not], - [Opcode.SHL, Shl], - [Opcode.SHR, Shr], + //[Opcode.AND, And], + //[Opcode.OR, Or], + //[Opcode.XOR, Xor], + //[Opcode.NOT, Not], + //[Opcode.SHL, Shl], + //[Opcode.SHR, Shr], //// Compute - Type Conversions - [Opcode.CAST, Cast], + //[Opcode.CAST, Cast], //// Execution Environment //[Opcode.ADDRESS, Address], @@ -69,9 +72,9 @@ export const INSTRUCTION_SET: Map = ne [Opcode.INTERNALCALL, InternalCall], [Opcode.INTERNALRETURN, InternalReturn], //// Machine State - Memory - [Opcode.SET, Set], - [Opcode.MOV, Mov], - [Opcode.CMOV, CMov], + //[Opcode.SET, Set], + //[Opcode.MOV, Mov], + //[Opcode.CMOV, CMov], //// World State //[Opcode.BLOCKHEADERBYNUMBER, Blockheaderbynumber], diff --git a/yarn-project/acir-simulator/src/avm/opcodes/memory.test.ts b/yarn-project/acir-simulator/src/avm/opcodes/memory.test.ts deleted file mode 100644 index 3b02ef36c32c..000000000000 --- a/yarn-project/acir-simulator/src/avm/opcodes/memory.test.ts +++ /dev/null @@ -1,182 +0,0 @@ -import { Fr } from '@aztec/foundation/fields'; - -import { mock } from 'jest-mock-extended'; - -import { AvmMachineState } from '../avm_machine_state.js'; -import { AvmStateManager } from '../avm_state_manager.js'; -import { CMov, CalldataCopy, Cast, Mov, Set } from './memory.js'; - -describe('Memory instructions', () => { - let machineState: AvmMachineState; - let stateManager = mock(); - - beforeEach(() => { - machineState = new AvmMachineState([]); - stateManager = mock(); - }); - - it('Should SET memory correctly', () => { - const value = 123456n; - - new Set(value, 1).execute(machineState, stateManager); - - const expected = new Fr(value); - const actual = machineState.readMemory(1); - expect(actual).toEqual(expected); - }); - - // TODO(https://github.com/AztecProtocol/aztec-packages/issues/3987): tags are not implemented yet - this will behave as a mov - describe('CAST', () => { - it('Should work correctly on different memory cells', () => { - const value = new Fr(123456n); - - machineState.writeMemory(0, value); - - new Cast(/*aOffset=*/ 0, /*dstOffset=*/ 1).execute(machineState, stateManager); - - const actual = machineState.readMemory(1); - expect(actual).toEqual(value); - }); - - it('Should work correctly on same memory cell', () => { - const value = new Fr(123456n); - - machineState.writeMemory(0, value); - - new Cast(/*aOffset=*/ 0, /*dstOffset=*/ 0).execute(machineState, stateManager); - - const actual = machineState.readMemory(0); - expect(actual).toEqual(value); - }); - }); - - describe('MOV', () => { - it('Should work correctly on different memory cells', () => { - const value = new Fr(123456n); - - machineState.writeMemory(0, value); - - new Mov(/*aOffset=*/ 0, /*dstOffset=*/ 1).execute(machineState, stateManager); - - const actual = machineState.readMemory(1); - expect(actual).toEqual(value); - }); - - it('Should work correctly on same memory cell', () => { - const value = new Fr(123456n); - - machineState.writeMemory(0, value); - - new Mov(/*aOffset=*/ 0, /*dstOffset=*/ 0).execute(machineState, stateManager); - - const actual = machineState.readMemory(0); - expect(actual).toEqual(value); - }); - }); - - describe('MOV', () => { - it('Should move A if COND is true, on different memory cells', () => { - const valueA = new Fr(123456n); - const valueB = new Fr(80n); - const valueCondition = new Fr(22n); - - machineState.writeMemory(0, valueA); - machineState.writeMemory(1, valueB); - machineState.writeMemory(2, valueCondition); - - new CMov(/*aOffset=*/ 0, /*bOffset=*/ 1, /*condOffset=*/ 2, /*dstOffset=*/ 3).execute(machineState, stateManager); - - const actual = machineState.readMemory(3); - expect(actual).toEqual(valueA); - }); - - it('Should move B if COND is false, on different memory cells', () => { - const valueA = new Fr(123456n); - const valueB = new Fr(80n); - const valueCondition = new Fr(0n); - - machineState.writeMemory(0, valueA); - machineState.writeMemory(1, valueB); - machineState.writeMemory(2, valueCondition); - - new CMov(/*aOffset=*/ 0, /*bOffset=*/ 1, /*condOffset=*/ 2, /*dstOffset=*/ 3).execute(machineState, stateManager); - - const actual = machineState.readMemory(3); - expect(actual).toEqual(valueB); - }); - - it('Should move A if COND is true, on overlapping memory cells', () => { - const valueA = new Fr(123456n); - const valueB = new Fr(80n); - const valueCondition = new Fr(22n); - - machineState.writeMemory(0, valueA); - machineState.writeMemory(1, valueB); - machineState.writeMemory(2, valueCondition); - - new CMov(/*aOffset=*/ 0, /*bOffset=*/ 1, /*condOffset=*/ 2, /*dstOffset=*/ 2).execute(machineState, stateManager); - - const actual = machineState.readMemory(2); - expect(actual).toEqual(valueA); - }); - - it('Should move B if COND is false, on overlapping memory cells', () => { - const valueA = new Fr(123456n); - const valueB = new Fr(80n); - const valueCondition = new Fr(0n); - - machineState.writeMemory(0, valueA); - machineState.writeMemory(1, valueB); - machineState.writeMemory(2, valueCondition); - - new CMov(/*aOffset=*/ 0, /*bOffset=*/ 1, /*condOffset=*/ 2, /*dstOffset=*/ 2).execute(machineState, stateManager); - - const actual = machineState.readMemory(2); - expect(actual).toEqual(valueB); - }); - }); - - describe('CALLDATA', () => { - it('Writes nothing if size is 0', () => { - const previousValue = new Fr(123456n); - const calldata = [new Fr(1n), new Fr(2n), new Fr(3n)]; - - machineState = new AvmMachineState(calldata); - machineState.writeMemory(0, previousValue); - - new CalldataCopy(/*cdOffset=*/ 2, /*copySize=*/ 0, /*dstOffset=*/ 0).execute(machineState, stateManager); - - const actual = machineState.readMemory(0); - expect(actual).toEqual(previousValue); - }); - - it('Copies all calldata', () => { - const previousValue = new Fr(123456n); - const calldata = [new Fr(1n), new Fr(2n), new Fr(3n)]; - - machineState = new AvmMachineState(calldata); - machineState.writeMemory(0, previousValue); - - new CalldataCopy(/*cdOffset=*/ 0, /*copySize=*/ 3, /*dstOffset=*/ 0).execute(machineState, stateManager); - - const actual = machineState.readMemoryChunk(/*offset=*/ 0, /*size=*/ 3); - expect(actual).toEqual(calldata); - }); - - it('Copies slice of calldata', () => { - const previousValue = new Fr(123456n); - const calldata = [new Fr(1n), new Fr(2n), new Fr(3n)]; - - machineState = new AvmMachineState(calldata); - machineState.writeMemory(0, previousValue); - - new CalldataCopy(/*cdOffset=*/ 1, /*copySize=*/ 2, /*dstOffset=*/ 0).execute(machineState, stateManager); - - const expected = calldata.slice(1); - const actual = machineState.readMemoryChunk(/*offset=*/ 0, /*size=*/ 2); - expect(actual).toEqual(expected); - }); - - // TODO: check bad cases (i.e., out of bounds) - }); -}); diff --git a/yarn-project/acir-simulator/src/avm/opcodes/memory.ts b/yarn-project/acir-simulator/src/avm/opcodes/memory.ts index 3e6bbc62afdd..c856645eef9b 100644 --- a/yarn-project/acir-simulator/src/avm/opcodes/memory.ts +++ b/yarn-project/acir-simulator/src/avm/opcodes/memory.ts @@ -9,12 +9,13 @@ export class Set extends Instruction { static type: string = 'SET'; static numberOfOperands = 2; - constructor(private value: bigint, private destOffset: number) { + constructor(private constt: bigint, private destOffset: number) { super(); } execute(machineState: AvmMachineState, _stateManager: AvmStateManager): void { - machineState.writeMemory(this.destOffset, new Fr(this.value)); + const dest = new Fr(this.constt); + machineState.writeMemory(this.destOffset, dest); this.incrementPc(machineState); } @@ -57,31 +58,6 @@ export class Mov extends Instruction { } } -/** - */ -export class CMov extends Instruction { - static type: string = 'MOV'; - static numberOfOperands = 4; - - constructor( - private aOffset: number, - private bOffset: number, - private condOffset: number, - private destOffset: number, - ) { - super(); - } - - execute(machineState: AvmMachineState, _stateManager: AvmStateManager): void { - const a = machineState.readMemory(this.aOffset); - const b = machineState.readMemory(this.bOffset); - const cond = machineState.readMemory(this.condOffset); - - machineState.writeMemory(this.destOffset, cond.toBigInt() ? a : b); - - this.incrementPc(machineState); - } -} - /** - */ export class CalldataCopy extends Instruction { static type: string = 'CALLDATACOPY'; diff --git a/yarn-project/acir-simulator/src/avm/opcodes/opcodes.ts b/yarn-project/acir-simulator/src/avm/opcodes/opcodes.ts index 6f3f37090078..e0760e102132 100644 --- a/yarn-project/acir-simulator/src/avm/opcodes/opcodes.ts +++ b/yarn-project/acir-simulator/src/avm/opcodes/opcodes.ts @@ -1,87 +1,83 @@ /** - * All AVM opcodes. - * Source: https://yp-aztec.netlify.app/docs/public-vm/instruction-set + * All AVM opcodes */ export enum Opcode { // Compute // Compute - Arithmetic - ADD = 0x00, - SUB = 0x01, - MUL = 0x02, - DIV = 0x03, + ADD, + SUB, + MUL, + DIV, // Compute - Comparators - EQ = 0x04, - LT = 0x05, - LTE = 0x06, + EQ, + LT, + LTE, // Compute - Bitwise - AND = 0x07, - OR = 0x08, - XOR = 0x09, - NOT = 0x0a, - SHL = 0x0b, - SHR = 0x0c, + AND, + OR, + XOR, + NOT, + SHL, + SHR, // Compute - Type Conversions - CAST = 0x0d, + CAST, // Execution Environment - ADDRESS = 0x0e, - STORAGEADDRESS = 0x0f, - ORIGIN = 0x10, - SENDER = 0x11, - PORTAL = 0x12, - FEEPERL1GAS = 0x13, - FEEPERL2GAS = 0x14, - FEEPERDAGAS = 0x15, - CONTRACTCALLDEPTH = 0x16, + ADDRESS, + STORAGEADDRESS, + ORIGIN, + SENDER, + PORTAL, + FEEPERL1GAS, + FEEPERL2GAS, + FEEPERDAGAS, + CONTRACTCALLDEPTH, // Execution Environment - Globals - CHAINID = 0x17, - VERSION = 0x18, - BLOCKNUMBER = 0x19, - TIMESTAMP = 0x1a, - COINBASE = 0x1b, - BLOCKL1GASLIMIT = 0x1c, - BLOCKL2GASLIMIT = 0x1d, - BLOCKDAGASLIMIT = 0x1e, + CHAINID, + VERSION, + BLOCKNUMBER, + TIMESTAMP, + COINBASE, + BLOCKL1GASLIMIT, + BLOCKL2GASLIMIT, + BLOCKDAGASLIMIT, // Execution Environment - Calldata - CALLDATACOPY = 0x1f, + CALLDATACOPY, // Machine State // Machine State - Gas - L1GASLEFT = 0x20, - L2GASLEFT = 0x21, - DAGASLEFT = 0x22, + L1GASLEFT, + L2GASLEFT, + DAGASLEFT, // Machine State - Internal Control Flow - JUMP = 0x23, - JUMPI = 0x24, - INTERNALCALL = 0x25, - INTERNALRETURN = 0x26, + JUMP, + JUMPI, + INTERNALCALL, + INTERNALRETURN, // Machine State - Memory - SET = 0x27, - MOV = 0x28, - CMOV = 0x29, + SET, + MOV, + CMOV, // World State - BLOCKHEADERBYNUMBER = 0x2a, - SLOAD = 0x2b, // Public Storage - SSTORE = 0x2c, // Public Storage - READL1TOL2MSG = 0x2d, // Messages - SENDL2TOL1MSG = 0x2e, // Messages - EMITNOTEHASH = 0x2f, // Notes & Nullifiers - EMITNULLIFIER = 0x30, // Notes & Nullifiers + BLOCKHEADERBYNUMBER, + SLOAD, // Public Storage + SSTORE, // Public Storage + READL1TOL2MSG, // Messages + SENDL2TOL1MSG, // Messages + EMITNOTEHASH, // Notes & Nullifiers + EMITNULLIFIER, // Notes & Nullifiers // Accrued Substate - EMITUNENCRYPTEDLOG = 0x31, + EMITUNENCRYPTEDLOG, // Control Flow - Contract Calls - CALL = 0x32, - STATICCALL = 0x33, - RETURN = 0x34, - REVERT = 0x35, + CALL, + STATICCALL, + RETURN, + REVERT, // Gadgets - KECCAK = 0x36, - POSEIDON = 0x37, - - // Add new opcodes before this - TOTAL_OPCODES_NUMBER, + KECCAK, + POSEIDON, } diff --git a/yarn-project/acir-simulator/src/client/db_oracle.ts b/yarn-project/acir-simulator/src/client/db_oracle.ts index 7090aa52300f..eb4f59fae84e 100644 --- a/yarn-project/acir-simulator/src/client/db_oracle.ts +++ b/yarn-project/acir-simulator/src/client/db_oracle.ts @@ -1,11 +1,11 @@ import { L2Block, MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@aztec/circuit-types'; -import { BlockHeader, CompleteAddress } from '@aztec/circuits.js'; +import { BlockHeader, CompleteAddress, GrumpkinPrivateKey, PublicKey } from '@aztec/circuits.js'; import { FunctionArtifactWithDebugMetadata, FunctionSelector } from '@aztec/foundation/abi'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { EthAddress } from '@aztec/foundation/eth-address'; import { Fr } from '@aztec/foundation/fields'; -import { KeyPair, NoteData } from '../acvm/index.js'; +import { NoteData } from '../acvm/index.js'; import { CommitmentsDB } from '../public/db.js'; /** @@ -43,16 +43,16 @@ export interface DBOracle extends CommitmentsDB { popCapsule(): Promise; /** - * Retrieve the nullifier key pair associated with a specific account. + * Retrieve the secret key associated with a specific public key. * The function only allows access to the secret keys of the transaction creator, - * and throws an error if the address does not match the account address of the key pair. + * and throws an error if the address does not match the public key address of the key pair. * - * @param accountAddress - The account address. - * @param contractAddress - The contract address. - * @returns A Promise that resolves to the nullifier key pair. - * @throws An Error if the input address does not match the account address of the key pair. + * @param contractAddress - The contract address. Ignored here. But we might want to return different keys for different contracts. + * @param pubKey - The public key of an account. + * @returns A Promise that resolves to the secret key. + * @throws An Error if the input address does not match the public key address of the key pair. */ - getNullifierKeyPair(accountAddress: AztecAddress, contractAddress: AztecAddress): Promise; + getSecretKey(contractAddress: AztecAddress, pubKey: PublicKey): Promise; /** * Retrieves a set of notes stored in the database for a given contract address and storage slot. diff --git a/yarn-project/acir-simulator/src/client/private_execution.test.ts b/yarn-project/acir-simulator/src/client/private_execution.test.ts index 775433dbeb86..becd6a0f73c6 100644 --- a/yarn-project/acir-simulator/src/client/private_execution.test.ts +++ b/yarn-project/acir-simulator/src/client/private_execution.test.ts @@ -1,4 +1,4 @@ -import { L1ToL2Message, Note, PackedArguments, TxExecutionRequest } from '@aztec/circuit-types'; +import { Note, PackedArguments, TxExecutionRequest } from '@aztec/circuit-types'; import { BlockHeader, CallContext, @@ -9,10 +9,8 @@ import { MAX_NEW_COMMITMENTS_PER_CALL, NOTE_HASH_TREE_HEIGHT, PublicCallRequest, + PublicKey, TxContext, - computeNullifierSecretKey, - computeSiloedNullifierSecretKey, - derivePublicKey, nonEmptySideEffects, sideEffectArrayToValueArray, } from '@aztec/circuits.js'; @@ -54,7 +52,6 @@ import { default as levelup } from 'levelup'; import { type MemDown, default as memdown } from 'memdown'; import { getFunctionSelector } from 'viem'; -import { KeyPair } from '../acvm/index.js'; import { buildL1ToL2Message } from '../test/utils.js'; import { computeSlotForMapping } from '../utils.js'; import { DBOracle } from './db_oracle.js'; @@ -78,15 +75,13 @@ describe('Private Execution test suite', () => { let recipient: AztecAddress; let ownerCompleteAddress: CompleteAddress; let recipientCompleteAddress: CompleteAddress; - let ownerNullifierKeyPair: KeyPair; - let recipientNullifierKeyPair: KeyPair; const treeHeights: { [name: string]: number } = { noteHash: NOTE_HASH_TREE_HEIGHT, l1ToL2Messages: L1_TO_L2_MSG_TREE_HEIGHT, }; - let trees: { [name: keyof typeof treeHeights]: AppendOnlyTree } = {}; + const trees: { [name: keyof typeof treeHeights]: AppendOnlyTree } = {}; const txContextFields: FieldsOf = { isContractDeploymentTx: false, isFeePaymentTx: false, @@ -143,7 +138,7 @@ describe('Private Execution test suite', () => { await trees[name].appendLeaves(leaves.map(l => l.toBuffer())); // Update root. - const newRoot = trees[name].getRoot(true); + const newRoot = trees[name].getRoot(false); const prevRoots = blockHeader.toBuffer(); const rootIndex = name === 'noteHash' ? 0 : 32 * 3; const newRoots = Buffer.concat([prevRoots.subarray(0, rootIndex), newRoot, prevRoots.subarray(rootIndex + 32)]); @@ -162,37 +157,18 @@ describe('Private Execution test suite', () => { owner = ownerCompleteAddress.address; recipient = recipientCompleteAddress.address; - - const ownerNullifierSecretKey = computeNullifierSecretKey(ownerPk); - ownerNullifierKeyPair = { - secretKey: ownerNullifierSecretKey, - publicKey: derivePublicKey(ownerNullifierSecretKey), - }; - - const recipientNullifierSecretKey = computeNullifierSecretKey(recipientPk); - recipientNullifierKeyPair = { - secretKey: recipientNullifierSecretKey, - publicKey: derivePublicKey(recipientNullifierSecretKey), - }; }); beforeEach(() => { - trees = {}; oracle = mock(); - oracle.getNullifierKeyPair.mockImplementation((accountAddress: AztecAddress, contractAddress: AztecAddress) => { - if (accountAddress.equals(ownerCompleteAddress.address)) { - return Promise.resolve({ - publicKey: ownerNullifierKeyPair.publicKey, - secretKey: computeSiloedNullifierSecretKey(ownerNullifierKeyPair.secretKey, contractAddress), - }); + oracle.getSecretKey.mockImplementation((contractAddress: AztecAddress, pubKey: PublicKey) => { + if (pubKey.equals(ownerCompleteAddress.publicKey)) { + return Promise.resolve(ownerPk); } - if (accountAddress.equals(recipientCompleteAddress.address)) { - return Promise.resolve({ - publicKey: recipientNullifierKeyPair.publicKey, - secretKey: computeSiloedNullifierSecretKey(recipientNullifierKeyPair.secretKey, contractAddress), - }); + if (pubKey.equals(recipientCompleteAddress.publicKey)) { + return Promise.resolve(recipientPk); } - throw new Error(`Unknown address ${accountAddress}`); + throw new Error(`Unknown address ${pubKey}`); }); oracle.getBlockHeader.mockResolvedValue(blockHeader); @@ -477,248 +453,53 @@ describe('Private Execution test suite', () => { }); }); - describe('L1 to L2', () => { + it('Should be able to consume a dummy cross chain message', async () => { + const bridgedAmount = 100n; const artifact = getFunctionArtifact(TestContractArtifact, 'consume_mint_private_message'); - const canceller = EthAddress.random(); - let bridgedAmount = 100n; + const secretForL1ToL2MessageConsumption = new Fr(1n); const secretHashForRedeemingNotes = new Fr(2n); - let secretForL1ToL2MessageConsumption = new Fr(1n); - - let crossChainMsgRecipient: AztecAddress | undefined; - let crossChainMsgSender: EthAddress | undefined; - let messageKey: Fr | undefined; - - let preimage: L1ToL2Message; - - let args: Fr[]; - - beforeEach(() => { - bridgedAmount = 100n; - secretForL1ToL2MessageConsumption = new Fr(2n); - - crossChainMsgRecipient = undefined; - crossChainMsgSender = undefined; - messageKey = undefined; - }); - - const computePreimage = () => - buildL1ToL2Message( - getFunctionSelector('mint_private(bytes32,uint256,address)').substring(2), - [secretHashForRedeemingNotes, new Fr(bridgedAmount), canceller.toField()], - crossChainMsgRecipient ?? contractAddress, - secretForL1ToL2MessageConsumption, - ); - - const computeArgs = () => - encodeArguments(artifact, [ - secretHashForRedeemingNotes, - bridgedAmount, - canceller.toField(), - messageKey ?? preimage.hash(), - secretForL1ToL2MessageConsumption, - ]); - - const mockOracles = async () => { - const tree = await insertLeaves([messageKey ?? preimage.hash()], 'l1ToL2Messages'); - oracle.getL1ToL2Message.mockImplementation(async () => { - return Promise.resolve({ - message: preimage.toFieldArray(), - index: 0n, - siblingPath: (await tree.getSiblingPath(0n, false)).toFieldArray(), - }); - }); - }; - - it('Should be able to consume a dummy cross chain message', async () => { - preimage = computePreimage(); - - args = computeArgs(); + const canceller = EthAddress.random(); + const preimage = buildL1ToL2Message( + getFunctionSelector('mint_private(bytes32,uint256,address)').substring(2), + [secretHashForRedeemingNotes, new Fr(bridgedAmount), canceller.toField()], + contractAddress, + secretForL1ToL2MessageConsumption, + ); - await mockOracles(); - // Update state - oracle.getBlockHeader.mockResolvedValue(blockHeader); + // stub message key + const messageKey = Fr.random(); + const tree = await insertLeaves([messageKey], 'l1ToL2Messages'); - const result = await runSimulator({ - contractAddress, - artifact, - args, - portalContractAddress: crossChainMsgSender ?? preimage.sender.sender, - txContext: { version: new Fr(1n), chainId: new Fr(1n) }, + oracle.getL1ToL2Message.mockImplementation(async () => { + return Promise.resolve({ + message: preimage.toFieldArray(), + index: 0n, + siblingPath: (await tree.getSiblingPath(0n, false)).toFieldArray(), }); - - // Check a nullifier has been inserted - const newNullifiers = sideEffectArrayToValueArray( - nonEmptySideEffects(result.callStackItem.publicInputs.newNullifiers), - ); - - expect(newNullifiers).toHaveLength(1); - }); - - it('Message not matching requested key', async () => { - messageKey = Fr.random(); - - preimage = computePreimage(); - - args = computeArgs(); - - await mockOracles(); - // Update state - oracle.getBlockHeader.mockResolvedValue(blockHeader); - - await expect( - runSimulator({ - contractAddress, - artifact, - args, - portalContractAddress: crossChainMsgSender ?? preimage.sender.sender, - txContext: { version: new Fr(1n), chainId: new Fr(1n) }, - }), - ).rejects.toThrowError('Message not matching requested key'); - }); - - it('Invalid membership proof', async () => { - preimage = computePreimage(); - - args = computeArgs(); - - await mockOracles(); - - await expect( - runSimulator({ - contractAddress, - artifact, - args, - portalContractAddress: crossChainMsgSender ?? preimage.sender.sender, - txContext: { version: new Fr(1n), chainId: new Fr(1n) }, - }), - ).rejects.toThrowError('Message not in state'); - }); - - it('Invalid recipient', async () => { - crossChainMsgRecipient = AztecAddress.random(); - - preimage = computePreimage(); - - args = computeArgs(); - - await mockOracles(); - // Update state - oracle.getBlockHeader.mockResolvedValue(blockHeader); - - await expect( - runSimulator({ - contractAddress, - artifact, - args, - portalContractAddress: crossChainMsgSender ?? preimage.sender.sender, - txContext: { version: new Fr(1n), chainId: new Fr(1n) }, - }), - ).rejects.toThrowError('Invalid recipient'); }); - it('Invalid sender', async () => { - crossChainMsgSender = EthAddress.random(); - preimage = computePreimage(); - - args = computeArgs(); - - await mockOracles(); - // Update state - oracle.getBlockHeader.mockResolvedValue(blockHeader); - - await expect( - runSimulator({ - contractAddress, - artifact, - args, - portalContractAddress: crossChainMsgSender ?? preimage.sender.sender, - txContext: { version: new Fr(1n), chainId: new Fr(1n) }, - }), - ).rejects.toThrowError('Invalid sender'); - }); - - it('Invalid chainid', async () => { - preimage = computePreimage(); - - args = computeArgs(); - - await mockOracles(); - // Update state - oracle.getBlockHeader.mockResolvedValue(blockHeader); - - await expect( - runSimulator({ - contractAddress, - artifact, - args, - portalContractAddress: crossChainMsgSender ?? preimage.sender.sender, - txContext: { version: new Fr(1n), chainId: new Fr(2n) }, - }), - ).rejects.toThrowError('Invalid Chainid'); - }); - - it('Invalid version', async () => { - preimage = computePreimage(); - - args = computeArgs(); - - await mockOracles(); - // Update state - oracle.getBlockHeader.mockResolvedValue(blockHeader); - - await expect( - runSimulator({ - contractAddress, - artifact, - args, - portalContractAddress: crossChainMsgSender ?? preimage.sender.sender, - txContext: { version: new Fr(2n), chainId: new Fr(1n) }, - }), - ).rejects.toThrowError('Invalid Version'); + const args = [ + secretHashForRedeemingNotes, + bridgedAmount, + canceller.toField(), + messageKey, + secretForL1ToL2MessageConsumption, + ]; + const result = await runSimulator({ + contractAddress, + artifact, + args, + portalContractAddress: preimage.sender.sender, + txContext: { version: new Fr(1n), chainId: new Fr(1n) }, }); - it('Invalid content', async () => { - preimage = computePreimage(); - - bridgedAmount = bridgedAmount + 1n; // Invalid amount - args = computeArgs(); - - await mockOracles(); - // Update state - oracle.getBlockHeader.mockResolvedValue(blockHeader); - - await expect( - runSimulator({ - contractAddress, - artifact, - args, - portalContractAddress: crossChainMsgSender ?? preimage.sender.sender, - txContext: { version: new Fr(1n), chainId: new Fr(1n) }, - }), - ).rejects.toThrowError('Invalid Content'); - }); + // Check a nullifier has been inserted + const newNullifiers = sideEffectArrayToValueArray( + nonEmptySideEffects(result.callStackItem.publicInputs.newNullifiers), + ); - it('Invalid Secret', async () => { - preimage = computePreimage(); - - secretForL1ToL2MessageConsumption = Fr.random(); - args = computeArgs(); - - await mockOracles(); - // Update state - oracle.getBlockHeader.mockResolvedValue(blockHeader); - - await expect( - runSimulator({ - contractAddress, - artifact, - args, - portalContractAddress: crossChainMsgSender ?? preimage.sender.sender, - txContext: { version: new Fr(1n), chainId: new Fr(1n) }, - }), - ).rejects.toThrowError('Invalid message secret'); - }); + expect(newNullifiers).toHaveLength(1); }); it('Should be able to consume a dummy public to private message', async () => { @@ -878,15 +659,7 @@ describe('Private Execution test suite', () => { expect(gotNoteValue).toEqual(amountToTransfer); const nullifier = result.callStackItem.publicInputs.newNullifiers[0]; - const siloedNullifierSecretKey = computeSiloedNullifierSecretKey( - ownerNullifierKeyPair.secretKey, - contractAddress, - ); - const expectedNullifier = hashFields([ - innerNoteHash, - siloedNullifierSecretKey.low, - siloedNullifierSecretKey.high, - ]); + const expectedNullifier = hashFields([innerNoteHash, ownerPk.low, ownerPk.high]); expect(nullifier.value).toEqual(expectedNullifier); }); @@ -959,15 +732,7 @@ describe('Private Execution test suite', () => { expect(gotNoteValue).toEqual(amountToTransfer); const nullifier = execGetThenNullify.callStackItem.publicInputs.newNullifiers[0]; - const siloedNullifierSecretKey = computeSiloedNullifierSecretKey( - ownerNullifierKeyPair.secretKey, - contractAddress, - ); - const expectedNullifier = hashFields([ - innerNoteHash, - siloedNullifierSecretKey.low, - siloedNullifierSecretKey.high, - ]); + const expectedNullifier = hashFields([innerNoteHash, ownerPk.low, ownerPk.high]); expect(nullifier.value).toEqual(expectedNullifier); // check that the last get_notes call return no note diff --git a/yarn-project/acir-simulator/src/client/simulator.test.ts b/yarn-project/acir-simulator/src/client/simulator.test.ts index 7c5a3e830e28..b1e0d95a4bcc 100644 --- a/yarn-project/acir-simulator/src/client/simulator.test.ts +++ b/yarn-project/acir-simulator/src/client/simulator.test.ts @@ -4,7 +4,7 @@ import { computeUniqueCommitment, siloCommitment } from '@aztec/circuits.js/abis import { ABIParameterVisibility, FunctionArtifactWithDebugMetadata, getFunctionArtifact } from '@aztec/foundation/abi'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { pedersenHash } from '@aztec/foundation/crypto'; -import { Fr, GrumpkinScalar, Point } from '@aztec/foundation/fields'; +import { Fr, GrumpkinScalar } from '@aztec/foundation/fields'; import { TokenContractArtifact } from '@aztec/noir-contracts/Token'; import { MockProxy, mock } from 'jest-mock-extended'; @@ -15,20 +15,20 @@ import { AcirSimulator } from './simulator.js'; describe('Simulator', () => { let oracle: MockProxy; let simulator: AcirSimulator; + let ownerCompleteAddress: CompleteAddress; + let owner: AztecAddress; const ownerPk = GrumpkinScalar.fromString('2dcc5485a58316776299be08c78fa3788a1a7961ae30dc747fb1be17692a8d32'); - const ownerCompleteAddress = CompleteAddress.fromPrivateKeyAndPartialAddress(ownerPk, Fr.random()); - const owner = ownerCompleteAddress.address; - const ownerNullifierSecretKey = GrumpkinScalar.random(); - const ownerNullifierPublicKey = Point.random(); const hashFields = (data: Fr[]) => Fr.fromBuffer(pedersenHash(data.map(f => f.toBuffer()))); + beforeAll(() => { + ownerCompleteAddress = CompleteAddress.fromPrivateKeyAndPartialAddress(ownerPk, Fr.random()); + owner = ownerCompleteAddress.address; + }); + beforeEach(() => { oracle = mock(); - oracle.getNullifierKeyPair.mockResolvedValue({ - secretKey: ownerNullifierSecretKey, - publicKey: ownerNullifierPublicKey, - }); + oracle.getSecretKey.mockResolvedValue(ownerPk); oracle.getCompleteAddress.mockResolvedValue(ownerCompleteAddress); simulator = new AcirSimulator(oracle); @@ -50,11 +50,7 @@ describe('Simulator', () => { const innerNoteHash = hashFields([storageSlot, valueNoteHash]); const siloedNoteHash = siloCommitment(contractAddress, innerNoteHash); const uniqueSiloedNoteHash = computeUniqueCommitment(nonce, siloedNoteHash); - const innerNullifier = hashFields([ - uniqueSiloedNoteHash, - ownerNullifierSecretKey.low, - ownerNullifierSecretKey.high, - ]); + const innerNullifier = hashFields([uniqueSiloedNoteHash, ownerPk.low, ownerPk.high]); const result = await simulator.computeNoteHashAndNullifier(contractAddress, nonce, storageSlot, note); diff --git a/yarn-project/acir-simulator/src/client/simulator.ts b/yarn-project/acir-simulator/src/client/simulator.ts index 74e6c1ae4eed..92430a19969a 100644 --- a/yarn-project/acir-simulator/src/client/simulator.ts +++ b/yarn-project/acir-simulator/src/client/simulator.ts @@ -184,7 +184,7 @@ export class AcirSimulator { const extendedNoteItems = note.items.concat(Array(maxNoteFields - note.items.length).fill(Fr.ZERO)); const execRequest: FunctionCall = { - to: contractAddress, + to: AztecAddress.ZERO, functionData: FunctionData.empty(), args: encodeArguments(artifact, [contractAddress, nonce, storageSlot, extendedNoteItems]), }; @@ -192,7 +192,7 @@ export class AcirSimulator { const [innerNoteHash, siloedNoteHash, uniqueSiloedNoteHash, innerNullifier] = (await this.runUnconstrained( execRequest, artifact, - contractAddress, + AztecAddress.ZERO, )) as bigint[]; return { diff --git a/yarn-project/acir-simulator/src/client/view_data_oracle.ts b/yarn-project/acir-simulator/src/client/view_data_oracle.ts index 3fb79b16b6fd..b029833f2ea3 100644 --- a/yarn-project/acir-simulator/src/client/view_data_oracle.ts +++ b/yarn-project/acir-simulator/src/client/view_data_oracle.ts @@ -7,7 +7,7 @@ import { NullifierMembershipWitness, PublicDataWitness, } from '@aztec/circuit-types'; -import { BlockHeader } from '@aztec/circuits.js'; +import { BlockHeader, PublicKey } from '@aztec/circuits.js'; import { computeGlobalsHash, siloNullifier } from '@aztec/circuits.js/abis'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { Fr } from '@aztec/foundation/fields'; @@ -36,11 +36,11 @@ export class ViewDataOracle extends TypedOracle { } /** - * Return the nullifier key pair of an account to use in a specific contract. - * @param account - The account address of the nullifier key. + * Return the secret key of a owner to use in a specific contract. + * @param owner - The owner of the secret key. */ - public getNullifierKeyPair(account: AztecAddress) { - return this.db.getNullifierKeyPair(account, this.contractAddress); + public getSecretKey(owner: PublicKey) { + return this.db.getSecretKey(this.contractAddress, owner); } /** @@ -240,7 +240,8 @@ export class ViewDataOracle extends TypedOracle { * @returns The l1 to l2 message data */ public async getL1ToL2Message(msgKey: Fr) { - return await this.db.getL1ToL2Message(msgKey); + const message = await this.db.getL1ToL2Message(msgKey); + return { ...message, root: this.blockHeader.l1ToL2MessageTreeRoot }; } /** diff --git a/yarn-project/acir-simulator/src/public/index.test.ts b/yarn-project/acir-simulator/src/public/index.test.ts index 739a4bfcd3e0..05d9654ae476 100644 --- a/yarn-project/acir-simulator/src/public/index.test.ts +++ b/yarn-project/acir-simulator/src/public/index.test.ts @@ -1,4 +1,3 @@ -import { L1ToL2Message } from '@aztec/circuit-types'; import { BlockHeader, CallContext, FunctionData, GlobalVariables, L1_TO_L2_MSG_TREE_HEIGHT } from '@aztec/circuits.js'; import { FunctionArtifact, FunctionSelector, encodeArguments } from '@aztec/foundation/abi'; import { AztecAddress } from '@aztec/foundation/aztec-address'; @@ -354,6 +353,69 @@ describe('ACIR public execution simulator', () => { expect(result.newL2ToL1Messages[0].toBuffer()).toEqual(expectedNewMessageValue); }); + it('Should be able to consume an L1 to L2 message in the public context', async () => { + const mintPublicArtifact = TestContractArtifact.functions.find(f => f.name === 'consume_mint_public_message')!; + + // Set up cross chain message + const canceller = EthAddress.random(); + + const bridgedAmount = 20n; + const secret = new Fr(1n); + const recipient = AztecAddress.random(); + + const preimage = buildL1ToL2Message( + getFunctionSelector('mint_public(bytes32,uint256,address)').substring(2), + [recipient.toField(), new Fr(bridgedAmount), canceller.toField()], + contractAddress, + secret, + ); + + // Stub message key + const messageKey = Fr.random(); + const args = encodeArguments(mintPublicArtifact, [ + recipient.toField(), + bridgedAmount, + canceller.toField(), + messageKey, + secret, + ]); + + const callContext = CallContext.from({ + msgSender: AztecAddress.random(), + storageContractAddress: contractAddress, + portalContractAddress: preimage.sender.sender, + functionSelector: FunctionSelector.empty(), + isContractDeployment: false, + isDelegateCall: false, + isStaticCall: false, + startSideEffectCounter: 0, + }); + + publicContracts.getBytecode.mockResolvedValue(Buffer.from(mintPublicArtifact.bytecode, 'base64')); + publicState.storageRead.mockResolvedValue(Fr.ZERO); + + // Mock response + commitmentsDb.getL1ToL2Message.mockImplementation(async () => { + return await Promise.resolve({ + message: preimage.toFieldArray(), + index: 0n, + siblingPath: Array(L1_TO_L2_MSG_TREE_HEIGHT).fill(Fr.random()), + }); + }); + + const execution: PublicExecution = { contractAddress, functionData, args, callContext }; + + const gv = new GlobalVariables( + new Fr(preimage.sender.chainId), + new Fr(preimage.recipient.version), + Fr.ZERO, + Fr.ZERO, + ); + const result = await executor.simulate(execution, gv); + + expect(result.newNullifiers.length).toEqual(1); + }); + it('Should be able to create a nullifier from the public context', async () => { const createNullifierPublicArtifact = TestContractArtifact.functions.find( f => f.name === 'create_nullifier_public', @@ -383,228 +445,5 @@ describe('ACIR public execution simulator', () => { const expectedNewMessageValue = pedersenHash(params.map(a => a.toBuffer())); expect(result.newNullifiers[0].value.toBuffer()).toEqual(expectedNewMessageValue); }); - - describe('L1 to L2 messages', () => { - const mintPublicArtifact = TestContractArtifact.functions.find(f => f.name === 'consume_mint_public_message')!; - - const canceller = EthAddress.random(); - const tokenRecipient = AztecAddress.random(); - let bridgedAmount = 20n; - let secret = new Fr(1); - - let crossChainMsgRecipient: AztecAddress | undefined; - let crossChainMsgSender: EthAddress | undefined; - let messageKey: Fr | undefined; - - let preimage: L1ToL2Message; - let globalVariables: GlobalVariables; - - let args: Fr[]; - let callContext: CallContext; - - beforeEach(() => { - bridgedAmount = 20n; - secret = new Fr(1); - - crossChainMsgRecipient = undefined; - crossChainMsgSender = undefined; - messageKey = undefined; - }); - - const computePreImage = () => - buildL1ToL2Message( - getFunctionSelector('mint_public(bytes32,uint256,address)').substring(2), - [tokenRecipient.toField(), new Fr(bridgedAmount), canceller.toField()], - crossChainMsgRecipient ?? contractAddress, - secret, - ); - - const computeArgs = () => - encodeArguments(mintPublicArtifact, [ - tokenRecipient.toField(), - bridgedAmount, - canceller.toField(), - messageKey ?? preimage.hash(), - secret, - ]); - - const computeCallContext = () => - CallContext.from({ - msgSender: AztecAddress.random(), - storageContractAddress: contractAddress, - portalContractAddress: crossChainMsgSender ?? preimage.sender.sender, - functionSelector: FunctionSelector.empty(), - isContractDeployment: false, - isDelegateCall: false, - isStaticCall: false, - startSideEffectCounter: 0, - }); - - const computeGlobalVariables = () => - new GlobalVariables(new Fr(preimage.sender.chainId), new Fr(preimage.recipient.version), Fr.ZERO, Fr.ZERO); - - const mockOracles = () => { - publicContracts.getBytecode.mockResolvedValue(Buffer.from(mintPublicArtifact.bytecode, 'base64')); - publicState.storageRead.mockResolvedValue(Fr.ZERO); - - const siblingPath = Array(L1_TO_L2_MSG_TREE_HEIGHT).fill(Fr.random()); - let root = messageKey ?? preimage.hash(); - for (const sibling of siblingPath) { - root = Fr.fromBuffer(pedersenHash([root.toBuffer(), sibling.toBuffer()])); - } - commitmentsDb.getL1ToL2Message.mockImplementation(async () => { - return await Promise.resolve({ - message: preimage.toFieldArray(), - index: 0n, - siblingPath, - }); - }); - - return root; - }; - - it('Should be able to consume an L1 to L2 message in the public context', async () => { - preimage = computePreImage(); - - args = computeArgs(); - callContext = computeCallContext(); - - // Prepare the state - blockHeader.l1ToL2MessageTreeRoot = mockOracles(); - globalVariables = computeGlobalVariables(); - - const execution: PublicExecution = { contractAddress, functionData, args, callContext }; - executor = new PublicExecutor(publicState, publicContracts, commitmentsDb, blockHeader); - const result = await executor.simulate(execution, globalVariables); - expect(result.newNullifiers.length).toEqual(1); - }); - - it('Message not matching requested key', async () => { - // Using a random value for the message key - messageKey = Fr.random(); - - preimage = computePreImage(); - args = computeArgs(); - callContext = computeCallContext(); - - // Prepare the state - blockHeader.l1ToL2MessageTreeRoot = mockOracles(); - globalVariables = computeGlobalVariables(); - - const execution: PublicExecution = { contractAddress, functionData, args, callContext }; - executor = new PublicExecutor(publicState, publicContracts, commitmentsDb, blockHeader); - await expect(executor.simulate(execution, globalVariables)).rejects.toThrowError( - 'Message not matching requested key', - ); - }); - - it('Invalid membership proof', async () => { - preimage = computePreImage(); - args = computeArgs(); - callContext = computeCallContext(); - - // Mock oracles but don't update state - mockOracles(); - - // Prepare the state - globalVariables = computeGlobalVariables(); - - const execution: PublicExecution = { contractAddress, functionData, args, callContext }; - executor = new PublicExecutor(publicState, publicContracts, commitmentsDb, blockHeader); - await expect(executor.simulate(execution, globalVariables)).rejects.toThrowError('Message not in state'); - }); - - it('Invalid recipient', async () => { - crossChainMsgRecipient = AztecAddress.random(); - preimage = computePreImage(); - args = computeArgs(); - callContext = computeCallContext(); - - // Prepare the state - blockHeader.l1ToL2MessageTreeRoot = mockOracles(); - globalVariables = computeGlobalVariables(); - - const execution: PublicExecution = { contractAddress, functionData, args, callContext }; - executor = new PublicExecutor(publicState, publicContracts, commitmentsDb, blockHeader); - await expect(executor.simulate(execution, globalVariables)).rejects.toThrowError('Invalid recipient'); - }); - - it('Invalid sender', async () => { - crossChainMsgSender = EthAddress.random(); - preimage = computePreImage(); - args = computeArgs(); - callContext = computeCallContext(); - - // Prepare the state - blockHeader.l1ToL2MessageTreeRoot = mockOracles(); - globalVariables = computeGlobalVariables(); - - const execution: PublicExecution = { contractAddress, functionData, args, callContext }; - executor = new PublicExecutor(publicState, publicContracts, commitmentsDb, blockHeader); - await expect(executor.simulate(execution, globalVariables)).rejects.toThrowError('Invalid sender'); - }); - - it('Invalid chainid', async () => { - preimage = computePreImage(); - args = computeArgs(); - callContext = computeCallContext(); - - // Prepare the state - blockHeader.l1ToL2MessageTreeRoot = mockOracles(); - globalVariables = computeGlobalVariables(); - globalVariables.chainId = Fr.random(); - - const execution: PublicExecution = { contractAddress, functionData, args, callContext }; - executor = new PublicExecutor(publicState, publicContracts, commitmentsDb, blockHeader); - await expect(executor.simulate(execution, globalVariables)).rejects.toThrowError('Invalid Chainid'); - }); - - it('Invalid version', async () => { - preimage = computePreImage(); - args = computeArgs(); - callContext = computeCallContext(); - - // Prepare the state - blockHeader.l1ToL2MessageTreeRoot = mockOracles(); - globalVariables = computeGlobalVariables(); - globalVariables.version = Fr.random(); - - const execution: PublicExecution = { contractAddress, functionData, args, callContext }; - executor = new PublicExecutor(publicState, publicContracts, commitmentsDb, blockHeader); - await expect(executor.simulate(execution, globalVariables)).rejects.toThrowError('Invalid Version'); - }); - - it('Invalid Content', async () => { - preimage = computePreImage(); - - bridgedAmount = bridgedAmount + 1n; // Invalid amount - args = computeArgs(); - callContext = computeCallContext(); - - // Prepare the state - blockHeader.l1ToL2MessageTreeRoot = mockOracles(); - globalVariables = computeGlobalVariables(); - - const execution: PublicExecution = { contractAddress, functionData, args, callContext }; - executor = new PublicExecutor(publicState, publicContracts, commitmentsDb, blockHeader); - await expect(executor.simulate(execution, globalVariables)).rejects.toThrowError('Invalid Content'); - }); - - it('Invalid secret', async () => { - preimage = computePreImage(); - - secret = Fr.random(); // Invalid secret - args = computeArgs(); - callContext = computeCallContext(); - - // Prepare the state - blockHeader.l1ToL2MessageTreeRoot = mockOracles(); - globalVariables = computeGlobalVariables(); - - const execution: PublicExecution = { contractAddress, functionData, args, callContext }; - executor = new PublicExecutor(publicState, publicContracts, commitmentsDb, blockHeader); - await expect(executor.simulate(execution, globalVariables)).rejects.toThrowError('Invalid message secret'); - }); - }); }); }); diff --git a/yarn-project/acir-simulator/src/public/public_execution_context.ts b/yarn-project/acir-simulator/src/public/public_execution_context.ts index 6b2674886c86..886c0c40434b 100644 --- a/yarn-project/acir-simulator/src/public/public_execution_context.ts +++ b/yarn-project/acir-simulator/src/public/public_execution_context.ts @@ -102,7 +102,9 @@ export class PublicExecutionContext extends TypedOracle { * @returns The l1 to l2 message data */ public async getL1ToL2Message(msgKey: Fr) { - return await this.commitmentsDb.getL1ToL2Message(msgKey); + // l1 to l2 messages in public contexts TODO: https://github.com/AztecProtocol/aztec-packages/issues/616 + const message = await this.commitmentsDb.getL1ToL2Message(msgKey); + return { ...message, root: this.blockHeader.l1ToL2MessageTreeRoot }; } /** diff --git a/yarn-project/aztec-nr/.gitrepo b/yarn-project/aztec-nr/.gitrepo index f79bcdda7ec8..5374705e2dfd 100644 --- a/yarn-project/aztec-nr/.gitrepo +++ b/yarn-project/aztec-nr/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/AztecProtocol/aztec-nr branch = master - commit = b92262c1babe98cea0251398d4bc658eeb212080 + commit = ecbd4b0a4bf02c8221499b700b7da72363d561fc method = merge cmdver = 0.4.6 - parent = af3e038a85585aa1957fe2c00e3bd9d58efcda46 + parent = eb0c17382c5ae5f97b4a796b42bfe59edc24699c diff --git a/yarn-project/aztec-nr/address-note/src/address_note.nr b/yarn-project/aztec-nr/address-note/src/address_note.nr index 199cbd7b078a..dc5e0fa47d6e 100644 --- a/yarn-project/aztec-nr/address-note/src/address_note.nr +++ b/yarn-project/aztec-nr/address-note/src/address_note.nr @@ -10,7 +10,7 @@ use dep::aztec::{ }, oracle::{ rand::rand, - nullifier_key::get_nullifier_secret_key, + get_secret_key::get_secret_key, get_public_key::get_public_key, }, hash::pedersen_hash, @@ -59,20 +59,9 @@ impl AddressNote { pedersen_hash(self.serialize(), 0) } - pub fn compute_nullifier(self, context: &mut PrivateContext) -> Field { + pub fn compute_nullifier(self) -> Field { let note_hash_for_nullify = compute_note_hash_for_read_or_nullify(AddressNoteMethods, self); - let secret = context.request_nullifier_secret_key(self.owner); - // TODO(#1205) Should use a non-zero generator index. - pedersen_hash([ - note_hash_for_nullify, - secret.low, - secret.high, - ],0) - } - - pub fn compute_nullifier_without_context(self) -> Field { - let note_hash_for_nullify = compute_note_hash_for_read_or_nullify(AddressNoteMethods, self); - let secret = get_nullifier_secret_key(self.owner); + let secret = get_secret_key(self.owner); // TODO(#1205) Should use a non-zero generator index. pedersen_hash([ note_hash_for_nullify, @@ -112,12 +101,8 @@ fn compute_note_hash(note: AddressNote) -> Field { note.compute_note_hash() } -fn compute_nullifier(note: AddressNote, context: &mut PrivateContext) -> Field { - note.compute_nullifier(context) -} - -fn compute_nullifier_without_context(note: AddressNote) -> Field { - note.compute_nullifier_without_context() +fn compute_nullifier(note: AddressNote) -> Field { + note.compute_nullifier() } fn get_header(note: AddressNote) -> NoteHeader { @@ -138,7 +123,6 @@ global AddressNoteMethods = NoteInterface { serialize, compute_note_hash, compute_nullifier, - compute_nullifier_without_context, get_header, set_header, broadcast, diff --git a/yarn-project/aztec-nr/aztec/src/context.nr b/yarn-project/aztec-nr/aztec/src/context.nr index 6329a9d541f1..b89e570f53fd 100644 --- a/yarn-project/aztec-nr/aztec/src/context.nr +++ b/yarn-project/aztec-nr/aztec/src/context.nr @@ -1,22 +1,3 @@ -use crate::{ - abi::{ - PrivateContextInputs, - PublicContextInputs, - }, - key::nullifier_key::validate_nullifier_key_against_address, - messaging::process_l1_to_l2_message, - oracle::{ - arguments, - call_private_function::call_private_function_internal, - public_call::call_public_function_internal, - enqueue_public_function_call::enqueue_public_function_call_internal, - context::get_portal_address, - get_block_header::get_block_header, - nullifier_key::get_nullifier_key_pair, - }, - types::vec::BoundedVec, - utils::Reader, -}; use dep::protocol_types::{ abis::{ block_header::BlockHeader, @@ -53,14 +34,35 @@ use dep::protocol_types::{ hash::hash_args, grumpkin_point::GrumpkinPoint, }; -use dep::std::{ - grumpkin_scalar::GrumpkinScalar, - option::Option, -}; // TODO(https://github.com/AztecProtocol/aztec-packages/issues/1165) // use dep::std::collections::vec::Vec; +use crate::abi::{ + PrivateContextInputs, + PublicContextInputs, +}; + +// l1 to l2 messaging +use crate::messaging::process_l1_to_l2_message; + +use crate::types::{ + vec::BoundedVec, +}; + +use crate::utils::Reader; + +use crate::oracle::{ + arguments, + call_private_function::call_private_function_internal, + public_call::call_public_function_internal, + enqueue_public_function_call::enqueue_public_function_call_internal, + context::get_portal_address, + get_block_header::get_block_header, +}; + +use dep::std::option::Option; + // When finished, one can call .finish() to convert back to the abi struct PrivateContext { // docs:start:private-context @@ -199,14 +201,6 @@ impl PrivateContext { self.side_effect_counter = self.side_effect_counter + 1; } - pub fn request_nullifier_secret_key(&mut self, account: AztecAddress) -> GrumpkinScalar { - let key_pair = get_nullifier_key_pair(account); - validate_nullifier_key_against_address(account, key_pair.public_key, key_pair.secret_key); - // TODO: Add request to context. - // self.context.push_nullifier_key_validation_request(public_key, secret_key); - key_pair.secret_key - } - // docs:start:context_message_portal pub fn message_portal(&mut self, content: Field) // docs:end:context_message_portal diff --git a/yarn-project/aztec-nr/aztec/src/history/note_validity.nr b/yarn-project/aztec-nr/aztec/src/history/note_validity.nr index 30abac51c749..d98a9e878318 100644 --- a/yarn-project/aztec-nr/aztec/src/history/note_validity.nr +++ b/yarn-project/aztec-nr/aztec/src/history/note_validity.nr @@ -12,8 +12,8 @@ pub fn prove_note_validity( note_interface: NoteInterface, note_with_header: Note, block_number: u32, // The block at which we'll prove that the note exists - context: &mut PrivateContext + context: PrivateContext ) { - prove_note_inclusion(note_interface, note_with_header, block_number, *context); + prove_note_inclusion(note_interface, note_with_header, block_number, context); prove_note_not_nullified(note_interface, note_with_header, block_number, context); } diff --git a/yarn-project/aztec-nr/aztec/src/history/nullifier_non_inclusion.nr b/yarn-project/aztec-nr/aztec/src/history/nullifier_non_inclusion.nr index f4cb297d17ad..47036d2f9f3e 100644 --- a/yarn-project/aztec-nr/aztec/src/history/nullifier_non_inclusion.nr +++ b/yarn-project/aztec-nr/aztec/src/history/nullifier_non_inclusion.nr @@ -53,9 +53,9 @@ pub fn prove_note_not_nullified( note_interface: NoteInterface, note_with_header: Note, block_number: u32, // The block at which we'll prove that the note was not nullified - context: &mut PrivateContext + context: PrivateContext ) { - let nullifier = compute_siloed_nullifier(note_interface, note_with_header, context); + let nullifier = compute_siloed_nullifier(note_interface, note_with_header); - prove_nullifier_non_inclusion(nullifier, block_number, *context); + prove_nullifier_non_inclusion(nullifier, block_number, context); } diff --git a/yarn-project/aztec-nr/aztec/src/key.nr b/yarn-project/aztec-nr/aztec/src/key.nr deleted file mode 100644 index 3ea8deca7544..000000000000 --- a/yarn-project/aztec-nr/aztec/src/key.nr +++ /dev/null @@ -1 +0,0 @@ -mod nullifier_key; diff --git a/yarn-project/aztec-nr/aztec/src/key/nullifier_key.nr b/yarn-project/aztec-nr/aztec/src/key/nullifier_key.nr deleted file mode 100644 index 3f07dba4b2ce..000000000000 --- a/yarn-project/aztec-nr/aztec/src/key/nullifier_key.nr +++ /dev/null @@ -1,24 +0,0 @@ -use crate::oracle::get_public_key::get_public_key; -use dep::protocol_types::{ - address::AztecAddress, - grumpkin_point::GrumpkinPoint, -}; -use dep::std::{ - grumpkin_scalar::GrumpkinScalar, - grumpkin_scalar_mul::grumpkin_fixed_base, -}; - -pub fn validate_nullifier_key_against_address( - address: AztecAddress, - nullifier_public_key: GrumpkinPoint, - nullifier_secret_key: GrumpkinScalar -) { - // TODO: Nullifier public key should be part of the address. - // Validation of the secret key should happen in the kernel circuit. - let owner_public_key = get_public_key(address); - assert(owner_public_key.x == nullifier_public_key.x); - assert(owner_public_key.y == nullifier_public_key.y); - let computed_public_key = grumpkin_fixed_base(nullifier_secret_key); - assert(owner_public_key.x == computed_public_key[0]); - assert(owner_public_key.y == computed_public_key[1]); -} diff --git a/yarn-project/aztec-nr/aztec/src/lib.nr b/yarn-project/aztec-nr/aztec/src/lib.nr index 9bf7bf42c8f5..39c5b6c290ed 100644 --- a/yarn-project/aztec-nr/aztec/src/lib.nr +++ b/yarn-project/aztec-nr/aztec/src/lib.nr @@ -2,7 +2,6 @@ mod abi; mod context; mod hash; mod history; -mod key; mod log; mod messaging; mod note; diff --git a/yarn-project/aztec-nr/aztec/src/messaging.nr b/yarn-project/aztec-nr/aztec/src/messaging.nr index 78dc5d33eec7..ef659f198ecd 100644 --- a/yarn-project/aztec-nr/aztec/src/messaging.nr +++ b/yarn-project/aztec-nr/aztec/src/messaging.nr @@ -6,8 +6,6 @@ use l1_to_l2_message_getter_data::make_l1_to_l2_message_getter_data; use crate::abi::PublicContextInputs; use crate::oracle::get_l1_to_l2_message::get_l1_to_l2_message_call; -use dep::std::merkle::compute_merkle_root; - use dep::protocol_types::address::{ AztecAddress, EthAddress, @@ -27,32 +25,23 @@ pub fn process_l1_to_l2_message( let returned_message = get_l1_to_l2_message_call(msg_key); let l1_to_l2_message_data = make_l1_to_l2_message_getter_data(returned_message, 0, secret); - // Check that the returned message is actually the message we looked up - let msg_hash = l1_to_l2_message_data.message.hash(); - assert(msg_hash == msg_key, "Message not matching requested key"); - - // Check that the message is in the tree - let root = compute_merkle_root( - msg_hash, - l1_to_l2_message_data.leaf_index, - l1_to_l2_message_data.sibling_path - ); - assert(root == l1_to_l2_root, "Message not in state"); + // Check tree roots against the inputs + assert(l1_to_l2_message_data.root == l1_to_l2_root); // Validate this is the target contract - assert(l1_to_l2_message_data.message.recipient.eq(storage_contract_address), "Invalid recipient"); + assert(l1_to_l2_message_data.message.recipient.eq(storage_contract_address)); // Validate the sender is the portal contract - assert(l1_to_l2_message_data.message.sender.eq(portal_contract_address), "Invalid sender"); + assert(l1_to_l2_message_data.message.sender.eq(portal_contract_address)); // Validate the chain id is correct - assert(l1_to_l2_message_data.message.chainId == chain_id, "Invalid Chainid"); + assert(l1_to_l2_message_data.message.chainId == chain_id); // Validate the version is correct - assert(l1_to_l2_message_data.message.version == version, "Invalid Version"); + assert(l1_to_l2_message_data.message.version == version); // Validate the message hash is correct - assert(l1_to_l2_message_data.message.content == content, "Invalid Content"); + assert(l1_to_l2_message_data.message.content == content); // Validate the message secret is correct l1_to_l2_message_data.message.validate_message_secret(); diff --git a/yarn-project/aztec-nr/aztec/src/messaging/l1_to_l2_message.nr b/yarn-project/aztec-nr/aztec/src/messaging/l1_to_l2_message.nr index a4dfcfa4e527..39aeba687424 100644 --- a/yarn-project/aztec-nr/aztec/src/messaging/l1_to_l2_message.nr +++ b/yarn-project/aztec-nr/aztec/src/messaging/l1_to_l2_message.nr @@ -49,10 +49,10 @@ impl L1ToL2Message { pub fn validate_message_secret(self: Self) { let recomputed_hash = pedersen_hash([self.secret], GENERATOR_INDEX__L1_TO_L2_MESSAGE_SECRET); - assert(self.secret_hash == recomputed_hash, "Invalid message secret"); + assert(self.secret_hash == recomputed_hash); } - fn hash(self: Self) -> Field { + fn message_hash(self: Self) -> Field { let mut hash_bytes: [u8; 256] = [0; 256]; let sender_bytes = self.sender.to_field().to_be_bytes(32); let chainId_bytes = self.chainId.to_be_bytes(32); @@ -81,7 +81,7 @@ impl L1ToL2Message { // The nullifier of a l1 to l2 message is the hash of the message salted with the secret and tree index // docs:start:l1_to_l2_message_compute_nullifier pub fn compute_nullifier(self: Self) -> Field { - let message_hash = self.hash(); + let message_hash = self.message_hash(); pedersen_hash([message_hash, self.secret, self.tree_index], GENERATOR_INDEX__NULLIFIER) } // docs:end:l1_to_l2_message_compute_nullifier diff --git a/yarn-project/aztec-nr/aztec/src/messaging/l1_to_l2_message_getter_data.nr b/yarn-project/aztec-nr/aztec/src/messaging/l1_to_l2_message_getter_data.nr index 34f21c60395f..882103f7fdf3 100644 --- a/yarn-project/aztec-nr/aztec/src/messaging/l1_to_l2_message_getter_data.nr +++ b/yarn-project/aztec-nr/aztec/src/messaging/l1_to_l2_message_getter_data.nr @@ -8,11 +8,12 @@ use crate::utils::arr_copy_slice; struct L1ToL2MessageGetterData { message: L1ToL2Message, sibling_path: [Field; L1_TO_L2_MSG_TREE_HEIGHT], - leaf_index: Field + leaf_index: Field, + root: Field, } pub fn l1_to_l2_message_getter_len() -> Field { - L1_TO_L2_MESSAGE_LENGTH + 1 + L1_TO_L2_MSG_TREE_HEIGHT + L1_TO_L2_MESSAGE_LENGTH + 1 + L1_TO_L2_MSG_TREE_HEIGHT + 1 } pub fn make_l1_to_l2_message_getter_data( @@ -31,6 +32,7 @@ pub fn make_l1_to_l2_message_getter_data( fields, [0; L1_TO_L2_MSG_TREE_HEIGHT], L1_TO_L2_MESSAGE_LENGTH + 1 - ) + ), + root: fields[start + L1_TO_L2_MESSAGE_LENGTH + L1_TO_L2_MSG_TREE_HEIGHT + 1] } } diff --git a/yarn-project/aztec-nr/aztec/src/note/lifecycle.nr b/yarn-project/aztec-nr/aztec/src/note/lifecycle.nr index ec741e6dbae1..0eb21346f8d4 100644 --- a/yarn-project/aztec-nr/aztec/src/note/lifecycle.nr +++ b/yarn-project/aztec-nr/aztec/src/note/lifecycle.nr @@ -60,7 +60,7 @@ pub fn destroy_note( let mut nullifier = 0; let mut nullified_commitment: Field = 0; let compute_nullifier = note_interface.compute_nullifier; - nullifier = compute_nullifier(note, context); + nullifier = compute_nullifier(note); // We also need the note commitment corresponding to the "nullifier" let get_header = note_interface.get_header; diff --git a/yarn-project/aztec-nr/aztec/src/note/note_interface.nr b/yarn-project/aztec-nr/aztec/src/note/note_interface.nr index 614c20d27770..b56d2030645a 100644 --- a/yarn-project/aztec-nr/aztec/src/note/note_interface.nr +++ b/yarn-project/aztec-nr/aztec/src/note/note_interface.nr @@ -9,9 +9,7 @@ struct NoteInterface { compute_note_hash: fn (Note) -> Field, - compute_nullifier: fn (Note, &mut PrivateContext) -> Field, - - compute_nullifier_without_context: fn (Note) -> Field, + compute_nullifier: fn (Note) -> Field, get_header: fn (Note) -> NoteHeader, diff --git a/yarn-project/aztec-nr/aztec/src/note/utils.nr b/yarn-project/aztec-nr/aztec/src/note/utils.nr index 5d88d904a77f..d9286fad1232 100644 --- a/yarn-project/aztec-nr/aztec/src/note/utils.nr +++ b/yarn-project/aztec-nr/aztec/src/note/utils.nr @@ -3,7 +3,6 @@ use dep::protocol_types::{ hash::pedersen_hash, }; use crate::{ - context::PrivateContext, note::{ note_hash::{compute_inner_hash, compute_siloed_hash, compute_unique_hash}, note_header::NoteHeader, @@ -40,16 +39,12 @@ pub fn compute_unique_siloed_note_hash(note_interface: NoteInterface( - note_interface: NoteInterface, - note_with_header: Note, - context: &mut PrivateContext -) -> Field { +pub fn compute_siloed_nullifier(note_interface: NoteInterface, note_with_header: Note) -> Field { let get_header = note_interface.get_header; let header = get_header(note_with_header); let compute_nullifier = note_interface.compute_nullifier; - let inner_nullifier = compute_nullifier(note_with_header, context); + let inner_nullifier = compute_nullifier(note_with_header); let input = [header.contract_address.to_field(), inner_nullifier]; pedersen_hash(input, GENERATOR_INDEX__OUTER_NULLIFIER) @@ -93,8 +88,8 @@ pub fn compute_note_hash_and_nullifier( let unique_siloed_note_hash = compute_unique_hash(note_header.nonce, siloed_note_hash); - let compute_nullifier_without_context = note_interface.compute_nullifier_without_context; - let inner_nullifier = compute_nullifier_without_context(note); + let compute_nullifier = note_interface.compute_nullifier; + let inner_nullifier = compute_nullifier(note); [inner_note_hash, siloed_note_hash, unique_siloed_note_hash, inner_nullifier] } diff --git a/yarn-project/aztec-nr/aztec/src/oracle.nr b/yarn-project/aztec-nr/aztec/src/oracle.nr index 81eb3571a492..edd47519d2b3 100644 --- a/yarn-project/aztec-nr/aztec/src/oracle.nr +++ b/yarn-project/aztec-nr/aztec/src/oracle.nr @@ -11,7 +11,7 @@ mod get_nullifier_membership_witness; mod get_public_data_witness; mod get_membership_witness; mod get_public_key; -mod nullifier_key; +mod get_secret_key; mod get_sibling_path; mod rand; mod enqueue_public_function_call; diff --git a/yarn-project/aztec-nr/aztec/src/oracle/get_secret_key.nr b/yarn-project/aztec-nr/aztec/src/oracle/get_secret_key.nr new file mode 100644 index 000000000000..a4da1c2a5857 --- /dev/null +++ b/yarn-project/aztec-nr/aztec/src/oracle/get_secret_key.nr @@ -0,0 +1,25 @@ +use crate::oracle::get_public_key::get_public_key; +use dep::protocol_types::{ + address::AztecAddress, + grumpkin_point::GrumpkinPoint, +}; + +#[oracle(getSecretKey)] +fn get_secret_key_oracle(_owner: GrumpkinPoint) -> [Field; dep::std::grumpkin_scalar::GRUMPKIN_SCALAR_SERIALIZED_LEN] {} + +unconstrained fn get_secret_key_internal(owner_public_key: GrumpkinPoint) -> dep::std::grumpkin_scalar::GrumpkinScalar { + dep::std::grumpkin_scalar::deserialize_grumpkin_scalar(get_secret_key_oracle(owner_public_key)) +} + +pub fn get_secret_key(owner: AztecAddress) -> dep::std::grumpkin_scalar::GrumpkinScalar { + let owner_public_key = get_public_key(owner); + let secret = get_secret_key_internal(owner_public_key); + + // Constrain the owner - Nullifier secret key is currently just the encryption private key so we can constrain + // the owner by deriving the public key from the secret key and checking the result. + let computed_public_key = dep::std::grumpkin_scalar_mul::grumpkin_fixed_base(secret); + assert(owner_public_key.x == computed_public_key[0]); + assert(owner_public_key.y == computed_public_key[1]); + + secret +} diff --git a/yarn-project/aztec-nr/aztec/src/oracle/nullifier_key.nr b/yarn-project/aztec-nr/aztec/src/oracle/nullifier_key.nr deleted file mode 100644 index b97b2d651a3e..000000000000 --- a/yarn-project/aztec-nr/aztec/src/oracle/nullifier_key.nr +++ /dev/null @@ -1,29 +0,0 @@ -use dep::protocol_types::{ - address::AztecAddress, - grumpkin_point::GrumpkinPoint, -}; -use dep::std::grumpkin_scalar::GrumpkinScalar; - -struct KeyPair { - public_key: GrumpkinPoint, - secret_key: GrumpkinScalar, -} - -#[oracle(getNullifierKeyPair)] -fn get_nullifier_key_pair_oracle(_account: AztecAddress) -> [Field; 4] {} - -unconstrained fn get_nullifier_key_pair_internal(account: AztecAddress) -> KeyPair { - let result = get_nullifier_key_pair_oracle(account); - KeyPair { - public_key: GrumpkinPoint { x: result[0], y: result[1] }, - secret_key: GrumpkinScalar { high: result[2], low: result[3] } - } -} - -pub fn get_nullifier_key_pair(account: AztecAddress) -> KeyPair { - get_nullifier_key_pair_internal(account) -} - -pub fn get_nullifier_secret_key(account: AztecAddress) -> GrumpkinScalar { - get_nullifier_key_pair_internal(account).secret_key -} diff --git a/yarn-project/aztec-nr/aztec/src/state_vars/immutable_singleton.nr b/yarn-project/aztec-nr/aztec/src/state_vars/immutable_singleton.nr index 5bdc4d072d38..e87555d5a82d 100644 --- a/yarn-project/aztec-nr/aztec/src/state_vars/immutable_singleton.nr +++ b/yarn-project/aztec-nr/aztec/src/state_vars/immutable_singleton.nr @@ -1,10 +1,6 @@ use dep::std::option::Option; use dep::protocol_types::{ address::AztecAddress, - constants::{ - GENERATOR_INDEX__INITIALIZATION_NULLIFIER, - }, - hash::pedersen_hash, }; use crate::context::{PrivateContext, Context}; @@ -15,12 +11,14 @@ use crate::note::{ note_viewer_options::NoteViewerOptions, }; use crate::oracle::notes::check_nullifier_exists; +use crate::state_vars::singleton::compute_singleton_initialization_nullifier; // docs:start:struct struct ImmutableSingleton { context: Option<&mut PrivateContext>, storage_slot: Field, note_interface: NoteInterface, + compute_initialization_nullifier: fn (Field, Option) -> Field, } // docs:end:struct @@ -32,27 +30,19 @@ impl ImmutableSingleton { note_interface: NoteInterface, ) -> Self { assert(storage_slot != 0, "Storage slot 0 not allowed. Storage slots must start from 1."); - Self { + ImmutableSingleton { context: context.private, storage_slot, note_interface, + compute_initialization_nullifier: compute_singleton_initialization_nullifier, } } // docs:end:new - // The following computation is leaky, in that it doesn't hide the storage slot that has been initialized, nor does it hide the contract address of this contract. - // When this initialization nullifier is emitted, an observer could do a dictionary or rainbow attack to learn the preimage of this nullifier to deduce the storage slot and contract address. - // For some applications, leaking the details that a particular state variable of a particular contract has been initialized will be unacceptable. - // Under such circumstances, such application developers might wish to _not_ use this state variable type. - // This is especially dangerous for initial assignment to elements of a `Map` type (for example), because the storage slot often also identifies an actor. - // e.g. the initial assignment to `my_map.at(msg.sender)` will leak: `msg.sender`, the fact that an element of `my_map` was assigned-to for the first time, and the contract_address. - pub fn compute_initialization_nullifier(self) -> Field { - pedersen_hash([self.storage_slot], GENERATOR_INDEX__INITIALIZATION_NULLIFIER) - } - // docs:start:is_initialized - unconstrained pub fn is_initialized(self) -> bool { - let nullifier = self.compute_initialization_nullifier(); + unconstrained pub fn is_initialized(self, owner: Option) -> bool { + let compute_initialization_nullifier = self.compute_initialization_nullifier; + let nullifier = compute_initialization_nullifier(self.storage_slot, owner); check_nullifier_exists(nullifier) } // docs:end:is_initialized @@ -61,12 +51,14 @@ impl ImmutableSingleton { pub fn initialize( self, note: &mut Note, + owner: Option, broadcast: bool, ) { let context = self.context.unwrap(); // Nullify the storage slot. - let nullifier = self.compute_initialization_nullifier(); + let compute_initialization_nullifier = self.compute_initialization_nullifier; + let nullifier = compute_initialization_nullifier(self.storage_slot, owner); context.push_new_nullifier(nullifier, 0); create_note( 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 b5a2d3fe2801..28cd3ae23b8f 100644 --- a/yarn-project/aztec-nr/aztec/src/state_vars/singleton.nr +++ b/yarn-project/aztec-nr/aztec/src/state_vars/singleton.nr @@ -16,15 +16,28 @@ use crate::note::{ note_viewer_options::NoteViewerOptions, }; use crate::oracle::{ - nullifier_key::get_nullifier_secret_key, + get_secret_key::get_secret_key, notes::check_nullifier_exists, }; +pub fn compute_singleton_initialization_nullifier(storage_slot: Field, owner: Option) -> Field { + if owner.is_some() { + let secret = get_secret_key(owner.unwrap_unchecked()); + pedersen_hash( + [storage_slot, secret.low, secret.high], + GENERATOR_INDEX__INITIALIZATION_NULLIFIER + ) + } else { + pedersen_hash([storage_slot], GENERATOR_INDEX__INITIALIZATION_NULLIFIER) + } +} + // docs:start:struct struct Singleton { context: Option<&mut PrivateContext>, storage_slot: Field, note_interface: NoteInterface, + compute_initialization_nullifier: fn (Field, Option) -> Field, } // docs:end:struct @@ -36,29 +49,19 @@ impl Singleton { note_interface: NoteInterface, ) -> Self { assert(storage_slot != 0, "Storage slot 0 not allowed. Storage slots must start from 1."); - Self { + Singleton { context: context.private, storage_slot, note_interface, + compute_initialization_nullifier: compute_singleton_initialization_nullifier, } } // docs:end:new - // The following computation is leaky, in that it doesn't hide the storage slot that has been initialized, nor does it hide the contract address of this contract. - // When this initialization nullifier is emitted, an observer could do a dictionary or rainbow attack to learn the preimage of this nullifier to deduce the storage slot and contract address. - // For some applications, leaking the details that a particular state variable of a particular contract has been initialized will be unacceptable. - // Under such circumstances, such application developers might wish to _not_ use this state variable type. - // This is especially dangerous for initial assignment to elements of a `Map` type (for example), because the storage slot often also identifies an actor. e.g. - // the initial assignment to `my_map.at(msg.sender)` will leak: `msg.sender`, the fact that an element of `my_map` was assigned-to for the first time, and the contract_address. - // Note: subsequent nullification of this state variable, via the `replace` method will not be leaky, if the `compute_nullifier()` method of the underlying note is designed to ensure privacy. - // For example, if the `compute_nullifier()` method injects the secret key of a note owner into the computed nullifier's preimage. - pub fn compute_initialization_nullifier(self) -> Field { - pedersen_hash([self.storage_slot], GENERATOR_INDEX__INITIALIZATION_NULLIFIER) - } - // docs:start:is_initialized - unconstrained pub fn is_initialized(self) -> bool { - let nullifier = self.compute_initialization_nullifier(); + unconstrained pub fn is_initialized(self, owner: Option) -> bool { + let compute_initialization_nullifier = self.compute_initialization_nullifier; + let nullifier = compute_initialization_nullifier(self.storage_slot, owner); check_nullifier_exists(nullifier) } // docs:end:is_initialized @@ -67,12 +70,14 @@ impl Singleton { pub fn initialize( self, note: &mut Note, + owner: Option, broadcast: bool, ) { let context = self.context.unwrap(); // Nullify the storage slot. - let nullifier = self.compute_initialization_nullifier(); + let compute_initialization_nullifier = self.compute_initialization_nullifier; + let nullifier = compute_initialization_nullifier(self.storage_slot, owner); context.push_new_nullifier(nullifier, 0); create_note(context, self.storage_slot, note, self.note_interface, broadcast); diff --git a/yarn-project/aztec-nr/field-note/src/field_note.nr b/yarn-project/aztec-nr/field-note/src/field_note.nr index 8aa8fbe5520c..6267a7b6016e 100644 --- a/yarn-project/aztec-nr/field-note/src/field_note.nr +++ b/yarn-project/aztec-nr/field-note/src/field_note.nr @@ -41,12 +41,7 @@ impl FieldNote { pedersen_hash(self.serialize(), 0) } - pub fn compute_nullifier(_self: Self, _context: &mut PrivateContext) -> Field { - // This note is expected to be shared between users and for this reason can't be nullified using a secret. - 0 - } - - pub fn compute_nullifier_without_context(_self: Self) -> Field { + pub fn compute_nullifier(self) -> Field { // This note is expected to be shared between users and for this reason can't be nullified using a secret. 0 } @@ -68,12 +63,8 @@ fn compute_note_hash(note: FieldNote) -> Field { note.compute_note_hash() } -fn compute_nullifier(note: FieldNote, context: &mut PrivateContext) -> Field { - note.compute_nullifier(context) -} - -fn compute_nullifier_without_context(note: FieldNote) -> Field { - note.compute_nullifier_without_context() +fn compute_nullifier(note: FieldNote) -> Field { + note.compute_nullifier() } fn get_header(note: FieldNote) -> NoteHeader { @@ -95,7 +86,6 @@ global FieldNoteMethods = NoteInterface { serialize, compute_note_hash, compute_nullifier, - compute_nullifier_without_context, get_header, set_header, broadcast, diff --git a/yarn-project/aztec-nr/value-note/src/value_note.nr b/yarn-project/aztec-nr/value-note/src/value_note.nr index 4cffea0d4fa3..d02037e49982 100644 --- a/yarn-project/aztec-nr/value-note/src/value_note.nr +++ b/yarn-project/aztec-nr/value-note/src/value_note.nr @@ -7,7 +7,7 @@ use dep::aztec::{ }, oracle::{ rand::rand, - nullifier_key::get_nullifier_secret_key, + get_secret_key::get_secret_key, get_public_key::get_public_key, }, log::emit_encrypted_log, @@ -58,9 +58,9 @@ impl ValueNote { // docs:start:nullifier - pub fn compute_nullifier(self, context: &mut PrivateContext) -> Field { + pub fn compute_nullifier(self) -> Field { let note_hash_for_nullify = compute_note_hash_for_read_or_nullify(ValueNoteMethods, self); - let secret = context.request_nullifier_secret_key(self.owner); + let secret = get_secret_key(self.owner); // TODO(#1205) Should use a non-zero generator index. pedersen_hash([ note_hash_for_nullify, @@ -71,17 +71,6 @@ impl ValueNote { // docs:end:nullifier - pub fn compute_nullifier_without_context(self) -> Field { - let note_hash_for_nullify = compute_note_hash_for_read_or_nullify(ValueNoteMethods, self); - let secret = get_nullifier_secret_key(self.owner); - // TODO(#1205) Should use a non-zero generator index. - pedersen_hash([ - note_hash_for_nullify, - secret.low, - secret.high, - ],0) - } - pub fn set_header(&mut self, header: NoteHeader) { self.header = header; } @@ -111,12 +100,8 @@ fn compute_note_hash(note: ValueNote) -> Field { note.compute_note_hash() } -fn compute_nullifier(note: ValueNote, context: &mut PrivateContext) -> Field { - note.compute_nullifier(context) -} - -fn compute_nullifier_without_context(note: ValueNote) -> Field { - note.compute_nullifier_without_context() +fn compute_nullifier(note: ValueNote) -> Field { + note.compute_nullifier() } fn get_header(note: ValueNote) -> NoteHeader { @@ -137,7 +122,6 @@ global ValueNoteMethods = NoteInterface { serialize, compute_note_hash, compute_nullifier, - compute_nullifier_without_context, get_header, set_header, broadcast, diff --git a/yarn-project/aztec.js/.eslintrc.cjs b/yarn-project/aztec.js/.eslintrc.cjs index ec1dd3e14de0..e659927475c0 100644 --- a/yarn-project/aztec.js/.eslintrc.cjs +++ b/yarn-project/aztec.js/.eslintrc.cjs @@ -1 +1 @@ -module.exports = require('@aztec/foundation/eslint.docs'); +module.exports = require('@aztec/foundation/eslint'); diff --git a/yarn-project/circuit-types/src/keys/key_store.ts b/yarn-project/circuit-types/src/keys/key_store.ts index d9da2be7d50b..682aa89862e5 100644 --- a/yarn-project/circuit-types/src/keys/key_store.ts +++ b/yarn-project/circuit-types/src/keys/key_store.ts @@ -1,4 +1,4 @@ -import { AztecAddress, GrumpkinPrivateKey, PublicKey } from '@aztec/circuits.js'; +import { GrumpkinPrivateKey, PublicKey } from '@aztec/circuits.js'; /** * Represents a secure storage for managing keys. @@ -36,29 +36,4 @@ export interface KeyStore { * @deprecated We should not require a keystore to expose private keys in plain. */ getAccountPrivateKey(pubKey: PublicKey): Promise; - - /** - * Retrieves the nullifier secret key of the account associated with the specified AztecAddress. - * Throws an error if the provided public key is not found in the list of registered accounts. - * @param pubKey - The public key of the account for which the secret key is requested. - * @returns A Promise that resolves to the nullifier secret key. - */ - getNullifierSecretKey(pubKey: PublicKey): Promise; - - /** - * Retrieves the nullifier public key of the account associated with the specified AztecAddress. - * Throws an error if the provided public key is not found in the list of registered accounts. - * @param pubKey - The public key of the account for which the nullifier public key is requested. - * @returns A Promise that resolves to the nullifier public key. - */ - getNullifierPublicKey(pubKey: PublicKey): Promise; - - /** - * Retrieves the nullifier secret key for use in a specific contract. - * Throws an error if the provided public key is not found in the list of registered accounts. - * @param pubKey - The public key of the account for which the private key is requested. - * @param contractAddress - The address of the contract requesting the nullifier key. - * @returns A Promise that resolves to the nullifier secret key. - */ - getSiloedNullifierSecretKey(pubKey: PublicKey, contractAddress: AztecAddress): Promise; } diff --git a/yarn-project/circuit-types/src/l1_to_l2_message.ts b/yarn-project/circuit-types/src/l1_to_l2_message.ts index 2165d4bd49ec..a072e6c270ba 100644 --- a/yarn-project/circuit-types/src/l1_to_l2_message.ts +++ b/yarn-project/circuit-types/src/l1_to_l2_message.ts @@ -1,6 +1,5 @@ import { AztecAddress } from '@aztec/foundation/aztec-address'; import { toBigIntBE, toBufferBE } from '@aztec/foundation/bigint-buffer'; -import { sha256 } from '@aztec/foundation/crypto'; import { EthAddress } from '@aztec/foundation/eth-address'; import { Fr } from '@aztec/foundation/fields'; import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; @@ -117,10 +116,6 @@ export class L1ToL2Message { return serializeToBuffer(this.sender, this.recipient, this.content, this.secretHash, this.deadline, this.fee); } - hash(): Fr { - return Fr.fromBufferReduce(sha256(serializeToBuffer(...this.toFieldArray()))); - } - static fromBuffer(buffer: Buffer | BufferReader): L1ToL2Message { const reader = BufferReader.asReader(buffer); const sender = reader.readObject(L1Actor); diff --git a/yarn-project/circuits.js/src/constants.gen.ts b/yarn-project/circuits.js/src/constants.gen.ts index 39a05fee9ca7..79cd3856febc 100644 --- a/yarn-project/circuits.js/src/constants.gen.ts +++ b/yarn-project/circuits.js/src/constants.gen.ts @@ -48,7 +48,7 @@ export const NUM_FIELDS_PER_SHA256 = 2; export const ARGS_HASH_CHUNK_LENGTH = 32; export const ARGS_HASH_CHUNK_COUNT = 16; export const L1_TO_L2_MESSAGE_LENGTH = 8; -export const L1_TO_L2_MESSAGE_ORACLE_CALL_LENGTH = 25; +export const L1_TO_L2_MESSAGE_ORACLE_CALL_LENGTH = 26; export const MAX_NOTE_FIELDS_LENGTH = 20; export const GET_NOTE_ORACLE_RETURN_LENGTH = 23; export const MAX_NOTES_PER_PAGE = 10; diff --git a/yarn-project/circuits.js/src/index.ts b/yarn-project/circuits.js/src/index.ts index 347db88ae51b..91e7dd069b3b 100644 --- a/yarn-project/circuits.js/src/index.ts +++ b/yarn-project/circuits.js/src/index.ts @@ -1,5 +1,4 @@ export * from './structs/index.js'; export * from './contract/index.js'; -export * from './keys/index.js'; export * from './types/index.js'; export * from './constants.gen.js'; diff --git a/yarn-project/circuits.js/src/keys/index.ts b/yarn-project/circuits.js/src/keys/index.ts deleted file mode 100644 index 09ec99767c4d..000000000000 --- a/yarn-project/circuits.js/src/keys/index.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { AztecAddress } from '@aztec/foundation/aztec-address'; -import { pedersenHash } from '@aztec/foundation/crypto'; -import { Fr, GrumpkinScalar } from '@aztec/foundation/fields'; - -import { Grumpkin } from '../barretenberg/crypto/grumpkin/index.js'; -import { GrumpkinPrivateKey } from '../types/grumpkin_private_key.js'; - -/** - * Derives the public key of a secret key. - */ -export function derivePublicKey(secretKey: GrumpkinPrivateKey) { - const grumpkin = new Grumpkin(); - return grumpkin.mul(grumpkin.generator(), secretKey); -} - -/** - * Derives a new secret key from a secret key and an index. - */ -function _deriveSecretKey(secretKey: GrumpkinPrivateKey, index: Fr): GrumpkinPrivateKey { - // TODO: Temporary hack. Should replace it with a secure way to derive the secret key. - const hash = pedersenHash([secretKey.high, secretKey.low, index].map(v => v.toBuffer())); - return new GrumpkinScalar(hash); -} - -/** - * Computes the nullifier secret key from seed secret key. - */ -export function computeNullifierSecretKey(seedSecretKey: GrumpkinPrivateKey): GrumpkinPrivateKey { - // TODO - // return deriveSecretKey(seedSecretKey, new Fr(1)); - return seedSecretKey; -} - -/** - * Computes the nullifier secret key for a contract. - */ -export function computeSiloedNullifierSecretKey( - nullifierSecretKey: GrumpkinPrivateKey, - _contractAddress: AztecAddress, -): GrumpkinPrivateKey { - // TODO - // return deriveSecretKey(nullifierSecretKey, contractAddress); - return nullifierSecretKey; -} diff --git a/yarn-project/circuits.js/src/types/grumpkin_private_key.ts b/yarn-project/circuits.js/src/types/grumpkin_private_key.ts index 16ed36795871..8a394773730d 100644 --- a/yarn-project/circuits.js/src/types/grumpkin_private_key.ts +++ b/yarn-project/circuits.js/src/types/grumpkin_private_key.ts @@ -1,4 +1,4 @@ -import { GrumpkinScalar } from '@aztec/foundation/fields'; +import { GrumpkinScalar } from '../index.js'; /** A type alias for private key which belongs to the scalar field of Grumpkin curve. */ export type GrumpkinPrivateKey = GrumpkinScalar; diff --git a/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts b/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts index f3bb23e15d8a..4f01c5b41e15 100644 --- a/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts +++ b/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts @@ -161,7 +161,7 @@ describe('e2e_cross_chain_messaging', () => { secretForL2MessageConsumption, ) .simulate(), - ).rejects.toThrowError("Invalid Content 'l1_to_l2_message_data.message.content == content'"); + ).rejects.toThrowError("Cannot satisfy constraint 'l1_to_l2_message_data.message.content == content"); // send the right one - const consumptionTx = l2Bridge @@ -234,6 +234,8 @@ describe('e2e_cross_chain_messaging', () => { .withWallet(user2Wallet) .methods.claim_public(ownerAddress, bridgeAmount, ethAccount, messageKey, secretForL2MessageConsumption) .simulate(), - ).rejects.toThrowError("Invalid Content 'l1_to_l2_message_data.message.content == content'"); + ).rejects.toThrowError( + "Failed to solve brillig function, reason: explicit trap hit in brillig 'l1_to_l2_message_data.message.content == content'", + ); }, 120_000); }); diff --git a/yarn-project/end-to-end/src/e2e_lending_contract.test.ts b/yarn-project/end-to-end/src/e2e_lending_contract.test.ts index bc6baf42a99d..77c58873e463 100644 --- a/yarn-project/end-to-end/src/e2e_lending_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_lending_contract.test.ts @@ -250,6 +250,18 @@ describe('e2e_lending_contract', () => { .send(), ); }); + describe('failure cases', () => { + it('calling internal _deposit function directly', async () => { + // Try to call the internal `_deposit` function directly + // This should: + // - not change any storage values. + // - fail + + await expect( + lendingContract.methods._deposit(lendingAccount.address.toField(), 42n, collateralAsset.address).simulate(), + ).rejects.toThrow(); + }); + }); }); describe('Borrow', () => { diff --git a/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts b/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts index ea57f757f733..a6975b6b0f8f 100644 --- a/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts +++ b/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts @@ -136,7 +136,7 @@ describe('e2e_public_cross_chain_messaging', () => { .withWallet(user2Wallet) .methods.claim_public(user2Wallet.getAddress(), bridgeAmount, ethAccount, messageKey, secret) .simulate(), - ).rejects.toThrow("Invalid Content 'l1_to_l2_message_data.message.content == content'"); + ).rejects.toThrow(); // user2 consumes owner's L1-> L2 message on bridge contract and mints public tokens on L2 logger("user2 consumes owner's message on L2 Publicly"); @@ -185,6 +185,6 @@ describe('e2e_public_cross_chain_messaging', () => { .withWallet(user2Wallet) .methods.claim_private(secretHash, bridgeAmount, ethAccount, messageKey, secret) .simulate(), - ).rejects.toThrowError("Invalid Content 'l1_to_l2_message_data.message.content == content'"); + ).rejects.toThrowError("Cannot satisfy constraint 'l1_to_l2_message_data.message.content == content"); }, 60_000); }); diff --git a/yarn-project/end-to-end/src/e2e_singleton.test.ts b/yarn-project/end-to-end/src/e2e_singleton.test.ts deleted file mode 100644 index 6c1407ef053d..000000000000 --- a/yarn-project/end-to-end/src/e2e_singleton.test.ts +++ /dev/null @@ -1,142 +0,0 @@ -import { TxStatus, Wallet } from '@aztec/aztec.js'; -import { DocsExampleContract } from '@aztec/noir-contracts'; - -import { setup } from './fixtures/utils.js'; - -describe('e2e_singleton', () => { - let wallet: Wallet; - - let teardown: () => Promise; - let contract: DocsExampleContract; - - const POINTS = 1n; - const RANDOMNESS = 2n; - - beforeAll(async () => { - ({ teardown, wallet } = await setup()); - contract = await DocsExampleContract.deploy(wallet).send().deployed(); - }, 25_000); - - afterAll(() => teardown()); - - describe('Singleton', () => { - it('fail to read uninitialized singleton', async () => { - expect(await contract.methods.is_legendary_initialized().view()).toEqual(false); - await expect(contract.methods.get_legendary_card().view()).rejects.toThrowError(); - }); - - it('initialize singleton', async () => { - expect(await contract.methods.is_legendary_initialized().view()).toEqual(false); - const receipt = await contract.methods.initialize_private(RANDOMNESS, POINTS).send().wait(); - expect(receipt.status).toEqual(TxStatus.MINED); - - const tx = await wallet.getTx(receipt.txHash); - expect(tx?.newCommitments.length).toEqual(1); - // 1 for the tx, another for the initializer - expect(tx?.newNullifiers.length).toEqual(2); - expect(await contract.methods.is_legendary_initialized().view()).toEqual(true); - }); - - it('fail to reinitialize', async () => { - expect(await contract.methods.is_legendary_initialized().view()).toEqual(true); - await expect(contract.methods.initialize_private(RANDOMNESS, POINTS).send().wait()).rejects.toThrowError(); - expect(await contract.methods.is_legendary_initialized().view()).toEqual(true); - }); - - it('read initialized singleton', async () => { - expect(await contract.methods.is_legendary_initialized().view()).toEqual(true); - const { points, randomness } = await contract.methods.get_legendary_card().view(); - expect(points).toEqual(POINTS); - expect(randomness).toEqual(RANDOMNESS); - }); - - it('replace with same value', async () => { - expect(await contract.methods.is_legendary_initialized().view()).toEqual(true); - const noteBefore = await contract.methods.get_legendary_card().view(); - const receipt = await contract.methods.update_legendary_card(RANDOMNESS, POINTS).send().wait(); - expect(receipt.status).toEqual(TxStatus.MINED); - - const tx = await wallet.getTx(receipt.txHash); - expect(tx?.newCommitments.length).toEqual(1); - // 1 for the tx, another for the nullifier of the previous note - expect(tx?.newNullifiers.length).toEqual(2); - - const noteAfter = await contract.methods.get_legendary_card().view(); - - expect(noteBefore.owner).toEqual(noteAfter.owner); - expect(noteBefore.points).toEqual(noteAfter.points); - expect(noteBefore.randomness).toEqual(noteAfter.randomness); - expect(noteBefore.header.contract_address).toEqual(noteAfter.header.contract_address); - expect(noteBefore.header.storage_slot).toEqual(noteAfter.header.storage_slot); - expect(noteBefore.header.is_transient).toEqual(noteAfter.header.is_transient); - // !!! Nonce must be different - expect(noteBefore.header.nonce).not.toEqual(noteAfter.header.nonce); - }); - - it('replace singleton with other values', async () => { - expect(await contract.methods.is_legendary_initialized().view()).toEqual(true); - const receipt = await contract.methods - .update_legendary_card(RANDOMNESS + 2n, POINTS + 1n) - .send() - .wait(); - expect(receipt.status).toEqual(TxStatus.MINED); - const tx = await wallet.getTx(receipt.txHash); - expect(tx?.newCommitments.length).toEqual(1); - // 1 for the tx, another for the nullifier of the previous note - expect(tx?.newNullifiers.length).toEqual(2); - - const { points, randomness } = await contract.methods.get_legendary_card().view(); - expect(points).toEqual(POINTS + 1n); - expect(randomness).toEqual(RANDOMNESS + 2n); - }); - - it('replace singleton dependent on prior value', async () => { - expect(await contract.methods.is_legendary_initialized().view()).toEqual(true); - const noteBefore = await contract.methods.get_legendary_card().view(); - const receipt = await contract.methods.increase_legendary_points().send().wait(); - expect(receipt.status).toEqual(TxStatus.MINED); - const tx = await wallet.getTx(receipt.txHash); - expect(tx?.newCommitments.length).toEqual(1); - // 1 for the tx, another for the nullifier of the previous note - expect(tx?.newNullifiers.length).toEqual(2); - - const { points, randomness } = await contract.methods.get_legendary_card().view(); - expect(points).toEqual(noteBefore.points + 1n); - expect(randomness).toEqual(noteBefore.randomness); - }); - }); - - describe('Immutable Singleton', () => { - it('fail to read uninitialized singleton', async () => { - expect(await contract.methods.is_imm_initialized().view()).toEqual(false); - await expect(contract.methods.get_imm_card().view()).rejects.toThrowError(); - }); - - it('initialize singleton', async () => { - expect(await contract.methods.is_imm_initialized().view()).toEqual(false); - const receipt = await contract.methods.initialize_immutable_singleton(RANDOMNESS, POINTS).send().wait(); - expect(receipt.status).toEqual(TxStatus.MINED); - - const tx = await wallet.getTx(receipt.txHash); - expect(tx?.newCommitments.length).toEqual(1); - // 1 for the tx, another for the initializer - expect(tx?.newNullifiers.length).toEqual(2); - expect(await contract.methods.is_imm_initialized().view()).toEqual(true); - }); - - it('fail to reinitialize', async () => { - expect(await contract.methods.is_imm_initialized().view()).toEqual(true); - await expect( - contract.methods.initialize_immutable_singleton(RANDOMNESS, POINTS).send().wait(), - ).rejects.toThrowError(); - expect(await contract.methods.is_imm_initialized().view()).toEqual(true); - }); - - it('read initialized singleton', async () => { - expect(await contract.methods.is_imm_initialized().view()).toEqual(true); - const { points, randomness } = await contract.methods.get_imm_card().view(); - expect(points).toEqual(POINTS); - expect(randomness).toEqual(RANDOMNESS); - }); - }); -}); diff --git a/yarn-project/foundation/.eslintrc.cjs b/yarn-project/foundation/.eslintrc.cjs index daa6e7a51ebd..31c960d6c127 100644 --- a/yarn-project/foundation/.eslintrc.cjs +++ b/yarn-project/foundation/.eslintrc.cjs @@ -1,3 +1,41 @@ +// See https://typescript-eslint.io/play/#ts=5.1.6&showAST=es&fileType=.ts +const contexts = [ + // All methods in an interface + 'TSInterfaceDeclaration TSMethodSignature', + // All public methods in a class that does not implement an interface + 'ClassDeclaration[implements.length=0] MethodDefinition[accessibility=public]', + // TODO: All methods public by default in a class that does not implement an interface + // 'ClassDeclaration[implements.length=0] MethodDefinition[accessibility=undefined][key.type=Identifier]', + // TODO: All export const from the top level of a file + // 'ExportNamedDeclaration[declaration.type=VariableDeclaration]', + // Legacy contexts (needs review) + 'TSParameterProperty[accessibility=public]', + 'TSPropertySignature', + 'PropertySignature', + 'TSInterfaceDeclaration', + 'InterfaceDeclaration', + 'TSPropertyDefinition[accessibility=public]', + 'PropertyDefinition[accessibility=public]', + 'TSTypeAliasDeclaration', + 'TypeAliasDeclaration', + 'TSTypeDeclaration', + 'TypeDeclaration', + 'TSEnumDeclaration', + 'EnumDeclaration', + 'TSClassDeclaration', + 'ClassDeclaration', + 'TSClassExpression', + 'ClassExpression', + 'TSFunctionExpression', + 'FunctionExpression', + 'TSInterfaceExpression', + 'InterfaceExpression', + 'TSEnumExpression', + 'EnumExpression', +]; + +const JSDOC_RULES_LEVEL = 'error'; + module.exports = { extends: [ 'eslint:recommended', @@ -74,8 +112,27 @@ module.exports = { ], 'import/no-extraneous-dependencies': 'error', 'import/no-cycle': 'warn', + 'tsdoc/syntax': JSDOC_RULES_LEVEL, + 'jsdoc/require-jsdoc': [ + JSDOC_RULES_LEVEL, + { + contexts, + checkConstructors: false, + checkGetters: true, + checkSetters: true, + }, + ], + 'jsdoc/require-description': [JSDOC_RULES_LEVEL, { contexts }], + 'jsdoc/require-hyphen-before-param-description': [JSDOC_RULES_LEVEL], + 'jsdoc/require-param': [JSDOC_RULES_LEVEL, { contexts, checkDestructured: false }], + 'jsdoc/require-param-description': [JSDOC_RULES_LEVEL, { contexts }], + 'jsdoc/require-param-name': [JSDOC_RULES_LEVEL, { contexts }], + 'jsdoc/require-property': [JSDOC_RULES_LEVEL, { contexts }], + 'jsdoc/require-property-description': [JSDOC_RULES_LEVEL, { contexts }], + 'jsdoc/require-property-name': [JSDOC_RULES_LEVEL, { contexts }], + 'jsdoc/require-returns': 'off', // this unfortunately doesn't block `fit` and `fdescribe` 'no-only-tests/no-only-tests': ['error'], }, - ignorePatterns: ['node_modules', 'dest*', 'dist', '*.js', '.eslintrc.cjs', '.eslintrc.*.cjs'], + ignorePatterns: ['node_modules', 'dest*', 'dist', '*.js', '.eslintrc.cjs'], }; diff --git a/yarn-project/foundation/.eslintrc.docs.cjs b/yarn-project/foundation/.eslintrc.docs.cjs deleted file mode 100644 index cac8e4f90959..000000000000 --- a/yarn-project/foundation/.eslintrc.docs.cjs +++ /dev/null @@ -1,69 +0,0 @@ -// See https://typescript-eslint.io/play/#ts=5.1.6&showAST=es&fileType=.ts -const contexts = [ - // All methods in an interface - 'TSInterfaceDeclaration TSMethodSignature', - // All public methods in a class that does not implement an interface - 'ClassDeclaration[implements.length=0] MethodDefinition[accessibility=public]', - // TODO: All methods public by default in a class that does not implement an interface - // 'ClassDeclaration[implements.length=0] MethodDefinition[accessibility=undefined][key.type=Identifier]', - // TODO: All export const from the top level of a file - // 'ExportNamedDeclaration[declaration.type=VariableDeclaration]', - // Legacy contexts below (needs review) - 'TSParameterProperty[accessibility=public]', - 'TSPropertySignature', - 'PropertySignature', - 'TSInterfaceDeclaration', - 'InterfaceDeclaration', - 'TSPropertyDefinition[accessibility=public]', - 'PropertyDefinition[accessibility=public]', - 'TSTypeAliasDeclaration', - 'TypeAliasDeclaration', - 'TSTypeDeclaration', - 'TypeDeclaration', - 'TSEnumDeclaration', - 'EnumDeclaration', - 'TSClassDeclaration', - 'ClassDeclaration', - 'TSClassExpression', - 'ClassExpression', - 'TSFunctionExpression', - 'FunctionExpression', - 'TSInterfaceExpression', - 'InterfaceExpression', - 'TSEnumExpression', - 'EnumExpression', -]; - -const base = require('./.eslintrc.cjs'); -const JSDOC_RULES_LEVEL = 'error'; - -module.exports = { - ...base, - plugins: [...base.plugins, 'jsdoc'], - overrides: [ - ...base.overrides, - { files: '*.test.ts', rules: { 'jsdoc/require-jsdoc': 'off' } }, - ], - rules: { - ...base.rules, - 'tsdoc/syntax': JSDOC_RULES_LEVEL, - 'jsdoc/require-jsdoc': [ - JSDOC_RULES_LEVEL, - { - contexts, - checkConstructors: false, - checkGetters: true, - checkSetters: true, - }, - ], - 'jsdoc/require-description': [JSDOC_RULES_LEVEL, { contexts }], - 'jsdoc/require-hyphen-before-param-description': [JSDOC_RULES_LEVEL], - 'jsdoc/require-param': [JSDOC_RULES_LEVEL, { contexts, checkDestructured: false }], - 'jsdoc/require-param-description': [JSDOC_RULES_LEVEL, { contexts }], - 'jsdoc/require-param-name': [JSDOC_RULES_LEVEL, { contexts }], - 'jsdoc/require-property': [JSDOC_RULES_LEVEL, { contexts }], - 'jsdoc/require-property-description': [JSDOC_RULES_LEVEL, { contexts }], - 'jsdoc/require-property-name': [JSDOC_RULES_LEVEL, { contexts }], - 'jsdoc/require-returns': 'off', - } -}; diff --git a/yarn-project/foundation/package.json b/yarn-project/foundation/package.json index 35d2d9480e21..0851e5c79d57 100644 --- a/yarn-project/foundation/package.json +++ b/yarn-project/foundation/package.json @@ -7,7 +7,6 @@ "types": "./dest/index.d.ts", "exports": { "./eslint": "./.eslintrc.cjs", - "./eslint.docs": "./.eslintrc.docs.cjs", "./prettier": "./.prettierrc.json", "./abi": "./dest/abi/index.js", "./async-map": "./dest/async-map/index.js", diff --git a/yarn-project/key-store/src/test_key_store.ts b/yarn-project/key-store/src/test_key_store.ts index f0af31ee6da9..1a5a96c2d1b8 100644 --- a/yarn-project/key-store/src/test_key_store.ts +++ b/yarn-project/key-store/src/test_key_store.ts @@ -1,13 +1,5 @@ import { KeyPair, KeyStore, PublicKey } from '@aztec/circuit-types'; -import { - AztecAddress, - GrumpkinPrivateKey, - GrumpkinScalar, - Point, - computeNullifierSecretKey, - computeSiloedNullifierSecretKey, - derivePublicKey, -} from '@aztec/circuits.js'; +import { GrumpkinPrivateKey, GrumpkinScalar, Point } from '@aztec/circuits.js'; import { Grumpkin } from '@aztec/circuits.js/barretenberg'; import { AztecKVStore, AztecMap } from '@aztec/kv-store'; @@ -46,21 +38,6 @@ export class TestKeyStore implements KeyStore { return Promise.resolve(account.getPrivateKey()); } - public async getNullifierSecretKey(pubKey: PublicKey) { - const privateKey = await this.getAccountPrivateKey(pubKey); - return computeNullifierSecretKey(privateKey); - } - - public async getNullifierPublicKey(pubKey: PublicKey) { - const secretKey = await this.getNullifierSecretKey(pubKey); - return derivePublicKey(secretKey); - } - - public async getSiloedNullifierSecretKey(pubKey: PublicKey, contractAddress: AztecAddress) { - const secretKey = await this.getNullifierSecretKey(pubKey); - return computeSiloedNullifierSecretKey(secretKey, contractAddress); - } - /** * Retrieve the KeyPair object associated with a given pub key. * Searches through the 'accounts' array for a matching public key and returns the corresponding account (KeyPair). diff --git a/yarn-project/noir-compiler/src/contract-interface-gen/typescript.ts b/yarn-project/noir-compiler/src/contract-interface-gen/typescript.ts index 90b622b6115c..c17d0d7abb48 100644 --- a/yarn-project/noir-compiler/src/contract-interface-gen/typescript.ts +++ b/yarn-project/noir-compiler/src/contract-interface-gen/typescript.ts @@ -166,7 +166,7 @@ function generateAbiStatement(name: string, artifactImportPath: string) { * @returns The corresponding ts code. */ export function generateTypescriptContractInterface(input: ContractArtifact, artifactImportPath?: string) { - const methods = input.functions.filter(f => f.name !== 'constructor' && !f.isInternal).map(generateMethod); + const methods = input.functions.filter(f => f.name !== 'constructor').map(generateMethod); const deploy = artifactImportPath && generateDeploy(input); const ctor = artifactImportPath && generateConstructor(input.name); const at = artifactImportPath && generateAt(input.name); diff --git a/yarn-project/noir-contracts/contracts/card_game_contract/src/cards.nr b/yarn-project/noir-contracts/contracts/card_game_contract/src/cards.nr index b0b17ef7ac15..6672ad559bc4 100644 --- a/yarn-project/noir-contracts/contracts/card_game_contract/src/cards.nr +++ b/yarn-project/noir-contracts/contracts/card_game_contract/src/cards.nr @@ -12,6 +12,7 @@ use dep::aztec::{ note_viewer_options::NoteViewerOptions, note_getter::view_notes, }, + oracle::get_secret_key::get_secret_key, state_vars::set::Set, }; use dep::std; @@ -195,9 +196,9 @@ impl Deck { global PACK_CARDS = 3; // Limited by number of write requests (max 4) -pub fn get_pack_cards(seed: Field, owner: AztecAddress, context: &mut PrivateContext) -> [Card; PACK_CARDS] { +pub fn get_pack_cards(seed: Field, owner: AztecAddress) -> [Card; PACK_CARDS] { // generate pseudo randomness deterministically from 'seed' and user secret - let secret = context.request_nullifier_secret_key(owner); + let secret = get_secret_key(owner); let mix = secret.high + secret.low + seed; let random_bytes = std::hash::sha256(mix.to_le_bytes(32)); diff --git a/yarn-project/noir-contracts/contracts/card_game_contract/src/main.nr b/yarn-project/noir-contracts/contracts/card_game_contract/src/main.nr index 4aacb388d9ab..f0f85b6e0cd9 100644 --- a/yarn-project/noir-contracts/contracts/card_game_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/card_game_contract/src/main.nr @@ -112,7 +112,7 @@ contract CardGame { fn buy_pack(seed: Field // The randomness used to generate the cards. Passed in for now. ) { let buyer = context.msg_sender(); - let mut cards = get_pack_cards(seed, buyer, &mut context); + let mut cards = get_pack_cards(seed, buyer); let mut collection = storage.collections.at(buyer); let _inserted_cards = collection.add_cards(cards, buyer); diff --git a/yarn-project/noir-contracts/contracts/docs_example_contract/src/account_contract_interface.nr b/yarn-project/noir-contracts/contracts/docs_example_contract/src/account_contract_interface.nr new file mode 100644 index 000000000000..0701b4819be2 --- /dev/null +++ b/yarn-project/noir-contracts/contracts/docs_example_contract/src/account_contract_interface.nr @@ -0,0 +1,11 @@ +struct AccountContractInterface { + address: Field, +} + +impl AccountContractInterface { + pub fn at(address: Field) -> Self { + AccountContractInterface { address } + } + + pub fn send_rewards(_self: Self, _rewards: u8) {} +} diff --git a/yarn-project/noir-contracts/contracts/docs_example_contract/src/actions.nr b/yarn-project/noir-contracts/contracts/docs_example_contract/src/actions.nr new file mode 100644 index 000000000000..9c9423f31ea8 --- /dev/null +++ b/yarn-project/noir-contracts/contracts/docs_example_contract/src/actions.nr @@ -0,0 +1,156 @@ +use dep::aztec::protocol_types::{ + address::AztecAddress, + constants::{MAX_NOTES_PER_PAGE, MAX_READ_REQUESTS_PER_CALL}, +}; +use dep::aztec::note::{ + note_getter_options::NoteGetterOptions, note_viewer_options::NoteViewerOptions, +}; +use dep::aztec::state_vars::{ + immutable_singleton::ImmutableSingleton, map::Map, public_state::PublicState, set::Set, + singleton::Singleton, +}; +use dep::aztec::types::type_serialization::bool_serialization::BOOL_SERIALIZED_LEN; +use dep::std::option::Option; + +use crate::types::{ + card_note::{CardNote, CARD_NOTE_LEN}, + profile_note::{ProfileNote, PROFILE_NOTE_LEN}, + queen::{Queen, QUEEN_SERIALIZED_LEN}, + rules_note::{RulesNote, RULES_NOTE_LEN}, +}; + +// docs:start:state_vars-PublicStateRead +pub fn is_locked(state_var: PublicState) -> bool { + state_var.read() +} +// docs:end:state_vars-PublicStateRead + +// docs:start:state_vars-PublicStateWrite +pub fn lock(state_var: PublicState) { + state_var.write(true); +} +// docs:end:state_vars-PublicStateWrite + +pub fn unlock(state_var: PublicState) { + state_var.write(false); +} + +// docs:start:state_vars-PublicStateReadCustom +pub fn get_current_queen(state_var: PublicState) -> Queen { + state_var.read() +} +// docs:end:state_vars-PublicStateReadCustom + +pub fn can_replace_queen(state_var: PublicState, new_queen: Queen) -> bool { + let current_queen = get_current_queen(state_var); + new_queen.points > current_queen.points +} + +// docs:start:state_vars-PublicStateWriteCustom +pub fn replace_queen(state_var: PublicState, new_queen: Queen) { + state_var.write(new_queen); +} +// docs:end:state_vars-PublicStateWriteCustom + +// docs:start:state_vars-PublicStateReadWriteCustom +pub fn add_points_to_queen(state_var: PublicState, new_points: u8) { + let mut queen = state_var.read(); + queen.points += new_points; + state_var.write(queen); +} +// docs:end:state_vars-PublicStateReadWriteCustom + +// docs:start:state_vars-SingletonInit +pub fn init_legendary_card(state_var: Singleton, card: &mut CardNote) { + state_var.initialize(card, Option::some(card.owner), true); +} +// docs:end:state_vars-SingletonInit + +// docs:start:state_vars-SingletonReplace +pub fn update_legendary_card(state_var: Singleton, card: &mut CardNote) { + state_var.replace(card, true); +} +// docs:end:state_vars-SingletonReplace + +// docs:start:state_vars-SingletonGet +pub fn get_legendary_card(state_var: Singleton) -> CardNote { + state_var.get_note(true) +} +// docs:end:state_vars-SingletonGet + +// docs:start:state_vars-ImmutableSingletonInit +pub fn init_game_rules(state_var: ImmutableSingleton, rules: &mut RulesNote) { + state_var.initialize(rules, Option::none(), true); +} +// docs:end:state_vars-ImmutableSingletonInit + +// docs:start:state_vars-ImmutableSingletonGet +pub fn is_valid_card(state_var: ImmutableSingleton, card: CardNote) -> bool { + let rules = state_var.get_note(); + card.points >= rules.min_points & card.points <= rules.max_points +} +// docs:end:state_vars-ImmutableSingletonGet + +// docs:start:state_vars-SetInsert +pub fn add_new_card(state_var: Set, card: &mut CardNote) { + state_var.insert(card, true); +} +// docs:end:state_vars-SetInsert + +// docs:start:state_vars-SetRemove +pub fn remove_card(state_var: Set, card: CardNote) { + state_var.remove(card); +} +// docs:end:state_vars-SetRemove + +// docs:start:state_vars-SetGet +pub fn get_cards( + state_var: Set, + options: NoteGetterOptions +) -> [Option; MAX_READ_REQUESTS_PER_CALL] { + state_var.get_notes(options) +} +// docs:end:state_vars-SetGet + +// docs:start:state_vars-SetView +unconstrained pub fn view_cards( + state_var: Set, + options: NoteViewerOptions +) -> [Option; MAX_NOTES_PER_PAGE] { + state_var.view_notes(options) +} +// docs:end:state_vars-SetView + +unconstrained pub fn get_total_points(state_var: Set, account: AztecAddress, offset: u32) -> u8 { + let options = NoteViewerOptions::new().select(2, account.to_field()).set_offset(offset); + let mut total_points = 0; + let notes = view_cards(state_var, options); + for i in 0..notes.len() { + if notes[i].is_some() { + total_points += notes[i].unwrap_unchecked().points; + } + } + if notes[notes.len() - 1].is_some() { + total_points += get_total_points(state_var, account, offset + notes.len() as u32); + } + total_points +} + +// docs:start:state_vars-MapAtSingletonInit +pub fn add_new_profile( + state_var: Map>, + account: AztecAddress, + profile: &mut ProfileNote +) { + state_var.at(account).initialize(profile, Option::some(account), true); +} +// docs:end:state_vars-MapAtSingletonInit + +// docs:start:state_vars-MapAtSingletonGet +pub fn get_profile( + state_var: Map>, + account: AztecAddress +) -> ProfileNote { + state_var.at(account).get_note(true) +} +// docs:end:state_vars-MapAtSingletonGet diff --git a/yarn-project/noir-contracts/contracts/docs_example_contract/src/main.nr b/yarn-project/noir-contracts/contracts/docs_example_contract/src/main.nr index e7c9befa319f..8870c2972670 100644 --- a/yarn-project/noir-contracts/contracts/docs_example_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/docs_example_contract/src/main.nr @@ -1,164 +1,210 @@ +mod account_contract_interface; +mod actions; mod options; mod types; -// Following is a very simple game to show case use of singleton in as minimalistic way as possible -// It also serves as an e2e test that you can read and then replace the singleton in the same call -// (tests ordering in the circuit) - -// you have a card (singleton). Anyone can create a bigger card. Whoever is bigger will be the leader. -// it also has dummy methods and other examples used for documentation e.g. -// how to create custom notes, a custom struct for public state, a custom note that may be unencrypted -// also has `options.nr` which shows various ways of using `NoteGetterOptions` to query notes -// it also shows what our macros do behind the scenes! - contract DocsExample { - // how to import dependencies defined in your workspace use dep::aztec::protocol_types::{ - abis::function_selector::FunctionSelector, address::AztecAddress, + abis::function_selector::FunctionSelector, }; + use dep::std::option::Option; use dep::aztec::{ - note::{ - note_header::NoteHeader, - utils as note_utils, - }, context::{PrivateContext, PublicContext, Context}, - state_vars::{map::Map, public_state::PublicState,singleton::Singleton, immutable_singleton::ImmutableSingleton}, + state_vars::{ + immutable_singleton::ImmutableSingleton, map::Map, public_state::PublicState, set::Set, + singleton::Singleton, + }, + }; + // docs:start:state_vars-PublicStateBoolImport + use dep::aztec::types::type_serialization::bool_serialization::{ + BoolSerializationMethods, BOOL_SERIALIZED_LEN, }; - // how to import methods from other files/folders within your workspace + // docs:end:state_vars-PublicStateBoolImport + use crate::account_contract_interface::AccountContractInterface; + use crate::actions; use crate::options::create_account_card_getter_options; use crate::types::{ card_note::{CardNote, CardNoteMethods, CARD_NOTE_LEN}, - leader::{Leader, LeaderSerializationMethods, LEADER_SERIALIZED_LEN}, + profile_note::{ProfileNote, ProfileNoteMethods, PROFILE_NOTE_LEN}, + queen::{Queen, QueenSerializationMethods, QUEEN_SERIALIZED_LEN}, + rules_note::{RulesNote, RulesNoteMethods, RULES_NOTE_LEN}, }; + // docs:start:storage-struct-declaration struct Storage { - // Shows how to create a custom struct in Public - leader: PublicState, + locked: PublicState, + queen: PublicState, + game_rules: ImmutableSingleton, // docs:start:storage-singleton-declaration legendary_card: Singleton, // docs:end:storage-singleton-declaration - // just used for docs example to show how to create a singleton map. + cards: Set, // docs:start:storage-map-singleton-declaration - profiles: Map>, + profiles: Map>, // docs:end:storage-map-singleton-declaration - imm_singleton: ImmutableSingleton, } + // docs:end:storage-struct-declaration + // docs:start:storage-declaration + // docs:start:state_vars-PublicState + // docs:start:state_vars-PublicStateCustomStruct + // docs:start:state_vars-Singleton + // docs:start:state_vars-ImmutableSingleton + // docs:start:state_vars-Set + // docs:start:state_vars-MapSingleton impl Storage { fn init(context: Context) -> Self { Storage { - leader: PublicState::new( + // highlight-next-line:state_vars-PublicState + locked: PublicState::new(context, 1, BoolSerializationMethods), + // highlight-next-line:state_vars-PublicStateCustomStruct + queen: PublicState::new( context, - 1, - LeaderSerializationMethods, + 2, + QueenSerializationMethods, ), + // highlight-next-line:state_vars-ImmutableSingleton + game_rules: ImmutableSingleton::new(context, 3, RulesNoteMethods), + // highlight-next-line:state_vars-Singleton // docs:start:start_vars_singleton - legendary_card: Singleton::new(context, 2, CardNoteMethods), + legendary_card: Singleton::new(context, 4, CardNoteMethods), // docs:end:start_vars_singleton - // just used for docs example (not for game play): - // docs:start:state_vars-MapSingleton + // highlight-next-line:state_vars-Set + cards: Set::new(context, 5, CardNoteMethods), + // highlight-next-line:state_vars-MapSingleton profiles: Map::new( context, - 3, + 6, |context, slot| { - Singleton::new(context, slot, CardNoteMethods) + Singleton::new(context, slot, ProfileNoteMethods) }, ), - // docs:end:state_vars-MapSingleton - imm_singleton: ImmutableSingleton::new(context, 4, CardNoteMethods), } } } + // docs:end:state_vars-PublicState + // docs:end:state_vars-PublicStateCustomStruct + // docs:end:state_vars-Singleton + // docs:end:state_vars-ImmutableSingleton + // docs:end:state_vars-Set + // docs:end:state_vars-MapSingleton + // docs:end:storage-declaration - #[aztec(private)] - fn constructor() {} + global REPLACE_QUEEN_FUNCTION_SELECTOR = 11111111; + global GET_POINTS_OF_COMMON_CARD_FUNCTION_SELECTOR = 11111111; #[aztec(private)] - fn initialize_immutable_singleton(randomness: Field, points: u8) { - let mut new_card = CardNote::new(points, randomness, context.msg_sender()); - storage.imm_singleton.initialize(&mut new_card, true); - } + fn constructor(min_points: u8, max_points: u8, legendary_card_secret: Field) { + let mut game_rules = RulesNote::new(min_points, max_points, Option::some(AztecAddress::zero())); + actions::init_game_rules(storage.game_rules, &mut game_rules); - #[aztec(private)] - // msg_sender() is 0 at deploy time. So created another function - fn initialize_private(randomness: Field, points: u8) { - let mut legendary_card = CardNote::new(points, randomness, context.msg_sender()); - // create and broadcast note - storage.legendary_card.initialize(&mut legendary_card, true); + let mut legendary_card = CardNote::new(0, legendary_card_secret, AztecAddress::zero()); + actions::init_legendary_card(storage.legendary_card, &mut legendary_card); } - #[aztec(private)] - fn update_legendary_card(randomness: Field, points: u8) { - let mut new_card = CardNote::new(points, randomness, context.msg_sender()); - storage.legendary_card.replace(&mut new_card, true); + // docs:start:storage-init + #[aztec(public)] + fn lock() { + // highlight-next-line:storage-init - context.call_public_function( - context.this_address(), - FunctionSelector::from_signature("update_leader((Field),u8)"), - [context.msg_sender().to_field(), points as Field] - ); + storage.locked.write(true); } + // docs:end:storage-init - #[aztec(private)] - fn increase_legendary_points() { - // Ensure `points` > current value - // Also serves as a e2e test that you can `get_note()` and then `replace()` - - // docs:start:state_vars-SingletonGet - let card = storage.legendary_card.get_note(false); - // docs:end:state_vars-SingletonGet + // docs:start:functions-OpenFunction + #[aztec(public)] + fn unlock() { + actions::unlock(storage.locked); + } + // docs:end:functions-OpenFunction - let points = card.points + 1; + #[aztec(public)] + fn replace_queen(account: AztecAddress, points: u8) { + let new_queen = Queen { account, points }; - let mut new_card = CardNote::new(points, card.randomness, context.msg_sender()); - // docs:start:state_vars-SingletonReplace - storage.legendary_card.replace(&mut new_card, true); - // docs:end:state_vars-SingletonReplace + assert(actions::can_replace_queen(storage.queen, new_queen)); - context.call_public_function( - context.this_address(), - FunctionSelector::from_signature("update_leader((Field),u8)"), - [context.msg_sender().to_field(), points as Field] - ); + actions::replace_queen(storage.queen, new_queen); } + // docs:start:state_vars-PublicStateWriteBeforeCall #[aztec(public)] - internal fn update_leader(account: AztecAddress, points: u8) { - let new_leader = Leader { account, points }; - storage.leader.write(new_leader); - } + fn replace_queen_unsafe() { + let account = context.msg_sender(); + let points = actions::get_total_points(storage.cards, account, 0); + + let current_queen = storage.queen.read(); + assert(!account.eq(current_queen.account)); + assert(points > current_queen.points); - unconstrained fn get_leader() -> pub Leader { - storage.leader.read() + AccountContractInterface::at(account.to_field()).send_rewards(current_queen.points); + + let new_queen = Queen { account, points }; + storage.queen.write(new_queen); } + // docs:end:state_vars-PublicStateWriteBeforeCall - unconstrained fn get_legendary_card() -> pub CardNote { - storage.legendary_card.view_note() + // docs:start:functions-SecretFunction + #[aztec(private)] + fn add_common_cards(secrets: [Field; 4]) { + for i in 0..secrets.len() as u8 { + let mut card = CardNote::new(0, secrets[i], AztecAddress::zero()); + actions::add_new_card(storage.cards, &mut card); + } } + // docs:end:functions-SecretFunction + + #[aztec(private)] + fn update_legendary_card(new_points: u8, new_secret: Field) { + let owner = inputs.call_context.msg_sender; + let mut updated_card = CardNote::new(new_points, new_secret, owner); - unconstrained fn is_legendary_initialized() -> pub bool { - storage.legendary_card.is_initialized() + assert(actions::is_valid_card(storage.game_rules, updated_card)); + + actions::update_legendary_card(storage.legendary_card, &mut updated_card); } - unconstrained fn get_imm_card() -> pub CardNote { - storage.imm_singleton.view_note() + #[aztec(private)] + fn become_queen() { + let legendary_card = actions::get_legendary_card(storage.legendary_card); + + let owner = legendary_card.owner; + let result = context.call_private_function( + inputs.call_context.storage_contract_address, + FunctionSelector::from_field(GET_POINTS_OF_COMMON_CARD_FUNCTION_SELECTOR), + [owner.to_field(), 0] + ); + let total_points = legendary_card.points + result[0] as u8; + + context.call_public_function( + inputs.call_context.storage_contract_address, + FunctionSelector::from_field(REPLACE_QUEEN_FUNCTION_SELECTOR), + [owner.to_field(), total_points as Field] + ); } - unconstrained fn is_imm_initialized() -> pub bool { - storage.imm_singleton.is_initialized() + #[aztec(private)] + fn get_points_of_common_cards(account: AztecAddress, offset: u32) { + let mut total_points = 0; + let options = create_account_card_getter_options(account, offset); + let cards = actions::get_cards(storage.cards, options); + for i in 0..cards.len() { + if (cards[i].is_some()) { + let card = cards[i].unwrap_unchecked(); + assert(card.owner.eq(account)); + total_points += card.points; + } + } + + context.return_values.push(total_points as Field); } - // TODO: remove this placeholder once https://github.com/AztecProtocol/aztec-packages/issues/2918 is implemented - unconstrained fn compute_note_hash_and_nullifier( - contract_address: AztecAddress, - nonce: Field, - storage_slot: Field, - serialized_note: [Field; CARD_NOTE_LEN] - ) -> pub [Field; 4] { - let note_header = NoteHeader::new(contract_address, nonce, storage_slot); - note_utils::compute_note_hash_and_nullifier(CardNoteMethods, note_header, serialized_note) + // docs:start:functions-UnconstrainedFunction + unconstrained fn get_total_points(account: AztecAddress) -> pub u8 { + actions::get_total_points(storage.cards, account, 0) } + // docs:end:functions-UnconstrainedFunction /// Macro equivalence section use dep::aztec::abi; @@ -223,4 +269,21 @@ contract DocsExample { // ************************************************************ } // docs:end:simple_macro_example_expanded + + // Cross chain messaging section + // Demonstrates a cross chain message + // docs:start:l1_to_l2_cross_chain_message + #[aztec(private)] + fn send_to_l1() {} + // docs:end:l1_to_l2_cross_chain_message + + // TODO: remove this placeholder once https://github.com/AztecProtocol/aztec-packages/issues/2918 is implemented + unconstrained fn compute_note_hash_and_nullifier( + contract_address: AztecAddress, + nonce: Field, + storage_slot: Field, + serialized_note: [Field; 0] + ) -> pub [Field; 4] { + [0, 0, 0, 0] + } } diff --git a/yarn-project/noir-contracts/contracts/docs_example_contract/src/options.nr b/yarn-project/noir-contracts/contracts/docs_example_contract/src/options.nr index 9742345f8ca7..8fb26e6e7d73 100644 --- a/yarn-project/noir-contracts/contracts/docs_example_contract/src/options.nr +++ b/yarn-project/noir-contracts/contracts/docs_example_contract/src/options.nr @@ -6,8 +6,6 @@ use dep::aztec::protocol_types::{ use dep::aztec::note::note_getter_options::{NoteGetterOptions, Sort, SortOrder}; use dep::std::option::Option; -// Shows how to use NoteGetterOptions and query for notes. - // docs:start:state_vars-NoteGetterOptionsSelectSortOffset pub fn create_account_card_getter_options( account: AztecAddress, diff --git a/yarn-project/noir-contracts/contracts/docs_example_contract/src/types.nr b/yarn-project/noir-contracts/contracts/docs_example_contract/src/types.nr index 630d5c9b87e6..b8bf6dc7bfd8 100644 --- a/yarn-project/noir-contracts/contracts/docs_example_contract/src/types.nr +++ b/yarn-project/noir-contracts/contracts/docs_example_contract/src/types.nr @@ -1,2 +1,4 @@ mod card_note; -mod leader; +mod profile_note; +mod queen; +mod rules_note; diff --git a/yarn-project/noir-contracts/contracts/docs_example_contract/src/types/card_note.nr b/yarn-project/noir-contracts/contracts/docs_example_contract/src/types/card_note.nr index f185518c412f..97da78e65192 100644 --- a/yarn-project/noir-contracts/contracts/docs_example_contract/src/types/card_note.nr +++ b/yarn-project/noir-contracts/contracts/docs_example_contract/src/types/card_note.nr @@ -6,7 +6,7 @@ use dep::aztec::{ utils::compute_note_hash_for_read_or_nullify, }, oracle::{ - nullifier_key::get_nullifier_secret_key, + get_secret_key::get_secret_key, get_public_key::get_public_key, }, log::emit_encrypted_log, @@ -14,37 +14,35 @@ use dep::aztec::{ context::PrivateContext, }; -// Shows how to create a custom note - global CARD_NOTE_LEN: Field = 3; // docs:start:state_vars-CardNote struct CardNote { points: u8, - randomness: Field, + secret: Field, owner: AztecAddress, header: NoteHeader, } // docs:end:state_vars-CardNote impl CardNote { - pub fn new(points: u8, randomness: Field, owner: AztecAddress) -> Self { + pub fn new(points: u8, secret: Field, owner: AztecAddress) -> Self { CardNote { points, - randomness, + secret, owner, header: NoteHeader::empty(), } } pub fn serialize(self) -> [Field; CARD_NOTE_LEN] { - [self.points as Field, self.randomness, self.owner.to_field()] + [self.points as Field, self.secret, self.owner.to_field()] } pub fn deserialize(serialized_note: [Field; CARD_NOTE_LEN]) -> Self { CardNote { points: serialized_note[0] as u8, - randomness: serialized_note[1], + secret: serialized_note[1], owner: AztecAddress::from_field(serialized_note[2]), header: NoteHeader::empty(), } @@ -53,24 +51,14 @@ impl CardNote { pub fn compute_note_hash(self) -> Field { pedersen_hash([ self.points as Field, - self.randomness, + self.secret, self.owner.to_field(), ],0) } - pub fn compute_nullifier(self, context: &mut PrivateContext) -> Field { + pub fn compute_nullifier(self) -> Field { let note_hash_for_nullify = compute_note_hash_for_read_or_nullify(CardNoteMethods, self); - let secret = context.request_nullifier_secret_key(self.owner); - pedersen_hash([ - note_hash_for_nullify, - secret.high, - secret.low, - ],0) - } - - pub fn compute_nullifier_without_context(self) -> Field { - let note_hash_for_nullify = compute_note_hash_for_read_or_nullify(CardNoteMethods, self); - let secret = get_nullifier_secret_key(self.owner); + let secret = get_secret_key(self.owner); pedersen_hash([ note_hash_for_nullify, secret.high, @@ -107,12 +95,8 @@ fn compute_note_hash(note: CardNote) -> Field { note.compute_note_hash() } -fn compute_nullifier(note: CardNote, context: &mut PrivateContext) -> Field { - note.compute_nullifier(context) -} - -fn compute_nullifier_without_context(note: CardNote) -> Field { - note.compute_nullifier_without_context() +fn compute_nullifier(note: CardNote) -> Field { + note.compute_nullifier() } fn get_header(note: CardNote) -> NoteHeader { @@ -133,7 +117,6 @@ global CardNoteMethods = NoteInterface { serialize, compute_note_hash, compute_nullifier, - compute_nullifier_without_context, get_header, set_header, broadcast, diff --git a/yarn-project/noir-contracts/contracts/docs_example_contract/src/types/leader.nr b/yarn-project/noir-contracts/contracts/docs_example_contract/src/types/leader.nr deleted file mode 100644 index ca034261ec00..000000000000 --- a/yarn-project/noir-contracts/contracts/docs_example_contract/src/types/leader.nr +++ /dev/null @@ -1,23 +0,0 @@ -use dep::aztec::protocol_types::address::AztecAddress; -use dep::aztec::types::type_serialization::TypeSerializationInterface; - -// Shows how to create a custom struct in Public -struct Leader { - account: AztecAddress, - points: u8, -} - -global LEADER_SERIALIZED_LEN: Field = 2; - -fn deserialize(fields: [Field; LEADER_SERIALIZED_LEN]) -> Leader { - Leader { account: AztecAddress::from_field(fields[0]), points: fields[1] as u8 } -} - -fn serialize(leader: Leader) -> [Field; LEADER_SERIALIZED_LEN] { - [leader.account.to_field(), leader.points as Field] -} - -global LeaderSerializationMethods = TypeSerializationInterface { - deserialize, - serialize, -}; diff --git a/yarn-project/noir-contracts/contracts/docs_example_contract/src/types/profile_note.nr b/yarn-project/noir-contracts/contracts/docs_example_contract/src/types/profile_note.nr new file mode 100644 index 000000000000..201c796c8052 --- /dev/null +++ b/yarn-project/noir-contracts/contracts/docs_example_contract/src/types/profile_note.nr @@ -0,0 +1,119 @@ +use dep::std::option::Option; +use dep::aztec::{ + protocol_types::address::AztecAddress, + note::{ + note_header::NoteHeader, + note_interface::NoteInterface, + }, + oracle::get_public_key::get_public_key, + log::emit_encrypted_log, + hash::pedersen_hash, + context::PrivateContext, +}; + +global PROFILE_NOTE_LEN: Field = 2; + +struct ProfileNote { + avatar: Field, + xp: Field, + maybe_owner: Option, + header: NoteHeader, +} + +impl ProfileNote { + pub fn new(avatar: Field, xp: Field, maybe_owner: Option) -> Self { + ProfileNote { + avatar, + xp, + maybe_owner, + header: NoteHeader::empty(), + } + } + + pub fn serialize(self) -> [Field; PROFILE_NOTE_LEN] { + [self.avatar, self.xp] + } + + pub fn deserialize(serialized_note: [Field; PROFILE_NOTE_LEN]) -> Self { + ProfileNote { + avatar: serialized_note[0], + xp: serialized_note[1], + maybe_owner: Option::none(), + header: NoteHeader::empty(), + } + } + + pub fn compute_note_hash(self) -> Field { + pedersen_hash([ + self.avatar, + self.xp, + ],0) + } + + pub fn compute_nullifier(_self: Self) -> Field { + assert(false); // Not allowed. + 0 + } + + pub fn set_header(&mut self, header: NoteHeader) { + self.header = header; + } + + pub fn set_owner(&mut self, owner: AztecAddress) { + self.maybe_owner = Option::some(owner); + } + + // Broadcasts the note as an encrypted log on L1. + pub fn broadcast(self, context: &mut PrivateContext, slot: Field) { + assert(self.maybe_owner.is_some(), "Note owner must be set when the broadcast flow is triggered."); + let owner = self.maybe_owner.unwrap_unchecked(); + + let encryption_pub_key = get_public_key(owner); + emit_encrypted_log( + context, + (*context).this_address(), + slot, + encryption_pub_key, + self.serialize(), + ); + } +} + +fn deserialize(serialized_note: [Field; PROFILE_NOTE_LEN]) -> ProfileNote { + ProfileNote::deserialize(serialized_note) +} + +fn serialize(note: ProfileNote) -> [Field; PROFILE_NOTE_LEN] { + note.serialize() +} + +fn compute_note_hash(note: ProfileNote) -> Field { + note.compute_note_hash() +} + +fn compute_nullifier(note: ProfileNote) -> Field { + note.compute_nullifier() +} + +fn get_header(note: ProfileNote) -> NoteHeader { + note.header +} + +fn set_header(note: &mut ProfileNote, header: NoteHeader) { + note.set_header(header) +} + +// Broadcasts the note as an encrypted log on L1. +fn broadcast(context: &mut PrivateContext, slot: Field, note: ProfileNote) { + note.broadcast(context, slot); +} + +global ProfileNoteMethods = NoteInterface { + deserialize, + serialize, + compute_note_hash, + compute_nullifier, + get_header, + set_header, + broadcast, +}; diff --git a/yarn-project/noir-contracts/contracts/docs_example_contract/src/types/queen.nr b/yarn-project/noir-contracts/contracts/docs_example_contract/src/types/queen.nr new file mode 100644 index 000000000000..acd4ed0f7caf --- /dev/null +++ b/yarn-project/noir-contracts/contracts/docs_example_contract/src/types/queen.nr @@ -0,0 +1,26 @@ +use dep::aztec::protocol_types::address::AztecAddress; +use dep::aztec::types::type_serialization::TypeSerializationInterface; + +// docs:start:state_vars-CustomStruct +struct Queen { + account: AztecAddress, + points: u8, +} +// docs:end:state_vars-CustomStruct + +// docs:start:state_vars-PublicStateCustomStruct +global QUEEN_SERIALIZED_LEN: Field = 2; + +fn deserialize(fields: [Field; QUEEN_SERIALIZED_LEN]) -> Queen { + Queen { account: AztecAddress::from_field(fields[0]), points: fields[1] as u8 } +} + +fn serialize(queen: Queen) -> [Field; QUEEN_SERIALIZED_LEN] { + [queen.account.to_field(), queen.points as Field] +} + +global QueenSerializationMethods = TypeSerializationInterface { + deserialize, + serialize, +}; +// docs:end:state_vars-PublicStateCustomStruct diff --git a/yarn-project/noir-contracts/contracts/docs_example_contract/src/types/rules_note.nr b/yarn-project/noir-contracts/contracts/docs_example_contract/src/types/rules_note.nr new file mode 100644 index 000000000000..d3abaecb5d18 --- /dev/null +++ b/yarn-project/noir-contracts/contracts/docs_example_contract/src/types/rules_note.nr @@ -0,0 +1,119 @@ +use dep::std::option::Option; +use dep::aztec::{ + protocol_types::address::AztecAddress, + note::{ + note_header::NoteHeader, + note_interface::NoteInterface, + }, + oracle::get_public_key::get_public_key, + log::emit_encrypted_log, + hash::pedersen_hash, + context::PrivateContext, +}; + +global RULES_NOTE_LEN: Field = 2; + +struct RulesNote { + min_points: u8, + max_points: u8, + maybe_owner: Option, + header: NoteHeader, +} + +impl RulesNote { + pub fn new(min_points: u8, max_points: u8, maybe_owner: Option) -> Self { + RulesNote { + min_points, + max_points, + maybe_owner, + header: NoteHeader::empty(), + } + } + + pub fn serialize(self) -> [Field; RULES_NOTE_LEN] { + [self.min_points as Field, self.max_points as Field] + } + + pub fn deserialize(serialized_note: [Field; RULES_NOTE_LEN]) -> Self { + RulesNote { + min_points: serialized_note[0] as u8, + max_points: serialized_note[1] as u8, + maybe_owner: Option::none(), + header: NoteHeader::empty(), + } + } + + pub fn compute_note_hash(self) -> Field { + pedersen_hash([ + self.min_points as Field, + self.max_points as Field, + ],0) + } + + pub fn compute_nullifier(_self: Self) -> Field { + // Not used + 0 + } + + pub fn set_header(&mut self, header: NoteHeader) { + self.header = header; + } + + pub fn set_owner(&mut self, owner: AztecAddress) { + self.maybe_owner = Option::some(owner); + } + + // Broadcasts the note as an encrypted log on L1. + pub fn broadcast(self, context: &mut PrivateContext, slot: Field) { + assert(self.maybe_owner.is_some(), "Note owner must be set when the broadcast flow is triggered."); + let owner = self.maybe_owner.unwrap_unchecked(); + + let encryption_pub_key = get_public_key(owner); + emit_encrypted_log( + context, + (*context).this_address(), + slot, + encryption_pub_key, + self.serialize(), + ); + } +} + +fn deserialize(serialized_note: [Field; RULES_NOTE_LEN]) -> RulesNote { + RulesNote::deserialize(serialized_note) +} + +fn serialize(note: RulesNote) -> [Field; RULES_NOTE_LEN] { + note.serialize() +} + +fn compute_note_hash(note: RulesNote) -> Field { + note.compute_note_hash() +} + +fn compute_nullifier(note: RulesNote) -> Field { + note.compute_nullifier() +} + +fn get_header(note: RulesNote) -> NoteHeader { + note.header +} + +fn set_header(note: &mut RulesNote, header: NoteHeader) { + note.set_header(header) +} + +// Broadcasts the note as an encrypted log on L1. +fn broadcast(context: &mut PrivateContext, slot: Field, note: RulesNote) { + note.broadcast(context, slot); +} + +global RulesNoteMethods = NoteInterface { + deserialize, + serialize, + compute_note_hash, + compute_nullifier, + get_header, + set_header, + broadcast, +}; diff --git a/yarn-project/noir-contracts/contracts/easy_private_voting_contract/src/main.nr b/yarn-project/noir-contracts/contracts/easy_private_voting_contract/src/main.nr index ceddb93c70c2..54db9e4017a9 100644 --- a/yarn-project/noir-contracts/contracts/easy_private_voting_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/easy_private_voting_contract/src/main.nr @@ -6,6 +6,7 @@ contract EasyPrivateVoting { address::AztecAddress, }, context::{PrivateContext, Context}, + oracle::get_secret_key::get_secret_key, // used to compute nullifier state_vars::{ map::Map, public_state::PublicState,}, types::type_serialization::{ // serialization methods for using booleans and aztec addresses bool_serialization::{BoolSerializationMethods, BOOL_SERIALIZED_LEN}, @@ -70,7 +71,7 @@ contract EasyPrivateVoting { // docs:start:cast_vote #[aztec(private)] // annotation to mark function as private and expose private context fn cast_vote(candidate: Field) { - let secret = context.request_nullifier_secret_key(context.msg_sender()); // get secret key of caller of function + let secret = get_secret_key(context.msg_sender()); // get secret key of caller of function let nullifier = dep::std::hash::pedersen_hash([context.msg_sender().to_field(), secret.low, secret.high]); // compute nullifier with this secret key so others can't descrypt it context.push_new_nullifier(nullifier, 0); // push nullifier context.call_public_function( diff --git a/yarn-project/noir-contracts/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr b/yarn-project/noir-contracts/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr index 779c8debeccc..c0aea096b20b 100644 --- a/yarn-project/noir-contracts/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr +++ b/yarn-project/noir-contracts/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr @@ -6,7 +6,7 @@ use dep::aztec::{ utils::compute_unique_siloed_note_hash, }, oracle::{ - nullifier_key::get_nullifier_secret_key, + get_secret_key::get_secret_key, get_public_key::get_public_key, }, log::emit_encrypted_log, @@ -60,20 +60,9 @@ impl EcdsaPublicKeyNote { [x, last_x, y, last_y, self.owner.to_field()] } - pub fn compute_nullifier(self, context: &mut PrivateContext) -> Field { + pub fn compute_nullifier(self) -> Field { let unique_siloed_note_hash = compute_unique_siloed_note_hash(EcdsaPublicKeyNoteInterface, self); - let secret = context.request_nullifier_secret_key(self.owner); - // TODO(#1205) Should use a non-zero generator index. - pedersen_hash([ - unique_siloed_note_hash, - secret.low, - secret.high, - ],0) - } - - pub fn compute_nullifier_without_context(self) -> Field { - let unique_siloed_note_hash = compute_unique_siloed_note_hash(EcdsaPublicKeyNoteInterface, self); - let secret = get_nullifier_secret_key(self.owner); + let secret = get_secret_key(self.owner); // TODO(#1205) Should use a non-zero generator index. pedersen_hash([ unique_siloed_note_hash, @@ -127,12 +116,8 @@ fn compute_note_hash(note: EcdsaPublicKeyNote) -> Field { pedersen_hash(note.serialize(), 0) } -fn compute_nullifier(note: EcdsaPublicKeyNote, context: &mut PrivateContext) -> Field { - note.compute_nullifier(context) -} - -fn compute_nullifier_without_context(note: EcdsaPublicKeyNote) -> Field { - note.compute_nullifier_without_context() +fn compute_nullifier(note: EcdsaPublicKeyNote) -> Field { + note.compute_nullifier() } fn get_header(note: EcdsaPublicKeyNote) -> NoteHeader { @@ -153,7 +138,6 @@ global EcdsaPublicKeyNoteInterface = NoteInterface { serialize, compute_note_hash, compute_nullifier, - compute_nullifier_without_context, get_header, set_header, broadcast, diff --git a/yarn-project/noir-contracts/contracts/ecdsa_account_contract/src/main.nr b/yarn-project/noir-contracts/contracts/ecdsa_account_contract/src/main.nr index da730b23c32f..a12e0c02600f 100644 --- a/yarn-project/noir-contracts/contracts/ecdsa_account_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/ecdsa_account_contract/src/main.nr @@ -45,7 +45,7 @@ contract EcdsaAccount { fn constructor(signing_pub_key_x: pub [u8; 32], signing_pub_key_y: pub [u8; 32]) { let this = context.this_address(); let mut pub_key_note = EcdsaPublicKeyNote::new(signing_pub_key_x, signing_pub_key_y, this); - storage.public_key.initialize(&mut pub_key_note, true); + storage.public_key.initialize(&mut pub_key_note, Option::none(), true); } // Note: If you globally change the entrypoint signature don't forget to update default_entrypoint.ts diff --git a/yarn-project/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr b/yarn-project/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr index 5b99fdd60bbc..f0882caff1b5 100644 --- a/yarn-project/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr @@ -23,11 +23,11 @@ contract InclusionProofs { note_header::NoteHeader, utils as note_utils, }, - // docs:start:imports + history::{ contract_inclusion::{ prove_contract_inclusion, - }, + }, note_inclusion::{ prove_note_commitment_inclusion, prove_note_inclusion, @@ -46,11 +46,9 @@ contract InclusionProofs { prove_public_value_inclusion, }, }, - // docs:end:imports }; - // docs:start:value_note_imports use dep::value_note::value_note::{ValueNote, ValueNoteMethods, VALUE_NOTE_LEN}; - // docs:end:value_note_imports + struct Storage { private_values: Map>, public_value: PublicState, @@ -86,7 +84,6 @@ contract InclusionProofs { storage.public_value.write(value); } - // docs:start:create_note // Creates a value note owned by `owner`. #[aztec(private)] fn create_note(owner: AztecAddress, value: Field) { @@ -94,7 +91,6 @@ contract InclusionProofs { let mut note = ValueNote::new(value, owner); owner_private_values.insert(&mut note, true); } - // docs:end:create_note // Proves that the owner owned a ValueNote at block `block_number`. #[aztec(private)] @@ -106,24 +102,20 @@ contract InclusionProofs { // PXE performs note commitment inclusion check when you add a new note). spare_commitment: Field ) { - // docs:start:get_note_from_pxe // 1) Get the note from PXE. let private_values = storage.private_values.at(owner); let options = NoteGetterOptions::new().select(1, owner.to_field()).set_limit(1); let notes = private_values.get_notes(options); let maybe_note = notes[0]; - // docs:end:get_note_from_pxe // 2) Prove the note inclusion if maybe_note.is_some() { - // docs:start:prove_note_inclusion prove_note_inclusion( ValueNoteMethods, maybe_note.unwrap_unchecked(), block_number, context ); - // docs:end:prove_note_inclusion } else { // Note was not found so we will prove inclusion of the spare commitment prove_note_commitment_inclusion(spare_commitment, block_number, context); @@ -148,19 +140,15 @@ contract InclusionProofs { // 3) Compute the nullifier from the note if maybe_note.is_some() { - // docs:start:prove_note_not_nullified prove_note_not_nullified( ValueNoteMethods, maybe_note.unwrap_unchecked(), block_number, - &mut context + context ); - // docs:end:prove_note_not_nullified } else { // Note was not found so we will use the spare nullifier - // docs:start:prove_nullifier_non_inclusion prove_nullifier_non_inclusion(spare_nullifier, block_number, context); - // docs:end:prove_nullifier_non_inclusion }; } @@ -176,12 +164,9 @@ contract InclusionProofs { let note = notes[0].unwrap(); // 2) Prove the note validity - // docs:start:prove_note_validity - prove_note_validity(ValueNoteMethods, note, block_number, &mut context); - // docs:end:prove_note_validity + prove_note_validity(ValueNoteMethods, note, block_number, context); } - // docs:start:nullify_note #[aztec(private)] fn nullify_note(owner: AztecAddress) { let private_values = storage.private_values.at(owner); @@ -191,7 +176,6 @@ contract InclusionProofs { private_values.remove(note); } - // docs:end:nullify_note // Proves nullifier existed at block `block_number`. // Note: I am not getting a nullifier of the note that was created in this contract in this function because it is @@ -201,9 +185,7 @@ contract InclusionProofs { nullifier: Field, block_number: u32 // The block at which we'll prove that the nullifier not exists in the tree ) { - // docs:start:prove_nullifier_inclusion prove_nullifier_inclusion(nullifier, block_number, context); - // docs:end:prove_nullifier_inclusion } #[aztec(private)] diff --git a/yarn-project/noir-contracts/contracts/schnorr_account_contract/src/main.nr b/yarn-project/noir-contracts/contracts/schnorr_account_contract/src/main.nr index 001437e9c9df..77203a70388a 100644 --- a/yarn-project/noir-contracts/contracts/schnorr_account_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/schnorr_account_contract/src/main.nr @@ -46,7 +46,7 @@ contract SchnorrAccount { let this = context.this_address(); // docs:start:initialize let mut pub_key_note = PublicKeyNote::new(signing_pub_key_x, signing_pub_key_y, this); - storage.signing_public_key.initialize(&mut pub_key_note, true); + storage.signing_public_key.initialize(&mut pub_key_note, Option::none(), true); // docs:end:initialize } diff --git a/yarn-project/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr b/yarn-project/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr index 2db16db6be3b..3d3eb1ecfa1a 100644 --- a/yarn-project/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr +++ b/yarn-project/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr @@ -6,7 +6,7 @@ use dep::aztec::{ }, hash::pedersen_hash, oracle::{ - nullifier_key::get_nullifier_secret_key, + get_secret_key::get_secret_key, get_public_key::get_public_key, }, log::emit_encrypted_log, @@ -40,20 +40,9 @@ impl PublicKeyNote { [self.x, self.y, self.owner.to_field()] } - pub fn compute_nullifier(self, context: &mut PrivateContext) -> Field { + pub fn compute_nullifier(self) -> Field { let unique_siloed_note_hash = compute_unique_siloed_note_hash(PublicKeyNoteMethods, self); - let secret = context.request_nullifier_secret_key(self.owner); - // TODO(#1205) Should use a non-zero generator index. - pedersen_hash([ - unique_siloed_note_hash, - secret.low, - secret.high, - ],0) - } - - pub fn compute_nullifier_without_context(self) -> Field { - let unique_siloed_note_hash = compute_unique_siloed_note_hash(PublicKeyNoteMethods, self); - let secret = get_nullifier_secret_key(self.owner); + let secret = get_secret_key(self.owner); // TODO(#1205) Should use a non-zero generator index. pedersen_hash([ unique_siloed_note_hash, @@ -97,12 +86,8 @@ fn compute_note_hash(note: PublicKeyNote) -> Field { pedersen_hash(note.serialize(), 0) } -fn compute_nullifier(note: PublicKeyNote, context: &mut PrivateContext) -> Field { - note.compute_nullifier(context) -} - -fn compute_nullifier_without_context(note: PublicKeyNote) -> Field { - note.compute_nullifier_without_context() +fn compute_nullifier(note: PublicKeyNote) -> Field { + note.compute_nullifier() } fn get_header(note: PublicKeyNote) -> NoteHeader { @@ -123,7 +108,6 @@ global PublicKeyNoteMethods = NoteInterface { serialize, compute_note_hash, compute_nullifier, - compute_nullifier_without_context, get_header, set_header, broadcast, diff --git a/yarn-project/noir-contracts/contracts/test_contract/src/main.nr b/yarn-project/noir-contracts/contracts/test_contract/src/main.nr index 6402ec444e81..aac608c1bd82 100644 --- a/yarn-project/noir-contracts/contracts/test_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/test_contract/src/main.nr @@ -193,7 +193,7 @@ contract Test { #[aztec(private)] fn set_constant(value: Field) { let mut note = FieldNote::new(value); - storage.example_constant.initialize(&mut note, false); + storage.example_constant.initialize(&mut note, Option::none(), false); } unconstrained fn get_constant() -> pub Field { diff --git a/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/main.nr b/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/main.nr index 46ff827b00c9..0845c0ec0daa 100644 --- a/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/main.nr @@ -110,7 +110,7 @@ contract TokenBlacklist { #[aztec(private)] fn constructor(admin: AztecAddress, slow_updates_contract: AztecAddress) { let mut slow_note = FieldNote::new(slow_updates_contract.to_field()); - storage.slow_update.initialize(&mut slow_note, false); + storage.slow_update.initialize(&mut slow_note, Option::none(), false); // docs:end:constructor let selector = FunctionSelector::from_signature("_initialize((Field),(Field))"); context.call_public_function( diff --git a/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/balance_set.nr b/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/balance_set.nr index e63efeab3064..f0ecb0797296 100644 --- a/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/balance_set.nr +++ b/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/balance_set.nr @@ -16,6 +16,12 @@ use dep::aztec::note::{ note_interface::NoteInterface, utils::compute_note_hash_for_read_or_nullify, }; +use dep::aztec::oracle::{ + rand::rand, + get_secret_key::get_secret_key, + get_public_key::get_public_key, +}; + use crate::types::token_note::{TokenNote, TOKEN_NOTE_LEN, TokenNoteMethods}; // A set implementing standard manipulation of balances. diff --git a/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr b/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr index 41e921d16d0c..8a2275361911 100644 --- a/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr +++ b/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr @@ -13,7 +13,7 @@ use dep::aztec::{ }; use dep::aztec::oracle::{ rand::rand, - nullifier_key::get_nullifier_secret_key, + get_secret_key::get_secret_key, get_public_key::get_public_key, }; use dep::safe_math::SafeU120; @@ -68,9 +68,9 @@ impl TokenNote { } // docs:start:nullifier - pub fn compute_nullifier(self, context: &mut PrivateContext) -> Field { + pub fn compute_nullifier(self) -> Field { let note_hash_for_nullify = compute_note_hash_for_read_or_nullify(TokenNoteMethods, self); - let secret = context.request_nullifier_secret_key(self.owner); + let secret = get_secret_key(self.owner); // TODO(#1205) Should use a non-zero generator index. pedersen_hash([ note_hash_for_nullify, @@ -80,17 +80,6 @@ impl TokenNote { } // docs:end:nullifier - pub fn compute_nullifier_without_context(self) -> Field { - let note_hash_for_nullify = compute_note_hash_for_read_or_nullify(TokenNoteMethods, self); - let secret = get_nullifier_secret_key(self.owner); - // TODO(#1205) Should use a non-zero generator index. - pedersen_hash([ - note_hash_for_nullify, - secret.low, - secret.high, - ],0) - } - pub fn set_header(&mut self, header: NoteHeader) { self.header = header; } @@ -123,12 +112,8 @@ fn compute_note_hash(note: TokenNote) -> Field { note.compute_note_hash() } -fn compute_nullifier(note: TokenNote, context: &mut PrivateContext) -> Field { - note.compute_nullifier(context) -} - -fn compute_nullifier_without_context(note: TokenNote) -> Field { - note.compute_nullifier_without_context() +fn compute_nullifier(note: TokenNote) -> Field { + note.compute_nullifier() } fn get_header(note: TokenNote) -> NoteHeader { @@ -149,7 +134,6 @@ global TokenNoteMethods = NoteInterface { serialize, compute_note_hash, compute_nullifier, - compute_nullifier_without_context, get_header, set_header, broadcast, diff --git a/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr b/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr index 98867d1225cc..12772aed42fe 100644 --- a/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr +++ b/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr @@ -70,11 +70,7 @@ impl TransparentNote { ],0) } - pub fn compute_nullifier(self, _context: &mut PrivateContext) -> Field { - self.compute_nullifier_without_context() - } - - pub fn compute_nullifier_without_context(self) -> Field { + pub fn compute_nullifier(self) -> Field { // TODO(#1386): should use `compute_note_hash_for_read_or_nullify` once public functions inject nonce! let siloed_note_hash = compute_siloed_note_hash(TransparentNoteMethods, self); // TODO(#1205) Should use a non-zero generator index. @@ -106,12 +102,8 @@ fn compute_note_hash(note: TransparentNote) -> Field { note.compute_note_hash() } -fn compute_nullifier(note: TransparentNote, context: &mut PrivateContext) -> Field { - note.compute_nullifier(context) -} - -fn compute_nullifier_without_context(note: TransparentNote) -> Field { - note.compute_nullifier_without_context() +fn compute_nullifier(note: TransparentNote) -> Field { + note.compute_nullifier() } fn get_header(note: TransparentNote) -> NoteHeader { @@ -131,7 +123,6 @@ global TransparentNoteMethods = NoteInterface { serialize, compute_note_hash, compute_nullifier, - compute_nullifier_without_context, get_header, set_header, broadcast, diff --git a/yarn-project/noir-contracts/contracts/token_contract/src/types/balance_set.nr b/yarn-project/noir-contracts/contracts/token_contract/src/types/balance_set.nr index fc2303da23b2..80b6a2ceeddd 100644 --- a/yarn-project/noir-contracts/contracts/token_contract/src/types/balance_set.nr +++ b/yarn-project/noir-contracts/contracts/token_contract/src/types/balance_set.nr @@ -18,6 +18,12 @@ use dep::aztec::note::{ note_interface::NoteInterface, utils::compute_note_hash_for_read_or_nullify, }; +use dep::aztec::oracle::{ + rand::rand, + get_secret_key::get_secret_key, + get_public_key::get_public_key, +}; + use crate::types::token_note::{TokenNote, TOKEN_NOTE_LEN, TokenNoteMethods}; // A set implementing standard manipulation of balances. diff --git a/yarn-project/noir-contracts/contracts/token_contract/src/types/token_note.nr b/yarn-project/noir-contracts/contracts/token_contract/src/types/token_note.nr index f87ccd3cef2d..d2d9ef68f1fb 100644 --- a/yarn-project/noir-contracts/contracts/token_contract/src/types/token_note.nr +++ b/yarn-project/noir-contracts/contracts/token_contract/src/types/token_note.nr @@ -17,7 +17,7 @@ use dep::aztec::{ }; use dep::aztec::oracle::{ rand::rand, - nullifier_key::get_nullifier_secret_key, + get_secret_key::get_secret_key, get_public_key::get_public_key, }; use dep::safe_math::SafeU120; @@ -72,9 +72,9 @@ impl TokenNote { } // docs:start:nullifier - pub fn compute_nullifier(self, context: &mut PrivateContext) -> Field { + pub fn compute_nullifier(self) -> Field { let note_hash_for_nullify = compute_note_hash_for_read_or_nullify(TokenNoteMethods, self); - let secret = context.request_nullifier_secret_key(self.owner); + let secret = get_secret_key(self.owner); // TODO(#1205) Should use a non-zero generator index. pedersen_hash([ note_hash_for_nullify, @@ -84,17 +84,6 @@ impl TokenNote { } // docs:end:nullifier - pub fn compute_nullifier_without_context(self) -> Field { - let note_hash_for_nullify = compute_note_hash_for_read_or_nullify(TokenNoteMethods, self); - let secret = get_nullifier_secret_key(self.owner); - // TODO(#1205) Should use a non-zero generator index. - pedersen_hash([ - note_hash_for_nullify, - secret.low, - secret.high, - ],0) - } - pub fn set_header(&mut self, header: NoteHeader) { self.header = header; } @@ -127,12 +116,8 @@ fn compute_note_hash(note: TokenNote) -> Field { note.compute_note_hash() } -fn compute_nullifier(note: TokenNote, context: &mut PrivateContext) -> Field { - note.compute_nullifier(context) -} - -fn compute_nullifier_without_context(note: TokenNote) -> Field { - note.compute_nullifier_without_context() +fn compute_nullifier(note: TokenNote) -> Field { + note.compute_nullifier() } fn get_header(note: TokenNote) -> NoteHeader { @@ -153,7 +138,6 @@ global TokenNoteMethods = NoteInterface { serialize, compute_note_hash, compute_nullifier, - compute_nullifier_without_context, get_header, set_header, broadcast, diff --git a/yarn-project/noir-contracts/contracts/token_contract/src/types/transparent_note.nr b/yarn-project/noir-contracts/contracts/token_contract/src/types/transparent_note.nr index deb2bcdf6f1b..034b4b3390f7 100644 --- a/yarn-project/noir-contracts/contracts/token_contract/src/types/transparent_note.nr +++ b/yarn-project/noir-contracts/contracts/token_contract/src/types/transparent_note.nr @@ -70,11 +70,7 @@ impl TransparentNote { ],0) } - pub fn compute_nullifier(self, _context: &mut PrivateContext) -> Field { - self.compute_nullifier_without_context() - } - - pub fn compute_nullifier_without_context(self) -> Field { + pub fn compute_nullifier(self) -> Field { // TODO(#1386): should use `compute_note_hash_for_read_or_nullify` once public functions inject nonce! let siloed_note_hash = compute_siloed_note_hash(TransparentNoteMethods, self); // TODO(#1205) Should use a non-zero generator index. @@ -106,12 +102,8 @@ fn compute_note_hash(note: TransparentNote) -> Field { note.compute_note_hash() } -fn compute_nullifier(note: TransparentNote, context: &mut PrivateContext) -> Field { - note.compute_nullifier(context) -} - -fn compute_nullifier_without_context(note: TransparentNote) -> Field { - note.compute_nullifier_without_context() +fn compute_nullifier(note: TransparentNote) -> Field { + note.compute_nullifier() } fn get_header(note: TransparentNote) -> NoteHeader { @@ -131,7 +123,6 @@ global TransparentNoteMethods = NoteInterface { serialize, compute_note_hash, compute_nullifier, - compute_nullifier_without_context, get_header, set_header, broadcast, diff --git a/yarn-project/noir-protocol-circuits/src/crates/types/src/constants.nr b/yarn-project/noir-protocol-circuits/src/crates/types/src/constants.nr index ae5fa0d5e191..c0b05053066e 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/types/src/constants.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/types/src/constants.nr @@ -86,7 +86,7 @@ global ARGS_HASH_CHUNK_COUNT: u32 = 16; // Move these constants to a noir file once the issue bellow is resolved: // https://github.com/noir-lang/noir/issues/1734 global L1_TO_L2_MESSAGE_LENGTH: Field = 8; -global L1_TO_L2_MESSAGE_ORACLE_CALL_LENGTH: Field = 25; +global L1_TO_L2_MESSAGE_ORACLE_CALL_LENGTH: Field = 26; global MAX_NOTE_FIELDS_LENGTH: Field = 20; // GET_NOTE_ORACLE_RETURN_LENGT = MAX_NOTE_FIELDS_LENGTH + 1 + 2 // The plus 1 is 1 extra field for nonce. diff --git a/yarn-project/pxe/src/simulator_oracle/index.ts b/yarn-project/pxe/src/simulator_oracle/index.ts index 50d62d00996f..1caa8fb88452 100644 --- a/yarn-project/pxe/src/simulator_oracle/index.ts +++ b/yarn-project/pxe/src/simulator_oracle/index.ts @@ -1,4 +1,4 @@ -import { DBOracle, KeyPair, MessageLoadOracleInputs } from '@aztec/acir-simulator'; +import { DBOracle, MessageLoadOracleInputs } from '@aztec/acir-simulator'; import { KeyStore, L2Block, @@ -7,7 +7,16 @@ import { PublicDataWitness, StateInfoProvider, } from '@aztec/circuit-types'; -import { AztecAddress, BlockHeader, CompleteAddress, EthAddress, Fr, FunctionSelector } from '@aztec/circuits.js'; +import { + AztecAddress, + BlockHeader, + CompleteAddress, + EthAddress, + Fr, + FunctionSelector, + GrumpkinPrivateKey, + PublicKey, +} from '@aztec/circuits.js'; import { FunctionArtifactWithDebugMetadata } from '@aztec/foundation/abi'; import { createDebugLogger } from '@aztec/foundation/log'; @@ -26,11 +35,8 @@ export class SimulatorOracle implements DBOracle { private log = createDebugLogger('aztec:pxe:simulator_oracle'), ) {} - async getNullifierKeyPair(accountAddress: AztecAddress, contractAddress: AztecAddress): Promise { - const accountPublicKey = (await this.db.getCompleteAddress(accountAddress))!.publicKey; - const publicKey = await this.keyStore.getNullifierPublicKey(accountPublicKey); - const secretKey = await this.keyStore.getSiloedNullifierSecretKey(accountPublicKey, contractAddress); - return { publicKey, secretKey }; + getSecretKey(_contractAddress: AztecAddress, pubKey: PublicKey): Promise { + return this.keyStore.getAccountPrivateKey(pubKey); } async getCompleteAddress(address: AztecAddress): Promise { diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock index 53d6be964455..5e7bbb294741 100644 --- a/yarn-project/yarn.lock +++ b/yarn-project/yarn.lock @@ -2784,7 +2784,7 @@ __metadata: resolution: "@noir-lang/backend_barretenberg@portal:../noir/packages/backend_barretenberg::locator=%40aztec%2Faztec3-packages%40workspace%3A." dependencies: "@aztec/bb.js": 0.19.0 - "@noir-lang/types": 0.23.0 + "@noir-lang/types": 0.22.0 fflate: ^0.8.0 languageName: node linkType: soft @@ -2793,9 +2793,9 @@ __metadata: version: 0.0.0-use.local resolution: "@noir-lang/noir_js@portal:../noir/packages/noir_js::locator=%40aztec%2Faztec3-packages%40workspace%3A." dependencies: - "@noir-lang/acvm_js": 0.39.0 - "@noir-lang/noirc_abi": 0.23.0 - "@noir-lang/types": 0.23.0 + "@noir-lang/acvm_js": 0.38.0 + "@noir-lang/noirc_abi": 0.22.0 + "@noir-lang/types": 0.22.0 languageName: node linkType: soft @@ -2809,7 +2809,7 @@ __metadata: version: 0.0.0-use.local resolution: "@noir-lang/types@portal:../noir/packages/types::locator=%40aztec%2Faztec3-packages%40workspace%3A." dependencies: - "@noir-lang/noirc_abi": 0.23.0 + "@noir-lang/noirc_abi": 0.22.0 languageName: node linkType: soft From ef7b56781c97509f6a64dff380f6a4b705bfc825 Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Wed, 24 Jan 2024 16:04:00 -0500 Subject: [PATCH 03/27] Revert "Revert "Merge branch 'master' into jc/update-contract-storage"" This reverts commit 11d82f9aaa55f0c4b8545b80423baa6e4d95d6e1. --- .circleci/config.yml | 26 +- .release-please-manifest.json | 6 +- CHANGELOG.md | 66 + barretenberg/.gitrepo | 4 +- barretenberg/CHANGELOG.md | 24 + barretenberg/acir_tests/Dockerfile.bb | 9 +- barretenberg/acir_tests/Dockerfile.bb.js | 5 +- .../flows/accumulate_and_verify_goblin.sh | 6 + barretenberg/acir_tests/run_acir_tests.sh | 1 + barretenberg/cpp/CMakeLists.txt | 2 +- barretenberg/cpp/pil/avm/README.txt | 21 + barretenberg/cpp/pil/avm/alu_chip.pil | 201 + barretenberg/cpp/pil/avm/avm_mini.pil | 13 +- .../cpp/src/barretenberg/bb/get_bn254_crs.cpp | 20 +- .../cpp/src/barretenberg/bb/get_bn254_crs.hpp | 6 +- .../src/barretenberg/bb/get_grumpkin_crs.cpp | 8 +- .../src/barretenberg/bb/get_grumpkin_crs.hpp | 6 +- barretenberg/cpp/src/barretenberg/bb/main.cpp | 61 +- .../src/barretenberg/benchmark/CMakeLists.txt | 1 + .../benchmark/basics_bench/basics.bench.cpp | 26 +- .../benchmark/commit_bench/CMakeLists.txt | 18 + .../benchmark/commit_bench/commit.bench.cpp | 38 + .../benchmark/commit_bench/main.bench.cpp | 3 + .../benchmark/goblin_bench/eccvm.bench.cpp | 2 +- .../benchmark/goblin_bench/goblin.bench.cpp | 3 +- .../benchmark/ipa_bench/ipa.bench.cpp | 3 +- .../plonk_bench/standard_plonk.bench.cpp | 6 +- .../protogalaxy_bench/protogalaxy.bench.cpp | 6 +- .../relations_bench/barycentric.bench.cpp | 2 +- .../relations_bench/relations.bench.cpp | 2 +- ...enchmark_utilities.hpp => mock_proofs.hpp} | 83 +- .../ultra_bench/ultra_honk.bench.cpp | 20 +- .../ultra_bench/ultra_honk_rounds.bench.cpp | 6 +- .../ultra_bench/ultra_plonk.bench.cpp | 20 +- .../ultra_bench/ultra_plonk_rounds.bench.cpp | 6 +- .../benchmark/widgets_bench/widget.bench.cpp | 6 +- .../commitment_key.test.hpp | 4 +- .../commitment_schemes/gemini/gemini.test.cpp | 7 +- .../commitment_schemes/ipa/ipa.test.cpp | 6 +- .../commitment_schemes/kzg/kzg.test.cpp | 2 +- .../cpp/src/barretenberg/common/ref_array.hpp | 5 +- .../src/barretenberg/common/ref_vector.hpp | 5 +- .../cpp/src/barretenberg/common/std_array.hpp | 4 +- .../src/barretenberg/common/std_vector.hpp | 5 +- .../cpp/src/barretenberg/common/thread.hpp | 19 +- .../src/barretenberg/crypto/aes128/aes128.cpp | 29 +- .../src/barretenberg/crypto/aes128/aes128.hpp | 18 +- .../crypto/aes128/aes128.test.cpp | 10 +- .../src/barretenberg/crypto/aes128/c_bind.cpp | 4 +- .../crypto/blake2s/blake2-impl.hpp | 4 +- .../barretenberg/crypto/blake2s/blake2s.cpp | 10 +- .../barretenberg/crypto/blake2s/blake2s.hpp | 4 +- .../crypto/blake2s/blake2s.test.cpp | 4 +- .../barretenberg/crypto/blake2s/c_bind.cpp | 6 +- .../crypto/blake3s/blake3s.test.cpp | 4 +- .../src/barretenberg/crypto/ecdsa/c_bind.cpp | 12 +- .../src/barretenberg/crypto/ecdsa/ecdsa.hpp | 24 +- .../barretenberg/crypto/ecdsa/ecdsa.test.cpp | 56 +- .../barretenberg/crypto/ecdsa/ecdsa_impl.hpp | 16 +- .../crypto/generators/generator_data.hpp | 4 +- .../barretenberg/crypto/hashers/hashers.hpp | 2 +- .../cpp/src/barretenberg/crypto/hmac/hmac.hpp | 8 +- .../barretenberg/crypto/hmac/hmac.test.cpp | 2 + .../crypto/pedersen_commitment/pedersen.cpp | 4 +- .../crypto/pedersen_commitment/pedersen.hpp | 4 +- .../pedersen_commitment/pedersen.test.cpp | 4 +- .../crypto/pedersen_hash/pedersen.cpp | 4 +- .../crypto/pedersen_hash/pedersen.hpp | 4 +- .../crypto/pedersen_hash/pedersen.test.cpp | 4 +- .../crypto/poseidon2/poseidon2.bench.cpp | 5 +- .../crypto/poseidon2/poseidon2.cpp | 4 +- .../crypto/poseidon2/poseidon2.hpp | 4 +- .../crypto/poseidon2/poseidon2.test.cpp | 34 +- .../poseidon2/poseidon2_cpp_params.sage | 4 +- .../crypto/poseidon2/poseidon2_params.hpp | 4 +- .../poseidon2/poseidon2_permutation.hpp | 4 +- .../poseidon2/poseidon2_permutation.test.cpp | 38 +- .../crypto/poseidon2/sponge/sponge.hpp | 4 +- .../barretenberg/crypto/schnorr/c_bind.cpp | 24 +- .../barretenberg/crypto/schnorr/c_bind.hpp | 2 +- .../barretenberg/crypto/schnorr/multisig.hpp | 34 +- .../crypto/schnorr/multisig.test.cpp | 20 +- .../crypto/schnorr/proof_of_possession.hpp | 16 +- .../schnorr/proof_of_possession.test.cpp | 14 +- .../barretenberg/crypto/schnorr/schnorr.hpp | 24 +- .../barretenberg/crypto/schnorr/schnorr.tcc | 22 +- .../crypto/schnorr/schnorr.test.cpp | 62 +- .../dsl/acir_format/acir_format.cpp | 16 +- .../dsl/acir_format/acir_format.hpp | 15 +- .../dsl/acir_format/acir_format.test.cpp | 182 +- .../acir_format/acir_to_constraint_buf.hpp | 43 +- .../dsl/acir_format/bigint_constraint.cpp | 33 + .../dsl/acir_format/bigint_constraint.hpp | 35 + .../acir_format/bigint_constraint.test.cpp | 88 + .../dsl/acir_format/block_constraint.test.cpp | 23 +- .../dsl/acir_format/ecdsa_secp256k1.cpp | 26 +- .../dsl/acir_format/ecdsa_secp256k1.hpp | 2 +- .../dsl/acir_format/ecdsa_secp256k1.test.cpp | 25 +- .../dsl/acir_format/ecdsa_secp256r1.cpp | 24 +- .../dsl/acir_format/ecdsa_secp256r1.test.cpp | 38 +- .../acir_format/recursion_constraint.test.cpp | 95 +- .../dsl/acir_format/schnorr_verify.cpp | 10 +- .../dsl/acir_format/serde/acir.hpp | 1318 ++++-- .../dsl/acir_proofs/acir_composer.cpp | 31 +- .../dsl/acir_proofs/acir_composer.hpp | 10 +- .../barretenberg/dsl/acir_proofs/c_bind.cpp | 47 +- .../barretenberg/dsl/acir_proofs/c_bind.hpp | 37 +- .../dsl/acir_proofs/goblin_acir_composer.cpp | 65 + .../dsl/acir_proofs/goblin_acir_composer.hpp | 73 + .../cpp/src/barretenberg/dsl/types.hpp | 2 +- .../barretenberg/ecc/curves/bn254/bn254.hpp | 4 +- .../barretenberg/ecc/curves/bn254/g1.test.cpp | 4 +- .../barretenberg/ecc/curves/bn254/g2.test.cpp | 2 +- .../ecc/curves/grumpkin/grumpkin.hpp | 4 +- .../ecc/curves/grumpkin/grumpkin.test.cpp | 5 +- .../ecc/curves/secp256k1/secp256k1.hpp | 4 +- .../ecc/curves/secp256k1/secp256k1.test.cpp | 9 +- .../ecc/curves/secp256r1/secp256r1.hpp | 4 +- .../ecc/curves/secp256r1/secp256r1.test.cpp | 9 +- .../src/barretenberg/ecc/fields/field12.hpp | 2 +- .../src/barretenberg/ecc/fields/field2.hpp | 2 +- .../ecc/fields/field2_declarations.hpp | 8 +- .../src/barretenberg/ecc/fields/field6.hpp | 2 +- .../ecc/fields/field_declarations.hpp | 9 +- .../barretenberg/ecc/fields/field_impl.hpp | 4 +- .../ecc/groups/affine_element.hpp | 6 +- .../ecc/groups/affine_element.test.cpp | 2 - .../ecc/groups/affine_element_impl.hpp | 9 +- .../src/barretenberg/ecc/groups/element.hpp | 4 +- .../barretenberg/ecc/groups/element_impl.hpp | 4 +- .../src/barretenberg/ecc/groups/wnaf.test.cpp | 4 +- .../eccvm/eccvm_composer.test.cpp | 14 +- .../eccvm/eccvm_transcript.test.cpp | 11 +- .../cpp/src/barretenberg/flavor/ecc_vm.hpp | 6 +- .../src/barretenberg/flavor/flavor.test.cpp | 10 +- .../flavor/generated/AvmMini_flavor.hpp | 300 +- .../flavor/generated/Toy_flavor.hpp | 6 +- .../src/barretenberg/flavor/goblin_ultra.hpp | 67 +- .../flavor/goblin_ultra_recursive.hpp | 20 +- .../cpp/src/barretenberg/flavor/ultra.hpp | 48 +- .../barretenberg/flavor/ultra_recursive.hpp | 96 +- .../goblin/full_goblin_recursion.test.cpp | 10 +- .../cpp/src/barretenberg/goblin/goblin.hpp | 158 +- .../grumpkin_srs_gen/grumpkin_srs_gen.cpp | 2 +- .../join_split_example/constants.hpp | 6 +- .../fixtures/user_context.hpp | 14 +- .../proofs/compute_circuit_data.hpp | 8 +- .../inner_proof_data/inner_proof_data.cpp | 38 +- .../inner_proof_data/inner_proof_data.hpp | 44 +- .../inner_proof_data.test.cpp | 4 +- .../join_split/compute_circuit_data.cpp | 14 +- .../join_split/compute_circuit_data.hpp | 8 +- .../join_split/compute_signing_data.cpp | 14 +- .../join_split/compute_signing_data.hpp | 8 +- .../proofs/join_split/create_proof.hpp | 8 +- .../proofs/join_split/join_split.cpp | 12 +- .../proofs/join_split/join_split.hpp | 8 +- .../proofs/join_split/join_split.test.cpp | 158 +- .../proofs/join_split/join_split_circuit.cpp | 28 +- .../proofs/join_split/join_split_circuit.hpp | 10 +- .../join_split/join_split_js_parity.test.cpp | 14 +- .../proofs/join_split/join_split_tx.cpp | 8 +- .../proofs/join_split/join_split_tx.hpp | 10 +- .../proofs/join_split/join_split_tx.test.cpp | 4 +- .../proofs/join_split/sign_join_split_tx.cpp | 18 +- .../proofs/join_split/sign_join_split_tx.hpp | 12 +- .../proofs/join_split/verify_signature.hpp | 12 +- .../proofs/mock/mock_circuit.hpp | 8 +- .../proofs/mock/mock_circuit.test.cpp | 8 +- .../notes/circuit/account/account_note.hpp | 12 +- .../proofs/notes/circuit/account/commit.hpp | 12 +- .../proofs/notes/circuit/asset_id.cpp | 4 +- .../proofs/notes/circuit/asset_id.hpp | 4 +- .../proofs/notes/circuit/bridge_call_data.hpp | 10 +- .../proofs/notes/circuit/claim/claim_note.hpp | 12 +- .../claim/complete_partial_commitment.hpp | 12 +- .../notes/circuit/claim/compute_nullifier.hpp | 12 +- .../claim/create_partial_commitment.hpp | 12 +- .../notes/circuit/claim/witness_data.hpp | 4 +- .../proofs/notes/circuit/value/commit.hpp | 4 +- .../value/complete_partial_commitment.hpp | 4 +- .../notes/circuit/value/compute_nullifier.cpp | 4 +- .../notes/circuit/value/compute_nullifier.hpp | 4 +- .../circuit/value/compute_nullifier.test.cpp | 6 +- .../value/create_partial_commitment.hpp | 4 +- .../proofs/notes/circuit/value/value_note.hpp | 4 +- .../notes/circuit/value/value_note.test.cpp | 8 +- .../notes/circuit/value/witness_data.hpp | 4 +- .../proofs/notes/constants.hpp | 8 +- .../notes/native/account/account_note.cpp | 6 +- .../notes/native/account/account_note.hpp | 12 +- .../compute_account_alias_hash_nullifier.hpp | 4 +- .../compute_account_public_key_nullifier.hpp | 4 +- .../proofs/notes/native/asset_id.cpp | 4 +- .../proofs/notes/native/asset_id.hpp | 4 +- .../proofs/notes/native/bridge_call_data.hpp | 10 +- .../proofs/notes/native/claim/claim_note.hpp | 4 +- .../notes/native/claim/claim_note_tx_data.hpp | 12 +- .../claim/complete_partial_commitment.hpp | 4 +- .../notes/native/claim/compute_nullifier.hpp | 4 +- .../claim/create_partial_commitment.hpp | 4 +- .../value/complete_partial_commitment.hpp | 8 +- .../notes/native/value/compute_nullifier.cpp | 6 +- .../notes/native/value/compute_nullifier.hpp | 10 +- .../value/create_partial_commitment.hpp | 8 +- .../proofs/notes/native/value/value_note.hpp | 12 +- .../join_split_example/proofs/verify.hpp | 6 +- .../barretenberg/join_split_example/types.hpp | 8 +- .../numeric/bitop/count_leading_zeros.hpp | 4 +- .../bitop/count_leading_zeros.test.cpp | 2 + .../barretenberg/numeric/bitop/get_msb.hpp | 4 +- .../numeric/bitop/get_msb.test.cpp | 2 + .../barretenberg/numeric/bitop/keep_n_lsb.hpp | 4 +- .../src/barretenberg/numeric/bitop/pow.hpp | 4 +- .../src/barretenberg/numeric/bitop/rotate.hpp | 4 +- .../numeric/bitop/sparse_form.hpp | 4 +- .../barretenberg/numeric/random/engine.cpp | 14 +- .../barretenberg/numeric/random/engine.hpp | 22 +- .../numeric/random/engine.test.cpp | 12 +- .../barretenberg/numeric/uint128/uint128.hpp | 4 +- .../numeric/uint128/uint128.test.cpp | 8 +- .../numeric/uint128/uint128_impl.hpp | 4 +- .../barretenberg/numeric/uint256/uint256.hpp | 6 +- .../numeric/uint256/uint256.test.cpp | 6 +- .../numeric/uint256/uint256_impl.hpp | 4 +- .../src/barretenberg/numeric/uintx/uintx.hpp | 8 +- .../barretenberg/numeric/uintx/uintx.test.cpp | 24 +- .../barretenberg/numeric/uintx/uintx_impl.hpp | 4 +- .../plonk/composer/standard_composer.test.cpp | 3 +- .../plonk/composer/ultra_composer.test.cpp | 13 +- .../commitment_scheme.test.cpp | 2 +- .../plonk/proof_system/prover/prover.test.cpp | 3 +- .../proving_key/proving_key.test.cpp | 5 +- .../public_inputs/public_inputs.test.cpp | 2 +- .../verification_key.test.cpp | 10 +- .../proof_system/verifier/verifier.test.cpp | 2 +- .../plonk/transcript/transcript.cpp | 4 +- .../plonk/transcript/transcript.test.cpp | 6 +- .../polynomials/barycentric.test.cpp | 4 +- .../barretenberg/polynomials/polynomial.hpp | 49 +- .../polynomial_arithmetic.test.cpp | 2 +- .../src/barretenberg/polynomials/pow.test.cpp | 23 +- .../polynomials/univariate.test.cpp | 124 +- .../eccvm/eccvm_builder_types.hpp | 4 +- .../eccvm/eccvm_circuit_builder.hpp | 20 +- .../eccvm/eccvm_circuit_builder.test.cpp | 31 +- .../circuit_builder/eccvm/msm_builder.hpp | 8 +- .../eccvm/precomputed_tables_builder.hpp | 10 +- .../eccvm/transcript_builder.hpp | 4 +- .../generated/AvmMini_circuit_builder.hpp | 93 +- ...goblin_translator_circuit_builder.test.cpp | 13 +- .../goblin_translator_mini.fuzzer.cpp | 7 +- .../goblin_ultra_circuit_builder.cpp | 2 +- .../goblin_ultra_circuit_builder.test.cpp | 2 +- .../standard_circuit_builder.test.cpp | 7 +- .../toy_avm/toy_avm_circuit_builder.test.cpp | 9 +- .../ultra_circuit_builder.test.cpp | 6 +- .../composer/composer_lib.test.cpp | 6 +- .../composer/permutation_lib.test.cpp | 6 +- .../library/grand_product_library.test.cpp | 21 +- .../proof_system/op_queue/ecc_op_queue.hpp | 2 +- .../op_queue/ecc_op_queue.test.cpp | 9 +- .../proof_system/plookup_tables/aes128.hpp | 10 +- .../proof_system/plookup_tables/blake2s.hpp | 6 +- .../proof_system/plookup_tables/dummy.hpp | 6 +- .../plookup_tables/fixed_base/fixed_base.cpp | 4 +- .../plookup_tables/fixed_base/fixed_base.hpp | 4 +- .../fixed_base/fixed_base_params.hpp | 4 +- .../plookup_tables/keccak/keccak_chi.hpp | 6 +- .../plookup_tables/keccak/keccak_input.hpp | 6 +- .../plookup_tables/keccak/keccak_output.hpp | 6 +- .../plookup_tables/keccak/keccak_rho.hpp | 6 +- .../plookup_tables/keccak/keccak_theta.hpp | 6 +- .../non_native_group_generator.cpp | 6 +- .../non_native_group_generator.hpp | 6 +- .../plookup_tables/plookup_tables.cpp | 4 +- .../plookup_tables/plookup_tables.hpp | 4 +- .../proof_system/plookup_tables/sha256.hpp | 6 +- .../proof_system/plookup_tables/sparse.hpp | 6 +- .../proof_system/plookup_tables/types.hpp | 4 +- .../proof_system/plookup_tables/uint.hpp | 6 +- .../protogalaxy/combiner.test.cpp | 51 +- .../protogalaxy/protogalaxy_prover.cpp | 4 - .../protogalaxy/protogalaxy_verifier.cpp | 15 + .../relations/generated/AvmMini/alu_chip.hpp | 280 ++ .../relations/generated/AvmMini/avm_mini.hpp | 140 +- .../generated/AvmMini/declare_views.hpp | 40 +- .../relations/generated/AvmMini/mem_trace.hpp | 24 +- .../relations/nested_containers.test.cpp | 12 +- .../relations/relation_manual.test.cpp | 15 +- ...n_translator_relation_consistency.test.cpp | 4 - .../ultra_relation_consistency.test.cpp | 6 +- .../serialize/msgpack_schema.test.cpp | 25 +- .../smt_verification/smt_bigfield.test.cpp | 6 +- .../smt_verification/smt_examples.test.cpp | 9 +- .../smt_verification/smt_polynomials.test.cpp | 9 +- .../circuits/ecdsa_circuit.hpp | 28 +- .../solidity_helpers/proof_gen.cpp | 2 +- .../srs/factories/mem_crs_factory.test.cpp | 4 +- .../factories/mem_grumpkin_crs_factory.cpp | 2 +- .../cpp/src/barretenberg/srs/global_crs.cpp | 8 +- .../srs/scalar_multiplication.test.cpp | 191 +- .../commitment/pedersen/pedersen.test.cpp | 7 +- .../stdlib/encryption/aes128/aes128.cpp | 4 +- .../stdlib/encryption/aes128/aes128.test.cpp | 4 +- .../stdlib/encryption/ecdsa/ecdsa.hpp | 29 +- .../stdlib/encryption/ecdsa/ecdsa.test.cpp | 103 +- .../stdlib/encryption/ecdsa/ecdsa_impl.hpp | 25 +- .../stdlib/encryption/schnorr/schnorr.cpp | 52 +- .../stdlib/encryption/schnorr/schnorr.hpp | 25 +- .../encryption/schnorr/schnorr.test.cpp | 75 +- .../stdlib/hash/blake2s/blake2s.test.cpp | 10 +- .../stdlib/hash/blake2s/blake_util.hpp | 2 +- .../stdlib/hash/blake3s/blake3s.test.cpp | 4 +- .../stdlib/hash/keccak/keccak.cpp | 2 +- .../stdlib/hash/keccak/keccak.test.cpp | 6 +- .../stdlib/hash/pedersen/pedersen.test.cpp | 35 +- .../stdlib/hash/poseidon2/poseidon2.test.cpp | 9 +- .../stdlib/hash/sha256/sha256.test.cpp | 67 +- .../stdlib/hash/sha256/sha256_plookup.cpp | 2 +- .../stdlib/merkle_tree/hash.test.cpp | 5 +- .../stdlib/merkle_tree/membership.test.cpp | 13 +- .../stdlib/merkle_tree/merkle_tree.bench.cpp | 2 +- .../stdlib/merkle_tree/merkle_tree.test.cpp | 9 +- .../nullifier_tree/nullifier_tree.test.cpp | 4 +- .../primitives/bigfield/bigfield.test.cpp | 30 +- .../primitives/biggroup/biggroup.test.cpp | 16 +- .../biggroup/biggroup_goblin.test.cpp | 4 +- .../primitives/bit_array/bit_array.test.cpp | 5 +- .../stdlib/primitives/bool/bool.test.cpp | 4 +- .../primitives/byte_array/byte_array.test.cpp | 3 - .../circuit_builders/circuit_builders_fwd.hpp | 6 +- .../stdlib/primitives/curves/bn254.hpp | 2 + .../stdlib/primitives/curves/secp256k1.hpp | 28 +- .../stdlib/primitives/field/array.test.cpp | 7 +- .../stdlib/primitives/field/field.test.cpp | 50 +- .../primitives/group/cycle_group.test.cpp | 5 +- .../stdlib/primitives/logic/logic.test.cpp | 9 +- .../primitives/memory/dynamic_array.test.cpp | 7 +- .../primitives/memory/ram_table.test.cpp | 17 +- .../primitives/memory/rom_table.test.cpp | 9 +- .../packed_byte_array.test.cpp | 5 +- .../primitives/plookup/plookup.test.cpp | 79 +- .../primitives/safe_uint/safe_uint.test.cpp | 6 +- .../stdlib/primitives/uint/plookup/logic.cpp | 2 +- .../stdlib/primitives/uint/uint.test.cpp | 12 +- .../honk/transcript/transcript.test.cpp | 6 +- .../verifier/decider_recursive_verifier.cpp | 96 + .../verifier/decider_recursive_verifier.hpp | 30 + .../protogalaxy_recursive_verifier.cpp | 320 ++ .../protogalaxy_recursive_verifier.hpp | 118 + .../protogalaxy_recursive_verifier.test.cpp | 350 ++ .../verifier/ultra_recursive_verifier.hpp | 5 - .../recursion/transcript/transcript.test.cpp | 23 +- .../verification_key.test.cpp | 6 +- .../recursion/verifier/verifier.test.cpp | 18 +- .../src/barretenberg/stdlib/types/ultra.hpp | 4 +- .../barretenberg/stdlib/utility/utility.hpp | 4 + .../instance/prover_instance.test.cpp | 5 +- .../sumcheck/partial_evaluation.test.cpp | 3 - .../barretenberg/sumcheck/sumcheck.test.cpp | 22 +- .../sumcheck/sumcheck_round.test.cpp | 18 +- .../transcript/transcript.test.cpp | 12 +- .../goblin_translator_composer.test.cpp | 16 +- .../ultra_honk/databus_composer.test.cpp | 10 +- .../ultra_honk/goblin_ultra_composer.test.cpp | 16 +- .../goblin_ultra_transcript.test.cpp | 3 +- .../ultra_honk/protogalaxy.test.cpp | 28 +- .../ultra_honk/relation_correctness.test.cpp | 42 +- .../barretenberg/ultra_honk/sumcheck.test.cpp | 17 +- .../ultra_honk/ultra_composer.hpp | 3 +- .../ultra_honk/ultra_composer.test.cpp | 86 +- .../ultra_honk/ultra_transcript.test.cpp | 3 +- .../vm/avm_trace/AvmMini_alu_trace.cpp | 347 ++ .../vm/avm_trace/AvmMini_alu_trace.hpp | 49 + .../vm/avm_trace/AvmMini_common.hpp | 4 +- .../vm/avm_trace/AvmMini_helper.cpp | 6 + .../vm/avm_trace/AvmMini_mem_trace.cpp | 48 +- .../vm/avm_trace/AvmMini_mem_trace.hpp | 43 +- .../vm/avm_trace/AvmMini_trace.cpp | 170 +- .../vm/avm_trace/AvmMini_trace.hpp | 5 + .../vm/generated/AvmMini_prover.cpp | 2 + .../vm/generated/AvmMini_verifier.cpp | 51 + .../vm/tests/AvmMini_arithmetic.test.cpp | 1459 +++++- .../vm/tests/AvmMini_common.test.hpp | 13 + .../vm/tests/AvmMini_control_flow.test.cpp | 19 +- .../vm/tests/AvmMini_memory.test.cpp | 42 +- .../barretenberg/vm/tests/helpers.test.cpp | 34 +- .../barretenberg/vm/tests/helpers.test.hpp | 7 +- barretenberg/exports.json | 59 +- barretenberg/ts/CHANGELOG.md | 7 + barretenberg/ts/package.json | 2 +- barretenberg/ts/src/barretenberg_api/index.ts | 92 +- barretenberg/ts/src/main.ts | 47 +- .../src/contracts/src/types/balance_set.nr | 6 - .../src/contracts/src/types/token_note.nr | 26 +- .../contracts/src/types/transparent_note.nr | 15 +- .../src/aztec3/utils/types/circuit_types.hpp | 2 +- docs/docs/about_aztec/history/history.mdx | 97 - docs/docs/about_aztec/overview.mdx | 10 +- .../advanced/data_structures/trees.md | 34 +- .../docs/concepts/foundation/accounts/keys.md | 2 +- docs/docs/concepts/foundation/main.md | 47 +- .../history_lib_reference.md | 119 + .../historical_access/how_to_prove_history.md | 102 + .../contracts/syntax/storage/private_state.md | 16 +- .../contracts/syntax/storage/public_state.md | 3 +- .../dev_docs/getting_started/core-concepts.md | 44 +- docs/docs/dev_docs/getting_started/main.md | 10 +- .../dev_docs/getting_started/quickstart.md | 6 +- .../token_portal/depositing_to_aztec.md | 15 +- .../dev_docs/tutorials/token_portal/setup.md | 30 +- .../token_portal/typescript_glue_code.md | 17 +- .../token_portal/withdrawing_to_l1.md | 20 +- .../writing_private_voting_contract.md | 2 +- docs/docs/intro.md | 64 +- docs/docs/misc/migration_notes.md | 86 +- docs/sidebars.js | 13 +- docs/yarn.lock | 3950 +++++++++-------- .../src/core/libraries/ConstantsGen.sol | 2 +- l1-contracts/test/portals/TokenPortal.sol | 2 +- noir/.github/actions/setup/action.yml | 2 +- noir/.github/workflows/docs-dead-links.yml | 2 +- noir/.github/workflows/docs-pr.yml | 52 +- noir/.github/workflows/publish-docs.yml | 9 +- noir/.github/workflows/release.yml | 14 +- noir/.gitrepo | 4 +- noir/.release-please-manifest.json | 4 +- noir/CHANGELOG.md | 92 + noir/Cargo.lock | 129 +- noir/Cargo.toml | 16 +- noir/acvm-repo/CHANGELOG.md | 32 + noir/acvm-repo/acir/Cargo.toml | 2 +- noir/acvm-repo/acir/codegen/acir.cpp | 644 ++- .../acir/src/circuit/black_box_functions.rs | 25 + .../opcodes/black_box_function_call.rs | 56 +- noir/acvm-repo/acir_field/Cargo.toml | 2 +- noir/acvm-repo/acvm/Cargo.toml | 2 +- .../acvm/src/compiler/transformers/mod.rs | 12 +- noir/acvm-repo/acvm/src/pwg/blackbox/mod.rs | 6 + noir/acvm-repo/acvm_js/Cargo.toml | 2 +- noir/acvm-repo/acvm_js/package.json | 2 +- noir/acvm-repo/blackbox_solver/Cargo.toml | 2 +- .../bn254_blackbox_solver/Cargo.toml | 2 +- noir/acvm-repo/brillig/Cargo.toml | 2 +- noir/acvm-repo/brillig/src/black_box.rs | 79 +- noir/acvm-repo/brillig_vm/Cargo.toml | 2 +- noir/acvm-repo/brillig_vm/src/black_box.rs | 12 + noir/aztec_macros/src/lib.rs | 41 +- noir/bootstrap_cache.sh | 1 + noir/compiler/fm/src/file_map.rs | 4 + .../noirc_driver/tests/stdlib_warnings.rs | 9 +- .../brillig/brillig_gen/brillig_black_box.rs | 101 + .../src/brillig/brillig_ir/debug_show.rs | 53 + noir/compiler/noirc_evaluator/src/ssa.rs | 14 +- .../ssa/acir_gen/acir_ir/generated_acir.rs | 62 + .../noirc_evaluator/src/ssa/acir_gen/mod.rs | 411 +- .../src/ssa/function_builder/mod.rs | 8 +- .../src/ssa/ir/instruction/call.rs | 9 +- .../noirc_evaluator/src/ssa/ir/types.rs | 2 +- .../src/ssa/opt/bubble_up_constrains.rs | 153 + .../src/ssa/opt/fill_internal_slices.rs | 765 ---- .../noirc_evaluator/src/ssa/opt/mod.rs | 2 +- .../src/ssa/ssa_gen/context.rs | 12 +- .../src/hir/def_collector/dc_crate.rs | 6 +- .../src/hir/def_collector/dc_mod.rs | 4 +- .../noirc_frontend/src/hir/def_map/mod.rs | 2 +- noir/compiler/noirc_frontend/src/hir/mod.rs | 28 +- .../src/hir/resolution/resolver.rs | 21 +- .../src/hir/resolution/traits.rs | 20 +- .../noirc_frontend/src/hir/type_check/expr.rs | 2 +- .../noirc_frontend/src/hir_def/traits.rs | 2 +- .../noirc_frontend/src/hir_def/types.rs | 57 +- .../src/monomorphization/mod.rs | 11 +- .../noirc_frontend/src/node_interner.rs | 36 +- .../noirc_frontend/src/resolve_locations.rs | 52 +- noir/compiler/noirc_frontend/src/tests.rs | 2 +- noir/compiler/noirc_printable_type/src/lib.rs | 113 +- noir/compiler/wasm/package.json | 2 +- noir/compiler/wasm/src/compile.rs | 19 +- noir/compiler/wasm/src/compile_new.rs | 13 +- .../explainers/explainer-oracle.md | 57 - .../version-v0.22.0/how_to/how-to-oracles.md | 280 -- .../version-v0.22.0/noir/syntax/oracles.md | 23 - noir/flake.nix | 2 +- .../execution_success/bit_and/Prover.toml | 2 + .../execution_success/bit_and/src/main.nr | 8 +- .../execution_success/debug_logs/src/main.nr | 20 + .../Nargo.toml | 2 +- .../Prover.toml | 0 .../src/main.nr | 0 .../test-binaries/mock_backend/Cargo.lock | 171 +- noir/tooling/lsp/Cargo.toml | 2 + noir/tooling/lsp/src/lib.rs | 85 +- noir/tooling/lsp/src/notifications/mod.rs | 9 +- .../lsp/src/requests/code_lens_request.rs | 2 +- .../lsp/src/requests/goto_declaration.rs | 10 +- .../lsp/src/requests/goto_definition.rs | 27 +- noir/tooling/lsp/src/requests/mod.rs | 20 +- noir/tooling/lsp/src/requests/profile_run.rs | 13 +- noir/tooling/lsp/src/requests/test_run.rs | 7 +- noir/tooling/lsp/src/requests/tests.rs | 6 +- noir/tooling/lsp/src/types.rs | 11 +- noir/tooling/nargo/src/lib.rs | 25 +- noir/tooling/nargo/src/ops/compile.rs | 46 +- noir/tooling/nargo/src/ops/mod.rs | 2 +- noir/tooling/nargo_cli/Cargo.toml | 2 +- noir/tooling/nargo_cli/build.rs | 11 +- noir/tooling/nargo_cli/src/cli/check_cmd.rs | 10 +- .../nargo_cli/src/cli/codegen_verifier_cmd.rs | 28 +- noir/tooling/nargo_cli/src/cli/compile_cmd.rs | 115 +- noir/tooling/nargo_cli/src/cli/dap_cmd.rs | 5 +- noir/tooling/nargo_cli/src/cli/debug_cmd.rs | 5 +- noir/tooling/nargo_cli/src/cli/execute_cmd.rs | 5 +- noir/tooling/nargo_cli/src/cli/export_cmd.rs | 8 +- noir/tooling/nargo_cli/src/cli/info_cmd.rs | 19 +- noir/tooling/nargo_cli/src/cli/prove_cmd.rs | 5 +- noir/tooling/nargo_cli/src/cli/test_cmd.rs | 13 +- noir/tooling/nargo_cli/src/cli/verify_cmd.rs | 5 +- noir/tooling/noir_codegen/package.json | 2 +- noir/tooling/noir_js/package.json | 2 +- .../noir_js_backend_barretenberg/package.json | 2 +- noir/tooling/noir_js_types/package.json | 2 +- noir/tooling/noirc_abi_wasm/package.json | 2 +- noir/yarn.lock | 74 +- yarn-project/accounts/.eslintrc.cjs | 2 +- .../acir-simulator/src/acvm/oracle/oracle.ts | 16 +- .../src/acvm/oracle/typed_oracle.ts | 34 +- .../acir-simulator/src/acvm/serialize.ts | 7 +- .../src/avm/avm_message_call_result.ts | 10 +- .../src/avm/interpreter/interpreter.test.ts | 19 +- .../src/avm/interpreter/interpreter.ts | 48 +- .../src/avm/opcodes/bitwise.test.ts | 166 + .../acir-simulator/src/avm/opcodes/bitwise.ts | 3 + .../src/avm/opcodes/control_flow.test.ts | 3 +- .../src/avm/opcodes/instruction_set.ts | 27 +- .../src/avm/opcodes/memory.test.ts | 182 + .../acir-simulator/src/avm/opcodes/memory.ts | 30 +- .../acir-simulator/src/avm/opcodes/opcodes.ts | 118 +- .../acir-simulator/src/client/db_oracle.ts | 18 +- .../src/client/private_execution.test.ts | 331 +- .../src/client/simulator.test.ts | 24 +- .../acir-simulator/src/client/simulator.ts | 4 +- .../src/client/view_data_oracle.ts | 13 +- .../acir-simulator/src/public/index.test.ts | 287 +- .../src/public/public_execution_context.ts | 4 +- yarn-project/aztec-nr/.gitrepo | 4 +- .../aztec-nr/address-note/src/address_note.nr | 26 +- yarn-project/aztec-nr/aztec/src/context.nr | 56 +- .../aztec/src/history/note_validity.nr | 4 +- .../src/history/nullifier_non_inclusion.nr | 6 +- yarn-project/aztec-nr/aztec/src/key.nr | 1 + .../aztec-nr/aztec/src/key/nullifier_key.nr | 24 + yarn-project/aztec-nr/aztec/src/lib.nr | 1 + yarn-project/aztec-nr/aztec/src/messaging.nr | 25 +- .../aztec/src/messaging/l1_to_l2_message.nr | 6 +- .../messaging/l1_to_l2_message_getter_data.nr | 8 +- .../aztec-nr/aztec/src/note/lifecycle.nr | 2 +- .../aztec-nr/aztec/src/note/note_interface.nr | 4 +- yarn-project/aztec-nr/aztec/src/note/utils.nr | 13 +- yarn-project/aztec-nr/aztec/src/oracle.nr | 2 +- .../aztec/src/oracle/get_secret_key.nr | 25 - .../aztec/src/oracle/nullifier_key.nr | 29 + .../src/state_vars/immutable_singleton.nr | 28 +- .../aztec/src/state_vars/singleton.nr | 39 +- .../aztec-nr/field-note/src/field_note.nr | 16 +- .../aztec-nr/value-note/src/value_note.nr | 26 +- yarn-project/aztec.js/.eslintrc.cjs | 2 +- .../circuit-types/src/keys/key_store.ts | 27 +- .../circuit-types/src/l1_to_l2_message.ts | 5 + yarn-project/circuits.js/src/constants.gen.ts | 2 +- yarn-project/circuits.js/src/index.ts | 1 + yarn-project/circuits.js/src/keys/index.ts | 44 + .../src/types/grumpkin_private_key.ts | 2 +- .../src/e2e_cross_chain_messaging.test.ts | 6 +- .../src/e2e_lending_contract.test.ts | 12 - .../e2e_public_cross_chain_messaging.test.ts | 4 +- .../end-to-end/src/e2e_singleton.test.ts | 142 + yarn-project/foundation/.eslintrc.cjs | 59 +- yarn-project/foundation/.eslintrc.docs.cjs | 69 + yarn-project/foundation/package.json | 1 + yarn-project/key-store/src/test_key_store.ts | 25 +- .../src/contract-interface-gen/typescript.ts | 2 +- .../contracts/card_game_contract/src/cards.nr | 5 +- .../contracts/card_game_contract/src/main.nr | 2 +- .../src/account_contract_interface.nr | 11 - .../docs_example_contract/src/actions.nr | 156 - .../docs_example_contract/src/main.nr | 255 +- .../docs_example_contract/src/options.nr | 2 + .../docs_example_contract/src/types.nr | 4 +- .../src/types/card_note.nr | 39 +- .../docs_example_contract/src/types/leader.nr | 23 + .../src/types/profile_note.nr | 119 - .../docs_example_contract/src/types/queen.nr | 26 - .../src/types/rules_note.nr | 119 - .../easy_private_voting_contract/src/main.nr | 3 +- .../src/ecdsa_public_key_note.nr | 26 +- .../ecdsa_account_contract/src/main.nr | 2 +- .../inclusion_proofs_contract/src/main.nr | 28 +- .../schnorr_account_contract/src/main.nr | 2 +- .../src/public_key_note.nr | 26 +- .../contracts/test_contract/src/main.nr | 2 +- .../token_blacklist_contract/src/main.nr | 2 +- .../src/types/balance_set.nr | 6 - .../src/types/token_note.nr | 26 +- .../src/types/transparent_note.nr | 15 +- .../token_contract/src/types/balance_set.nr | 6 - .../token_contract/src/types/token_note.nr | 26 +- .../src/types/transparent_note.nr | 15 +- .../src/crates/types/src/constants.nr | 2 +- .../pxe/src/simulator_oracle/index.ts | 20 +- yarn-project/yarn.lock | 10 +- 612 files changed, 14770 insertions(+), 8829 deletions(-) create mode 100755 barretenberg/acir_tests/flows/accumulate_and_verify_goblin.sh create mode 100644 barretenberg/cpp/pil/avm/README.txt create mode 100644 barretenberg/cpp/pil/avm/alu_chip.pil create mode 100644 barretenberg/cpp/src/barretenberg/benchmark/commit_bench/CMakeLists.txt create mode 100644 barretenberg/cpp/src/barretenberg/benchmark/commit_bench/commit.bench.cpp create mode 100644 barretenberg/cpp/src/barretenberg/benchmark/commit_bench/main.bench.cpp rename barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/{benchmark_utilities.hpp => mock_proofs.hpp} (69%) create mode 100644 barretenberg/cpp/src/barretenberg/dsl/acir_format/bigint_constraint.cpp create mode 100644 barretenberg/cpp/src/barretenberg/dsl/acir_format/bigint_constraint.hpp create mode 100644 barretenberg/cpp/src/barretenberg/dsl/acir_format/bigint_constraint.test.cpp create mode 100644 barretenberg/cpp/src/barretenberg/dsl/acir_proofs/goblin_acir_composer.cpp create mode 100644 barretenberg/cpp/src/barretenberg/dsl/acir_proofs/goblin_acir_composer.hpp create mode 100644 barretenberg/cpp/src/barretenberg/relations/generated/AvmMini/alu_chip.hpp create mode 100644 barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp create mode 100644 barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.hpp create mode 100644 barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp create mode 100644 barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.hpp create mode 100644 barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.test.cpp create mode 100644 barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_alu_trace.cpp create mode 100644 barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_alu_trace.hpp create mode 100644 barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_common.test.hpp delete mode 100644 docs/docs/about_aztec/history/history.mdx create mode 100644 docs/docs/dev_docs/contracts/syntax/historical_access/history_lib_reference.md create mode 100644 docs/docs/dev_docs/contracts/syntax/historical_access/how_to_prove_history.md create mode 100644 noir/compiler/noirc_evaluator/src/ssa/opt/bubble_up_constrains.rs delete mode 100644 noir/compiler/noirc_evaluator/src/ssa/opt/fill_internal_slices.rs delete mode 100644 noir/docs/versioned_docs/version-v0.22.0/explainers/explainer-oracle.md delete mode 100644 noir/docs/versioned_docs/version-v0.22.0/how_to/how-to-oracles.md delete mode 100644 noir/docs/versioned_docs/version-v0.22.0/noir/syntax/oracles.md rename noir/test_programs/execution_success/{nested_slice_dynamic => nested_array_in_slice}/Nargo.toml (62%) rename noir/test_programs/execution_success/{nested_slice_dynamic => nested_array_in_slice}/Prover.toml (100%) rename noir/test_programs/execution_success/{nested_slice_dynamic => nested_array_in_slice}/src/main.nr (100%) create mode 100644 yarn-project/acir-simulator/src/avm/opcodes/bitwise.test.ts create mode 100644 yarn-project/acir-simulator/src/avm/opcodes/memory.test.ts create mode 100644 yarn-project/aztec-nr/aztec/src/key.nr create mode 100644 yarn-project/aztec-nr/aztec/src/key/nullifier_key.nr delete mode 100644 yarn-project/aztec-nr/aztec/src/oracle/get_secret_key.nr create mode 100644 yarn-project/aztec-nr/aztec/src/oracle/nullifier_key.nr create mode 100644 yarn-project/circuits.js/src/keys/index.ts create mode 100644 yarn-project/end-to-end/src/e2e_singleton.test.ts create mode 100644 yarn-project/foundation/.eslintrc.docs.cjs delete mode 100644 yarn-project/noir-contracts/contracts/docs_example_contract/src/account_contract_interface.nr delete mode 100644 yarn-project/noir-contracts/contracts/docs_example_contract/src/actions.nr create mode 100644 yarn-project/noir-contracts/contracts/docs_example_contract/src/types/leader.nr delete mode 100644 yarn-project/noir-contracts/contracts/docs_example_contract/src/types/profile_note.nr delete mode 100644 yarn-project/noir-contracts/contracts/docs_example_contract/src/types/queen.nr delete mode 100644 yarn-project/noir-contracts/contracts/docs_example_contract/src/types/rules_note.nr diff --git a/.circleci/config.yml b/.circleci/config.yml index 81eb7344f1f5..07dd2a3ee5ff 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -599,6 +599,17 @@ jobs: name: "Test" command: cond_spot_run_compose end-to-end 4 ./scripts/docker-compose.yml TEST=e2e_sandbox_example.test.ts + e2e-singleton: + docker: + - image: aztecprotocol/alpine-build-image + resource_class: small + steps: + - *checkout + - *setup_env + - run: + name: "Test" + command: cond_spot_run_compose end-to-end 4 ./scripts/docker-compose.yml TEST=e2e_singleton.test.ts + e2e-block-building: docker: - image: aztecprotocol/alpine-build-image @@ -775,17 +786,6 @@ jobs: name: "Test" command: cond_spot_run_compose end-to-end 4 ./scripts/docker-compose-no-sandbox.yml TEST=e2e_persistence.test.ts - e2e-p2p: - docker: - - image: aztecprotocol/alpine-build-image - resource_class: small - steps: - - *checkout - - *setup_env - - run: - name: "Test" - command: cond_spot_run_compose end-to-end 4 ./scripts/docker-compose-no-sandbox.yml TEST=e2e_p2p_network.test.ts - e2e-browser: docker: - image: aztecprotocol/alpine-build-image @@ -1228,6 +1228,7 @@ workflows: # TODO(3458): Investigate intermittent failure # - e2e-slow-tree: *e2e_test - e2e-sandbox-example: *e2e_test + - e2e-singleton: *e2e_test - e2e-block-building: *e2e_test - e2e-nested-contract: *e2e_test - e2e-non-contract-account: *e2e_test @@ -1245,7 +1246,6 @@ workflows: - integration-l1-publisher: *e2e_test - integration-archiver-l1-to-l2: *e2e_test - e2e-persistence: *e2e_test - - e2e-p2p: *e2e_test - e2e-browser: *e2e_test - e2e-card-game: *e2e_test - pxe: *e2e_test @@ -1265,6 +1265,7 @@ workflows: - e2e-token-contract - e2e-blacklist-token-contract - e2e-sandbox-example + - e2e-singleton - e2e-block-building - e2e-nested-contract - e2e-non-contract-account @@ -1282,7 +1283,6 @@ workflows: - integration-l1-publisher - integration-archiver-l1-to-l2 - e2e-persistence - - e2e-p2p - e2e-browser - e2e-card-game - pxe diff --git a/.release-please-manifest.json b/.release-please-manifest.json index cd45c1c86ae3..fce3dcc81f62 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,5 +1,5 @@ { - ".": "0.19.0", - "barretenberg": "0.19.0", - "barretenberg/ts": "0.19.0" + ".": "0.20.0", + "barretenberg": "0.20.0", + "barretenberg/ts": "0.20.0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index d8f7898f35b7..d71d1a92c8cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,71 @@ # Changelog +## [0.20.0](https://github.com/AztecProtocol/aztec-packages/compare/aztec-packages-v0.19.0...aztec-packages-v0.20.0) (2024-01-22) + + +### ⚠ BREAKING CHANGES + +* nullifier key ([#4166](https://github.com/AztecProtocol/aztec-packages/issues/4166)) +* Unify ABIs between nargo and yarn-project ([#3989](https://github.com/AztecProtocol/aztec-packages/issues/3989)) + +### Features + +* **avm:** Add internal jump and return, adjust control flow ([#4140](https://github.com/AztecProtocol/aztec-packages/issues/4140)) ([b77afb1](https://github.com/AztecProtocol/aztec-packages/commit/b77afb14c609cfc04663a318eecaa8cbd3b2fa85)) +* **avm:** Better field arithmetic ([#4142](https://github.com/AztecProtocol/aztec-packages/issues/4142)) ([7308e31](https://github.com/AztecProtocol/aztec-packages/commit/7308e31c981ec7c03d0474811b2979e6f418f348)) +* **avm:** Encode TS AVM instructions as bytecode, especially for testing ([#4115](https://github.com/AztecProtocol/aztec-packages/issues/4115)) ([de6e2ed](https://github.com/AztecProtocol/aztec-packages/commit/de6e2edc09b823542f45e14b45c32ec10894f6c7)) +* **avm:** Improve interpreter errors and tests ([#4173](https://github.com/AztecProtocol/aztec-packages/issues/4173)) ([f0fb594](https://github.com/AztecProtocol/aztec-packages/commit/f0fb5942386e2e091cb6d1b23108ac74c1c6b75d)) +* Benchmark commit function ([#4178](https://github.com/AztecProtocol/aztec-packages/issues/4178)) ([ea84085](https://github.com/AztecProtocol/aztec-packages/commit/ea840857d8134c9af6f233b414f6d990cd2abd6d)) +* Goblin acir composer ([#4112](https://github.com/AztecProtocol/aztec-packages/issues/4112)) ([5e85b92](https://github.com/AztecProtocol/aztec-packages/commit/5e85b92f48bc31fe55315de9f45c4907e417cb6a)) +* Nullifier key ([#4166](https://github.com/AztecProtocol/aztec-packages/issues/4166)) ([7c07665](https://github.com/AztecProtocol/aztec-packages/commit/7c076653169771223a378f6c01bd9d3e3aafb682)) +* **public-vm:** Avm journal ([#3945](https://github.com/AztecProtocol/aztec-packages/issues/3945)) ([5658468](https://github.com/AztecProtocol/aztec-packages/commit/56584683340cd29b26adbcc60d3cd58fe889e8ad)) +* Publish block body separately ([#4118](https://github.com/AztecProtocol/aztec-packages/issues/4118)) ([a04e1e3](https://github.com/AztecProtocol/aztec-packages/commit/a04e1e351fe0b42dfa6ef7d1894dffbcff19b187)), closes [#3944](https://github.com/AztecProtocol/aztec-packages/issues/3944) +* Unify ABIs between nargo and yarn-project ([#3989](https://github.com/AztecProtocol/aztec-packages/issues/3989)) ([d083438](https://github.com/AztecProtocol/aztec-packages/commit/d0834380a749a48d31e3075f831f3279f18fc01e)) +* Update noir ([#4082](https://github.com/AztecProtocol/aztec-packages/issues/4082)) ([0e6037a](https://github.com/AztecProtocol/aztec-packages/commit/0e6037ad48fc1eb8ab3524d64755f4f27f64bf36)) +* Updating L2 Block encoding and `Rollup.process` function ([#4015](https://github.com/AztecProtocol/aztec-packages/issues/4015)) ([2d8eb37](https://github.com/AztecProtocol/aztec-packages/commit/2d8eb37edbc9164639fe6d20140364288e2b72a9)), closes [#3936](https://github.com/AztecProtocol/aztec-packages/issues/3936) [#4010](https://github.com/AztecProtocol/aztec-packages/issues/4010) [#4011](https://github.com/AztecProtocol/aztec-packages/issues/4011) + + +### Bug Fixes + +* Bb.js version in yarn lockfile ([7b96760](https://github.com/AztecProtocol/aztec-packages/commit/7b96760f7d201d984bab885b996b218bd427be22)) +* **build:** Publish bb.js from CCI ([#4151](https://github.com/AztecProtocol/aztec-packages/issues/4151)) ([09dbfcd](https://github.com/AztecProtocol/aztec-packages/commit/09dbfcd7e8d3b15cf79686eea44a4032f2aa4bbb)) +* Make CMake version warning fatal ([#4144](https://github.com/AztecProtocol/aztec-packages/issues/4144)) ([b1443fa](https://github.com/AztecProtocol/aztec-packages/commit/b1443faf9d8f308dbad6d0aa365b1feb8385557d)) +* Misleading error message in `PublicState::read` ([#4149](https://github.com/AztecProtocol/aztec-packages/issues/4149)) ([fa4d919](https://github.com/AztecProtocol/aztec-packages/commit/fa4d919d25b5253d1f39b7f2db183771f461fe1b)) +* Nargo destination path in bootstrap cache ([#4103](https://github.com/AztecProtocol/aztec-packages/issues/4103)) ([4901309](https://github.com/AztecProtocol/aztec-packages/commit/490130979a5d3a3e703c7e28417835aa86fa8cd7)) +* Reinstate Ultra arith rec verifier test ([#3886](https://github.com/AztecProtocol/aztec-packages/issues/3886)) ([995973b](https://github.com/AztecProtocol/aztec-packages/commit/995973b0226ddd7ae4cb5c3501859bec10f4eb93)) +* Upload_benchmarks_to_s3.sh missing exit ([#4046](https://github.com/AztecProtocol/aztec-packages/issues/4046)) ([52a9327](https://github.com/AztecProtocol/aztec-packages/commit/52a93279e43ae6780e8bfc253ee0570a443ed472)) + + +### Miscellaneous + +* Archiver store ([#3966](https://github.com/AztecProtocol/aztec-packages/issues/3966)) ([af2be87](https://github.com/AztecProtocol/aztec-packages/commit/af2be878b49aceb668480e5a291aed7dea5319ba)) +* **avm:** List avm opcodes in a (enum => class) map in TS ([#4113](https://github.com/AztecProtocol/aztec-packages/issues/4113)) ([dee564a](https://github.com/AztecProtocol/aztec-packages/commit/dee564a16293ff8f0aa2c6ba9fb0d1d6235ba251)) +* **bb:** More concise namespaces, plookup => bb::plookup ([#4146](https://github.com/AztecProtocol/aztec-packages/issues/4146)) ([14d39ed](https://github.com/AztecProtocol/aztec-packages/commit/14d39edbe1a6753849581a664184d4e98baf923d)) +* **bb:** Namespace plonk::stdlib => stdlib ([#4117](https://github.com/AztecProtocol/aztec-packages/issues/4117)) ([cd2f67f](https://github.com/AztecProtocol/aztec-packages/commit/cd2f67f5cbc471b9120f7c7070b96ba0d4994865)) +* **bb:** Namespace proof_system=>bb ([#4116](https://github.com/AztecProtocol/aztec-packages/issues/4116)) ([7438db3](https://github.com/AztecProtocol/aztec-packages/commit/7438db31b29860aa2c0af54afa8413711a24e1eb)) +* **docs:** Aztec-up doesnt need `latest`, remove warnings around sandbox/cli npm pkgs ([#4138](https://github.com/AztecProtocol/aztec-packages/issues/4138)) ([2bbf7a9](https://github.com/AztecProtocol/aztec-packages/commit/2bbf7a919172bea9842b4e65129160e0e4ee0050)) +* **docs:** Update js release notes for 0.18.0 ([#4051](https://github.com/AztecProtocol/aztec-packages/issues/4051)) ([bdbe963](https://github.com/AztecProtocol/aztec-packages/commit/bdbe963b114813a49017daebe5b34757692328ce)) +* **docs:** Update lsp install instructions ([#4110](https://github.com/AztecProtocol/aztec-packages/issues/4110)) ([3138816](https://github.com/AztecProtocol/aztec-packages/commit/3138816b8b7480bd85eab8739e1d0bc72a5a5361)), closes [#4098](https://github.com/AztecProtocol/aztec-packages/issues/4098) +* Dont mirror build-system mirror_repos.yml ([#4067](https://github.com/AztecProtocol/aztec-packages/issues/4067)) ([04f8e0d](https://github.com/AztecProtocol/aztec-packages/commit/04f8e0dfde5a3d4f54621726891aedc071212a8a)) +* Fixes many broken urls ([#4109](https://github.com/AztecProtocol/aztec-packages/issues/4109)) ([41ae75c](https://github.com/AztecProtocol/aztec-packages/commit/41ae75cdee6285729551965972e8cb039ff3045a)) +* Remove dependency cycles in `sequencer-client` ([#4017](https://github.com/AztecProtocol/aztec-packages/issues/4017)) ([fe4538b](https://github.com/AztecProtocol/aztec-packages/commit/fe4538b36c1cdb19c0c7245f7a73c9f5ee131a4a)) +* Remove lodash times in favor of foundation fn ([#3877](https://github.com/AztecProtocol/aztec-packages/issues/3877)) ([a10eef0](https://github.com/AztecProtocol/aztec-packages/commit/a10eef0a77cb52e00ffedb10ed325bd63fa0c971)) +* Remove mutex dependency ([#4160](https://github.com/AztecProtocol/aztec-packages/issues/4160)) ([3b82be0](https://github.com/AztecProtocol/aztec-packages/commit/3b82be0f266c838c823bbe26cfea99337d7180a9)) +* Remove unnecessary computation ([#4133](https://github.com/AztecProtocol/aztec-packages/issues/4133)) ([f35bdb8](https://github.com/AztecProtocol/aztec-packages/commit/f35bdb84722dbd01535da5542a0ec7c1fb96e5c7)) +* Remove unused noir-version json ([#4105](https://github.com/AztecProtocol/aztec-packages/issues/4105)) ([afca819](https://github.com/AztecProtocol/aztec-packages/commit/afca819166b9b5882b5d94062ac50cbb8dc590fb)) +* Remove unwanted submodules ([#4085](https://github.com/AztecProtocol/aztec-packages/issues/4085)) ([dda7c9c](https://github.com/AztecProtocol/aztec-packages/commit/dda7c9c4fa8da54d28b99b1cf601328030485503)) +* Replace relative paths to noir-protocol-circuits ([59feeb5](https://github.com/AztecProtocol/aztec-packages/commit/59feeb5ed55ab022b99b83a31cf89bdabc0003c5)) +* Replace relative paths to noir-protocol-circuits ([44d9136](https://github.com/AztecProtocol/aztec-packages/commit/44d91361274a54f0e59f0ad5f8869f3f3aa49c2b)) +* Replace relative paths to noir-protocol-circuits ([84b0bad](https://github.com/AztecProtocol/aztec-packages/commit/84b0bad61a5fc751fdf01ae907bb9b7df3bece7b)) +* Simplify and fix DocsExample contract, e2e singleton + codegen to not show internal methods ([#4169](https://github.com/AztecProtocol/aztec-packages/issues/4169)) ([38d262e](https://github.com/AztecProtocol/aztec-packages/commit/38d262eddd4fca80a7726d17303fc084257ad460)) +* Update noir ([#4168](https://github.com/AztecProtocol/aztec-packages/issues/4168)) ([d40ad06](https://github.com/AztecProtocol/aztec-packages/commit/d40ad063606219119b41ba3acc883e62245bd035)) + + +### Documentation + +* Update migration notes ([#4175](https://github.com/AztecProtocol/aztec-packages/issues/4175)) ([dbc8174](https://github.com/AztecProtocol/aztec-packages/commit/dbc8174f010f15422a9485b567b60834a0a4aa2f)) +* **yellow-paper:** Update circuit sections for nullifier keys and static calls ([#4155](https://github.com/AztecProtocol/aztec-packages/issues/4155)) ([ed71a57](https://github.com/AztecProtocol/aztec-packages/commit/ed71a573bca18912e4590a5f8c8044778ad439c5)) +* **yellowpaper:** Refresh of avm instruction set ([#4081](https://github.com/AztecProtocol/aztec-packages/issues/4081)) ([52162ee](https://github.com/AztecProtocol/aztec-packages/commit/52162eed9ace2726c143a34520115c8530876187)) + ## [0.19.0](https://github.com/AztecProtocol/aztec-packages/compare/aztec-packages-v0.18.0...aztec-packages-v0.19.0) (2024-01-17) diff --git a/barretenberg/.gitrepo b/barretenberg/.gitrepo index f0f2d9349891..7f0d957fa4dd 100644 --- a/barretenberg/.gitrepo +++ b/barretenberg/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/AztecProtocol/barretenberg branch = master - commit = f01329ccb7a07c8828a06a19d0a4d77d3f89087a - parent = b77afb14c609cfc04663a318eecaa8cbd3b2fa85 + commit = 508a48cd064773b9e78681e6208ed707ecdfa6bf + parent = 6dac6504fdbe85c61ffd7aad7c37cc1b52ebf6d4 method = merge cmdver = 0.4.6 diff --git a/barretenberg/CHANGELOG.md b/barretenberg/CHANGELOG.md index 2d528f556f7a..5b5cb064b64f 100644 --- a/barretenberg/CHANGELOG.md +++ b/barretenberg/CHANGELOG.md @@ -1,5 +1,29 @@ # Changelog +## [0.20.0](https://github.com/AztecProtocol/aztec-packages/compare/barretenberg-v0.19.0...barretenberg-v0.20.0) (2024-01-22) + + +### Features + +* Benchmark commit function ([#4178](https://github.com/AztecProtocol/aztec-packages/issues/4178)) ([ea84085](https://github.com/AztecProtocol/aztec-packages/commit/ea840857d8134c9af6f233b414f6d990cd2abd6d)) +* Goblin acir composer ([#4112](https://github.com/AztecProtocol/aztec-packages/issues/4112)) ([5e85b92](https://github.com/AztecProtocol/aztec-packages/commit/5e85b92f48bc31fe55315de9f45c4907e417cb6a)) + + +### Bug Fixes + +* Make CMake version warning fatal ([#4144](https://github.com/AztecProtocol/aztec-packages/issues/4144)) ([b1443fa](https://github.com/AztecProtocol/aztec-packages/commit/b1443faf9d8f308dbad6d0aa365b1feb8385557d)) +* Reinstate Ultra arith rec verifier test ([#3886](https://github.com/AztecProtocol/aztec-packages/issues/3886)) ([995973b](https://github.com/AztecProtocol/aztec-packages/commit/995973b0226ddd7ae4cb5c3501859bec10f4eb93)) +* Upload_benchmarks_to_s3.sh missing exit ([#4046](https://github.com/AztecProtocol/aztec-packages/issues/4046)) ([52a9327](https://github.com/AztecProtocol/aztec-packages/commit/52a93279e43ae6780e8bfc253ee0570a443ed472)) + + +### Miscellaneous + +* **bb:** More concise namespaces, plookup => bb::plookup ([#4146](https://github.com/AztecProtocol/aztec-packages/issues/4146)) ([14d39ed](https://github.com/AztecProtocol/aztec-packages/commit/14d39edbe1a6753849581a664184d4e98baf923d)) +* **bb:** Namespace plonk::stdlib => stdlib ([#4117](https://github.com/AztecProtocol/aztec-packages/issues/4117)) ([cd2f67f](https://github.com/AztecProtocol/aztec-packages/commit/cd2f67f5cbc471b9120f7c7070b96ba0d4994865)) +* **bb:** Namespace proof_system=>bb ([#4116](https://github.com/AztecProtocol/aztec-packages/issues/4116)) ([7438db3](https://github.com/AztecProtocol/aztec-packages/commit/7438db31b29860aa2c0af54afa8413711a24e1eb)) +* Remove mutex dependency ([#4160](https://github.com/AztecProtocol/aztec-packages/issues/4160)) ([3b82be0](https://github.com/AztecProtocol/aztec-packages/commit/3b82be0f266c838c823bbe26cfea99337d7180a9)) +* Remove unwanted submodules ([#4085](https://github.com/AztecProtocol/aztec-packages/issues/4085)) ([dda7c9c](https://github.com/AztecProtocol/aztec-packages/commit/dda7c9c4fa8da54d28b99b1cf601328030485503)) + ## [0.19.0](https://github.com/AztecProtocol/aztec-packages/compare/barretenberg-v0.18.0...barretenberg-v0.19.0) (2024-01-17) diff --git a/barretenberg/acir_tests/Dockerfile.bb b/barretenberg/acir_tests/Dockerfile.bb index a20d3d53280b..006db0e53335 100644 --- a/barretenberg/acir_tests/Dockerfile.bb +++ b/barretenberg/acir_tests/Dockerfile.bb @@ -7,10 +7,13 @@ COPY --from=0 /usr/src/barretenberg/cpp/build /usr/src/barretenberg/cpp/build COPY --from=noir-acir-tests /usr/src/noir/test_programs /usr/src/noir/test_programs WORKDIR /usr/src/barretenberg/acir_tests COPY . . -# Run every acir test through native bb build prove_then_verify flow. +# Run every acir test through native bb build prove_then_verify flow for UltraPlonk. # This ensures we test independent pk construction through real/garbage witness data paths. RUN FLOW=prove_then_verify ./run_acir_tests.sh -# TODO(https://github.com/AztecProtocol/barretenberg/issues/811) make this able to run the default test -RUN FLOW=prove_and_verify_goblin ./run_acir_tests.sh +# This flow is essentially the GoblinUltraHonk equivalent to the UltraPlonk "prove and verify". (This functionality is +# accessed via the goblin "accumulate" mechanism). +RUN FLOW=accumulate_and_verify_goblin ./run_acir_tests.sh +# This is a "full" Goblin flow. It constructs and verifies four proofs: GoblinUltraHonk, ECCVM, Translator, and merge +RUN FLOW=prove_and_verify_goblin ./run_acir_tests.sh 6_array # Run 1_mul through native bb build, all_cmds flow, to test all cli args. RUN VERBOSE=1 FLOW=all_cmds ./run_acir_tests.sh 1_mul diff --git a/barretenberg/acir_tests/Dockerfile.bb.js b/barretenberg/acir_tests/Dockerfile.bb.js index 4409bf7ce22b..b894826a5c2f 100644 --- a/barretenberg/acir_tests/Dockerfile.bb.js +++ b/barretenberg/acir_tests/Dockerfile.bb.js @@ -14,7 +14,10 @@ COPY . . ENV VERBOSE=1 # Run double_verify_proof through bb.js on node to check 512k support. RUN BIN=../ts/dest/node/main.js FLOW=prove_then_verify ./run_acir_tests.sh double_verify_proof -RUN BIN=../ts/dest/node/main.js FLOW=prove_and_verify_goblin ./run_acir_tests.sh double_verify_proof +# Run a single arbitrary test not involving recursion through bb.js for GoblinUltraHonk +RUN BIN=../ts/dest/node/main.js FLOW=accumulate_and_verify_goblin ./run_acir_tests.sh 6_array +# Run a single arbitrary test not involving recursion through bb.js for full Goblin +RUN BIN=../ts/dest/node/main.js FLOW=prove_and_verify_goblin ./run_acir_tests.sh 6_array # Run 1_mul through bb.js build, all_cmds flow, to test all cli args. RUN BIN=../ts/dest/node/main.js FLOW=all_cmds ./run_acir_tests.sh 1_mul # Run double_verify_proof through bb.js on chrome testing multi-threaded browser support. diff --git a/barretenberg/acir_tests/flows/accumulate_and_verify_goblin.sh b/barretenberg/acir_tests/flows/accumulate_and_verify_goblin.sh new file mode 100755 index 000000000000..a89e1a1dba11 --- /dev/null +++ b/barretenberg/acir_tests/flows/accumulate_and_verify_goblin.sh @@ -0,0 +1,6 @@ +#!/bin/sh +set -eu + +VFLAG=${VERBOSE:+-v} + +$BIN accumulate_and_verify_goblin $VFLAG -c $CRS_PATH -b ./target/acir.gz \ No newline at end of file diff --git a/barretenberg/acir_tests/run_acir_tests.sh b/barretenberg/acir_tests/run_acir_tests.sh index ee28c975113f..5c7bb60c9e2c 100755 --- a/barretenberg/acir_tests/run_acir_tests.sh +++ b/barretenberg/acir_tests/run_acir_tests.sh @@ -29,6 +29,7 @@ fi export BIN CRS_PATH VERBOSE BRANCH +# copy the gzipped acir test data from noir/test_programs to barretenberg/acir_tests ./clone_test_vectors.sh cd acir_tests diff --git a/barretenberg/cpp/CMakeLists.txt b/barretenberg/cpp/CMakeLists.txt index 86a5a1ee2bd8..1bd35206df0e 100644 --- a/barretenberg/cpp/CMakeLists.txt +++ b/barretenberg/cpp/CMakeLists.txt @@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.24 FATAL_ERROR) project( Barretenberg DESCRIPTION "BN254 elliptic curve library, and PLONK SNARK prover" - VERSION 0.19.0 # x-release-please-version + VERSION 0.20.0 # x-release-please-version LANGUAGES CXX C ) # Insert version into `bb` config file diff --git a/barretenberg/cpp/pil/avm/README.txt b/barretenberg/cpp/pil/avm/README.txt new file mode 100644 index 000000000000..cf63996a3c26 --- /dev/null +++ b/barretenberg/cpp/pil/avm/README.txt @@ -0,0 +1,21 @@ +This folder contains PIL relations for the AVM. + +Applied heuristic to assess the cost of a relation is given below. +This will be used to determine whether it is worth to merge some +relations into one. + +N_mul = number of mulitplication in the relation +N_add = number of additions/subtraction in the relation +deg = degree of the relation (total degree of the polynomial) + +Relation cost: degree * (N_mul + N_add/4) + +Remark: addition/multiplication with a constant counts as well in the above metrics +Remark: For edge case, we prefer keep a good readability rather than merging. + +Future: There is an optimization in sumcheck protocol allowing to skip some + rows for relations which are not enabled for them (applies when not + enabled over 2 adjacent rows). However, this feature is not yet enabled + in the AVM context. This might change the decision on whether some relations + should be merged or not. Basically, merging relations would decrease the + likelihood to be disabled over adjacent rows. \ No newline at end of file diff --git a/barretenberg/cpp/pil/avm/alu_chip.pil b/barretenberg/cpp/pil/avm/alu_chip.pil new file mode 100644 index 000000000000..09cf037b016a --- /dev/null +++ b/barretenberg/cpp/pil/avm/alu_chip.pil @@ -0,0 +1,201 @@ +include "avm_mini.pil"; + +namespace aluChip(256); + + // ========= Table ALU-TR ================================================= + + // References to main trace table of sub-operations, clk, intermediate + // registers, operation selectors. + // TODO: Think on optimizations to decrease the number of such "copied" columns + pol commit alu_clk; + pol commit alu_ia; // Intermediate registers + pol commit alu_ib; + pol commit alu_ic; + pol commit alu_op_add; // Operation selectors + pol commit alu_op_sub; + pol commit alu_op_mul; + pol commit alu_op_div; + + // Flattened boolean instruction tags + pol commit alu_ff_tag; + pol commit alu_u8_tag; + pol commit alu_u16_tag; + pol commit alu_u32_tag; + pol commit alu_u64_tag; + pol commit alu_u128_tag; + + // 8-bit slice registers + pol commit alu_u8_r0; + pol commit alu_u8_r1; + + // 16-bit slice registers + pol commit alu_u16_r0; + pol commit alu_u16_r1; + pol commit alu_u16_r2; + pol commit alu_u16_r3; + pol commit alu_u16_r4; + pol commit alu_u16_r5; + pol commit alu_u16_r6; + pol commit alu_u16_r7; + + // 64-bit slice register + pol commit alu_u64_r0; + + // Carry flag + pol commit alu_cf; + + // ========= Type Constraints ============================================= + // TODO: Range constraints + // - for slice registers + // - intermediate registers ia and ib (inputs) depending on flag (or inherited from previous ops?) + // - intermediate register ic (in some operations it might be inherited based on ia and ib ranges. To be checked.) + // Carry flag: We will have to constraint to ensure that the + // arithmetic expressions are not overflowing finite field size + // Remark: Operation selectors are constrained in the main trace. + // TODO: Enforce the equivalence check for the selectors between both tables. + + // Boolean flattened instructions tags + alu_ff_tag * (1 - alu_ff_tag) = 0; + alu_u8_tag * (1 - alu_u8_tag) = 0; + alu_u16_tag * (1 - alu_u16_tag) = 0; + alu_u32_tag * (1 - alu_u32_tag) = 0; + alu_u64_tag * (1 - alu_u64_tag) = 0; + alu_u128_tag * (1 - alu_u128_tag) = 0; + + // Operation selectors are copied from main table and do not need to be constrained here. + // TODO: Ensure mutual exclusion of alu_op_add and alu_op_sub as some relations below + // requires it. + // TODO: Similarly, ensure the mutual exclusion of instruction tags + + // ========= Inter-table Constraints ====================================== + // TODO: Equivalence between intermediate registers, clk, type flag, operation + // An ALU chiplet flag will be introduced in main trace to select relevant rows. + + + // ========= EXPLANATIONS ================================================= + // Main trick for arithmetic operations modulo 2^k is to perform the operation + // over the integers and expressing the result as low + high * 2^k with low + // smaller than 2^k. low is used as the output. This works as long this does + // not underflow/overflow the underlying finite field order (u128 multiplication + // will be handled differently). If we want to prove that c = OP(a,b) where OP + // denotes an arithmetic operation modulo 2^k, we can achieve this with two relations: + // (1) low + high * 2^k - OP'(a,b) = 0 + // (2) low - c = 0 + // + // where OP' denotes the same operation as OP but over the integers (not mod 2^k). + // We support u8, u16, u32, u64, u128 types and decompose low into + // smaller bit slices, e.g., 16. For instance, low = s_0 + s_1 * 2^16 + s_2 * 2^32 + ... + // The slices have to be range constrained and there is a trade-off between the + // number of registers and complexity of the range constraints. + // + // Optimization: We will capture the relation (1) for all types under the same umbrella + // by re-using the decomposition used for u128 type for the lower types. + // This works because any larger power of 2^k divides 2^l whenever k <= l. + // To be able to express "low" for u8, we need a 8-bit limb for the lowest + // bits. A bit decomposition covering all types is: + // s8_0 + s8_1 * 2^8 + s16_0 * 2^16 + s16_1 * 2^32 ... + s16_6 * 2^112 + carry * 2^128 - OP'(a,b) = 0 + // where s8_i's are 8-bit registers and s16's 16-bit registers. + // For type uk, we set low to the k-bit truncated part of register decomposition. + // As example, for u32: low = s8_0 + s8_1 * 2^8 + s16_0 * 2^16 + // and for u8: low = s8_0 + // + // TODO: It is open whether we might get efficiency gain to use larger registers for the higher + // parts of the bit decomposition. + + // ============= Helper polynomial terms ============================ + // These are intermediate polynomial terms which are not commited but + // serves to an algebraic expression of commited polynomials in a more concise way. + + // Bit slices partial sums + pol sum_8 = alu_u8_r0; + pol sum_16 = sum_8 + alu_u8_r1 * 2**8; + pol sum_32 = sum_16 + alu_u16_r0 * 2**16; + pol sum_64 = sum_32 + alu_u16_r1 * 2**32 + alu_u16_r2 * 2**48; + pol sum_96 = sum_64 + alu_u16_r3 * 2**64 + alu_u16_r4 * 2**80; + pol sum_128 = sum_96 + alu_u16_r5 * 2**96 + alu_u16_r6 * 2**112; + + // ========= ADDITION/SUBTRACTION Operation Constraints =============================== + // + // Addition and subtraction relations are very similar and will be consolidated. + // For the addition we have to replace OP'(a,b) in the above relation by a+b and + // for subtraction by a-b. Using operation selector values to toggle "+b" vs. "-b" + // makes the deal with the adaptation that the carry term needs to be subtracted + // instead of being added. To sumarize, for the first relation, addition needs to + // satisfy: + // sum_128 + carry * 2^128 - a - b = 0 + // while the subtraction satisfies: + // sum_128 - carry * 2^128 - a + b = 0 + // + // Finally, we would like this relation to also satisfy the addition over the finite field. + // For this, we add c in the relation conditoned by the ff type selector alu_ff_tag. We emphasize + // that this relation alone for FF will not imply correctness of the FF addition. We only want + // it to be satisfied. A separate relation will ensure correctness of it. + // + // The second relation will consist in showing that sum_N - c = 0 for N = 8, 16, 32, 64, 128. + + #[ALU_ADD_SUB_1] + (alu_op_add + alu_op_sub) * (sum_128 - alu_ia + alu_ff_tag * alu_ic) + (alu_op_add - alu_op_sub) * (alu_cf * 2**128 - alu_ib) = 0; + + // Helper polynomial + pol sum_tag = alu_u8_tag * sum_8 + alu_u16_tag * sum_16 + alu_u32_tag * sum_32 + alu_u64_tag * sum_64 + alu_u128_tag * sum_128; + + #[ALU_ADD_SUB_2] + (alu_op_add + alu_op_sub) * (sum_tag + alu_ff_tag * alu_ia - alu_ic) + alu_ff_tag * (alu_op_add - alu_op_sub) * alu_ib = 0; + + // ========= MULTIPLICATION Operation Constraints =============================== + + // ff multiplication + #[ALU_MULTIPLICATION_FF] + alu_ff_tag * alu_op_mul * (alu_ia * alu_ib - alu_ic) = 0; + + + // We need 2k bits to express the product (a*b) over the integer, i.e., for type uk + // we express the product as sum_k (u8 is an exception as we need 8-bit registers) + + // We group relations for u8, u16, u32, u64 together. + + // Helper polynomial + pol sum_tag_no_128 = alu_u8_tag * sum_8 + alu_u16_tag * sum_16 + alu_u32_tag * sum_32 + alu_u64_tag * sum_64; + + #[ALU_MUL_COMMON_1] + (1 - alu_ff_tag - alu_u128_tag) * alu_op_mul * (sum_128 - alu_ia * alu_ib) = 0; + + #[ALU_MUL_COMMON_2] + alu_op_mul * (sum_tag_no_128 - (1 - alu_ff_tag - alu_u128_tag) * alu_ic) = 0; + + // ========= u128 MULTIPLICATION Operation Constraints =============================== + // + // We express a, b in 64-bit slices: a = a_l + a_h * 2^64 + // b = b_l + b_h * 2^64 + // We show that c satisfies: a_l * b_l + (a_h * b_l + a_l * b_h) * 2^64 = R * 2^128 + c + // for a R < 2^65. Equivalently: + // a * b_l + a_l * b_h * 2^64 = (CF * 2^64 + R') * 2^128 + c + // for a bit carry flag CF and R' range constrained to 64 bits. + // We use two lines in the execution trace. First line represents a + // as decomposed over 16-bit registers. Second line represents b. + // Selector flag is only toggled in the first line and we access b through + // shifted polynomials. + // R' is stored in alu_u64_r0 + + // 64-bit lower limb + pol sum_low_64 = alu_u16_r0 + alu_u16_r1 * 2**16 + alu_u16_r2 * 2**32 + alu_u16_r3 * 2**48; + + // 64-bit higher limb + pol sum_high_64 = alu_u16_r4 + alu_u16_r5 * 2**16 + alu_u16_r6 * 2**32 + alu_u16_r7 * 2**48; + + // 64-bit lower limb for next row + pol sum_low_shifted_64 = alu_u16_r0' + alu_u16_r1' * 2**16 + alu_u16_r2' * 2**32 + alu_u16_r3' * 2**48; + + // 64-bit higher limb for next row + pol sum_high_shifted_64 = alu_u16_r4' + alu_u16_r5' * 2**16 + alu_u16_r6' * 2**32 + alu_u16_r7' * 2**48; + + // Arithmetic relations + alu_u128_tag * alu_op_mul * (sum_low_64 + sum_high_64 * 2**64 - alu_ia) = 0; + alu_u128_tag * alu_op_mul * (sum_low_shifted_64 + sum_high_shifted_64 * 2**64 - alu_ib) = 0; + #[ALU_MULTIPLICATION_OUT_U128] + alu_u128_tag * alu_op_mul * ( + alu_ia * sum_low_shifted_64 + + sum_low_64 * sum_high_shifted_64 * 2**64 + - (alu_cf * 2**64 + alu_u64_r0) * 2**128 + - alu_ic + ) = 0; diff --git a/barretenberg/cpp/pil/avm/avm_mini.pil b/barretenberg/cpp/pil/avm/avm_mini.pil index cd3fb8f29e4c..26268fe25cd9 100644 --- a/barretenberg/cpp/pil/avm/avm_mini.pil +++ b/barretenberg/cpp/pil/avm/avm_mini.pil @@ -1,5 +1,6 @@ include "mem_trace.pil"; +include "alu_chip.pil"; namespace avmMini(256); @@ -102,18 +103,6 @@ namespace avmMini(256); tag_err * ib = 0; tag_err * ic = 0; - // Relation for addition over the finite field - #[SUBOP_ADDITION_FF] - sel_op_add * (ia + ib - ic) = 0; - - // Relation for subtraction over the finite field - #[SUBOP_SUBTRACTION_FF] - sel_op_sub * (ia - ib - ic) = 0; - - // Relation for multiplication over the finite field - #[SUBOP_MULTIPLICATION_FF] - sel_op_mul * (ia * ib - ic) = 0; - // Relation for division over the finite field // If tag_err == 1 in a division, then ib == 0 and op_err == 1. #[SUBOP_DIVISION_FF] diff --git a/barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.cpp b/barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.cpp index f724fad7ca0d..a0cc5f3b06d5 100644 --- a/barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.cpp +++ b/barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.cpp @@ -1,6 +1,7 @@ #include "get_bn254_crs.hpp" #include "barretenberg/bb/file_io.hpp" +namespace { std::vector download_bn254_g1_data(size_t num_points) { size_t g1_end = num_points * 64 - 1; @@ -26,8 +27,10 @@ std::vector download_bn254_g2_data() std::string command = "curl -s '" + url + "'"; return exec_pipe(command); } +} // namespace -std::vector get_bn254_g1_data(const std::filesystem::path& path, size_t num_points) +namespace bb { +std::vector get_bn254_g1_data(const std::filesystem::path& path, size_t num_points) { std::filesystem::create_directories(path); @@ -37,9 +40,9 @@ std::vector get_bn254_g1_data(const std::filesystem::pat if (g1_file_size >= num_points * 64 && g1_file_size % 64 == 0) { vinfo("using cached crs of size ", std::to_string(g1_file_size / 64), " at ", g1_path); auto data = read_file(g1_path, g1_file_size); - auto points = std::vector(num_points); + auto points = std::vector(num_points); for (size_t i = 0; i < num_points; ++i) { - points[i] = from_buffer(data, i * 64); + points[i] = from_buffer(data, i * 64); } return points; } @@ -48,14 +51,14 @@ std::vector get_bn254_g1_data(const std::filesystem::pat auto data = download_bn254_g1_data(num_points); write_file(g1_path, data); - auto points = std::vector(num_points); + auto points = std::vector(num_points); for (size_t i = 0; i < num_points; ++i) { - points[i] = from_buffer(data, i * 64); + points[i] = from_buffer(data, i * 64); } return points; } -bb::g2::affine_element get_bn254_g2_data(const std::filesystem::path& path) +g2::affine_element get_bn254_g2_data(const std::filesystem::path& path) { std::filesystem::create_directories(path); @@ -64,10 +67,11 @@ bb::g2::affine_element get_bn254_g2_data(const std::filesystem::path& path) if (g2_file_size == 128) { auto data = read_file(g2_path); - return from_buffer(data.data()); + return from_buffer(data.data()); } auto data = download_bn254_g2_data(); write_file(g2_path, data); - return from_buffer(data.data()); + return from_buffer(data.data()); } +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.hpp b/barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.hpp index 230e074f219a..4ceb35578130 100644 --- a/barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.hpp +++ b/barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.hpp @@ -8,5 +8,7 @@ #include #include -std::vector get_bn254_g1_data(const std::filesystem::path& path, size_t num_points); -bb::g2::affine_element get_bn254_g2_data(const std::filesystem::path& path); \ No newline at end of file +namespace bb { +std::vector get_bn254_g1_data(const std::filesystem::path& path, size_t num_points); +g2::affine_element get_bn254_g2_data(const std::filesystem::path& path); +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/bb/get_grumpkin_crs.cpp b/barretenberg/cpp/src/barretenberg/bb/get_grumpkin_crs.cpp index fca6a54de7b3..1942c278ea4a 100644 --- a/barretenberg/cpp/src/barretenberg/bb/get_grumpkin_crs.cpp +++ b/barretenberg/cpp/src/barretenberg/bb/get_grumpkin_crs.cpp @@ -1,5 +1,6 @@ #include "get_grumpkin_crs.hpp" +namespace { std::vector download_grumpkin_g1_data(size_t num_points) { size_t g1_start = 28; @@ -19,7 +20,9 @@ std::vector download_grumpkin_g1_data(size_t num_points) return data; } +} // namespace +namespace bb { std::vector get_grumpkin_g1_data(const std::filesystem::path& path, size_t num_points) { std::filesystem::create_directories(path); @@ -35,7 +38,7 @@ std::vector get_grumpkin_g1_data(const std::file auto data = read_file(file, 28 + num_points * 64); auto points = std::vector(num_points); auto size_of_points_in_bytes = num_points * 64; - bb::srs::IO::read_affine_elements_from_buffer( + srs::IO::read_affine_elements_from_buffer( points.data(), (char*)data.data(), size_of_points_in_bytes); return points; } @@ -52,6 +55,7 @@ std::vector get_grumpkin_g1_data(const std::file new_size_file.close(); auto points = std::vector(num_points); - bb::srs::IO::read_affine_elements_from_buffer(points.data(), (char*)data.data(), data.size()); + srs::IO::read_affine_elements_from_buffer(points.data(), (char*)data.data(), data.size()); return points; } +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/bb/get_grumpkin_crs.hpp b/barretenberg/cpp/src/barretenberg/bb/get_grumpkin_crs.hpp index 894885ce97eb..5c8f9fcef168 100644 --- a/barretenberg/cpp/src/barretenberg/bb/get_grumpkin_crs.hpp +++ b/barretenberg/cpp/src/barretenberg/bb/get_grumpkin_crs.hpp @@ -8,4 +8,8 @@ #include #include -std::vector get_grumpkin_g1_data(const std::filesystem::path& path, size_t num_points); \ No newline at end of file +namespace bb { + +std::vector get_grumpkin_g1_data(const std::filesystem::path& path, size_t num_points); + +} \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/bb/main.cpp b/barretenberg/cpp/src/barretenberg/bb/main.cpp index 5f75206108eb..6c567b00bcd7 100644 --- a/barretenberg/cpp/src/barretenberg/bb/main.cpp +++ b/barretenberg/cpp/src/barretenberg/bb/main.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -43,6 +44,12 @@ void init_bn254_crs(size_t dyadic_circuit_size) srs::init_crs_factory(bn254_g1_data, bn254_g2_data); } +/** + * @brief Initialize the global crs_factory for grumpkin based on a known dyadic circuit size + * @details Grumpkin crs is required only for the ECCVM + * + * @param dyadic_circuit_size power-of-2 circuit size + */ void init_grumpkin_crs(size_t eccvm_dyadic_circuit_size) { auto grumpkin_g1_data = get_grumpkin_g1_data(CRS_PATH, eccvm_dyadic_circuit_size); @@ -65,7 +72,7 @@ acir_format::WitnessVector get_witness(std::string const& witness_path) return acir_format::witness_buf_to_witness_data(witness_data); } -acir_format::acir_format get_constraint_system(std::string const& bytecode_path) +acir_format::AcirFormat get_constraint_system(std::string const& bytecode_path) { auto bytecode = get_bytecode(bytecode_path); return acir_format::circuit_buf_to_acir_format(bytecode); @@ -115,6 +122,43 @@ bool proveAndVerify(const std::string& bytecodePath, const std::string& witnessP return verified; } +/** + * @brief Constructs and verifies a Honk proof for an ACIR circuit via the Goblin accumulate mechanism + * + * Communication: + * - proc_exit: A boolean value is returned indicating whether the proof is valid. + * an exit code of 0 will be returned for success and 1 for failure. + * + * @param bytecodePath Path to the file containing the serialized acir constraint system + * @param witnessPath Path to the file containing the serialized witness + * @return verified + */ +bool accumulateAndVerifyGoblin(const std::string& bytecodePath, const std::string& witnessPath) +{ + // Populate the acir constraint system and witness from gzipped data + auto constraint_system = get_constraint_system(bytecodePath); + auto witness = get_witness(witnessPath); + + // Instantiate a Goblin acir composer and construct a bberg circuit from the acir representation + acir_proofs::GoblinAcirComposer acir_composer; + acir_composer.create_circuit(constraint_system, witness); + + // TODO(https://github.com/AztecProtocol/barretenberg/issues/811): Don't hardcode dyadic circuit size. Currently set + // to max circuit size present in acir tests suite. + size_t hardcoded_bn254_dyadic_size_hack = 1 << 18; + init_bn254_crs(hardcoded_bn254_dyadic_size_hack); + size_t hardcoded_grumpkin_dyadic_size_hack = 1 << 10; // For eccvm only + init_grumpkin_crs(hardcoded_grumpkin_dyadic_size_hack); + + // Call accumulate to generate a GoblinUltraHonk proof + auto proof = acir_composer.accumulate(); + + // Verify the GoblinUltraHonk proof + auto verified = acir_composer.verify_accumulator(proof); + + return verified; +} + /** * @brief Proves and Verifies an ACIR circuit * @@ -132,11 +176,13 @@ bool proveAndVerifyGoblin(const std::string& bytecodePath, const std::string& witnessPath, [[maybe_unused]] bool recursive) { + // Populate the acir constraint system and witness from gzipped data auto constraint_system = get_constraint_system(bytecodePath); auto witness = get_witness(witnessPath); - acir_proofs::AcirComposer acir_composer; - acir_composer.create_goblin_circuit(constraint_system, witness); + // Instantiate a Goblin acir composer and construct a bberg circuit from the acir representation + acir_proofs::GoblinAcirComposer acir_composer; + acir_composer.create_circuit(constraint_system, witness); // TODO(https://github.com/AztecProtocol/barretenberg/issues/811): Don't hardcode dyadic circuit size. Currently set // to max circuit size present in acir tests suite. @@ -145,9 +191,11 @@ bool proveAndVerifyGoblin(const std::string& bytecodePath, size_t hardcoded_grumpkin_dyadic_size_hack = 1 << 10; // For eccvm only init_grumpkin_crs(hardcoded_grumpkin_dyadic_size_hack); - auto proof = acir_composer.create_goblin_proof(); + // Generate a GoblinUltraHonk proof and a full Goblin proof + auto proof = acir_composer.accumulate_and_prove(); - auto verified = acir_composer.verify_goblin_proof(proof); + // Verify the GoblinUltraHonk proof and the full Goblin proof + auto verified = acir_composer.verify(proof); return verified; } @@ -458,6 +506,9 @@ int main(int argc, char* argv[]) if (command == "prove_and_verify") { return proveAndVerify(bytecode_path, witness_path, recursive) ? 0 : 1; } + if (command == "accumulate_and_verify_goblin") { + return accumulateAndVerifyGoblin(bytecode_path, witness_path) ? 0 : 1; + } if (command == "prove_and_verify_goblin") { return proveAndVerifyGoblin(bytecode_path, witness_path, recursive) ? 0 : 1; } diff --git a/barretenberg/cpp/src/barretenberg/benchmark/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/benchmark/CMakeLists.txt index 285f2bb5937b..e86e72df09d4 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/CMakeLists.txt +++ b/barretenberg/cpp/src/barretenberg/benchmark/CMakeLists.txt @@ -1,3 +1,4 @@ +add_subdirectory(commit_bench) add_subdirectory(decrypt_bench) add_subdirectory(ipa_bench) add_subdirectory(pippenger_bench) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/basics_bench/basics.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/basics_bench/basics.bench.cpp index 1d1cc37718a6..c3bf090f2cfa 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/basics_bench/basics.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/basics_bench/basics.bench.cpp @@ -40,7 +40,7 @@ using Fr = Curve::ScalarField; */ void parallel_for_field_element_addition(State& state) { - numeric::random::Engine& engine = numeric::random::get_debug_engine(); + numeric::RNG& engine = numeric::get_debug_randomness(); size_t num_cpus = get_num_cpus(); std::vector> copy_vector(num_cpus); for (size_t i = 0; i < num_cpus; i++) { @@ -72,7 +72,7 @@ void parallel_for_field_element_addition(State& state) */ void ff_addition(State& state) { - numeric::random::Engine& engine = numeric::random::get_debug_engine(); + numeric::RNG& engine = numeric::get_debug_randomness(); std::vector copy_vector(2); for (size_t j = 0; j < 2; j++) { copy_vector.emplace_back(Fr::random_element(&engine)); @@ -97,7 +97,7 @@ void ff_addition(State& state) */ void ff_multiplication(State& state) { - numeric::random::Engine& engine = numeric::random::get_debug_engine(); + numeric::RNG& engine = numeric::get_debug_randomness(); std::vector copy_vector(2); for (size_t j = 0; j < 2; j++) { copy_vector.emplace_back(Fr::random_element(&engine)); @@ -122,7 +122,7 @@ void ff_multiplication(State& state) */ void ff_sqr(State& state) { - numeric::random::Engine& engine = numeric::random::get_debug_engine(); + numeric::RNG& engine = numeric::get_debug_randomness(); std::vector copy_vector(2); for (size_t j = 0; j < 2; j++) { copy_vector.emplace_back(Fr::random_element(&engine)); @@ -147,7 +147,7 @@ void ff_sqr(State& state) */ void ff_invert(State& state) { - numeric::random::Engine& engine = numeric::random::get_debug_engine(); + numeric::RNG& engine = numeric::get_debug_randomness(); auto element = Fr::random_element(&engine); for (auto _ : state) { @@ -168,7 +168,7 @@ void ff_invert(State& state) */ void ff_to_montgomery(State& state) { - numeric::random::Engine& engine = numeric::random::get_debug_engine(); + numeric::RNG& engine = numeric::get_debug_randomness(); auto element = Fr::random_element(&engine); for (auto _ : state) { @@ -188,7 +188,7 @@ void ff_to_montgomery(State& state) */ void ff_from_montgomery(State& state) { - numeric::random::Engine& engine = numeric::random::get_debug_engine(); + numeric::RNG& engine = numeric::get_debug_randomness(); auto element = Fr::random_element(&engine); for (auto _ : state) { @@ -209,7 +209,7 @@ void ff_from_montgomery(State& state) */ void ff_reduce(State& state) { - numeric::random::Engine& engine = numeric::random::get_debug_engine(); + numeric::RNG& engine = numeric::get_debug_randomness(); auto element = Fr::random_element(&engine); for (auto _ : state) { @@ -230,7 +230,7 @@ void ff_reduce(State& state) */ void projective_point_addition(State& state) { - numeric::random::Engine& engine = numeric::random::get_debug_engine(); + numeric::RNG& engine = numeric::get_debug_randomness(); std::vector copy_vector(2); for (size_t j = 0; j < 2; j++) { copy_vector.emplace_back(Curve::Element::random_element(&engine)); @@ -255,7 +255,7 @@ void projective_point_addition(State& state) */ void projective_point_accidental_doubling(State& state) { - numeric::random::Engine& engine = numeric::random::get_debug_engine(); + numeric::RNG& engine = numeric::get_debug_randomness(); std::vector copy_vector(2); for (size_t j = 0; j < 2; j++) { copy_vector.emplace_back(Curve::Element::random_element(&engine)); @@ -280,7 +280,7 @@ void projective_point_accidental_doubling(State& state) */ void projective_point_doubling(State& state) { - numeric::random::Engine& engine = numeric::random::get_debug_engine(); + numeric::RNG& engine = numeric::get_debug_randomness(); std::vector copy_vector(2); for (size_t j = 0; j < 2; j++) { copy_vector.emplace_back(Curve::Element::random_element(&engine)); @@ -305,7 +305,7 @@ void projective_point_doubling(State& state) */ void scalar_multiplication(State& state) { - numeric::random::Engine& engine = numeric::random::get_debug_engine(); + numeric::RNG& engine = numeric::get_debug_randomness(); Curve::Element element = Curve::Element::random_element(&engine); Fr scalar = Fr::random_element(&engine); @@ -347,7 +347,7 @@ void cycle_waste(State& state) void sequential_copy(State& state) { - numeric::random::Engine& engine = numeric::random::get_debug_engine(); + numeric::RNG& engine = numeric::get_debug_randomness(); for (auto _ : state) { state.PauseTiming(); size_t num_cycles = 1 << static_cast(state.range(0)); diff --git a/barretenberg/cpp/src/barretenberg/benchmark/commit_bench/CMakeLists.txt b/barretenberg/cpp/src/barretenberg/benchmark/commit_bench/CMakeLists.txt new file mode 100644 index 000000000000..3bca58463b1e --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/benchmark/commit_bench/CMakeLists.txt @@ -0,0 +1,18 @@ +# Each source represents a separate benchmark suite +set(BENCHMARK_SOURCES + commit.bench.cpp +) + +# Required libraries for benchmark suites +set(LINKED_LIBRARIES + commitment_schemes + benchmark::benchmark +) + +# Add executable and custom target for each suite, e.g. ultra_honk_bench +foreach(BENCHMARK_SOURCE ${BENCHMARK_SOURCES}) + get_filename_component(BENCHMARK_NAME ${BENCHMARK_SOURCE} NAME_WE) # extract name without extension + add_executable(${BENCHMARK_NAME}_bench main.bench.cpp ${BENCHMARK_SOURCE}) + target_link_libraries(${BENCHMARK_NAME}_bench ${LINKED_LIBRARIES}) + add_custom_target(run_${BENCHMARK_NAME} COMMAND ${BENCHMARK_NAME} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +endforeach() \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/benchmark/commit_bench/commit.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/commit_bench/commit.bench.cpp new file mode 100644 index 000000000000..769901042855 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/benchmark/commit_bench/commit.bench.cpp @@ -0,0 +1,38 @@ + +#include "barretenberg/commitment_schemes/commitment_key.hpp" +#include + +namespace bb { + +template +std::shared_ptr> create_commitment_key(const size_t num_points) +{ + std::string srs_path; + if constexpr (std::same_as) { + srs_path = "../srs_db/ignition"; + } else { + static_assert(std::same_as); + srs_path = "../srs_db/grumpkin"; + } + std::shared_ptr> crs_factory( + new bb::srs::factories::FileCrsFactory(srs_path, num_points)); + return std::make_shared>(num_points, crs_factory); +} + +constexpr size_t MAX_LOG_NUM_POINTS = 24; +constexpr size_t MAX_NUM_POINTS = 1 << MAX_LOG_NUM_POINTS; + +auto key = create_commitment_key(MAX_NUM_POINTS); + +template void bench_commit(::benchmark::State& state) +{ + const size_t num_points = 1 << state.range(0); + const auto polynomial = Polynomial(num_points); + for (auto _ : state) { + benchmark::DoNotOptimize(key->commit(polynomial)); + } +} + +BENCHMARK(bench_commit)->DenseRange(10, MAX_LOG_NUM_POINTS)->Unit(benchmark::kMillisecond); + +} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/benchmark/commit_bench/main.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/commit_bench/main.bench.cpp new file mode 100644 index 000000000000..71fefa047228 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/benchmark/commit_bench/main.bench.cpp @@ -0,0 +1,3 @@ +#include + +BENCHMARK_MAIN(); diff --git a/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/eccvm.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/eccvm.bench.cpp index 630484837e11..4c89b375de5c 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/eccvm.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/eccvm.bench.cpp @@ -1,6 +1,6 @@ #include -#include "barretenberg/benchmark/ultra_bench/benchmark_utilities.hpp" +#include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp" #include "barretenberg/eccvm/eccvm_composer.hpp" #include "barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.hpp" diff --git a/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/goblin.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/goblin.bench.cpp index 40b95b7a7d2d..839c8237de44 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/goblin.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/goblin_bench/goblin.bench.cpp @@ -1,7 +1,7 @@ #include -#include "barretenberg/benchmark/ultra_bench/benchmark_utilities.hpp" +#include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp" #include "barretenberg/goblin/goblin.hpp" #include "barretenberg/goblin/mock_circuits.hpp" #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" @@ -9,7 +9,6 @@ using namespace benchmark; using namespace bb; -using namespace bb; namespace { void goblin_full(State& state) noexcept diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ipa_bench/ipa.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/ipa_bench/ipa.bench.cpp index e3da4560115d..3a25ee93dfd2 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ipa_bench/ipa.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ipa_bench/ipa.bench.cpp @@ -3,7 +3,6 @@ using namespace benchmark; using namespace bb; -using namespace bb; using namespace bb::honk::pcs::ipa; namespace { using Curve = curve::Grumpkin; @@ -29,7 +28,7 @@ std::vector opening_claims(MAX_POLYNOMIAL_DEGREE_LOG2 - MIN_POLYNO void ipa_open(State& state) noexcept { - numeric::random::Engine& engine = numeric::random::get_debug_engine(); + numeric::RNG& engine = numeric::get_debug_randomness(); for (auto _ : state) { state.PauseTiming(); size_t n = 1 << static_cast(state.range(0)); diff --git a/barretenberg/cpp/src/barretenberg/benchmark/plonk_bench/standard_plonk.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/plonk_bench/standard_plonk.bench.cpp index 71d790519c0b..1a1eff70e7a0 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/plonk_bench/standard_plonk.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/plonk_bench/standard_plonk.bench.cpp @@ -1,4 +1,4 @@ -#include "barretenberg/benchmark/ultra_bench/benchmark_utilities.hpp" +#include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp" #include "barretenberg/plonk/composer/standard_composer.hpp" #include "barretenberg/proof_system/circuit_builder/standard_circuit_builder.hpp" @@ -13,8 +13,8 @@ using StandardPlonk = bb::plonk::StandardComposer; static void construct_proof_standard_power_of_2(State& state) noexcept { auto log2_of_gates = static_cast(state.range(0)); - bench_utils::construct_proof_with_specified_num_iterations( - state, &bench_utils::generate_basic_arithmetic_circuit, log2_of_gates); + bb::mock_proofs::construct_proof_with_specified_num_iterations( + state, &bb::mock_proofs::generate_basic_arithmetic_circuit, log2_of_gates); } BENCHMARK(construct_proof_standard_power_of_2) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_bench/protogalaxy.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_bench/protogalaxy.bench.cpp index 80fd2e0d3b52..b0a4f05afbf9 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_bench/protogalaxy.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/protogalaxy_bench/protogalaxy.bench.cpp @@ -1,6 +1,6 @@ #include -#include "barretenberg/benchmark/ultra_bench/benchmark_utilities.hpp" +#include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp" #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" #include "barretenberg/ultra_honk/ultra_composer.hpp" @@ -23,14 +23,14 @@ void fold_one(State& state) noexcept const auto construct_instance = [&]() { Builder builder; - bench_utils::generate_basic_arithmetic_circuit(builder, log2_num_gates); + bb::mock_proofs::generate_basic_arithmetic_circuit(builder, log2_num_gates); return composer.create_instance(builder); }; std::shared_ptr instance_1 = construct_instance(); std::shared_ptr instance_2 = construct_instance(); - auto folding_prover = composer.create_folding_prover({ instance_1, instance_2 }, composer.commitment_key); + auto folding_prover = composer.create_folding_prover({ instance_1, instance_2 }); for (auto _ : state) { auto proof = folding_prover.fold_instances(); diff --git a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/barycentric.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/barycentric.bench.cpp index 19572fe6a0ea..b11d6b4771a7 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/barycentric.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/barycentric.bench.cpp @@ -5,7 +5,7 @@ using namespace benchmark; namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = bb::numeric::get_debug_randomness(); } using FF = bb::fr; diff --git a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp index e683523a7e3f..7541c6097544 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/relations_bench/relations.bench.cpp @@ -5,7 +5,7 @@ #include namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = bb::numeric::get_debug_randomness(); } using namespace bb::honk::sumcheck; diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/benchmark_utilities.hpp b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_proofs.hpp similarity index 69% rename from barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/benchmark_utilities.hpp rename to barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_proofs.hpp index d7fe88865074..6bbc81a58721 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/benchmark_utilities.hpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/mock_proofs.hpp @@ -20,9 +20,7 @@ #include "barretenberg/ultra_honk/ultra_composer.hpp" #include "barretenberg/ultra_honk/ultra_prover.hpp" -using namespace benchmark; - -namespace bench_utils { +namespace bb::mock_proofs { /** * @brief Generate test circuit with basic arithmetic operations @@ -32,9 +30,9 @@ namespace bench_utils { */ template void generate_basic_arithmetic_circuit(Builder& builder, size_t log2_num_gates) { - bb::stdlib::field_t a(bb::stdlib::witness_t(&builder, bb::fr::random_element())); - bb::stdlib::field_t b(bb::stdlib::witness_t(&builder, bb::fr::random_element())); - bb::stdlib::field_t c(&builder); + stdlib::field_t a(stdlib::witness_t(&builder, fr::random_element())); + stdlib::field_t b(stdlib::witness_t(&builder, fr::random_element())); + stdlib::field_t c(&builder); size_t passes = (1UL << log2_num_gates) / 4 - 4; if (static_cast(passes) <= 0) { throw std::runtime_error("too few gates"); @@ -58,9 +56,9 @@ template void generate_sha256_test_circuit(Builder& builder, { std::string in; in.resize(32); - bb::stdlib::packed_byte_array input(&builder, in); + stdlib::packed_byte_array input(&builder, in); for (size_t i = 0; i < num_iterations; i++) { - input = bb::stdlib::sha256(input); + input = stdlib::sha256(input); } } @@ -74,9 +72,9 @@ template void generate_keccak_test_circuit(Builder& builder, { std::string in = "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01"; - bb::stdlib::byte_array input(&builder, in); + stdlib::byte_array input(&builder, in); for (size_t i = 0; i < num_iterations; i++) { - input = bb::stdlib::keccak::hash(input); + input = stdlib::keccak::hash(input); } } @@ -88,24 +86,24 @@ template void generate_keccak_test_circuit(Builder& builder, */ template void generate_ecdsa_verification_test_circuit(Builder& builder, size_t num_iterations) { - using curve = bb::stdlib::secp256k1; + using curve = stdlib::secp256k1; using fr = typename curve::fr; using fq = typename curve::fq; using g1 = typename curve::g1; std::string message_string = "Instructions unclear, ask again later."; - crypto::ecdsa::key_pair account; + crypto::ecdsa_key_pair account; for (size_t i = 0; i < num_iterations; i++) { // Generate unique signature for each iteration account.private_key = curve::fr::random_element(); account.public_key = curve::g1::one * account.private_key; - crypto::ecdsa::signature signature = - crypto::ecdsa::construct_signature(message_string, account); + crypto::ecdsa_signature signature = + crypto::ecdsa_construct_signature(message_string, account); bool first_result = - crypto::ecdsa::verify_signature(message_string, account.public_key, signature); + crypto::ecdsa_verify_signature(message_string, account.public_key, signature); static_cast(first_result); // TODO(Cody): This is not used anywhere. std::vector rr(signature.r.begin(), signature.r.end()); @@ -114,18 +112,18 @@ template void generate_ecdsa_verification_test_circuit(Builde typename curve::g1_bigfr_ct public_key = curve::g1_bigfr_ct::from_witness(&builder, account.public_key); - bb::stdlib::ecdsa::signature sig{ typename curve::byte_array_ct(&builder, rr), - typename curve::byte_array_ct(&builder, ss), - bb::stdlib::uint8(&builder, vv) }; + stdlib::ecdsa_signature sig{ typename curve::byte_array_ct(&builder, rr), + typename curve::byte_array_ct(&builder, ss), + stdlib::uint8(&builder, vv) }; typename curve::byte_array_ct message(&builder, message_string); // Verify ecdsa signature - bb::stdlib::ecdsa::verify_signature(message, public_key, sig); + stdlib::ecdsa_verify_signature(message, public_key, sig); } } @@ -137,7 +135,7 @@ template void generate_ecdsa_verification_test_circuit(Builde */ template void generate_merkle_membership_test_circuit(Builder& builder, size_t num_iterations) { - using namespace bb::stdlib; + using namespace stdlib; using field_ct = field_t; using witness_ct = witness_t; using witness_ct = witness_t; @@ -164,33 +162,32 @@ template void generate_merkle_membership_test_circuit(Builder } // ultrahonk -inline bb::honk::UltraProver get_prover(bb::honk::UltraComposer& composer, - void (*test_circuit_function)(bb::honk::UltraComposer::CircuitBuilder&, size_t), - size_t num_iterations) +inline honk::UltraProver get_prover(honk::UltraComposer& composer, + void (*test_circuit_function)(honk::UltraComposer::CircuitBuilder&, size_t), + size_t num_iterations) { - bb::honk::UltraComposer::CircuitBuilder builder; + honk::UltraComposer::CircuitBuilder builder; test_circuit_function(builder, num_iterations); - std::shared_ptr instance = composer.create_instance(builder); + std::shared_ptr instance = composer.create_instance(builder); return composer.create_prover(instance); } // standard plonk -inline bb::plonk::Prover get_prover(bb::plonk::StandardComposer& composer, - void (*test_circuit_function)(bb::StandardCircuitBuilder&, size_t), - size_t num_iterations) +inline plonk::Prover get_prover(plonk::StandardComposer& composer, + void (*test_circuit_function)(StandardCircuitBuilder&, size_t), + size_t num_iterations) { - bb::StandardCircuitBuilder builder; + StandardCircuitBuilder builder; test_circuit_function(builder, num_iterations); return composer.create_prover(builder); } // ultraplonk -inline bb::plonk::UltraProver get_prover(bb::plonk::UltraComposer& composer, - void (*test_circuit_function)(bb::honk::UltraComposer::CircuitBuilder&, - size_t), - size_t num_iterations) +inline plonk::UltraProver get_prover(plonk::UltraComposer& composer, + void (*test_circuit_function)(honk::UltraComposer::CircuitBuilder&, size_t), + size_t num_iterations) { - bb::plonk::UltraComposer::CircuitBuilder builder; + plonk::UltraComposer::CircuitBuilder builder; test_circuit_function(builder, num_iterations); return composer.create_prover(builder); } @@ -205,10 +202,12 @@ inline bb::plonk::UltraProver get_prover(bb::plonk::UltraComposer& composer, * @param test_circuit_function */ template -void construct_proof_with_specified_num_iterations( - State& state, void (*test_circuit_function)(typename Composer::CircuitBuilder&, size_t), size_t num_iterations) +void construct_proof_with_specified_num_iterations(benchmark::State& state, + void (*test_circuit_function)(typename Composer::CircuitBuilder&, + size_t), + size_t num_iterations) { - bb::srs::init_crs_factory("../srs_db/ignition"); + srs::init_crs_factory("../srs_db/ignition"); Composer composer; @@ -223,4 +222,4 @@ void construct_proof_with_specified_num_iterations( } } -} // namespace bench_utils +} // namespace bb::mock_proofs diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk.bench.cpp index 1109a928f4ce..f560475a7af7 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk.bench.cpp @@ -1,6 +1,6 @@ #include -#include "barretenberg/benchmark/ultra_bench/benchmark_utilities.hpp" +#include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp" #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" #include "barretenberg/ultra_honk/ultra_composer.hpp" @@ -14,7 +14,7 @@ static void construct_proof_ultrahonk(State& state, void (*test_circuit_function)(UltraCircuitBuilder&, size_t)) noexcept { size_t num_iterations = 10; // 10x the circuit - bench_utils::construct_proof_with_specified_num_iterations( + bb::mock_proofs::construct_proof_with_specified_num_iterations( state, test_circuit_function, num_iterations); } @@ -24,22 +24,26 @@ static void construct_proof_ultrahonk(State& state, static void construct_proof_ultrahonk_power_of_2(State& state) noexcept { auto log2_of_gates = static_cast(state.range(0)); - bench_utils::construct_proof_with_specified_num_iterations( - state, &bench_utils::generate_basic_arithmetic_circuit, log2_of_gates); + bb::mock_proofs::construct_proof_with_specified_num_iterations( + state, &bb::mock_proofs::generate_basic_arithmetic_circuit, log2_of_gates); } // Define benchmarks -BENCHMARK_CAPTURE(construct_proof_ultrahonk, sha256, &bench_utils::generate_sha256_test_circuit) +BENCHMARK_CAPTURE(construct_proof_ultrahonk, + sha256, + &bb::mock_proofs::generate_sha256_test_circuit) ->Unit(kMillisecond); -BENCHMARK_CAPTURE(construct_proof_ultrahonk, keccak, &bench_utils::generate_keccak_test_circuit) +BENCHMARK_CAPTURE(construct_proof_ultrahonk, + keccak, + &bb::mock_proofs::generate_keccak_test_circuit) ->Unit(kMillisecond); BENCHMARK_CAPTURE(construct_proof_ultrahonk, ecdsa_verification, - &bench_utils::generate_ecdsa_verification_test_circuit) + &bb::mock_proofs::generate_ecdsa_verification_test_circuit) ->Unit(kMillisecond); BENCHMARK_CAPTURE(construct_proof_ultrahonk, merkle_membership, - &bench_utils::generate_merkle_membership_test_circuit) + &bb::mock_proofs::generate_merkle_membership_test_circuit) ->Unit(kMillisecond); BENCHMARK(construct_proof_ultrahonk_power_of_2) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk_rounds.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk_rounds.bench.cpp index b36e168b446f..8fd06307cec1 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk_rounds.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_honk_rounds.bench.cpp @@ -1,6 +1,6 @@ #include -#include "barretenberg/benchmark/ultra_bench/benchmark_utilities.hpp" +#include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp" #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" #include "barretenberg/ultra_honk/ultra_composer.hpp" #include "barretenberg/ultra_honk/ultra_prover.hpp" @@ -55,8 +55,8 @@ BBERG_PROFILE static void test_round(State& state, size_t index) noexcept state.PauseTiming(); honk::UltraComposer composer; // TODO(https://github.com/AztecProtocol/barretenberg/issues/761) benchmark both sparse and dense circuits - honk::UltraProver prover = bench_utils::get_prover( - composer, &bench_utils::generate_ecdsa_verification_test_circuit, 10); + honk::UltraProver prover = bb::mock_proofs::get_prover( + composer, &bb::mock_proofs::generate_ecdsa_verification_test_circuit, 10); test_round_inner(state, prover, index); state.ResumeTiming(); // NOTE: google bench is very finnicky, must end in ResumeTiming() for correctness diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk.bench.cpp index 0f16f152d2ce..a02fba5eb8a5 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk.bench.cpp @@ -1,4 +1,4 @@ -#include "barretenberg/benchmark/ultra_bench/benchmark_utilities.hpp" +#include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp" #include "barretenberg/plonk/composer/ultra_composer.hpp" #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" @@ -12,7 +12,7 @@ static void construct_proof_ultraplonk(State& state, void (*test_circuit_function)(UltraCircuitBuilder&, size_t)) noexcept { size_t num_iterations = 10; // 10x the circuit - bench_utils::construct_proof_with_specified_num_iterations( + bb::mock_proofs::construct_proof_with_specified_num_iterations( state, test_circuit_function, num_iterations); } @@ -22,22 +22,26 @@ static void construct_proof_ultraplonk(State& state, static void construct_proof_ultraplonk_power_of_2(State& state) noexcept { auto log2_of_gates = static_cast(state.range(0)); - bench_utils::construct_proof_with_specified_num_iterations( - state, &bench_utils::generate_basic_arithmetic_circuit, log2_of_gates); + bb::mock_proofs::construct_proof_with_specified_num_iterations( + state, &bb::mock_proofs::generate_basic_arithmetic_circuit, log2_of_gates); } // Define benchmarks -BENCHMARK_CAPTURE(construct_proof_ultraplonk, sha256, &bench_utils::generate_sha256_test_circuit) +BENCHMARK_CAPTURE(construct_proof_ultraplonk, + sha256, + &bb::mock_proofs::generate_sha256_test_circuit) ->Unit(kMillisecond); -BENCHMARK_CAPTURE(construct_proof_ultraplonk, keccak, &bench_utils::generate_keccak_test_circuit) +BENCHMARK_CAPTURE(construct_proof_ultraplonk, + keccak, + &bb::mock_proofs::generate_keccak_test_circuit) ->Unit(kMillisecond); BENCHMARK_CAPTURE(construct_proof_ultraplonk, ecdsa_verification, - &bench_utils::generate_ecdsa_verification_test_circuit) + &bb::mock_proofs::generate_ecdsa_verification_test_circuit) ->Unit(kMillisecond); BENCHMARK_CAPTURE(construct_proof_ultraplonk, merkle_membership, - &bench_utils::generate_merkle_membership_test_circuit) + &bb::mock_proofs::generate_merkle_membership_test_circuit) ->Unit(kMillisecond); BENCHMARK(construct_proof_ultraplonk_power_of_2) diff --git a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk_rounds.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk_rounds.bench.cpp index 8565dd96fbee..b78b825ce773 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk_rounds.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/ultra_bench/ultra_plonk_rounds.bench.cpp @@ -1,6 +1,6 @@ #include -#include "barretenberg/benchmark/ultra_bench/benchmark_utilities.hpp" +#include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp" #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" using namespace benchmark; @@ -54,8 +54,8 @@ BBERG_PROFILE static void test_round(State& state, size_t index) noexcept state.PauseTiming(); plonk::UltraComposer composer; // TODO: https://github.com/AztecProtocol/barretenberg/issues/761 benchmark both sparse and dense circuits - plonk::UltraProver prover = bench_utils::get_prover( - composer, &bench_utils::generate_ecdsa_verification_test_circuit, 10); + plonk::UltraProver prover = bb::mock_proofs::get_prover( + composer, &bb::mock_proofs::generate_ecdsa_verification_test_circuit, 10); test_round_inner(state, prover, index); // NOTE: google bench is very finnicky, must end in ResumeTiming() for correctness state.ResumeTiming(); diff --git a/barretenberg/cpp/src/barretenberg/benchmark/widgets_bench/widget.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/widgets_bench/widget.bench.cpp index b96f9f6ce78c..9b94063e3c21 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/widgets_bench/widget.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/widgets_bench/widget.bench.cpp @@ -1,4 +1,4 @@ -#include "barretenberg/benchmark/ultra_bench/benchmark_utilities.hpp" +#include "barretenberg/benchmark/ultra_bench/mock_proofs.hpp" #include "barretenberg/flavor/goblin_ultra.hpp" #include "barretenberg/flavor/ultra.hpp" #include "barretenberg/plonk/composer/standard_composer.hpp" @@ -19,7 +19,7 @@ // #define GET_PER_ROW_TIME namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = bb::numeric::get_debug_randomness(); } namespace bb::plonk { @@ -39,7 +39,7 @@ BasicPlonkKeyAndTranscript get_plonk_key_and_transcript() bb::srs::init_crs_factory("../srs_db/ignition"); auto inner_composer = plonk::UltraComposer(); auto builder = typename plonk::UltraComposer::CircuitBuilder(); - bench_utils::generate_basic_arithmetic_circuit(builder, 16); + bb::mock_proofs::generate_basic_arithmetic_circuit(builder, 16); UltraProver inner_prover = inner_composer.create_prover(builder); #ifdef GET_PER_ROW_TIME if (!(inner_prover.key->circuit_size == WIDGET_BENCH_TEST_CIRCUIT_SIZE)) { diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.test.hpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.test.hpp index df031f7404dc..3350e2ed8671 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.test.hpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/commitment_key.test.hpp @@ -75,7 +75,7 @@ template class CommitmentTest : public ::testing::Test { public: CommitmentTest() - : engine{ &numeric::random::get_engine() } + : engine{ &numeric::get_randomness() } {} std::shared_ptr ck() { return commitment_key; } @@ -170,7 +170,7 @@ template class CommitmentTest : public ::testing::Test { } } - numeric::random::Engine* engine; + numeric::RNG* engine; // Per-test-suite set-up. // Called before the first test in this test suite. diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.test.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.test.cpp index 1d6dd6779c21..09f65bbc6356 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/gemini/gemini.test.cpp @@ -7,7 +7,10 @@ #include #include -namespace bb::honk::pcs::gemini { +using namespace bb; +using namespace bb::honk; +using namespace bb::honk::pcs; +using namespace bb::honk::pcs::gemini; template class GeminiTest : public CommitmentTest { using GeminiProver = GeminiProver_; @@ -237,5 +240,3 @@ TYPED_TEST(GeminiTest, DoubleWithShift) multilinear_commitments, multilinear_commitments_to_be_shifted); } - -} // namespace bb::honk::pcs::gemini diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp index 3a9c26d1961d..6aafab2fd153 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp @@ -8,8 +8,11 @@ #include "barretenberg/polynomials/polynomial.hpp" #include "barretenberg/polynomials/polynomial_arithmetic.hpp" #include + using namespace bb; -namespace bb::honk::pcs::ipa::test { +using namespace bb::honk; +using namespace bb::honk::pcs; +using namespace bb::honk::pcs::ipa; using Curve = curve::Grumpkin; @@ -176,4 +179,3 @@ TEST_F(IPATest, GeminiShplonkIPAWithShift) EXPECT_EQ(verified, true); } -} // namespace bb::honk::pcs::ipa::test diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.test.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.test.cpp index 5e933bb7d6cd..30c02c0543a3 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.test.cpp @@ -32,7 +32,7 @@ TYPED_TEST(KZGTest, single) using Fr = typename TypeParam::ScalarField; auto witness = this->random_polynomial(n); - bb::g1::element commitment = this->commit(witness); + g1::element commitment = this->commit(witness); auto challenge = Fr::random_element(); auto evaluation = witness.evaluate(challenge); diff --git a/barretenberg/cpp/src/barretenberg/common/ref_array.hpp b/barretenberg/cpp/src/barretenberg/common/ref_array.hpp index 95224d8f7da1..b85556fa6d9f 100644 --- a/barretenberg/cpp/src/barretenberg/common/ref_array.hpp +++ b/barretenberg/cpp/src/barretenberg/common/ref_array.hpp @@ -5,7 +5,7 @@ #include #include -// TODO(https://github.com/AztecProtocol/barretenberg/issues/794) namespace this once convenient +namespace bb { /** * @brief A template class for a reference array. Behaves as if std::array was possible. * @@ -134,4 +134,5 @@ template RefArray concatenate(con (..., copy_into(ref_arrays, offset)); return RefArray{ concatenated }; -} \ No newline at end of file +} +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp b/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp index 523d75b8f5f3..c74d1b52c199 100644 --- a/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp +++ b/barretenberg/cpp/src/barretenberg/common/ref_vector.hpp @@ -6,7 +6,7 @@ #include #include -// TODO(https://github.com/AztecProtocol/barretenberg/issues/794) namespace this once convenient +namespace bb { /** * @brief A template class for a reference vector. Behaves as if std::vector was possible. * @@ -147,4 +147,5 @@ template static std::vector> to_vector_of_ref_vectors( result.push_back(RefVector{ inner }); } return result; -} \ No newline at end of file +} +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/common/std_array.hpp b/barretenberg/cpp/src/barretenberg/common/std_array.hpp index 850464ae36ad..cb70e124a67a 100644 --- a/barretenberg/cpp/src/barretenberg/common/std_array.hpp +++ b/barretenberg/cpp/src/barretenberg/common/std_array.hpp @@ -2,7 +2,7 @@ #include -// TODO(https://github.com/AztecProtocol/barretenberg/issues/794) namespace this once convenient +namespace bb { /** * @brief Concatenates multiple std::array objects into a single array. * @@ -37,3 +37,5 @@ template std::array concatenate(c return result; } + +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/common/std_vector.hpp b/barretenberg/cpp/src/barretenberg/common/std_vector.hpp index c3bf373820c4..f363b74635c5 100644 --- a/barretenberg/cpp/src/barretenberg/common/std_vector.hpp +++ b/barretenberg/cpp/src/barretenberg/common/std_vector.hpp @@ -1,7 +1,7 @@ #pragma once #include -// TODO(https://github.com/AztecProtocol/barretenberg/issues/794) namespace this once convenient +namespace bb { /** * @brief Concatenates multiple std::vector objects into a single std::vector. * @@ -22,4 +22,5 @@ template std::vector concatenate(const std::vector& vector, c (append(vectors), ...); return concatenated; -} \ No newline at end of file +} +} // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/common/thread.hpp b/barretenberg/cpp/src/barretenberg/common/thread.hpp index 8c67ca84d0ae..d75ae5d43897 100644 --- a/barretenberg/cpp/src/barretenberg/common/thread.hpp +++ b/barretenberg/cpp/src/barretenberg/common/thread.hpp @@ -19,7 +19,7 @@ inline size_t get_num_cpus() // For algorithms that need to be divided amongst power of 2 threads. inline size_t get_num_cpus_pow2() { - return static_cast(1ULL << numeric::get_msb(get_num_cpus())); + return static_cast(1ULL << bb::numeric::get_msb(get_num_cpus())); } void parallel_for(size_t num_iterations, const std::function& func); @@ -28,10 +28,19 @@ void run_loop_in_parallel(size_t num_points, size_t no_multhreading_if_less_or_equal = 0); template - requires(std::is_same_v> || - std::is_same_v>) -void run_loop_in_parallel_if_effective_internal( - size_t, const FunctionType&, size_t, size_t, size_t, size_t, size_t, size_t, size_t); +requires( + std::is_same_v> || + std::is_same_v>) void run_loop_in_parallel_if_effective_internal(size_t, + const FunctionType&, + size_t, + size_t, + size_t, + size_t, + size_t, + size_t, + size_t); /** * @brief Runs loop in parallel if parallelization if useful (costs less than the algorith) * diff --git a/barretenberg/cpp/src/barretenberg/crypto/aes128/aes128.cpp b/barretenberg/cpp/src/barretenberg/crypto/aes128/aes128.cpp index 629ca4e3c776..f107d4749c66 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/aes128/aes128.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/aes128/aes128.cpp @@ -6,8 +6,6 @@ #include #include -namespace crypto { -namespace aes128 { namespace { @@ -34,7 +32,7 @@ void sub_bytes(uint8_t* input) uint8_t i, j; for (i = 0; i < 4; ++i) { for (j = 0; j < 4; ++j) { - input[j * 4 + i] = sbox[input[j * 4 + i]]; + input[j * 4 + i] = bb::crypto::aes128_sbox[input[j * 4 + i]]; } } } @@ -43,7 +41,7 @@ void inverse_sub_bytes(uint8_t* input) { for (size_t i = 0; i < 4; ++i) { for (size_t j = 0; j < 4; ++j) { - input[j * 4 + i] = sbox_inverse[input[j * 4 + i]]; + input[j * 4 + i] = bb::crypto::aes128_sbox_inverse[input[j * 4 + i]]; } } } @@ -151,7 +149,9 @@ void inverse_mix_columns(uint8_t* input) } } // namespace -void expand_key(const uint8_t* key, uint8_t* round_key) +namespace bb::crypto { + +void aes128_expand_key(const uint8_t* key, uint8_t* round_key) { uint8_t temp[4]{}; @@ -176,10 +176,10 @@ void expand_key(const uint8_t* key, uint8_t* round_key) temp[2] = temp[3]; temp[3] = t; - temp[0] = sbox[temp[0]]; - temp[1] = sbox[temp[1]]; - temp[2] = sbox[temp[2]]; - temp[3] = sbox[temp[3]]; + temp[0] = aes128_sbox[temp[0]]; + temp[1] = aes128_sbox[temp[1]]; + temp[2] = aes128_sbox[temp[2]]; + temp[3] = aes128_sbox[temp[3]]; temp[0] = temp[0] ^ round_constants[i >> 2]; } @@ -224,10 +224,10 @@ void aes128_cipher(uint8_t* state, const uint8_t* round_key) add_round_key(state, round_key, 10); } -void encrypt_buffer_cbc(uint8_t* buffer, uint8_t* iv, const uint8_t* key, const size_t length) +void aes128_encrypt_buffer_cbc(uint8_t* buffer, uint8_t* iv, const uint8_t* key, const size_t length) { uint8_t round_key[176]; - expand_key(key, round_key); + aes128_expand_key(key, round_key); uint8_t block_state[16]{}; @@ -244,10 +244,10 @@ void encrypt_buffer_cbc(uint8_t* buffer, uint8_t* iv, const uint8_t* key, const } } -void decrypt_buffer_cbc(uint8_t* buffer, uint8_t* iv, const uint8_t* key, const size_t length) +void aes128_decrypt_buffer_cbc(uint8_t* buffer, uint8_t* iv, const uint8_t* key, const size_t length) { uint8_t round_key[176]; - expand_key(key, round_key); + aes128_expand_key(key, round_key); uint8_t block_state[16]{}; const size_t num_blocks = (length / 16); @@ -262,5 +262,4 @@ void decrypt_buffer_cbc(uint8_t* buffer, uint8_t* iv, const uint8_t* key, const } } -} // namespace aes128 -} // namespace crypto \ No newline at end of file +} // namespace bb::crypto \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/aes128/aes128.hpp b/barretenberg/cpp/src/barretenberg/crypto/aes128/aes128.hpp index dcc366f0d634..449b698413fb 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/aes128/aes128.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/aes128/aes128.hpp @@ -14,19 +14,18 @@ #include #include -namespace crypto { -namespace aes128 { +namespace bb::crypto { -void expand_key(const uint8_t* key, uint8_t* round_key); +void aes128_expand_key(const uint8_t* key, uint8_t* round_key); void aes128_inverse_cipher(uint8_t* state, const uint8_t* round_key); void aes128_cipher(uint8_t* state, const uint8_t* round_key); // n.b. these methods will update the initialization vector -void encrypt_buffer_cbc(uint8_t* buffer, uint8_t* iv, const uint8_t* key, const size_t length); -void decrypt_buffer_cbc(uint8_t* buf, uint8_t* iv, const uint8_t* key, const size_t length); +void aes128_encrypt_buffer_cbc(uint8_t* buffer, uint8_t* iv, const uint8_t* key, const size_t length); +void aes128_decrypt_buffer_cbc(uint8_t* buf, uint8_t* iv, const uint8_t* key, const size_t length); -constexpr uint64_t sparse_base = 9; -static constexpr uint8_t sbox[256] = { +constexpr uint64_t aes128_sparse_base = 9; +static constexpr uint8_t aes128_sbox[256] = { // 0 1 2 3 4 5 6 7 8 9 A B C D E F 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, @@ -44,7 +43,7 @@ static constexpr uint8_t sbox[256] = { 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16, }; -static constexpr uint8_t sbox_inverse[256] = { +static constexpr uint8_t aes128_sbox_inverse[256] = { 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb, 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e, 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, @@ -60,5 +59,4 @@ static constexpr uint8_t sbox_inverse[256] = { 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d }; -} // namespace aes128 -} // namespace crypto \ No newline at end of file +} // namespace bb::crypto \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/aes128/aes128.test.cpp b/barretenberg/cpp/src/barretenberg/crypto/aes128/aes128.test.cpp index 9918545c8a27..eae0f4f1c457 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/aes128/aes128.test.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/aes128/aes128.test.cpp @@ -2,6 +2,8 @@ #include +using namespace bb; + TEST(aes128, verify_cipher) { @@ -12,8 +14,8 @@ TEST(aes128, verify_cipher) uint8_t state[16]{ 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a }; uint8_t round_key[176]; - crypto::aes128::expand_key(key, round_key); - crypto::aes128::aes128_cipher(state, round_key); + crypto::aes128_expand_key(key, round_key); + crypto::aes128_cipher(state, round_key); for (size_t i = 0; i < 16; ++i) { EXPECT_EQ(state[i], expected[i]); @@ -33,7 +35,7 @@ TEST(aes128, encrypt_buffer_cbc) 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 }; - crypto::aes128::encrypt_buffer_cbc(in, iv, key, 64); + crypto::aes128_encrypt_buffer_cbc(in, iv, key, 64); for (size_t i = 0; i < 64; ++i) { EXPECT_EQ(in[i], out[i]); @@ -53,7 +55,7 @@ TEST(aes128, decrypt_buffer_cbc) 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef, 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 }; - crypto::aes128::decrypt_buffer_cbc(in, iv, key, 64); + crypto::aes128_decrypt_buffer_cbc(in, iv, key, 64); for (size_t i = 0; i < 64; ++i) { EXPECT_EQ(in[i], out[i]); diff --git a/barretenberg/cpp/src/barretenberg/crypto/aes128/c_bind.cpp b/barretenberg/cpp/src/barretenberg/crypto/aes128/c_bind.cpp index 1b30cdedbb64..e71762fd06dc 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/aes128/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/aes128/c_bind.cpp @@ -6,7 +6,7 @@ WASM_EXPORT void aes_encrypt_buffer_cbc( uint8_t const* in, uint8_t const* iv, uint8_t const* key, uint32_t const* length, uint8_t** r) { auto len = ntohl(*length); - crypto::aes128::encrypt_buffer_cbc((uint8_t*)in, (uint8_t*)iv, key, len); + bb::crypto::aes128_encrypt_buffer_cbc((uint8_t*)in, (uint8_t*)iv, key, len); std::vector result(in, in + len); *r = to_heap_buffer(result); } @@ -15,7 +15,7 @@ WASM_EXPORT void aes_decrypt_buffer_cbc( uint8_t const* in, uint8_t const* iv, uint8_t const* key, uint32_t const* length, uint8_t** r) { auto len = ntohl(*length); - crypto::aes128::decrypt_buffer_cbc((uint8_t*)in, (uint8_t*)iv, key, len); + bb::crypto::aes128_decrypt_buffer_cbc((uint8_t*)in, (uint8_t*)iv, key, len); std::vector result(in, in + len); *r = to_heap_buffer(result); } diff --git a/barretenberg/cpp/src/barretenberg/crypto/blake2s/blake2-impl.hpp b/barretenberg/cpp/src/barretenberg/crypto/blake2s/blake2-impl.hpp index 9d286bd579b2..4b6addc9ddd3 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/blake2s/blake2-impl.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/blake2s/blake2-impl.hpp @@ -18,7 +18,7 @@ #include #include -namespace blake2 { +namespace bb::crypto { #if !defined(__cplusplus) && (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L) #if defined(_MSC_VER) @@ -146,6 +146,6 @@ static BLAKE2_INLINE void secure_zero_memory(void* v, size_t n) memset_v(v, 0, n); } -} // namespace blake2 +} // namespace bb::crypto #endif \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/blake2s/blake2s.cpp b/barretenberg/cpp/src/barretenberg/crypto/blake2s/blake2s.cpp index 6fd5ae3c3493..ea4d44259db6 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/blake2s/blake2s.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/blake2s/blake2s.cpp @@ -13,14 +13,14 @@ https://blake2.net. */ -#include -#include -#include +#include +#include +#include #include "blake2-impl.hpp" #include "blake2s.hpp" -namespace blake2 { +namespace bb::crypto { static const uint32_t blake2s_IV[8] = { 0x6A09E667UL, 0xBB67AE85UL, 0x3C6EF372UL, 0xA54FF53AUL, 0x510E527FUL, 0x9B05688CUL, 0x1F83D9ABUL, 0x5BE0CD19UL }; @@ -233,4 +233,4 @@ std::array blake2s(std::vector const& input) return output; } -} // namespace blake2 +} // namespace bb::crypto diff --git a/barretenberg/cpp/src/barretenberg/crypto/blake2s/blake2s.hpp b/barretenberg/cpp/src/barretenberg/crypto/blake2s/blake2s.hpp index c009296e5b91..9c5ce71abe04 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/blake2s/blake2s.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/blake2s/blake2s.hpp @@ -19,7 +19,7 @@ #include #include -namespace blake2 { +namespace bb::crypto { #if defined(_MSC_VER) #define BLAKE2_PACKED(x) __pragma(pack(push, 1)) x __pragma(pack(pop)) @@ -73,4 +73,4 @@ int blake2s_final(blake2s_state* S, void* out, size_t outlen); std::array blake2s(std::vector const& input); -} // namespace blake2 \ No newline at end of file +} // namespace bb::crypto \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/blake2s/blake2s.test.cpp b/barretenberg/cpp/src/barretenberg/crypto/blake2s/blake2s.test.cpp index c76c889a41c6..0ef048a6295d 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/blake2s/blake2s.test.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/blake2s/blake2s.test.cpp @@ -5,6 +5,8 @@ #include #include +using namespace bb; + struct test_vector { std::string input; std::array output; @@ -382,6 +384,6 @@ TEST(misc_blake2s, test_vectors) { for (auto v : test_vectors) { std::vector input(v.input.begin(), v.input.end()); - EXPECT_EQ(blake2::blake2s(input), v.output); + EXPECT_EQ(crypto::blake2s(input), v.output); } } \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/blake2s/c_bind.cpp b/barretenberg/cpp/src/barretenberg/crypto/blake2s/c_bind.cpp index 07dfd3a0b31d..53c0a84b07be 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/blake2s/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/blake2s/c_bind.cpp @@ -10,14 +10,14 @@ WASM_EXPORT void blake2s(uint8_t const* data, out_buf32 out) { std::vector inputv; read(data, inputv); - auto output = blake2::blake2s(inputv); + auto output = bb::crypto::blake2s(inputv); std::copy(output.begin(), output.end(), out); } WASM_EXPORT void blake2s_to_field(uint8_t const* data, size_t length, uint8_t* r) { std::vector inputv(data, data + length); - auto output = blake2::blake2s(inputv); + auto output = bb::crypto::blake2s(inputv); auto result = bb::fr::serialize_from_buffer(output.data()); bb::fr::serialize_to_buffer(result, r); } @@ -27,7 +27,7 @@ WASM_EXPORT void blake2s_to_field_(uint8_t const* data, fr::out_buf r) { std::vector inputv; read(data, inputv); - auto output = blake2::blake2s(inputv); + auto output = bb::crypto::blake2s(inputv); auto result = bb::fr::serialize_from_buffer(output.data()); bb::fr::serialize_to_buffer(result, r); } diff --git a/barretenberg/cpp/src/barretenberg/crypto/blake3s/blake3s.test.cpp b/barretenberg/cpp/src/barretenberg/crypto/blake3s/blake3s.test.cpp index c4d93f3051dc..7f38889e02c3 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/blake3s/blake3s.test.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/blake3s/blake3s.test.cpp @@ -8,6 +8,8 @@ #include #include +using namespace bb; + struct test_vector { std::string_view input; std::array output; @@ -392,7 +394,7 @@ static constexpr std::array test_vectors{ TEST(MiscBlake3s, TestVectors) { - bb::constexpr_for<0, 1, 73>([&]() { + constexpr_for<0, 1, 73>([&]() { constexpr auto v = test_vectors[index]; std::vector input(v.input.begin(), v.input.end()); auto result_vector = blake3::blake3s(input); diff --git a/barretenberg/cpp/src/barretenberg/crypto/ecdsa/c_bind.cpp b/barretenberg/cpp/src/barretenberg/crypto/ecdsa/c_bind.cpp index f2dfcceb56cb..db8808a8c84e 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/ecdsa/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/ecdsa/c_bind.cpp @@ -18,9 +18,9 @@ WASM_EXPORT void ecdsa__construct_signature(uint8_t const* message, using serialize::write; auto priv_key = from_buffer(private_key); secp256k1::g1::affine_element pub_key = secp256k1::g1::one * priv_key; - crypto::ecdsa::key_pair key_pair = { priv_key, pub_key }; + bb::crypto::ecdsa_key_pair key_pair = { priv_key, pub_key }; - auto sig = crypto::ecdsa::construct_signature( + auto sig = bb::crypto::ecdsa_construct_signature( std::string((char*)message, msg_len), key_pair); write(output_sig_r, sig.r); write(output_sig_s, sig.s); @@ -39,9 +39,9 @@ WASM_EXPORT void ecdsa__recover_public_key_from_signature(uint8_t const* message std::copy(sig_s, sig_s + 32, s.begin()); const uint8_t v = *sig_v; - crypto::ecdsa::signature sig = { r, s, v }; + bb::crypto::ecdsa_signature sig = { r, s, v }; auto recovered_pub_key = - crypto::ecdsa::recover_public_key( + bb::crypto::ecdsa_recover_public_key( std::string((char*)message, msg_len), sig); serialize::write(output_pub_key, recovered_pub_key); } @@ -59,7 +59,7 @@ WASM_EXPORT bool ecdsa__verify_signature(uint8_t const* message, std::copy(sig_s, sig_s + 32, s.begin()); const uint8_t v = *sig_v; - crypto::ecdsa::signature sig = { r, s, v }; - return crypto::ecdsa::verify_signature( + bb::crypto::ecdsa_signature sig = { r, s, v }; + return bb::crypto::ecdsa_verify_signature( std::string((char*)message, msg_len), pubk, sig); } diff --git a/barretenberg/cpp/src/barretenberg/crypto/ecdsa/ecdsa.hpp b/barretenberg/cpp/src/barretenberg/crypto/ecdsa/ecdsa.hpp index 16106a5868ac..dabd63747208 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/ecdsa/ecdsa.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/ecdsa/ecdsa.hpp @@ -8,16 +8,15 @@ #include #include -namespace crypto { -namespace ecdsa { -template struct key_pair { +namespace bb::crypto { +template struct ecdsa_key_pair { Fr private_key; typename G1::affine_element public_key; // For serialization, update with any new fields MSGPACK_FIELDS(private_key, public_key); }; -struct signature { +struct ecdsa_signature { std::array r; std::array s; uint8_t v; @@ -26,28 +25,27 @@ struct signature { }; template -signature construct_signature(const std::string& message, const key_pair& account); +ecdsa_signature ecdsa_construct_signature(const std::string& message, const ecdsa_key_pair& account); template -typename G1::affine_element recover_public_key(const std::string& message, const signature& sig); +typename G1::affine_element ecdsa_recover_public_key(const std::string& message, const ecdsa_signature& sig); template -bool verify_signature(const std::string& message, - const typename G1::affine_element& public_key, - const signature& signature); +bool ecdsa_verify_signature(const std::string& message, + const typename G1::affine_element& public_key, + const ecdsa_signature& signature); -inline bool operator==(signature const& lhs, signature const& rhs) +inline bool operator==(ecdsa_signature const& lhs, ecdsa_signature const& rhs) { return lhs.r == rhs.r && lhs.s == rhs.s && lhs.v == rhs.v; } -inline std::ostream& operator<<(std::ostream& os, signature const& sig) +inline std::ostream& operator<<(std::ostream& os, ecdsa_signature const& sig) { os << "{ " << sig.r << ", " << sig.s << ", " << static_cast(sig.v) << " }"; return os; } -} // namespace ecdsa -} // namespace crypto +} // namespace bb::crypto #include "./ecdsa_impl.hpp" diff --git a/barretenberg/cpp/src/barretenberg/crypto/ecdsa/ecdsa.test.cpp b/barretenberg/cpp/src/barretenberg/crypto/ecdsa/ecdsa.test.cpp index b15e4a234be3..76b324682a05 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/ecdsa/ecdsa.test.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/ecdsa/ecdsa.test.cpp @@ -9,7 +9,7 @@ using namespace bb; TEST(ecdsa, msgpack) { - auto [actual, expected] = msgpack_roundtrip(crypto::ecdsa::signature{}); + auto [actual, expected] = msgpack_roundtrip(crypto::ecdsa_signature{}); EXPECT_EQ(actual, expected); } @@ -17,14 +17,14 @@ TEST(ecdsa, verify_signature_grumpkin_sha256) { std::string message = "The quick brown dog jumped over the lazy fox."; - crypto::ecdsa::key_pair account; + crypto::ecdsa_key_pair account; account.private_key = grumpkin::fr::random_element(); account.public_key = grumpkin::g1::one * account.private_key; - crypto::ecdsa::signature signature = - crypto::ecdsa::construct_signature(message, account); + crypto::ecdsa_signature signature = + crypto::ecdsa_construct_signature(message, account); - bool result = crypto::ecdsa::verify_signature( + bool result = crypto::ecdsa_verify_signature( message, account.public_key, signature); EXPECT_EQ(result, true); @@ -34,14 +34,14 @@ TEST(ecdsa, verify_signature_secp256r1_sha256) { std::string message = "The quick brown dog jumped over the lazy fox."; - crypto::ecdsa::key_pair account; + crypto::ecdsa_key_pair account; account.private_key = secp256r1::fr::random_element(); account.public_key = secp256r1::g1::one * account.private_key; - crypto::ecdsa::signature signature = - crypto::ecdsa::construct_signature(message, account); + crypto::ecdsa_signature signature = + crypto::ecdsa_construct_signature(message, account); - bool result = crypto::ecdsa::verify_signature( + bool result = crypto::ecdsa_verify_signature( message, account.public_key, signature); EXPECT_EQ(result, true); @@ -51,19 +51,18 @@ TEST(ecdsa, recover_public_key_secp256k1_sha256) { std::string message = "The quick brown dog jumped over the lazy fox."; - crypto::ecdsa::key_pair account; + crypto::ecdsa_key_pair account; account.private_key = secp256k1::fr::random_element(); account.public_key = secp256k1::g1::one * account.private_key; - crypto::ecdsa::signature signature = - crypto::ecdsa::construct_signature(message, account); + crypto::ecdsa_signature signature = + crypto::ecdsa_construct_signature(message, account); - bool result = crypto::ecdsa::verify_signature( + bool result = crypto::ecdsa_verify_signature( message, account.public_key, signature); auto recovered_public_key = - crypto::ecdsa::recover_public_key(message, - signature); + crypto::ecdsa_recover_public_key(message, signature); EXPECT_EQ(result, true); EXPECT_EQ(recovered_public_key, account.public_key); @@ -73,19 +72,18 @@ TEST(ecdsa, recover_public_key_secp256r1_sha256) { std::string message = "The quick brown dog jumped over the lazy fox."; - crypto::ecdsa::key_pair account; + crypto::ecdsa_key_pair account; account.private_key = secp256r1::fr::random_element(); account.public_key = secp256r1::g1::one * account.private_key; - crypto::ecdsa::signature signature = - crypto::ecdsa::construct_signature(message, account); + crypto::ecdsa_signature signature = + crypto::ecdsa_construct_signature(message, account); - bool result = crypto::ecdsa::verify_signature( + bool result = crypto::ecdsa_verify_signature( message, account.public_key, signature); auto recovered_public_key = - crypto::ecdsa::recover_public_key(message, - signature); + crypto::ecdsa_recover_public_key(message, signature); EXPECT_EQ(result, true); EXPECT_EQ(recovered_public_key, account.public_key); @@ -110,18 +108,18 @@ TEST(ecdsa, check_overflowing_r_and_s_are_rejected) std::vector message_vec = HexToBytes("41414141"); std::string message(message_vec.begin(), message_vec.end()); - crypto::ecdsa::signature signature; + crypto::ecdsa_signature signature; grumpkin::fr private_key; grumpkin::g1::affine_element public_key; - crypto::ecdsa::key_pair key_pair; + crypto::ecdsa_key_pair key_pair; // We create a private and public key and a signature private_key = grumpkin::fr::random_element(); public_key = grumpkin::g1::affine_element((grumpkin::g1::one * private_key).normalize()); key_pair = { private_key, public_key }; signature = - crypto::ecdsa::construct_signature(message, key_pair); + crypto::ecdsa_construct_signature(message, key_pair); // Check that the signature is correct - bool result = crypto::ecdsa::verify_signature( + bool result = crypto::ecdsa_verify_signature( message, public_key, signature); EXPECT_TRUE(result); using serialize::read; @@ -135,7 +133,7 @@ TEST(ecdsa, check_overflowing_r_and_s_are_rejected) using serialize::write; auto* p_r_m = &signature.r[0]; write(p_r_m, new_r); - result = crypto::ecdsa::verify_signature( + result = crypto::ecdsa_verify_signature( message, public_key, signature); // Signature verification should decline this signature, since it breaks specification EXPECT_FALSE(result); @@ -148,7 +146,7 @@ TEST(ecdsa, check_overflowing_r_and_s_are_rejected) auto* p_r_s = &signature.s[0]; write(p_r_m, old_r); write(p_r_s, new_s); - result = crypto::ecdsa::verify_signature( + result = crypto::ecdsa_verify_signature( message, public_key, signature); EXPECT_FALSE(result); } @@ -182,14 +180,14 @@ TEST(ecdsa, verify_signature_secp256r1_sha256_NIST_1) 0xef, 0x97, 0xb2, 0x18, 0xe9, 0x6f, 0x17, 0x5a, 0x3c, 0xcd, 0xda, 0x2a, 0xcc, 0x05, 0x89, 0x03, }; - crypto::ecdsa::signature sig{ r, s, 27 }; + crypto::ecdsa_signature sig{ r, s, 27 }; std::vector message_vec = HexToBytes("5905238877c77421f73e43ee3da6f2d9e2ccad5fc942dcec0cbd25482935faaf416983fe165b1a045ee2bcd2e6dca3bdf46" "c4310a7461f9a37960ca672d3feb5473e253605fb1ddfd28065b53cb5858a8ad28175bf9bd386a5e471ea7a65c17cc934a9" "d791e91491eb3754d03799790fe2d308d16146d5c9b0d0debd97d79ce8"); std::string message(message_vec.begin(), message_vec.end()); - bool result = crypto::ecdsa::verify_signature( + bool result = crypto::ecdsa_verify_signature( message, public_key, sig); EXPECT_EQ(result, true); } diff --git a/barretenberg/cpp/src/barretenberg/crypto/ecdsa/ecdsa_impl.hpp b/barretenberg/cpp/src/barretenberg/crypto/ecdsa/ecdsa_impl.hpp index 085ca7128359..26ae2b140044 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/ecdsa/ecdsa_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/ecdsa/ecdsa_impl.hpp @@ -4,13 +4,12 @@ #include "barretenberg/common/serialize.hpp" #include "barretenberg/numeric/uint256/uint256.hpp" -namespace crypto { -namespace ecdsa { +namespace bb::crypto { template -signature construct_signature(const std::string& message, const key_pair& account) +ecdsa_signature ecdsa_construct_signature(const std::string& message, const ecdsa_key_pair& account) { - signature sig; + ecdsa_signature sig; // use HMAC in PRF mode to derive 32-byte secret `k` std::vector pkey_buffer; @@ -53,7 +52,7 @@ signature construct_signature(const std::string& message, const key_pair } template -typename G1::affine_element recover_public_key(const std::string& message, const signature& sig) +typename G1::affine_element ecdsa_recover_public_key(const std::string& message, const ecdsa_signature& sig) { using serialize::read; uint256_t r_uint; @@ -125,7 +124,9 @@ typename G1::affine_element recover_public_key(const std::string& message, const } template -bool verify_signature(const std::string& message, const typename G1::affine_element& public_key, const signature& sig) +bool ecdsa_verify_signature(const std::string& message, + const typename G1::affine_element& public_key, + const ecdsa_signature& sig) { using serialize::read; uint256_t r_uint; @@ -169,5 +170,4 @@ bool verify_signature(const std::string& message, const typename G1::affine_elem Fr result(Rx); return result == r; } -} // namespace ecdsa -} // namespace crypto +} // namespace bb::crypto diff --git a/barretenberg/cpp/src/barretenberg/crypto/generators/generator_data.hpp b/barretenberg/cpp/src/barretenberg/crypto/generators/generator_data.hpp index acbe76ef3cdd..0e695abb02d6 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/generators/generator_data.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/generators/generator_data.hpp @@ -7,7 +7,7 @@ #include #include -namespace crypto { +namespace bb::crypto { /** * @brief class that stores precomputed generators used for Pedersen commitments and Pedersen hashes * @@ -143,4 +143,4 @@ template struct GeneratorContext { , domain_separator(_domain_separator) {} }; -} // namespace crypto \ No newline at end of file +} // namespace bb::crypto \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/hashers/hashers.hpp b/barretenberg/cpp/src/barretenberg/crypto/hashers/hashers.hpp index b3fb6e851056..f19224941d12 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/hashers/hashers.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/hashers/hashers.hpp @@ -31,5 +31,5 @@ struct Sha256Hasher { struct Blake2sHasher { static constexpr size_t BLOCK_SIZE = 64; static constexpr size_t OUTPUT_SIZE = 32; - static auto hash(const std::vector& message) { return blake2::blake2s(message); } + static auto hash(const std::vector& message) { return bb::crypto::blake2s(message); } }; diff --git a/barretenberg/cpp/src/barretenberg/crypto/hmac/hmac.hpp b/barretenberg/cpp/src/barretenberg/crypto/hmac/hmac.hpp index f2f0edfafdf9..a5d811fd21e9 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/hmac/hmac.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/hmac/hmac.hpp @@ -8,7 +8,7 @@ #include #include -namespace crypto { +namespace bb::crypto { /** * @brief Compute an HMAC given a secret key and a message * @@ -93,8 +93,8 @@ std::array hmac(const MessageContainer& message, con * @return Fr output field element as uint512_t( H(10...0 || HMAC(k,m)) || H(00...0 || HMAC(k,m)) ) % r */ template -Fr get_unbiased_field_from_hmac(const MessageContainer& message, const KeyContainer& key) - requires(Hash::OUTPUT_SIZE == 32) +Fr get_unbiased_field_from_hmac(const MessageContainer& message, + const KeyContainer& key) requires(Hash::OUTPUT_SIZE == 32) { // Strong assumption that works for now with our suite of Hashers static_assert(Hash::BLOCK_SIZE > Hash::OUTPUT_SIZE); @@ -126,4 +126,4 @@ Fr get_unbiased_field_from_hmac(const MessageContainer& message, const KeyContai Fr result((field_as_u512 % Fr::modulus).lo); return result; } -} // namespace crypto +} // namespace bb::crypto diff --git a/barretenberg/cpp/src/barretenberg/crypto/hmac/hmac.test.cpp b/barretenberg/cpp/src/barretenberg/crypto/hmac/hmac.test.cpp index 5e66bc8389e8..020ceedaf2ca 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/hmac/hmac.test.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/hmac/hmac.test.cpp @@ -8,6 +8,8 @@ #include #include +using namespace bb; + std::array hex_to_bytes(const std::string& hex) { std::array bytes; diff --git a/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.cpp b/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.cpp index 691a64b998bc..3880bd7ffbe2 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.cpp @@ -6,7 +6,7 @@ #include #endif -namespace crypto { +namespace bb::crypto { /** * @brief Given a vector of fields, generate a pedersen commitment using the indexed generators. @@ -30,4 +30,4 @@ typename Curve::AffineElement pedersen_commitment_base::commit_native(con return result.normalize(); } template class pedersen_commitment_base; -} // namespace crypto +} // namespace bb::crypto diff --git a/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.hpp b/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.hpp index fc750591eff8..517ede529d9a 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.hpp @@ -6,7 +6,7 @@ #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" #include -namespace crypto { +namespace bb::crypto { /** * @brief Performs pedersen commitments! @@ -31,4 +31,4 @@ template class pedersen_commitment_base { }; using pedersen_commitment = pedersen_commitment_base; -} // namespace crypto +} // namespace bb::crypto diff --git a/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.test.cpp b/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.test.cpp index f25ac05f0f2c..6d0d4db89ab0 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.test.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/pedersen_commitment/pedersen.test.cpp @@ -3,7 +3,7 @@ #include "barretenberg/crypto/generators/generator_data.hpp" #include -namespace crypto { +namespace bb::crypto { using bb::fr; @@ -51,4 +51,4 @@ TEST(Pedersen, GeneratorPrinter) } } -}; // namespace crypto \ No newline at end of file +}; // namespace bb::crypto \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.cpp b/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.cpp index 9e702eccb2f3..38c6f2421b1b 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.cpp @@ -1,7 +1,7 @@ #include "./pedersen.hpp" #include "../pedersen_commitment/pedersen.hpp" -namespace crypto { +namespace bb::crypto { /** * @brief Converts input uint8_t buffers into vector of field elements. Used to hash the Transcript in a @@ -80,4 +80,4 @@ typename Curve::BaseField pedersen_hash_base::hash_buffer(const std::vect } template class pedersen_hash_base; -} // namespace crypto \ No newline at end of file +} // namespace bb::crypto \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.hpp b/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.hpp index 8bd5bf82b05a..9e9cd638a7c7 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.hpp @@ -2,7 +2,7 @@ #include "../generators/generator_data.hpp" #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" -namespace crypto { +namespace bb::crypto { /** * @brief Performs pedersen hashes! * @@ -37,4 +37,4 @@ template class pedersen_hash_base { }; using pedersen_hash = pedersen_hash_base; -} // namespace crypto +} // namespace bb::crypto diff --git a/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.test.cpp b/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.test.cpp index 47c96cba9c78..0e4ade6fca1c 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.test.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/pedersen_hash/pedersen.test.cpp @@ -3,7 +3,7 @@ #include "barretenberg/numeric/uint256/uint256.hpp" #include -namespace crypto { +namespace bb::crypto { using bb::fr; @@ -21,4 +21,4 @@ TEST(Pedersen, HashWithIndex) EXPECT_EQ(r, fr(uint256_t("1c446df60816b897cda124524e6b03f36df0cec333fad87617aab70d7861daa6"))); } -} // namespace crypto \ No newline at end of file +} // namespace bb::crypto \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.bench.cpp b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.bench.cpp index 6b1b1457997a..6673734acdc4 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.bench.cpp @@ -11,7 +11,7 @@ grumpkin::fq poseidon_function(const size_t count) inputs[i] = grumpkin::fq::random_element(); } // hash count many field elements - inputs[0] = crypto::Poseidon2::hash(inputs); + inputs[0] = bb::crypto::Poseidon2::hash(inputs); return inputs[0]; } @@ -24,5 +24,4 @@ void native_poseidon2_commitment_bench(State& state) noexcept } BENCHMARK(native_poseidon2_commitment_bench)->Arg(10)->Arg(1000)->Arg(10000); -BENCHMARK_MAIN(); -// } // namespace crypto \ No newline at end of file +BENCHMARK_MAIN(); \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.cpp b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.cpp index ad96dc312713..1fce753975ba 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.cpp @@ -1,6 +1,6 @@ #include "poseidon2.hpp" -namespace crypto { +namespace bb::crypto { /** * @brief Hashes a vector of field elements */ @@ -45,4 +45,4 @@ typename Poseidon2::FF Poseidon2::hash_buffer(const std::vector< } template class Poseidon2; -} // namespace crypto \ No newline at end of file +} // namespace bb::crypto \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.hpp b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.hpp index 6969c680e177..446361696c2f 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.hpp @@ -4,7 +4,7 @@ #include "poseidon2_permutation.hpp" #include "sponge/sponge.hpp" -namespace crypto { +namespace bb::crypto { template class Poseidon2 { public: @@ -25,4 +25,4 @@ template class Poseidon2 { }; extern template class Poseidon2; -} // namespace crypto \ No newline at end of file +} // namespace bb::crypto \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.test.cpp b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.test.cpp index 0360b5696738..7903d1fceb6d 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.test.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2.test.cpp @@ -6,20 +6,19 @@ using namespace bb; namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } -namespace poseidon2_tests { TEST(Poseidon2, HashBasicTests) { - bb::fr a = bb::fr::random_element(&engine); - bb::fr b = bb::fr::random_element(&engine); - bb::fr c = bb::fr::random_element(&engine); - bb::fr d = bb::fr::random_element(&engine); + fr a = fr::random_element(&engine); + fr b = fr::random_element(&engine); + fr c = fr::random_element(&engine); + fr d = fr::random_element(&engine); - std::vector input1{ a, b, c, d }; - std::vector input2{ d, c, b, a }; + std::vector input1{ a, b, c, d }; + std::vector input2{ d, c, b, a }; auto r0 = crypto::Poseidon2::hash(input1); auto r1 = crypto::Poseidon2::hash(input1); @@ -34,15 +33,15 @@ TEST(Poseidon2, HashBasicTests) // flexibility of Poseidon's parametrisation) TEST(Poseidon2, HashConsistencyCheck) { - bb::fr a(std::string("9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); - bb::fr b(std::string("9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); - bb::fr c(std::string("0x9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); - bb::fr d(std::string("0x9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); + fr a(std::string("9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); + fr b(std::string("9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); + fr c(std::string("0x9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); + fr d(std::string("0x9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); - std::vector input{ a, b, c, d }; + std::vector input{ a, b, c, d }; auto result = crypto::Poseidon2::hash(input); - bb::fr expected(std::string("0x2f43a0f83b51a6f5fc839dea0ecec74947637802a579fa9841930a25a0bcec11")); + fr expected(std::string("0x2f43a0f83b51a6f5fc839dea0ecec74947637802a579fa9841930a25a0bcec11")); EXPECT_EQ(result, expected); } @@ -51,15 +50,14 @@ TEST(Poseidon2, HashBufferConsistencyCheck) { // 31 byte inputs because hash_buffer slicing is only injective with 31 bytes, as it slices 31 bytes for each field // element - bb::fr a(std::string("00000b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); + fr a(std::string("00000b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); auto input_vec = to_buffer(a); // takes field element and converts it to 32 bytes input_vec.erase(input_vec.begin()); // erase first byte since we want 31 bytes - std::vector input{ a }; + std::vector input{ a }; auto expected = crypto::Poseidon2::hash(input); - bb::fr result = crypto::Poseidon2::hash_buffer(input_vec); + fr result = crypto::Poseidon2::hash_buffer(input_vec); EXPECT_EQ(result, expected); } -} // namespace poseidon2_tests \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_cpp_params.sage b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_cpp_params.sage index 4250e98e8a92..685acd21e35b 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_cpp_params.sage +++ b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_cpp_params.sage @@ -661,7 +661,7 @@ print("#pragma once\n") print("#include \"barretenberg/ecc/curves/bn254/fr.hpp\"\n") -print("namespace crypto {\n") +print("namespace bb::crypto {\n") print("struct Poseidon2Bn254ScalarFieldParams{\n") print(" using FF = bb::fr;") @@ -723,4 +723,4 @@ for (i,val) in enumerate(state_out): print("};") print("};") -print("} // namespace crypto") \ No newline at end of file +print("} // namespace bb::crypto") \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_params.hpp b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_params.hpp index 7a4a3ab06199..9aeaadc7bf31 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_params.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_params.hpp @@ -5,7 +5,7 @@ #include "barretenberg/ecc/curves/bn254/fr.hpp" -namespace crypto { +namespace bb::crypto { struct Poseidon2Bn254ScalarFieldParams { @@ -449,4 +449,4 @@ struct Poseidon2Bn254ScalarFieldParams { FF(std::string("0x2e11c5cff2a22c64d01304b778d78f6998eff1ab73163a35603f54794c30847a")), }; }; -} // namespace crypto +} // namespace bb::crypto diff --git a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_permutation.hpp b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_permutation.hpp index 4f0794b893c8..15a3a8bd555f 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_permutation.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_permutation.hpp @@ -8,7 +8,7 @@ #include #include -namespace crypto { +namespace bb::crypto { /** * @brief Applies the Poseidon2 permutation function from https://eprint.iacr.org/2023/323 . @@ -162,4 +162,4 @@ template class Poseidon2Permutation { return current_state; } }; -} // namespace crypto \ No newline at end of file +} // namespace bb::crypto \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_permutation.test.cpp b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_permutation.test.cpp index 57d4b56a9578..744593bcb732 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_permutation.test.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/poseidon2_permutation.test.cpp @@ -6,11 +6,9 @@ using namespace bb; namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } -namespace poseidon2_tests { - TEST(Poseidon2Permutation, TestVectors) { @@ -24,13 +22,13 @@ TEST(Poseidon2Permutation, TestVectors) TEST(Poseidon2Permutation, BasicTests) { - bb::fr a = bb::fr::random_element(&engine); - bb::fr b = bb::fr::random_element(&engine); - bb::fr c = bb::fr::random_element(&engine); - bb::fr d = bb::fr::random_element(&engine); + fr a = fr::random_element(&engine); + fr b = fr::random_element(&engine); + fr c = fr::random_element(&engine); + fr d = fr::random_element(&engine); - std::array input1{ a, b, c, d }; - std::array input2{ d, c, b, a }; + std::array input1{ a, b, c, d }; + std::array input2{ d, c, b, a }; auto r0 = crypto::Poseidon2Permutation::permutation(input1); auto r1 = crypto::Poseidon2Permutation::permutation(input1); @@ -45,21 +43,19 @@ TEST(Poseidon2Permutation, BasicTests) // flexibility of Poseidon's parametrisation) TEST(Poseidon2Permutation, ConsistencyCheck) { - bb::fr a(std::string("9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); - bb::fr b(std::string("9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); - bb::fr c(std::string("0x9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); - bb::fr d(std::string("0x9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); + fr a(std::string("9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); + fr b(std::string("9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); + fr c(std::string("0x9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); + fr d(std::string("0x9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789")); - std::array input{ a, b, c, d }; + std::array input{ a, b, c, d }; auto result = crypto::Poseidon2Permutation::permutation(input); - std::array expected{ - bb::fr(std::string("0x2bf1eaf87f7d27e8dc4056e9af975985bccc89077a21891d6c7b6ccce0631f95")), - bb::fr(std::string("0x0c01fa1b8d0748becafbe452c0cb0231c38224ea824554c9362518eebdd5701f")), - bb::fr(std::string("0x018555a8eb50cf07f64b019ebaf3af3c925c93e631f3ecd455db07bbb52bbdd3")), - bb::fr(std::string("0x0cbea457c91c22c6c31fd89afd2541efc2edf31736b9f721e823b2165c90fd41")), + std::array expected{ + fr(std::string("0x2bf1eaf87f7d27e8dc4056e9af975985bccc89077a21891d6c7b6ccce0631f95")), + fr(std::string("0x0c01fa1b8d0748becafbe452c0cb0231c38224ea824554c9362518eebdd5701f")), + fr(std::string("0x018555a8eb50cf07f64b019ebaf3af3c925c93e631f3ecd455db07bbb52bbdd3")), + fr(std::string("0x0cbea457c91c22c6c31fd89afd2541efc2edf31736b9f721e823b2165c90fd41")), }; EXPECT_EQ(result, expected); } - -} // namespace poseidon2_tests \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/sponge/sponge.hpp b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/sponge/sponge.hpp index bc4a2c5c1dcb..2a99b88609fd 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/poseidon2/sponge/sponge.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/poseidon2/sponge/sponge.hpp @@ -7,7 +7,7 @@ #include "barretenberg/numeric/uint256/uint256.hpp" -namespace crypto { +namespace bb::crypto { /** * @brief Implements a cryptographic sponge over prime fields. @@ -165,4 +165,4 @@ template input) { return hash_variable_length<1>(input)[0]; } }; -} // namespace crypto \ No newline at end of file +} // namespace bb::crypto \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/crypto/schnorr/c_bind.cpp b/barretenberg/cpp/src/barretenberg/crypto/schnorr/c_bind.cpp index fa7a66811fea..55abbfa0bdb4 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/schnorr/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/schnorr/c_bind.cpp @@ -6,7 +6,7 @@ extern "C" { using namespace bb; using affine_element = grumpkin::g1::affine_element; -using multisig = crypto::schnorr::multisig; +using multisig = crypto::schnorr_multisig; using multisig_public_key = typename multisig::MultiSigPublicKey; WASM_EXPORT void schnorr_compute_public_key(uint8_t const* private_key, uint8_t* public_key_buf) @@ -32,8 +32,8 @@ WASM_EXPORT void schnorr_construct_signature(uint8_t const* message_buf, auto message = from_buffer(message_buf); auto priv_key = from_buffer(private_key); grumpkin::g1::affine_element pub_key = grumpkin::g1::one * priv_key; - crypto::schnorr::key_pair key_pair = { priv_key, pub_key }; - auto sig = crypto::schnorr::construct_signature(message, key_pair); + crypto::schnorr_key_pair key_pair = { priv_key, pub_key }; + auto sig = crypto::schnorr_construct_signature(message, key_pair); write(s, sig.s); write(e, sig.e); } @@ -47,18 +47,18 @@ WASM_EXPORT void schnorr_verify_signature( std::array e; std::copy(sig_s, sig_s + 32, s.begin()); std::copy(sig_e, sig_e + 32, e.begin()); - crypto::schnorr::signature sig = { s, e }; + crypto::schnorr_signature sig = { s, e }; *result = - crypto::schnorr::verify_signature(message, pubk, sig); + crypto::schnorr_verify_signature(message, pubk, sig); } WASM_EXPORT void schnorr_multisig_create_multisig_public_key(uint8_t const* private_key, uint8_t* multisig_pubkey_buf) { - using multisig = crypto::schnorr::multisig; + using multisig = crypto::schnorr_multisig; using multisig_public_key = typename multisig::MultiSigPublicKey; auto priv_key = from_buffer(private_key); grumpkin::g1::affine_element pub_key = grumpkin::g1::one * priv_key; - crypto::schnorr::key_pair key_pair = { priv_key, pub_key }; + crypto::schnorr_key_pair key_pair = { priv_key, pub_key }; auto agg_pubkey = multisig_public_key(key_pair); @@ -69,7 +69,7 @@ WASM_EXPORT void schnorr_multisig_validate_and_combine_signer_pubkeys(uint8_t co affine_element::out_buf combined_key_buf, bool* success) { - using multisig = crypto::schnorr::multisig; + using multisig = crypto::schnorr_multisig; auto pubkeys = from_buffer>(signer_pubkey_buf); auto combined_key = multisig::validate_and_combine_signer_pubkeys(pubkeys); @@ -86,7 +86,7 @@ WASM_EXPORT void schnorr_multisig_validate_and_combine_signer_pubkeys(uint8_t co WASM_EXPORT void schnorr_multisig_construct_signature_round_1(uint8_t* round_one_public_output_buf, uint8_t* round_one_private_output_buf) { - using multisig = crypto::schnorr::multisig; + using multisig = crypto::schnorr_multisig; auto [public_output, private_output] = multisig::construct_signature_round_1(); serialize::write(round_one_public_output_buf, public_output); @@ -101,11 +101,11 @@ WASM_EXPORT void schnorr_multisig_construct_signature_round_2(uint8_t const* mes uint8_t* round_two_buf, bool* success) { - using multisig = crypto::schnorr::multisig; + using multisig = crypto::schnorr_multisig; auto message = from_buffer(message_buf); auto priv_key = from_buffer(private_key); grumpkin::g1::affine_element pub_key = grumpkin::g1::one * priv_key; - crypto::schnorr::key_pair key_pair = { priv_key, pub_key }; + crypto::schnorr_key_pair key_pair = { priv_key, pub_key }; auto signer_pubkeys = from_buffer>(signer_pubkeys_buf); auto round_one_outputs = from_buffer>(round_one_public_buf); @@ -130,7 +130,7 @@ WASM_EXPORT void schnorr_multisig_combine_signatures(uint8_t const* message_buf, uint8_t* e, bool* success) { - using multisig = crypto::schnorr::multisig; + using multisig = crypto::schnorr_multisig; auto message = from_buffer(message_buf); auto signer_pubkeys = from_buffer>(signer_pubkeys_buf); diff --git a/barretenberg/cpp/src/barretenberg/crypto/schnorr/c_bind.hpp b/barretenberg/cpp/src/barretenberg/crypto/schnorr/c_bind.hpp index f18caabe3fe9..ba2049cc1e77 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/schnorr/c_bind.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/schnorr/c_bind.hpp @@ -7,7 +7,7 @@ extern "C" { using namespace bb; using affine_element = grumpkin::g1::affine_element; -using multisig = crypto::schnorr::multisig; +using multisig = crypto::schnorr_multisig; WASM_EXPORT void schnorr_compute_public_key(fr::in_buf private_key, affine_element::out_buf public_key_buf); WASM_EXPORT void schnorr_negate_public_key(affine_element::in_buf public_key_buffer, affine_element::out_buf output); diff --git a/barretenberg/cpp/src/barretenberg/crypto/schnorr/multisig.hpp b/barretenberg/cpp/src/barretenberg/crypto/schnorr/multisig.hpp index 7cafe9de2b30..4d48bfaec94f 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/schnorr/multisig.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/schnorr/multisig.hpp @@ -12,7 +12,7 @@ #include "proof_of_possession.hpp" #include "schnorr.hpp" -namespace crypto::schnorr { +namespace bb::crypto { /** * @brief Implements the SpeedyMuSig protocol; a secure 2-round interactive multisignature scheme @@ -25,7 +25,7 @@ namespace crypto::schnorr { * * @details SpeedyMuSig paper at https://eprint.iacr.org/2021/1375.pdf */ -template class multisig { +template class schnorr_multisig { // ensure that a different hash function is used for signature and proof of possession/nonce. // we can apply domain separation for HashRegNon but not for HashSig, so this ensures all hash functions @@ -37,7 +37,7 @@ template cl using Fr = typename G1::subgroup_field; using affine_element = typename G1::affine_element; using element = typename G1::element; - using key_pair = crypto::schnorr::key_pair; + using key_pair = crypto::schnorr_key_pair; /** * @brief MultiSigPublicKey wraps a signer's public key g1::affine_element @@ -56,7 +56,7 @@ template cl affine_element public_key = G1::affine_point_at_infinity; // proof of knowledge of the secret_key for public_key - ProofOfPossession proof_of_possession; + SchnorrProofOfPossession proof_of_possession; // For serialization, update with any new fields MSGPACK_FIELDS(public_key, proof_of_possession); @@ -69,15 +69,15 @@ template cl {} // Needed to appease MSGPACK_FIELDS MultiSigPublicKey(const affine_element& public_key, - const ProofOfPossession& proof_of_possession) + const SchnorrProofOfPossession& proof_of_possession) : public_key(public_key) , proof_of_possession(proof_of_possession) {} }; struct RoundOnePrivateOutput { - typedef uint8_t const* in_buf; - typedef uint8_t* out_buf; + using in_buf = const uint8_t*; + using out_buf = uint8_t*; Fr r; Fr s; @@ -86,10 +86,10 @@ template cl }; struct RoundOnePublicOutput { - typedef uint8_t const* in_buf; - typedef uint8_t const* vec_in_buf; - typedef uint8_t* out_buf; - typedef uint8_t** vec_out_buf; + using in_buf = const uint8_t*; + using vec_in_buf = const uint8_t*; + using out_buf = uint8_t*; + using vec_out_buf = uint8_t**; // R = r⋅G affine_element R; @@ -371,7 +371,7 @@ template cl affine_element R = construct_multisig_nonce(a, round_1_nonces); // Now we have the multisig nonce, compute schnorr challenge e (termed `c` in the speedyMuSig paper) - auto e_buf = generate_schnorr_challenge(message, *aggregate_pubkey, R); + auto e_buf = schnorr_generate_challenge(message, *aggregate_pubkey, R); Fr e = Fr::serialize_from_buffer(&e_buf[0]); // output of round 2 is z @@ -391,7 +391,7 @@ template cl * @return signature it's a Schnorr signature! Looks identical to a regular non-multisig Schnorr signature. * @return std::nullopt if any of the signature shares are invalid */ - static std::optional combine_signatures( + static std::optional combine_signatures( const std::string& message, const std::vector& signer_pubkeys, const std::vector& round_1_nonces, @@ -423,9 +423,9 @@ template cl // compute aggregate nonce R = R1 + ... + Rn + S1 * a + ... + Sn * a affine_element R = construct_multisig_nonce(a, round_1_nonces); - auto e_buf = generate_schnorr_challenge(message, *aggregate_pubkey, R); + auto e_buf = schnorr_generate_challenge(message, *aggregate_pubkey, R); - signature sig; + schnorr_signature sig; // copy e as its raw bit representation (without modular reduction) std::copy(e_buf.begin(), e_buf.end(), sig.e.begin()); @@ -437,11 +437,11 @@ template cl Fr::serialize_to_buffer(s, &sig.s[0]); // verify the final signature before returning - if (!verify_signature(message, *aggregate_pubkey, sig)) { + if (!schnorr_verify_signature(message, *aggregate_pubkey, sig)) { return std::nullopt; } return sig; } }; -} // namespace crypto::schnorr +} // namespace bb::crypto diff --git a/barretenberg/cpp/src/barretenberg/crypto/schnorr/multisig.test.cpp b/barretenberg/cpp/src/barretenberg/crypto/schnorr/multisig.test.cpp index e21f8231e7b2..fdff67dfdfb5 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/schnorr/multisig.test.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/schnorr/multisig.test.cpp @@ -8,8 +8,8 @@ using namespace bb; template struct MultisigTest : public ::testing::Test { using G = grumpkin::g1; using Fr = grumpkin::fr; - using KeyPair = crypto::schnorr::key_pair; - using multisig = crypto::schnorr::multisig; + using KeyPair = crypto::schnorr_key_pair; + using multisig = crypto::schnorr_multisig; using multisig_public_key = typename multisig::MultiSigPublicKey; static KeyPair generate_account() @@ -31,9 +31,9 @@ template struct MultisigTest : public ::testing::Test { return signer_pubkeys; } - static std::optional create_multisig(const std::string& message, - const std::vector& accounts, - const bool tamper_proof_of_possession = false) + static std::optional create_multisig(const std::string& message, + const std::vector& accounts, + const bool tamper_proof_of_possession = false) { std::vector round1_pub; std::vector round1_priv; @@ -70,8 +70,8 @@ TYPED_TEST(MultisigTest, verify_multi_signature_blake2s) using G = grumpkin::g1; using Fr = grumpkin::fr; using Fq = grumpkin::fq; - using KeyPair = crypto::schnorr::key_pair; - using multisig = crypto::schnorr::multisig; + using KeyPair = crypto::schnorr_key_pair; + using multisig = crypto::schnorr_multisig; std::string message = "The quick brown dog jumped over the lazy fox."; @@ -88,7 +88,7 @@ TYPED_TEST(MultisigTest, verify_multi_signature_blake2s) auto pub_key = multisig::validate_and_combine_signer_pubkeys(this->create_signer_pubkeys(accounts)); ASSERT_TRUE(pub_key.has_value()); - bool result = crypto::schnorr::verify_signature(message, *pub_key, *signature); + bool result = crypto::schnorr_verify_signature(message, *pub_key, *signature); EXPECT_EQ(result, true); } @@ -97,7 +97,7 @@ TYPED_TEST(MultisigTest, multi_signature_fails_if_proof_of_possession_invalid) { using G = grumpkin::g1; using Fr = grumpkin::fr; - using KeyPair = crypto::schnorr::key_pair; + using KeyPair = crypto::schnorr_key_pair; std::string message = "The quick brown dog jumped over the lazy fox."; @@ -116,7 +116,7 @@ TYPED_TEST(MultisigTest, multi_signature_fails_if_duplicates) { using G = grumpkin::g1; using Fr = grumpkin::fr; - using KeyPair = crypto::schnorr::key_pair; + using KeyPair = crypto::schnorr_key_pair; std::string message = "The quick brown dog jumped over the lazy fox."; diff --git a/barretenberg/cpp/src/barretenberg/crypto/schnorr/proof_of_possession.hpp b/barretenberg/cpp/src/barretenberg/crypto/schnorr/proof_of_possession.hpp index eea7cc202dc0..f99878900c58 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/schnorr/proof_of_possession.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/schnorr/proof_of_possession.hpp @@ -5,7 +5,7 @@ #include "barretenberg/common/serialize.hpp" #include "schnorr.hpp" -namespace crypto::schnorr { +namespace bb::crypto { /** * @brief A proof of possession is a Schnorr proof of knowledge of a secret key corresponding to a given public key. @@ -15,12 +15,12 @@ namespace crypto::schnorr { * @tparam G1 group over which the key pair was generated * @tparam Hash function used to derive the Fiat-Shamir challenge */ -template struct ProofOfPossession { +template struct SchnorrProofOfPossession { using Fq = typename G1::coordinate_field; using Fr = typename G1::subgroup_field; using affine_element = typename G1::affine_element; using element = typename G1::element; - using key_pair = crypto::schnorr::key_pair; + using key_pair = crypto::schnorr_key_pair; // challenge = e = H_reg(pk,pk,R) std::array challenge; @@ -28,7 +28,7 @@ template struct ProofOfPossession { Fr response = Fr::zero(); // restore default constructor to enable deserialization - ProofOfPossession() = default; + SchnorrProofOfPossession() = default; /** * @brief Create a new proof of possession for a given account. @@ -37,7 +37,7 @@ template struct ProofOfPossession { * * @param account a key_pair (secret_key, public_key) */ - ProofOfPossession(const key_pair& account) + SchnorrProofOfPossession(const key_pair& account) { auto secret_key = account.private_key; auto public_key = account.public_key; @@ -121,17 +121,17 @@ template struct ProofOfPossession { }; template -inline void read(B& it, ProofOfPossession& proof_of_possession) +inline void read(B& it, SchnorrProofOfPossession& proof_of_possession) { read(it, proof_of_possession.challenge); read(it, proof_of_possession.response); } template -inline void write(B& buf, ProofOfPossession const& proof_of_possession) +inline void write(B& buf, SchnorrProofOfPossession const& proof_of_possession) { write(buf, proof_of_possession.challenge); write(buf, proof_of_possession.response); } -} // namespace crypto::schnorr +} // namespace bb::crypto diff --git a/barretenberg/cpp/src/barretenberg/crypto/schnorr/proof_of_possession.test.cpp b/barretenberg/cpp/src/barretenberg/crypto/schnorr/proof_of_possession.test.cpp index 92f46cc3ebaa..6432209fc851 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/schnorr/proof_of_possession.test.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/schnorr/proof_of_possession.test.cpp @@ -8,7 +8,7 @@ using namespace bb; template struct ProofOfPossessionTest : public ::testing::Test { using G = grumpkin::g1; using Fr = grumpkin::fr; - using KeyPair = crypto::schnorr::key_pair; + using KeyPair = crypto::schnorr_key_pair; static KeyPair generate_account() { @@ -26,7 +26,7 @@ TYPED_TEST(ProofOfPossessionTest, valid_proof) { using G = grumpkin::g1; using Hash = TypeParam; - using Proof = crypto::schnorr::ProofOfPossession; + using Proof = crypto::SchnorrProofOfPossession; const auto account = this->generate_account(); const auto proof = Proof(account); @@ -37,7 +37,7 @@ TYPED_TEST(ProofOfPossessionTest, invalid_empty_proof) { using G = grumpkin::g1; using Hash = TypeParam; - using Proof = crypto::schnorr::ProofOfPossession; + using Proof = crypto::SchnorrProofOfPossession; const auto account = this->generate_account(); const auto proof = Proof(); @@ -48,7 +48,7 @@ TYPED_TEST(ProofOfPossessionTest, fail_with_different_account) { using G = grumpkin::g1; using Hash = TypeParam; - using Proof = crypto::schnorr::ProofOfPossession; + using Proof = crypto::SchnorrProofOfPossession; const auto account1 = this->generate_account(); const auto account2 = this->generate_account(); @@ -60,7 +60,7 @@ TYPED_TEST(ProofOfPossessionTest, fail_zero_challenge) { using G = grumpkin::g1; using Hash = TypeParam; - using Proof = crypto::schnorr::ProofOfPossession; + using Proof = crypto::SchnorrProofOfPossession; const auto account = this->generate_account(); auto proof = Proof(account); @@ -74,7 +74,7 @@ TYPED_TEST(ProofOfPossessionTest, fail_zero_response) { using G = grumpkin::g1; using Hash = TypeParam; - using Proof = crypto::schnorr::ProofOfPossession; + using Proof = crypto::SchnorrProofOfPossession; const auto account = this->generate_account(); auto proof = Proof(account); @@ -87,7 +87,7 @@ TYPED_TEST(ProofOfPossessionTest, serialize) { using G = grumpkin::g1; using Hash = TypeParam; - using Proof = crypto::schnorr::ProofOfPossession; + using Proof = crypto::SchnorrProofOfPossession; const auto account = this->generate_account(); const auto proof = Proof(account); EXPECT_TRUE(proof.verify(account.public_key)); diff --git a/barretenberg/cpp/src/barretenberg/crypto/schnorr/schnorr.hpp b/barretenberg/cpp/src/barretenberg/crypto/schnorr/schnorr.hpp index 516e50038c19..81ca306effc6 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/schnorr/schnorr.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/schnorr/schnorr.hpp @@ -12,9 +12,8 @@ #include "barretenberg/common/streams.hpp" #include "barretenberg/serialize/msgpack.hpp" -namespace crypto { -namespace schnorr { -template struct key_pair { +namespace bb::crypto { +template struct schnorr_key_pair { Fr private_key; typename G1::affine_element public_key; }; @@ -22,7 +21,7 @@ template struct key_pair { // Raw representation of a Schnorr signature (e,s). We use the short variant of Schnorr // where we include the challenge hash `e` instead of the group element R representing // the provers initial message. -struct signature { +struct schnorr_signature { // `s` is a serialized field element (also 32 bytes), representing the prover's response to // to the verifier challenge `e`. @@ -36,33 +35,34 @@ struct signature { }; template -bool verify_signature(const std::string& message, const typename G1::affine_element& public_key, const signature& sig); +bool schnorr_verify_signature(const std::string& message, + const typename G1::affine_element& public_key, + const schnorr_signature& sig); template -signature construct_signature(const std::string& message, const key_pair& account); +schnorr_signature schnorr_construct_signature(const std::string& message, const schnorr_key_pair& account); -inline bool operator==(signature const& lhs, signature const& rhs) +inline bool operator==(schnorr_signature const& lhs, schnorr_signature const& rhs) { return lhs.s == rhs.s && lhs.e == rhs.e; } -inline std::ostream& operator<<(std::ostream& os, signature const& sig) +inline std::ostream& operator<<(std::ostream& os, schnorr_signature const& sig) { os << "{ " << sig.s << ", " << sig.e << " }"; return os; } -template inline void read(B& it, key_pair& keypair) +template inline void read(B& it, schnorr_key_pair& keypair) { read(it, keypair.private_key); read(it, keypair.public_key); } -template inline void write(B& buf, key_pair const& keypair) +template inline void write(B& buf, schnorr_key_pair const& keypair) { write(buf, keypair.private_key); write(buf, keypair.public_key); } -} // namespace schnorr -} // namespace crypto +} // namespace bb::crypto #include "./schnorr.tcc" diff --git a/barretenberg/cpp/src/barretenberg/crypto/schnorr/schnorr.tcc b/barretenberg/cpp/src/barretenberg/crypto/schnorr/schnorr.tcc index 6156301bfed5..455101e75489 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/schnorr/schnorr.tcc +++ b/barretenberg/cpp/src/barretenberg/crypto/schnorr/schnorr.tcc @@ -5,8 +5,7 @@ #include "schnorr.hpp" -namespace crypto { -namespace schnorr { +namespace bb::crypto { /** * @brief Generate the schnorr signature challenge parameter `e` given a message, signer pubkey and nonce @@ -37,7 +36,7 @@ namespace schnorr { * are always private inputs to circuits) then nothing would be revealed anyway. */ template -static auto generate_schnorr_challenge(const std::string& message, +static auto schnorr_generate_challenge(const std::string& message, const typename G1::affine_element& pubkey, const typename G1::affine_element& R) { @@ -71,7 +70,7 @@ static auto generate_schnorr_challenge(const std::string& message, * @return signature */ template -signature construct_signature(const std::string& message, const key_pair& account) +schnorr_signature schnorr_construct_signature(const std::string& message, const schnorr_key_pair& account) { // sanity check to ensure our hash function produces `e_raw` // of exactly 32 bytes. @@ -94,7 +93,7 @@ signature construct_signature(const std::string& message, const key_pair typename G1::affine_element R(G1::one * k); - auto e_raw = generate_schnorr_challenge(message, public_key, R); + auto e_raw = schnorr_generate_challenge(message, public_key, R); // the conversion from e_raw results in a biased field element e Fr e = Fr::serialize_from_buffer(&e_raw[0]); Fr s = k - (private_key * e); @@ -106,17 +105,19 @@ signature construct_signature(const std::string& message, const key_pair // and e = e_uint % r, where r is the order of the curve, // and pk as the point representing the public_key, // then e•pk = e_uint•pk - signature sig; + schnorr_signature sig; Fr::serialize_to_buffer(s, &sig.s[0]); std::copy(e_raw.begin(), e_raw.end(), sig.e.begin()); return sig; } /** - * @brief Verify a Schnorr signature of the sort produced by construct_signature. + * @brief Verify a Schnorr signature of the sort produced by schnorr_construct_signature. */ template -bool verify_signature(const std::string& message, const typename G1::affine_element& public_key, const signature& sig) +bool schnorr_verify_signature(const std::string& message, + const typename G1::affine_element& public_key, + const schnorr_signature& sig) { using affine_element = typename G1::affine_element; using element = typename G1::element; @@ -149,8 +150,7 @@ bool verify_signature(const std::string& message, const typename G1::affine_elem // compare the _hashes_ rather than field elements modulo r // e = H(pedersen(r, pk.x, pk.y), m), where r = x(R) - auto target_e = generate_schnorr_challenge(message, public_key, R); + auto target_e = schnorr_generate_challenge(message, public_key, R); return std::equal(sig.e.begin(), sig.e.end(), target_e.begin(), target_e.end()); } -} // namespace schnorr -} // namespace crypto +} // namespace bb::crypto diff --git a/barretenberg/cpp/src/barretenberg/crypto/schnorr/schnorr.test.cpp b/barretenberg/cpp/src/barretenberg/crypto/schnorr/schnorr.test.cpp index 8890d4a5454d..6946053a4a88 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/schnorr/schnorr.test.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/schnorr/schnorr.test.cpp @@ -3,11 +3,11 @@ #include using namespace bb; -using namespace crypto::schnorr; +using namespace bb::crypto; -crypto::schnorr::key_pair generate_signature() +crypto::schnorr_key_pair generate_signature() { - crypto::schnorr::key_pair account; + crypto::schnorr_key_pair account; account.private_key = grumpkin::fr::random_element(); account.public_key = grumpkin::g1::one * account.private_key; return account; @@ -17,14 +17,14 @@ TEST(schnorr, verify_signature_keccak256) { std::string message = "The quick brown fox jumped over the lazy dog."; - crypto::schnorr::key_pair account; + crypto::schnorr_key_pair account; account.private_key = grumpkin::fr::random_element(); account.public_key = grumpkin::g1::one * account.private_key; - crypto::schnorr::signature signature = - crypto::schnorr::construct_signature(message, account); + crypto::schnorr_signature signature = + crypto::schnorr_construct_signature(message, account); - bool result = crypto::schnorr::verify_signature( + bool result = crypto::schnorr_verify_signature( message, account.public_key, signature); EXPECT_EQ(result, true); @@ -34,14 +34,14 @@ TEST(schnorr, verify_signature_sha256) { std::string message = "The quick brown dog jumped over the lazy fox."; - crypto::schnorr::key_pair account; + crypto::schnorr_key_pair account; account.private_key = grumpkin::fr::random_element(); account.public_key = grumpkin::g1::one * account.private_key; - crypto::schnorr::signature signature = - crypto::schnorr::construct_signature(message, account); + crypto::schnorr_signature signature = + crypto::schnorr_construct_signature(message, account); - bool result = crypto::schnorr::verify_signature( + bool result = crypto::schnorr_verify_signature( message, account.public_key, signature); EXPECT_EQ(result, true); @@ -51,15 +51,15 @@ TEST(schnorr, verify_signature_blake2s) { std::string message = "The quick brown dog jumped over the lazy fox."; - crypto::schnorr::key_pair account; + crypto::schnorr_key_pair account; // account.private_key = grumpkin::fr::random_element(); account.private_key = { 0x55555555, 0x55555555, 0x55555555, 0x55555555 }; account.public_key = grumpkin::g1::one * account.private_key; - crypto::schnorr::signature signature = - crypto::schnorr::construct_signature(message, account); + crypto::schnorr_signature signature = + crypto::schnorr_construct_signature(message, account); - bool result = crypto::schnorr::verify_signature( + bool result = crypto::schnorr_verify_signature( message, account.public_key, signature); EXPECT_EQ(result, true); @@ -78,62 +78,62 @@ TEST(schnorr, hmac_signature_consistency) // k is no longer identical, so signatures should be different. auto signature_a = - construct_signature(message_a, account_a); + schnorr_construct_signature(message_a, account_a); auto signature_b = - construct_signature(message_a, account_a); + schnorr_construct_signature(message_a, account_a); ASSERT_NE(signature_a.e, signature_b.e); ASSERT_NE(signature_a.s, signature_b.s); // same message, different accounts should give different sigs! auto signature_c = - construct_signature(message_a, account_a); + schnorr_construct_signature(message_a, account_a); auto signature_d = - construct_signature(message_a, account_b); + schnorr_construct_signature(message_a, account_b); ASSERT_NE(signature_c.e, signature_d.e); ASSERT_NE(signature_c.s, signature_d.s); // different message, same accounts should give different sigs! auto signature_e = - construct_signature(message_a, account_a); + schnorr_construct_signature(message_a, account_a); auto signature_f = - construct_signature(message_b, account_a); + schnorr_construct_signature(message_b, account_a); ASSERT_NE(signature_e.e, signature_f.e); ASSERT_NE(signature_e.s, signature_f.s); // different message, different accounts should give different sigs!! auto signature_g = - construct_signature(message_a, account_a); + schnorr_construct_signature(message_a, account_a); auto signature_h = - construct_signature(message_b, account_b); + schnorr_construct_signature(message_b, account_b); ASSERT_NE(signature_g.e, signature_h.e); ASSERT_NE(signature_g.s, signature_h.s); - bool res = verify_signature( + bool res = schnorr_verify_signature( message_a, account_a.public_key, signature_a); EXPECT_EQ(res, true); - res = verify_signature( + res = schnorr_verify_signature( message_a, account_a.public_key, signature_b); EXPECT_EQ(res, true); - res = verify_signature( + res = schnorr_verify_signature( message_a, account_a.public_key, signature_c); EXPECT_EQ(res, true); - res = verify_signature( + res = schnorr_verify_signature( message_a, account_b.public_key, signature_d); EXPECT_EQ(res, true); - res = verify_signature( + res = schnorr_verify_signature( message_a, account_a.public_key, signature_e); EXPECT_EQ(res, true); - res = verify_signature( + res = schnorr_verify_signature( message_b, account_a.public_key, signature_f); EXPECT_EQ(res, true); - res = verify_signature( + res = schnorr_verify_signature( message_a, account_a.public_key, signature_g); EXPECT_EQ(res, true); - res = verify_signature( + res = schnorr_verify_signature( message_b, account_b.public_key, signature_h); EXPECT_EQ(res, true); } diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp index 7299d359bc3b..0fb5cebbe555 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp @@ -6,7 +6,7 @@ namespace acir_format { template -void build_constraints(Builder& builder, acir_format const& constraint_system, bool has_valid_witness_assignments) +void build_constraints(Builder& builder, AcirFormat const& constraint_system, bool has_valid_witness_assignments) { // Add arithmetic gates for (const auto& constraint : constraint_system.constraints) { @@ -94,6 +94,14 @@ void build_constraints(Builder& builder, acir_format const& constraint_system, b create_block_constraints(builder, constraint, has_valid_witness_assignments); } + // Add big_int constraints + for (const auto& constraint : constraint_system.bigint_operations) { + create_bigint_operations_constraint(builder, constraint); + } + for (const auto& constraint : constraint_system.bigint_from_le_bytes_constraints) { + create_bigint_from_le_bytes_constraint(builder, constraint); + } + // TODO(https://github.com/AztecProtocol/barretenberg/issues/817): disable these for UGH for now since we're not yet // dealing with proper recursion if constexpr (IsGoblinBuilder) { @@ -188,7 +196,7 @@ void build_constraints(Builder& builder, acir_format const& constraint_system, b * @return Builder */ template -Builder create_circuit(const acir_format& constraint_system, size_t size_hint, WitnessVector const& witness) +Builder create_circuit(const AcirFormat& constraint_system, size_t size_hint, WitnessVector const& witness) { Builder builder{ size_hint, witness, constraint_system.public_inputs, constraint_system.varnum }; @@ -198,9 +206,9 @@ Builder create_circuit(const acir_format& constraint_system, size_t size_hint, W return builder; } -template UltraCircuitBuilder create_circuit(const acir_format& constraint_system, +template UltraCircuitBuilder create_circuit(const AcirFormat& constraint_system, size_t size_hint, WitnessVector const& witness); -template void build_constraints(GoblinUltraCircuitBuilder&, acir_format const&, bool); +template void build_constraints(GoblinUltraCircuitBuilder&, AcirFormat const&, bool); } // namespace acir_format diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.hpp index 1cd81b2edbbe..82cf7eccad33 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.hpp @@ -1,6 +1,7 @@ #pragma once #include "barretenberg/common/slab_allocator.hpp" #include "barretenberg/serialize/msgpack.hpp" +#include "bigint_constraint.hpp" #include "blake2s_constraint.hpp" #include "blake3_constraint.hpp" #include "block_constraint.hpp" @@ -18,7 +19,7 @@ namespace acir_format { -struct acir_format { +struct AcirFormat { // The number of witnesses in the circuit uint32_t varnum; @@ -41,6 +42,8 @@ struct acir_format { std::vector ec_add_constraints; std::vector ec_double_constraints; std::vector recursion_constraints; + std::vector bigint_from_le_bytes_constraints; + std::vector bigint_operations; // A standard plonk arithmetic constraint, as defined in the poly_triple struct, consists of selector values // for q_M,q_L,q_R,q_O,q_C and indices of three variables taking the role of left, right and output wire @@ -69,17 +72,19 @@ struct acir_format { fixed_base_scalar_mul_constraints, recursion_constraints, constraints, - block_constraints); + block_constraints, + bigint_from_le_bytes_constraints, + bigint_operations); - friend bool operator==(acir_format const& lhs, acir_format const& rhs) = default; + friend bool operator==(AcirFormat const& lhs, AcirFormat const& rhs) = default; }; using WitnessVector = std::vector>; template -Builder create_circuit(const acir_format& constraint_system, size_t size_hint = 0, WitnessVector const& witness = {}); +Builder create_circuit(const AcirFormat& constraint_system, size_t size_hint = 0, WitnessVector const& witness = {}); template -void build_constraints(Builder& builder, acir_format const& constraint_system, bool has_valid_witness_assignments); +void build_constraints(Builder& builder, AcirFormat const& constraint_system, bool has_valid_witness_assignments); } // namespace acir_format diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.test.cpp index 7aa0a0364ff4..8804cd0c573f 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.test.cpp @@ -7,7 +7,7 @@ #include "barretenberg/serialize/test_helper.hpp" #include "ecdsa_secp256k1.hpp" -namespace acir_format::tests { +using namespace acir_format; class AcirFormatTests : public ::testing::Test { protected: @@ -27,7 +27,7 @@ TEST_F(AcirFormatTests, TestASingleConstraintNoPubInputs) .q_c = 0, }; - acir_format constraint_system{ + AcirFormat constraint_system{ .varnum = 4, .public_inputs = {}, .logic_constraints = {}, @@ -47,6 +47,8 @@ TEST_F(AcirFormatTests, TestASingleConstraintNoPubInputs) .ec_add_constraints = {}, .ec_double_constraints = {}, .recursion_constraints = {}, + .bigint_from_le_bytes_constraints = {}, + .bigint_operations = {}, .constraints = { constraint }, .block_constraints = {}, }; @@ -139,27 +141,29 @@ TEST_F(AcirFormatTests, TestLogicGateFromNoirCircuit) // EXPR [ (1, _4, _6) (-1, _4) 0 ] // EXPR [ (-1, _6) 1 ] - acir_format constraint_system{ .varnum = 6, - .public_inputs = { 1 }, - .logic_constraints = { logic_constraint }, - .range_constraints = { range_a, range_b }, - .sha256_constraints = {}, - .schnorr_constraints = {}, - .ecdsa_k1_constraints = {}, - .ecdsa_r1_constraints = {}, - .blake2s_constraints = {}, - .blake3_constraints = {}, - .keccak_constraints = {}, - .keccak_var_constraints = {}, - .keccak_permutations = {}, - .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, - .fixed_base_scalar_mul_constraints = {}, - .ec_add_constraints = {}, - .ec_double_constraints = {}, - .recursion_constraints = {}, - .constraints = { expr_a, expr_b, expr_c, expr_d }, - .block_constraints = {} }; + AcirFormat constraint_system{ .varnum = 6, + .public_inputs = { 1 }, + .logic_constraints = { logic_constraint }, + .range_constraints = { range_a, range_b }, + .sha256_constraints = {}, + .schnorr_constraints = {}, + .ecdsa_k1_constraints = {}, + .ecdsa_r1_constraints = {}, + .blake2s_constraints = {}, + .blake3_constraints = {}, + .keccak_constraints = {}, + .keccak_var_constraints = {}, + .keccak_permutations = {}, + .pedersen_constraints = {}, + .pedersen_hash_constraints = {}, + .fixed_base_scalar_mul_constraints = {}, + .ec_add_constraints = {}, + .ec_double_constraints = {}, + .recursion_constraints = {}, + .bigint_from_le_bytes_constraints = {}, + .bigint_operations = {}, + .constraints = { expr_a, expr_b, expr_c, expr_d }, + .block_constraints = {} }; uint256_t inverse_of_five = fr(5).invert(); WitnessVector witness{ @@ -202,44 +206,46 @@ TEST_F(AcirFormatTests, TestSchnorrVerifyPass) .result = 76, .signature = signature, }; - acir_format constraint_system{ .varnum = 81, - .public_inputs = {}, - .logic_constraints = {}, - .range_constraints = range_constraints, - .sha256_constraints = {}, - .schnorr_constraints = { schnorr_constraint }, - .ecdsa_k1_constraints = {}, - .ecdsa_r1_constraints = {}, - .blake2s_constraints = {}, - .blake3_constraints = {}, - .keccak_constraints = {}, - .keccak_var_constraints = {}, - .keccak_permutations = {}, - .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, - .fixed_base_scalar_mul_constraints = {}, - .ec_add_constraints = {}, - .ec_double_constraints = {}, - .recursion_constraints = {}, - .constraints = { poly_triple{ - .a = schnorr_constraint.result, - .b = schnorr_constraint.result, - .c = schnorr_constraint.result, - .q_m = 0, - .q_l = 0, - .q_r = 0, - .q_o = 1, - .q_c = fr::neg_one(), - } }, - .block_constraints = {} }; + AcirFormat constraint_system{ .varnum = 81, + .public_inputs = {}, + .logic_constraints = {}, + .range_constraints = range_constraints, + .sha256_constraints = {}, + .schnorr_constraints = { schnorr_constraint }, + .ecdsa_k1_constraints = {}, + .ecdsa_r1_constraints = {}, + .blake2s_constraints = {}, + .blake3_constraints = {}, + .keccak_constraints = {}, + .keccak_var_constraints = {}, + .keccak_permutations = {}, + .pedersen_constraints = {}, + .pedersen_hash_constraints = {}, + .fixed_base_scalar_mul_constraints = {}, + .ec_add_constraints = {}, + .ec_double_constraints = {}, + .recursion_constraints = {}, + .bigint_from_le_bytes_constraints = {}, + .bigint_operations = {}, + .constraints = { poly_triple{ + .a = schnorr_constraint.result, + .b = schnorr_constraint.result, + .c = schnorr_constraint.result, + .q_m = 0, + .q_l = 0, + .q_r = 0, + .q_o = 1, + .q_c = fr::neg_one(), + } }, + .block_constraints = {} }; std::string message_string = "tenletters"; - crypto::schnorr::key_pair account; + crypto::schnorr_key_pair account; account.private_key = grumpkin::fr::random_element(); account.public_key = grumpkin::g1::one * account.private_key; - crypto::schnorr::signature signature_raw = - crypto::schnorr::construct_signature(message_string, - account); + crypto::schnorr_signature signature_raw = + crypto::schnorr_construct_signature(message_string, + account); uint256_t pub_x = account.public_key.x; uint256_t pub_y = account.public_key.y; WitnessVector witness{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, pub_x, pub_y, 5, 202, 31, 146, @@ -292,7 +298,7 @@ TEST_F(AcirFormatTests, TestSchnorrVerifySmallRange) .result = 76, .signature = signature, }; - acir_format constraint_system{ + AcirFormat constraint_system{ .varnum = 81, .public_inputs = {}, .logic_constraints = {}, @@ -312,6 +318,8 @@ TEST_F(AcirFormatTests, TestSchnorrVerifySmallRange) .ec_add_constraints = {}, .ec_double_constraints = {}, .recursion_constraints = {}, + .bigint_from_le_bytes_constraints = {}, + .bigint_operations = {}, .constraints = { poly_triple{ .a = schnorr_constraint.result, .b = schnorr_constraint.result, @@ -326,12 +334,12 @@ TEST_F(AcirFormatTests, TestSchnorrVerifySmallRange) }; std::string message_string = "tenletters"; - crypto::schnorr::key_pair account; + crypto::schnorr_key_pair account; account.private_key = grumpkin::fr::random_element(); account.public_key = grumpkin::g1::one * account.private_key; - crypto::schnorr::signature signature_raw = - crypto::schnorr::construct_signature(message_string, - account); + crypto::schnorr_signature signature_raw = + crypto::schnorr_construct_signature(message_string, + account); uint256_t pub_x = account.public_key.x; uint256_t pub_y = account.public_key.y; WitnessVector witness{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, pub_x, pub_y, 5, 202, 31, 146, @@ -402,7 +410,7 @@ TEST_F(AcirFormatTests, TestVarKeccak) .q_c = fr::neg_one() * fr(4), }; - acir_format constraint_system{ + AcirFormat constraint_system{ .varnum = 36, .public_inputs = {}, .logic_constraints = {}, @@ -422,6 +430,8 @@ TEST_F(AcirFormatTests, TestVarKeccak) .ec_add_constraints = {}, .ec_double_constraints = {}, .recursion_constraints = {}, + .bigint_from_le_bytes_constraints = {}, + .bigint_operations = {}, .constraints = { dummy }, .block_constraints = {}, }; @@ -445,27 +455,29 @@ TEST_F(AcirFormatTests, TestKeccakPermutation) 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50 }, }; - acir_format constraint_system{ .varnum = 51, - .public_inputs = {}, - .logic_constraints = {}, - .range_constraints = {}, - .sha256_constraints = {}, - .schnorr_constraints = {}, - .ecdsa_k1_constraints = {}, - .ecdsa_r1_constraints = {}, - .blake2s_constraints = {}, - .blake3_constraints = {}, - .keccak_constraints = {}, - .keccak_var_constraints = {}, - .keccak_permutations = { keccak_permutation }, - .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, - .fixed_base_scalar_mul_constraints = {}, - .ec_add_constraints = {}, - .ec_double_constraints = {}, - .recursion_constraints = {}, - .constraints = {}, - .block_constraints = {} }; + AcirFormat constraint_system{ .varnum = 51, + .public_inputs = {}, + .logic_constraints = {}, + .range_constraints = {}, + .sha256_constraints = {}, + .schnorr_constraints = {}, + .ecdsa_k1_constraints = {}, + .ecdsa_r1_constraints = {}, + .blake2s_constraints = {}, + .blake3_constraints = {}, + .keccak_constraints = {}, + .keccak_var_constraints = {}, + .keccak_permutations = { keccak_permutation }, + .pedersen_constraints = {}, + .pedersen_hash_constraints = {}, + .fixed_base_scalar_mul_constraints = {}, + .ec_add_constraints = {}, + .ec_double_constraints = {}, + .recursion_constraints = {}, + .bigint_from_le_bytes_constraints = {}, + .bigint_operations = {}, + .constraints = {}, + .block_constraints = {} }; WitnessVector witness{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, @@ -481,5 +493,3 @@ TEST_F(AcirFormatTests, TestKeccakPermutation) EXPECT_EQ(verifier.verify_proof(proof), true); } - -} // namespace acir_format::tests diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp index 4e6b0f8a617d..5d6cf0063b86 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp @@ -2,6 +2,7 @@ #include "acir_format.hpp" #include "barretenberg/common/container.hpp" #include "barretenberg/common/throw_or_abort.hpp" +#include "barretenberg/dsl/acir_format/bigint_constraint.hpp" #include "barretenberg/dsl/acir_format/blake2s_constraint.hpp" #include "barretenberg/dsl/acir_format/blake3_constraint.hpp" #include "barretenberg/dsl/acir_format/block_constraint.hpp" @@ -96,12 +97,12 @@ poly_triple serialize_arithmetic_gate(Circuit::Expression const& arg) return pt; } -void handle_arithmetic(Circuit::Opcode::AssertZero const& arg, acir_format& af) +void handle_arithmetic(Circuit::Opcode::AssertZero const& arg, AcirFormat& af) { af.constraints.push_back(serialize_arithmetic_gate(arg.value)); } -void handle_blackbox_func_call(Circuit::Opcode::BlackBoxFuncCall const& arg, acir_format& af) +void handle_blackbox_func_call(Circuit::Opcode::BlackBoxFuncCall const& arg, AcirFormat& af) { std::visit( [&](auto&& arg) { @@ -240,6 +241,40 @@ void handle_blackbox_func_call(Circuit::Opcode::BlackBoxFuncCall const& arg, aci .key_hash = arg.key_hash.witness.value, }; af.recursion_constraints.push_back(c); + } else if constexpr (std::is_same_v) { + af.bigint_from_le_bytes_constraints.push_back(BigIntFromLeBytes{ + .inputs = map(arg.inputs, [](auto& e) { return e.witness.value; }), + .modulus = map(arg.modulus, [](auto& e) -> uint32_t { return e; }), + .result = arg.output, + }); + } else if constexpr (std::is_same_v) { + af.bigint_operations.push_back(BigIntOperation{ + .lhs = arg.lhs, + .rhs = arg.rhs, + .result = arg.output, + .opcode = BigIntOperationType::Add, + }); + } else if constexpr (std::is_same_v) { + af.bigint_operations.push_back(BigIntOperation{ + .lhs = arg.lhs, + .rhs = arg.rhs, + .result = arg.output, + .opcode = BigIntOperationType::Neg, + }); + } else if constexpr (std::is_same_v) { + af.bigint_operations.push_back(BigIntOperation{ + .lhs = arg.lhs, + .rhs = arg.rhs, + .result = arg.output, + .opcode = BigIntOperationType::Mul, + }); + } else if constexpr (std::is_same_v) { + af.bigint_operations.push_back(BigIntOperation{ + .lhs = arg.lhs, + .rhs = arg.rhs, + .result = arg.output, + .opcode = BigIntOperationType::Div, + }); } }, arg.value.value); @@ -289,11 +324,11 @@ void handle_memory_op(Circuit::Opcode::MemoryOp const& mem_op, BlockConstraint& block.trace.push_back(acir_mem_op); } -acir_format circuit_buf_to_acir_format(std::vector const& buf) +AcirFormat circuit_buf_to_acir_format(std::vector const& buf) { auto circuit = Circuit::Circuit::bincodeDeserialize(buf); - acir_format af; + AcirFormat af; // `varnum` is the true number of variables, thus we add one to the index which starts at zero af.varnum = circuit.current_witness_index + 1; af.public_inputs = join({ map(circuit.public_parameters.value, [](auto e) { return e.value; }), diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/bigint_constraint.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/bigint_constraint.cpp new file mode 100644 index 000000000000..4780e5ca36c6 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/bigint_constraint.cpp @@ -0,0 +1,33 @@ +#include "bigint_constraint.hpp" +#include "barretenberg/dsl/types.hpp" +#include "barretenberg/numeric/uint256/uint256.hpp" +#include "barretenberg/stdlib/primitives/bigfield/bigfield.hpp" + +namespace acir_format { + +template void create_bigint_operations_constraint(Builder& builder, const BigIntOperation& input) +{ + // TODO + (void)builder; + info(input); +} + +template void create_bigint_operations_constraint(UltraCircuitBuilder& builder, + const BigIntOperation& input); +template void create_bigint_operations_constraint(GoblinUltraCircuitBuilder& builder, + const BigIntOperation& input); + +template +void create_bigint_from_le_bytes_constraint(Builder& builder, const BigIntFromLeBytes& input) +{ + // TODO + (void)builder; + info(input); +} + +template void create_bigint_from_le_bytes_constraint(UltraCircuitBuilder& builder, + const BigIntFromLeBytes& input); +template void create_bigint_from_le_bytes_constraint(GoblinUltraCircuitBuilder& builder, + const BigIntFromLeBytes& input); + +} // namespace acir_format diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/bigint_constraint.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/bigint_constraint.hpp new file mode 100644 index 000000000000..8b21ee5e7840 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/bigint_constraint.hpp @@ -0,0 +1,35 @@ +#pragma once +#include "barretenberg/dsl/types.hpp" +#include "barretenberg/serialize/msgpack.hpp" +#include +#include + +namespace acir_format { + +struct BigIntFromLeBytes { + std::vector inputs; + std::vector modulus; + uint32_t result; + + // For serialization, update with any new fields + MSGPACK_FIELDS(inputs, result); + friend bool operator==(BigIntFromLeBytes const& lhs, BigIntFromLeBytes const& rhs) = default; +}; + +enum BigIntOperationType { Add, Neg, Mul, Div }; + +struct BigIntOperation { + uint32_t lhs; + uint32_t rhs; + uint32_t result; + BigIntOperationType opcode; + + // For serialization, update with any new fields + MSGPACK_FIELDS(lhs, rhs, opcode, result); + friend bool operator==(BigIntOperation const& lhs, BigIntOperation const& rhs) = default; +}; + +template void create_bigint_operations_constraint(Builder& builder, const BigIntOperation& input); +template +void create_bigint_from_le_bytes_constraint(Builder& builder, const BigIntFromLeBytes& input); +} // namespace acir_format \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/bigint_constraint.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/bigint_constraint.test.cpp new file mode 100644 index 000000000000..0762bfd783a8 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/bigint_constraint.test.cpp @@ -0,0 +1,88 @@ +#include "bigint_constraint.hpp" +#include "acir_format.hpp" +#include "barretenberg/plonk/proof_system/types/proof.hpp" +#include "barretenberg/plonk/proof_system/verification_key/verification_key.hpp" + +#include +#include + +namespace acir_format::tests { + +class BigIntTests : public ::testing::Test { + protected: + static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } +}; + +TEST_F(BigIntTests, TestBigIntConstraintDummy) +{ + // Dummy Test: to be updated when big ints opcodes are implemented + BigIntOperation add_constraint{ + .lhs = 1, + .rhs = 2, + .result = 3, + .opcode = BigIntOperationType::Add, + }; + BigIntOperation neg_constraint{ + .lhs = 1, + .rhs = 2, + .result = 3, + .opcode = BigIntOperationType::Neg, + }; + BigIntOperation mul_constraint{ + .lhs = 1, + .rhs = 2, + .result = 3, + .opcode = BigIntOperationType::Mul, + }; + BigIntOperation div_constraint{ + .lhs = 1, + .rhs = 2, + .result = 3, + .opcode = BigIntOperationType::Div, + }; + BigIntFromLeBytes from_le_bytes_constraint{ + .inputs = { 0 }, + .modulus = { 23 }, + .result = 1, + }; + + AcirFormat constraint_system{ + .varnum = 4, + .public_inputs = {}, + .logic_constraints = {}, + .range_constraints = {}, + .sha256_constraints = {}, + .schnorr_constraints = {}, + .ecdsa_k1_constraints = {}, + .ecdsa_r1_constraints = {}, + .blake2s_constraints = {}, + .blake3_constraints = {}, + .keccak_constraints = {}, + .keccak_var_constraints = {}, + .keccak_permutations = {}, + .pedersen_constraints = {}, + .pedersen_hash_constraints = {}, + .fixed_base_scalar_mul_constraints = {}, + .ec_add_constraints = {}, + .ec_double_constraints = {}, + .recursion_constraints = {}, + .bigint_from_le_bytes_constraints = { from_le_bytes_constraint }, + .bigint_operations = { add_constraint, neg_constraint, mul_constraint, div_constraint }, + .constraints = {}, + .block_constraints = {}, + + }; + + WitnessVector witness{ 0, 0, 1 }; + auto builder = create_circuit(constraint_system, /*size_hint*/ 0, witness); + + auto composer = Composer(); + auto prover = composer.create_ultra_with_keccak_prover(builder); + auto proof = prover.construct_proof(); + + auto verifier = composer.create_ultra_with_keccak_verifier(builder); + + EXPECT_EQ(verifier.verify_proof(proof), true); +} + +} // namespace acir_format::tests \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/block_constraint.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/block_constraint.test.cpp index cb87035cae53..7c0444f61912 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/block_constraint.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/block_constraint.test.cpp @@ -6,7 +6,7 @@ #include #include -namespace acir_format::tests { +using namespace acir_format; class UltraPlonkRAM : public ::testing::Test { protected: @@ -19,7 +19,7 @@ size_t generate_block_constraint(BlockConstraint& constraint, WitnessVector& wit witness_len++; fr two = fr::one() + fr::one(); - poly_triple a0 = poly_triple{ + poly_triple a0{ .a = 0, .b = 0, .c = 0, @@ -30,7 +30,7 @@ size_t generate_block_constraint(BlockConstraint& constraint, WitnessVector& wit .q_c = 0, }; fr three = fr::one() + two; - poly_triple a1 = poly_triple{ + poly_triple a1{ .a = 0, .b = 0, .c = 0, @@ -40,7 +40,7 @@ size_t generate_block_constraint(BlockConstraint& constraint, WitnessVector& wit .q_o = 0, .q_c = three, }; - poly_triple r1 = poly_triple{ + poly_triple r1{ .a = 0, .b = 0, .c = 0, @@ -50,7 +50,7 @@ size_t generate_block_constraint(BlockConstraint& constraint, WitnessVector& wit .q_o = 0, .q_c = fr::neg_one(), }; - poly_triple r2 = poly_triple{ + poly_triple r2{ .a = 0, .b = 0, .c = 0, @@ -60,7 +60,7 @@ size_t generate_block_constraint(BlockConstraint& constraint, WitnessVector& wit .q_o = 0, .q_c = fr::neg_one(), }; - poly_triple y = poly_triple{ + poly_triple y{ .a = 1, .b = 0, .c = 0, @@ -72,7 +72,7 @@ size_t generate_block_constraint(BlockConstraint& constraint, WitnessVector& wit }; witness_values.emplace_back(2); witness_len++; - poly_triple z = poly_triple{ + poly_triple z{ .a = 2, .b = 0, .c = 0, @@ -84,12 +84,12 @@ size_t generate_block_constraint(BlockConstraint& constraint, WitnessVector& wit }; witness_values.emplace_back(3); witness_len++; - MemOp op1 = MemOp{ + MemOp op1{ .access_type = 0, .index = r1, .value = y, }; - MemOp op2 = MemOp{ + MemOp op2{ .access_type = 0, .index = r2, .value = z, @@ -108,7 +108,7 @@ TEST_F(UltraPlonkRAM, TestBlockConstraint) BlockConstraint block; WitnessVector witness_values; size_t num_variables = generate_block_constraint(block, witness_values); - acir_format constraint_system{ + AcirFormat constraint_system{ .varnum = static_cast(num_variables), .public_inputs = {}, .logic_constraints = {}, @@ -128,6 +128,8 @@ TEST_F(UltraPlonkRAM, TestBlockConstraint) .ec_add_constraints = {}, .ec_double_constraints = {}, .recursion_constraints = {}, + .bigint_from_le_bytes_constraints = {}, + .bigint_operations = {}, .constraints = {}, .block_constraints = { block }, }; @@ -141,4 +143,3 @@ TEST_F(UltraPlonkRAM, TestBlockConstraint) auto verifier = composer.create_verifier(builder); EXPECT_EQ(verifier.verify_proof(proof), true); } -} // namespace acir_format::tests diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.cpp index 3f0d17b86b60..ce6ff2dafc52 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.cpp @@ -6,10 +6,10 @@ namespace acir_format { using namespace bb::plonk; template -crypto::ecdsa::signature ecdsa_convert_signature(Builder& builder, std::vector signature) +crypto::ecdsa_signature ecdsa_convert_signature(Builder& builder, std::vector signature) { - crypto::ecdsa::signature signature_cr; + crypto::ecdsa_signature signature_cr; // Get the witness assignment for each witness index // Write the witness assignment to the byte_array @@ -117,9 +117,9 @@ void create_ecdsa_k1_verify_constraints(Builder& builder, std::vector ss(new_sig.s.begin(), new_sig.s.end()); uint8_t vv = new_sig.v; - stdlib::ecdsa::signature sig{ stdlib::byte_array(&builder, rr), - stdlib::byte_array(&builder, ss), - stdlib::uint8(&builder, vv) }; + stdlib::ecdsa_signature sig{ stdlib::byte_array(&builder, rr), + stdlib::byte_array(&builder, ss), + stdlib::uint8(&builder, vv) }; pub_key_x_fq.assert_is_in_field(); pub_key_y_fq.assert_is_in_field(); @@ -135,11 +135,11 @@ void create_ecdsa_k1_verify_constraints(Builder& builder, } bool_ct signature_result = - stdlib::ecdsa::verify_signature_prehashed_message_noassert( + stdlib::ecdsa_verify_signature_prehashed_message_noassert( message, public_key, sig); bool_ct signature_result_normalized = signature_result.normalize(); builder.assert_equal(signature_result_normalized.witness_index, input.result); @@ -160,14 +160,14 @@ template void dummy_ecdsa_constraint(Builder& builder, EcdsaS signature_.resize(64); // Create a valid signature with a valid public key - crypto::ecdsa::key_pair account; + crypto::ecdsa_key_pair account; account.private_key = 10; account.public_key = secp256k1_ct::g1::one * account.private_key; uint256_t pub_x_value = account.public_key.x; uint256_t pub_y_value = account.public_key.y; std::string message_string = "Instructions unclear, ask again later."; - crypto::ecdsa::signature signature = - crypto::ecdsa::construct_signature( + crypto::ecdsa_signature signature = + crypto::ecdsa_construct_signature( message_string, account); // Create new variables which will reference the valid public key and signature. diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.hpp index 45633d1728e4..7dd69f6af90b 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.hpp @@ -38,7 +38,7 @@ void create_ecdsa_k1_verify_constraints(Builder& builder, template void dummy_ecdsa_constraint(Builder& builder, EcdsaSecp256k1Constraint const& input); template -crypto::ecdsa::signature ecdsa_convert_signature(Builder& builder, std::vector signature); +crypto::ecdsa_signature ecdsa_convert_signature(Builder& builder, std::vector signature); witness_ct ecdsa_index_to_witness(Builder& builder, uint32_t index); template bb::stdlib::byte_array ecdsa_vector_of_bytes_to_byte_array(Builder& builder, diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.test.cpp index 841e71a148d3..2e17b97008dd 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256k1.test.cpp @@ -7,8 +7,8 @@ #include #include -namespace acir_format::tests { -using curve_ct = bb::stdlib::secp256k1; +using namespace acir_format; +using curve_ct = stdlib::secp256k1; class ECDSASecp256k1 : public ::testing::Test { protected: @@ -25,13 +25,13 @@ size_t generate_ecdsa_constraint(EcdsaSecp256k1Constraint& ecdsa_constraint, Wit std::copy(message_string.begin(), message_string.end(), std::back_inserter(message_buffer)); auto hashed_message = sha256::sha256(message_buffer); - crypto::ecdsa::key_pair account; + crypto::ecdsa_key_pair account; account.private_key = curve_ct::fr::random_element(); account.public_key = curve_ct::g1::one * account.private_key; - crypto::ecdsa::signature signature = - crypto::ecdsa::construct_signature(message_string, - account); + crypto::ecdsa_signature signature = + crypto::ecdsa_construct_signature(message_string, + account); uint256_t pub_x_value = account.public_key.x; uint256_t pub_y_value = account.public_key.y; @@ -87,7 +87,7 @@ TEST_F(ECDSASecp256k1, TestECDSAConstraintSucceed) EcdsaSecp256k1Constraint ecdsa_k1_constraint; WitnessVector witness_values; size_t num_variables = generate_ecdsa_constraint(ecdsa_k1_constraint, witness_values); - acir_format constraint_system{ + AcirFormat constraint_system{ .varnum = static_cast(num_variables), .public_inputs = {}, .logic_constraints = {}, @@ -107,6 +107,8 @@ TEST_F(ECDSASecp256k1, TestECDSAConstraintSucceed) .ec_add_constraints = {}, .ec_double_constraints = {}, .recursion_constraints = {}, + .bigint_from_le_bytes_constraints = {}, + .bigint_operations = {}, .constraints = {}, .block_constraints = {}, }; @@ -131,7 +133,7 @@ TEST_F(ECDSASecp256k1, TestECDSACompilesForVerifier) EcdsaSecp256k1Constraint ecdsa_k1_constraint; WitnessVector witness_values; size_t num_variables = generate_ecdsa_constraint(ecdsa_k1_constraint, witness_values); - acir_format constraint_system{ + AcirFormat constraint_system{ .varnum = static_cast(num_variables), .public_inputs = {}, .logic_constraints = {}, @@ -151,6 +153,8 @@ TEST_F(ECDSASecp256k1, TestECDSACompilesForVerifier) .ec_add_constraints = {}, .ec_double_constraints = {}, .recursion_constraints = {}, + .bigint_from_le_bytes_constraints = {}, + .bigint_operations = {}, .constraints = {}, .block_constraints = {}, }; @@ -170,7 +174,7 @@ TEST_F(ECDSASecp256k1, TestECDSAConstraintFail) // tamper with signature witness_values[witness_values.size() - 20] += 1; - acir_format constraint_system{ + AcirFormat constraint_system{ .varnum = static_cast(num_variables), .public_inputs = {}, .logic_constraints = {}, @@ -190,6 +194,8 @@ TEST_F(ECDSASecp256k1, TestECDSAConstraintFail) .ec_add_constraints = {}, .ec_double_constraints = {}, .recursion_constraints = {}, + .bigint_from_le_bytes_constraints = {}, + .bigint_operations = {}, .constraints = {}, .block_constraints = {}, }; @@ -203,4 +209,3 @@ TEST_F(ECDSASecp256k1, TestECDSAConstraintFail) auto verifier = composer.create_verifier(builder); EXPECT_EQ(verifier.verify_proof(proof), true); } -} // namespace acir_format::tests diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256r1.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256r1.cpp index 59e20aeda0e9..079c71697941 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256r1.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256r1.cpp @@ -49,9 +49,9 @@ void create_ecdsa_r1_verify_constraints(Builder& builder, std::vector ss(new_sig.s.begin(), new_sig.s.end()); uint8_t vv = new_sig.v; - stdlib::ecdsa::signature sig{ stdlib::byte_array(&builder, rr), - stdlib::byte_array(&builder, ss), - stdlib::uint8(&builder, vv) }; + stdlib::ecdsa_signature sig{ stdlib::byte_array(&builder, rr), + stdlib::byte_array(&builder, ss), + stdlib::uint8(&builder, vv) }; pub_key_x_fq.assert_is_in_field(); pub_key_y_fq.assert_is_in_field(); @@ -67,11 +67,11 @@ void create_ecdsa_r1_verify_constraints(Builder& builder, } bool_ct signature_result = - stdlib::ecdsa::verify_signature_prehashed_message_noassert( + stdlib::ecdsa_verify_signature_prehashed_message_noassert( message, public_key, sig); bool_ct signature_result_normalized = signature_result.normalize(); builder.assert_equal(signature_result_normalized.witness_index, input.result); @@ -100,13 +100,13 @@ template void dummy_ecdsa_constraint(Builder& builder, EcdsaS std::copy(message_string.begin(), message_string.end(), std::back_inserter(message_buffer)); auto hashed_message = sha256::sha256(message_buffer); - crypto::ecdsa::key_pair account; + crypto::ecdsa_key_pair account; account.private_key = 10; account.public_key = secp256r1::g1::one * account.private_key; - crypto::ecdsa::signature signature = - crypto::ecdsa::construct_signature(message_string, - account); + crypto::ecdsa_signature signature = + crypto::ecdsa_construct_signature(message_string, + account); uint256_t pub_x_value = account.public_key.x; uint256_t pub_y_value = account.public_key.y; diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256r1.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256r1.test.cpp index 72b5a616afc2..c3487e35da0f 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256r1.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/ecdsa_secp256r1.test.cpp @@ -7,8 +7,9 @@ #include #include -namespace acir_format::tests { -using curve_ct = bb::stdlib::secp256r1; +using namespace acir_format; + +using curve_ct = stdlib::secp256r1; // Generate r1 constraints given pre generated pubkey, sig and message values size_t generate_r1_constraints(EcdsaSecp256r1Constraint& ecdsa_r1_constraint, @@ -16,7 +17,7 @@ size_t generate_r1_constraints(EcdsaSecp256r1Constraint& ecdsa_r1_constraint, uint256_t pub_x_value, uint256_t pub_y_value, std::array hashed_message, - crypto::ecdsa::signature signature) + crypto::ecdsa_signature signature) { std::vector message_in; @@ -78,13 +79,13 @@ size_t generate_ecdsa_constraint(EcdsaSecp256r1Constraint& ecdsa_r1_constraint, std::copy(message_string.begin(), message_string.end(), std::back_inserter(message_buffer)); auto hashed_message = sha256::sha256(message_buffer); - crypto::ecdsa::key_pair account; + crypto::ecdsa_key_pair account; account.private_key = curve_ct::fr::random_element(); account.public_key = curve_ct::g1::one * account.private_key; - crypto::ecdsa::signature signature = - crypto::ecdsa::construct_signature(message_string, - account); + crypto::ecdsa_signature signature = + crypto::ecdsa_construct_signature(message_string, + account); return generate_r1_constraints( ecdsa_r1_constraint, witness_values, account.public_key.x, account.public_key.y, hashed_message, signature); @@ -105,7 +106,7 @@ TEST(ECDSASecp256r1, test_hardcoded) uint256_t pub_key_y = uint256_t("136093d7012e509a73715cbd0b00a3cc0ff4b5c01b3ffa196ab1fb327036b8e6"); // 0x2c70a8d084b62bfc5ce03641caf9f72ad4da8c81bfe6ec9487bb5e1bef62a13218ad9ee29eaf351fdc50f1520c425e9b908a07278b43b0ec7b872778c14e0784 - crypto::ecdsa::signature signature = { + crypto::ecdsa_signature signature = { .r = { 44, 112, 168, 208, 132, 182, 43, 252, 92, 224, 54, 65, 202, 249, 247, 42, 212, 218, 140, 129, 191, 230, 236, 148, 135, 187, 94, 27, 239, 98, 161, 50 }, .s = { 24, 173, 158, 226, 158, 175, 53, 31, 220, 80, 241, 82, 12, 66, 94, 155, @@ -113,7 +114,7 @@ TEST(ECDSASecp256r1, test_hardcoded) .v = 0 }; - crypto::ecdsa::key_pair account; + crypto::ecdsa_key_pair account; account.private_key = curve_ct::fr(uint256_t("0202020202020202020202020202020202020202020202020202020202020202")); account.public_key = curve_ct::g1::one * account.private_key; @@ -121,7 +122,7 @@ TEST(ECDSASecp256r1, test_hardcoded) size_t num_variables = generate_r1_constraints(ecdsa_r1_constraint, witness_values, pub_key_x, pub_key_y, hashed_message, signature); - acir_format constraint_system{ + AcirFormat constraint_system{ .varnum = static_cast(num_variables), .public_inputs = {}, .logic_constraints = {}, @@ -141,12 +142,14 @@ TEST(ECDSASecp256r1, test_hardcoded) .ec_add_constraints = {}, .ec_double_constraints = {}, .recursion_constraints = {}, + .bigint_from_le_bytes_constraints = {}, + .bigint_operations = {}, .constraints = {}, .block_constraints = {}, }; secp256r1::g1::affine_element pub_key = { pub_key_x, pub_key_y }; - bool we_ballin = crypto::ecdsa::verify_signature( + bool we_ballin = crypto::ecdsa_verify_signature( message, pub_key, signature); EXPECT_EQ(we_ballin, true); @@ -166,7 +169,7 @@ TEST(ECDSASecp256r1, TestECDSAConstraintSucceed) EcdsaSecp256r1Constraint ecdsa_r1_constraint; WitnessVector witness_values; size_t num_variables = generate_ecdsa_constraint(ecdsa_r1_constraint, witness_values); - acir_format constraint_system{ + AcirFormat constraint_system{ .varnum = static_cast(num_variables), .public_inputs = {}, .logic_constraints = {}, @@ -186,6 +189,8 @@ TEST(ECDSASecp256r1, TestECDSAConstraintSucceed) .ec_add_constraints = {}, .ec_double_constraints = {}, .recursion_constraints = {}, + .bigint_from_le_bytes_constraints = {}, + .bigint_operations = {}, .constraints = {}, .block_constraints = {}, }; @@ -209,7 +214,7 @@ TEST(ECDSASecp256r1, TestECDSACompilesForVerifier) EcdsaSecp256r1Constraint ecdsa_r1_constraint; WitnessVector witness_values; size_t num_variables = generate_ecdsa_constraint(ecdsa_r1_constraint, witness_values); - acir_format constraint_system{ + AcirFormat constraint_system{ .varnum = static_cast(num_variables), .public_inputs = {}, .logic_constraints = {}, @@ -229,6 +234,8 @@ TEST(ECDSASecp256r1, TestECDSACompilesForVerifier) .ec_add_constraints = {}, .ec_double_constraints = {}, .recursion_constraints = {}, + .bigint_from_le_bytes_constraints = {}, + .bigint_operations = {}, .constraints = {}, .block_constraints = {}, }; @@ -247,7 +254,7 @@ TEST(ECDSASecp256r1, TestECDSAConstraintFail) // tamper with signature witness_values[witness_values.size() - 20] += 1; - acir_format constraint_system{ + AcirFormat constraint_system{ .varnum = static_cast(num_variables), .public_inputs = {}, .logic_constraints = {}, @@ -267,6 +274,8 @@ TEST(ECDSASecp256r1, TestECDSAConstraintFail) .ec_add_constraints = {}, .ec_double_constraints = {}, .recursion_constraints = {}, + .bigint_from_le_bytes_constraints = {}, + .bigint_operations = {}, .constraints = {}, .block_constraints = {}, }; @@ -281,4 +290,3 @@ TEST(ECDSASecp256r1, TestECDSAConstraintFail) auto verifier = composer.create_verifier(builder); EXPECT_EQ(verifier.verify_proof(proof), true); } -} // namespace acir_format::tests diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.test.cpp index 457184ed0253..20650bf589b0 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.test.cpp @@ -6,13 +6,13 @@ #include #include +using namespace acir_format; using namespace bb::plonk; class AcirRecursionConstraint : public ::testing::Test { protected: static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } }; -namespace acir_format::test { Builder create_inner_circuit() { /** @@ -81,27 +81,29 @@ Builder create_inner_circuit() .q_c = 1, }; - acir_format constraint_system{ .varnum = 6, - .public_inputs = { 1, 2 }, - .logic_constraints = { logic_constraint }, - .range_constraints = { range_a, range_b }, - .sha256_constraints = {}, - .schnorr_constraints = {}, - .ecdsa_k1_constraints = {}, - .ecdsa_r1_constraints = {}, - .blake2s_constraints = {}, - .blake3_constraints = {}, - .keccak_constraints = {}, - .keccak_var_constraints = {}, - .keccak_permutations = {}, - .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, - .fixed_base_scalar_mul_constraints = {}, - .ec_add_constraints = {}, - .ec_double_constraints = {}, - .recursion_constraints = {}, - .constraints = { expr_a, expr_b, expr_c, expr_d }, - .block_constraints = {} }; + AcirFormat constraint_system{ .varnum = 6, + .public_inputs = { 1, 2 }, + .logic_constraints = { logic_constraint }, + .range_constraints = { range_a, range_b }, + .sha256_constraints = {}, + .schnorr_constraints = {}, + .ecdsa_k1_constraints = {}, + .ecdsa_r1_constraints = {}, + .blake2s_constraints = {}, + .blake3_constraints = {}, + .keccak_constraints = {}, + .keccak_var_constraints = {}, + .keccak_permutations = {}, + .pedersen_constraints = {}, + .pedersen_hash_constraints = {}, + .fixed_base_scalar_mul_constraints = {}, + .ec_add_constraints = {}, + .ec_double_constraints = {}, + .recursion_constraints = {}, + .bigint_from_le_bytes_constraints = {}, + .bigint_operations = {}, + .constraints = { expr_a, expr_b, expr_c, expr_d }, + .block_constraints = {} }; uint256_t inverse_of_five = fr(5).invert(); WitnessVector witness{ @@ -143,10 +145,10 @@ Builder create_outer_circuit(std::vector& inner_circuits) transcript::HashType::PedersenBlake3s, 16); - std::vector proof_witnesses = export_transcript_in_recursion_format(transcript); + std::vector proof_witnesses = export_transcript_in_recursion_format(transcript); // - Save the public inputs so that we can set their values. // - Then truncate them from the proof because the ACIR API expects proofs without public inputs - std::vector inner_public_input_values( + std::vector inner_public_input_values( proof_witnesses.begin(), proof_witnesses.begin() + static_cast(num_inner_public_inputs)); // We want to make sure that we do not remove the nested aggregation object in the case of the proof we want to @@ -233,27 +235,29 @@ Builder create_outer_circuit(std::vector& inner_circuits) circuit_idx++; } - acir_format constraint_system{ .varnum = static_cast(witness.size()), - .public_inputs = {}, - .logic_constraints = {}, - .range_constraints = {}, - .sha256_constraints = {}, - .schnorr_constraints = {}, - .ecdsa_k1_constraints = {}, - .ecdsa_r1_constraints = {}, - .blake2s_constraints = {}, - .blake3_constraints = {}, - .keccak_constraints = {}, - .keccak_var_constraints = {}, - .keccak_permutations = {}, - .pedersen_constraints = {}, - .pedersen_hash_constraints = {}, - .fixed_base_scalar_mul_constraints = {}, - .ec_add_constraints = {}, - .ec_double_constraints = {}, - .recursion_constraints = recursion_constraints, - .constraints = {}, - .block_constraints = {} }; + AcirFormat constraint_system{ .varnum = static_cast(witness.size()), + .public_inputs = {}, + .logic_constraints = {}, + .range_constraints = {}, + .sha256_constraints = {}, + .schnorr_constraints = {}, + .ecdsa_k1_constraints = {}, + .ecdsa_r1_constraints = {}, + .blake2s_constraints = {}, + .blake3_constraints = {}, + .keccak_constraints = {}, + .keccak_var_constraints = {}, + .keccak_permutations = {}, + .pedersen_constraints = {}, + .pedersen_hash_constraints = {}, + .fixed_base_scalar_mul_constraints = {}, + .ec_add_constraints = {}, + .ec_double_constraints = {}, + .recursion_constraints = recursion_constraints, + .bigint_from_le_bytes_constraints = {}, + .bigint_operations = {}, + .constraints = {}, + .block_constraints = {} }; auto outer_circuit = create_circuit(constraint_system, /*size_hint*/ 0, witness); @@ -364,4 +368,3 @@ TEST_F(AcirRecursionConstraint, TestFullRecursiveComposition) auto verifier = layer_3_composer.create_ultra_with_keccak_verifier(layer_3_circuit); EXPECT_EQ(verifier.verify_proof(proof), true); } -} // namespace acir_format::test diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/schnorr_verify.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/schnorr_verify.cpp index 931ee470903f..b4d7f4737d5d 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/schnorr_verify.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/schnorr_verify.cpp @@ -7,10 +7,10 @@ namespace acir_format { using namespace bb::stdlib; template -crypto::schnorr::signature convert_signature(Builder& builder, std::vector signature) +crypto::schnorr_signature convert_signature(Builder& builder, std::vector signature) { - crypto::schnorr::signature signature_cr; + crypto::schnorr_signature signature_cr; // Get the witness assignment for each witness index // Write the witness assignment to the byte_array @@ -75,7 +75,7 @@ template void create_schnorr_verify_constraints(Builder& buil { using witness_ct = bb::stdlib::witness_t; using cycle_group_ct = bb::stdlib::cycle_group; - using schnorr_signature_bits_ct = bb::stdlib::schnorr::signature_bits; + using schnorr_signature_bits_ct = bb::stdlib::schnorr_signature_bits; using bool_ct = bb::stdlib::bool_t; auto new_sig = convert_signature(builder, input.signature); @@ -93,9 +93,9 @@ template void create_schnorr_verify_constraints(Builder& buil cycle_group_ct pub_key{ witness_ct(&builder, pubkey_value_x), witness_ct(&builder, pubkey_value_y), false }; - schnorr_signature_bits_ct sig = schnorr::convert_signature(&builder, new_sig); + schnorr_signature_bits_ct sig = schnorr_convert_signature(&builder, new_sig); - bool_ct signature_result = schnorr::signature_verification_result(message, pub_key, sig); + bool_ct signature_result = schnorr_signature_verification_result(message, pub_key, sig); bool_ct signature_result_normalized = signature_result.normalize(); diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp index c85f609bbd1b..8e18e5bc043c 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/serde/acir.hpp @@ -206,6 +206,65 @@ struct BlackBoxFuncCall { static RecursiveAggregation bincodeDeserialize(std::vector); }; + struct BigIntAdd { + uint32_t lhs; + uint32_t rhs; + uint32_t output; + + friend bool operator==(const BigIntAdd&, const BigIntAdd&); + std::vector bincodeSerialize() const; + static BigIntAdd bincodeDeserialize(std::vector); + }; + + struct BigIntNeg { + uint32_t lhs; + uint32_t rhs; + uint32_t output; + + friend bool operator==(const BigIntNeg&, const BigIntNeg&); + std::vector bincodeSerialize() const; + static BigIntNeg bincodeDeserialize(std::vector); + }; + + struct BigIntMul { + uint32_t lhs; + uint32_t rhs; + uint32_t output; + + friend bool operator==(const BigIntMul&, const BigIntMul&); + std::vector bincodeSerialize() const; + static BigIntMul bincodeDeserialize(std::vector); + }; + + struct BigIntDiv { + uint32_t lhs; + uint32_t rhs; + uint32_t output; + + friend bool operator==(const BigIntDiv&, const BigIntDiv&); + std::vector bincodeSerialize() const; + static BigIntDiv bincodeDeserialize(std::vector); + }; + + struct BigIntFromLeBytes { + std::vector inputs; + std::vector modulus; + uint32_t output; + + friend bool operator==(const BigIntFromLeBytes&, const BigIntFromLeBytes&); + std::vector bincodeSerialize() const; + static BigIntFromLeBytes bincodeDeserialize(std::vector); + }; + + struct BigIntToLeBytes { + uint32_t input; + std::vector outputs; + + friend bool operator==(const BigIntToLeBytes&, const BigIntToLeBytes&); + std::vector bincodeSerialize() const; + static BigIntToLeBytes bincodeDeserialize(std::vector); + }; + std::variant + RecursiveAggregation, + BigIntAdd, + BigIntNeg, + BigIntMul, + BigIntDiv, + BigIntFromLeBytes, + BigIntToLeBytes> value; friend bool operator==(const BlackBoxFuncCall&, const BlackBoxFuncCall&); @@ -239,8 +304,6 @@ struct BlockId { static BlockId bincodeDeserialize(std::vector); }; -// TODO(https://github.com/AztecProtocol/barretenberg/issues/825): This struct is more general than it needs / should be -// allowed to be. We can only accommodate 1 quadratic term and 3 linear terms. struct Expression { std::vector> mul_terms; std::vector> linear_combinations; @@ -563,6 +626,65 @@ struct BlackBoxOp { static EmbeddedCurveDouble bincodeDeserialize(std::vector); }; + struct BigIntAdd { + Circuit::RegisterIndex lhs; + Circuit::RegisterIndex rhs; + Circuit::RegisterIndex output; + + friend bool operator==(const BigIntAdd&, const BigIntAdd&); + std::vector bincodeSerialize() const; + static BigIntAdd bincodeDeserialize(std::vector); + }; + + struct BigIntNeg { + Circuit::RegisterIndex lhs; + Circuit::RegisterIndex rhs; + Circuit::RegisterIndex output; + + friend bool operator==(const BigIntNeg&, const BigIntNeg&); + std::vector bincodeSerialize() const; + static BigIntNeg bincodeDeserialize(std::vector); + }; + + struct BigIntMul { + Circuit::RegisterIndex lhs; + Circuit::RegisterIndex rhs; + Circuit::RegisterIndex output; + + friend bool operator==(const BigIntMul&, const BigIntMul&); + std::vector bincodeSerialize() const; + static BigIntMul bincodeDeserialize(std::vector); + }; + + struct BigIntDiv { + Circuit::RegisterIndex lhs; + Circuit::RegisterIndex rhs; + Circuit::RegisterIndex output; + + friend bool operator==(const BigIntDiv&, const BigIntDiv&); + std::vector bincodeSerialize() const; + static BigIntDiv bincodeDeserialize(std::vector); + }; + + struct BigIntFromLeBytes { + Circuit::HeapVector inputs; + Circuit::HeapVector modulus; + Circuit::RegisterIndex output; + + friend bool operator==(const BigIntFromLeBytes&, const BigIntFromLeBytes&); + std::vector bincodeSerialize() const; + static BigIntFromLeBytes bincodeDeserialize(std::vector); + }; + + struct BigIntToLeBytes { + Circuit::RegisterIndex input; + Circuit::HeapVector output; + + friend bool operator==(const BigIntToLeBytes&, const BigIntToLeBytes&); + std::vector bincodeSerialize() const; + static BigIntToLeBytes bincodeDeserialize(std::vector); + }; + std::variant + EmbeddedCurveDouble, + BigIntAdd, + BigIntNeg, + BigIntMul, + BigIntDiv, + BigIntFromLeBytes, + BigIntToLeBytes> value; friend bool operator==(const BlackBoxOp&, const BlackBoxOp&); @@ -2883,25 +3011,31 @@ Circuit::BlackBoxFuncCall::RecursiveAggregation serde::Deserializable< namespace Circuit { -inline bool operator==(const BlackBoxOp& lhs, const BlackBoxOp& rhs) +inline bool operator==(const BlackBoxFuncCall::BigIntAdd& lhs, const BlackBoxFuncCall::BigIntAdd& rhs) { - if (!(lhs.value == rhs.value)) { + if (!(lhs.lhs == rhs.lhs)) { + return false; + } + if (!(lhs.rhs == rhs.rhs)) { + return false; + } + if (!(lhs.output == rhs.output)) { return false; } return true; } -inline std::vector BlackBoxOp::bincodeSerialize() const +inline std::vector BlackBoxFuncCall::BigIntAdd::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp BlackBoxOp::bincodeDeserialize(std::vector input) +inline BlackBoxFuncCall::BigIntAdd BlackBoxFuncCall::BigIntAdd::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -2912,29 +3046,34 @@ inline BlackBoxOp BlackBoxOp::bincodeDeserialize(std::vector input) template <> template -void serde::Serializable::serialize(const Circuit::BlackBoxOp& obj, Serializer& serializer) +void serde::Serializable::serialize( + const Circuit::BlackBoxFuncCall::BigIntAdd& obj, Serializer& serializer) { - serializer.increase_container_depth(); - serde::Serializable::serialize(obj.value, serializer); - serializer.decrease_container_depth(); + serde::Serializable::serialize(obj.lhs, serializer); + serde::Serializable::serialize(obj.rhs, serializer); + serde::Serializable::serialize(obj.output, serializer); } template <> template -Circuit::BlackBoxOp serde::Deserializable::deserialize(Deserializer& deserializer) +Circuit::BlackBoxFuncCall::BigIntAdd serde::Deserializable::deserialize( + Deserializer& deserializer) { - deserializer.increase_container_depth(); - Circuit::BlackBoxOp obj; - obj.value = serde::Deserializable::deserialize(deserializer); - deserializer.decrease_container_depth(); + Circuit::BlackBoxFuncCall::BigIntAdd obj; + obj.lhs = serde::Deserializable::deserialize(deserializer); + obj.rhs = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Circuit { -inline bool operator==(const BlackBoxOp::Sha256& lhs, const BlackBoxOp::Sha256& rhs) +inline bool operator==(const BlackBoxFuncCall::BigIntNeg& lhs, const BlackBoxFuncCall::BigIntNeg& rhs) { - if (!(lhs.message == rhs.message)) { + if (!(lhs.lhs == rhs.lhs)) { + return false; + } + if (!(lhs.rhs == rhs.rhs)) { return false; } if (!(lhs.output == rhs.output)) { @@ -2943,17 +3082,17 @@ inline bool operator==(const BlackBoxOp::Sha256& lhs, const BlackBoxOp::Sha256& return true; } -inline std::vector BlackBoxOp::Sha256::bincodeSerialize() const +inline std::vector BlackBoxFuncCall::BigIntNeg::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::Sha256 BlackBoxOp::Sha256::bincodeDeserialize(std::vector input) +inline BlackBoxFuncCall::BigIntNeg BlackBoxFuncCall::BigIntNeg::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -2964,28 +3103,34 @@ inline BlackBoxOp::Sha256 BlackBoxOp::Sha256::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Circuit::BlackBoxOp::Sha256& obj, - Serializer& serializer) +void serde::Serializable::serialize( + const Circuit::BlackBoxFuncCall::BigIntNeg& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.message, serializer); + serde::Serializable::serialize(obj.lhs, serializer); + serde::Serializable::serialize(obj.rhs, serializer); serde::Serializable::serialize(obj.output, serializer); } template <> template -Circuit::BlackBoxOp::Sha256 serde::Deserializable::deserialize(Deserializer& deserializer) +Circuit::BlackBoxFuncCall::BigIntNeg serde::Deserializable::deserialize( + Deserializer& deserializer) { - Circuit::BlackBoxOp::Sha256 obj; - obj.message = serde::Deserializable::deserialize(deserializer); + Circuit::BlackBoxFuncCall::BigIntNeg obj; + obj.lhs = serde::Deserializable::deserialize(deserializer); + obj.rhs = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Circuit { -inline bool operator==(const BlackBoxOp::Blake2s& lhs, const BlackBoxOp::Blake2s& rhs) +inline bool operator==(const BlackBoxFuncCall::BigIntMul& lhs, const BlackBoxFuncCall::BigIntMul& rhs) { - if (!(lhs.message == rhs.message)) { + if (!(lhs.lhs == rhs.lhs)) { + return false; + } + if (!(lhs.rhs == rhs.rhs)) { return false; } if (!(lhs.output == rhs.output)) { @@ -2994,17 +3139,17 @@ inline bool operator==(const BlackBoxOp::Blake2s& lhs, const BlackBoxOp::Blake2s return true; } -inline std::vector BlackBoxOp::Blake2s::bincodeSerialize() const +inline std::vector BlackBoxFuncCall::BigIntMul::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::Blake2s BlackBoxOp::Blake2s::bincodeDeserialize(std::vector input) +inline BlackBoxFuncCall::BigIntMul BlackBoxFuncCall::BigIntMul::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3015,29 +3160,34 @@ inline BlackBoxOp::Blake2s BlackBoxOp::Blake2s::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Circuit::BlackBoxOp::Blake2s& obj, - Serializer& serializer) +void serde::Serializable::serialize( + const Circuit::BlackBoxFuncCall::BigIntMul& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.message, serializer); + serde::Serializable::serialize(obj.lhs, serializer); + serde::Serializable::serialize(obj.rhs, serializer); serde::Serializable::serialize(obj.output, serializer); } template <> template -Circuit::BlackBoxOp::Blake2s serde::Deserializable::deserialize( +Circuit::BlackBoxFuncCall::BigIntMul serde::Deserializable::deserialize( Deserializer& deserializer) { - Circuit::BlackBoxOp::Blake2s obj; - obj.message = serde::Deserializable::deserialize(deserializer); + Circuit::BlackBoxFuncCall::BigIntMul obj; + obj.lhs = serde::Deserializable::deserialize(deserializer); + obj.rhs = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Circuit { -inline bool operator==(const BlackBoxOp::Blake3& lhs, const BlackBoxOp::Blake3& rhs) +inline bool operator==(const BlackBoxFuncCall::BigIntDiv& lhs, const BlackBoxFuncCall::BigIntDiv& rhs) { - if (!(lhs.message == rhs.message)) { + if (!(lhs.lhs == rhs.lhs)) { + return false; + } + if (!(lhs.rhs == rhs.rhs)) { return false; } if (!(lhs.output == rhs.output)) { @@ -3046,17 +3196,17 @@ inline bool operator==(const BlackBoxOp::Blake3& lhs, const BlackBoxOp::Blake3& return true; } -inline std::vector BlackBoxOp::Blake3::bincodeSerialize() const +inline std::vector BlackBoxFuncCall::BigIntDiv::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::Blake3 BlackBoxOp::Blake3::bincodeDeserialize(std::vector input) +inline BlackBoxFuncCall::BigIntDiv BlackBoxFuncCall::BigIntDiv::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3067,28 +3217,34 @@ inline BlackBoxOp::Blake3 BlackBoxOp::Blake3::bincodeDeserialize(std::vector template -void serde::Serializable::serialize(const Circuit::BlackBoxOp::Blake3& obj, - Serializer& serializer) +void serde::Serializable::serialize( + const Circuit::BlackBoxFuncCall::BigIntDiv& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.message, serializer); + serde::Serializable::serialize(obj.lhs, serializer); + serde::Serializable::serialize(obj.rhs, serializer); serde::Serializable::serialize(obj.output, serializer); } template <> template -Circuit::BlackBoxOp::Blake3 serde::Deserializable::deserialize(Deserializer& deserializer) +Circuit::BlackBoxFuncCall::BigIntDiv serde::Deserializable::deserialize( + Deserializer& deserializer) { - Circuit::BlackBoxOp::Blake3 obj; - obj.message = serde::Deserializable::deserialize(deserializer); + Circuit::BlackBoxFuncCall::BigIntDiv obj; + obj.lhs = serde::Deserializable::deserialize(deserializer); + obj.rhs = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Circuit { -inline bool operator==(const BlackBoxOp::Keccak256& lhs, const BlackBoxOp::Keccak256& rhs) +inline bool operator==(const BlackBoxFuncCall::BigIntFromLeBytes& lhs, const BlackBoxFuncCall::BigIntFromLeBytes& rhs) { - if (!(lhs.message == rhs.message)) { + if (!(lhs.inputs == rhs.inputs)) { + return false; + } + if (!(lhs.modulus == rhs.modulus)) { return false; } if (!(lhs.output == rhs.output)) { @@ -3097,17 +3253,18 @@ inline bool operator==(const BlackBoxOp::Keccak256& lhs, const BlackBoxOp::Kecca return true; } -inline std::vector BlackBoxOp::Keccak256::bincodeSerialize() const +inline std::vector BlackBoxFuncCall::BigIntFromLeBytes::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::Keccak256 BlackBoxOp::Keccak256::bincodeDeserialize(std::vector input) +inline BlackBoxFuncCall::BigIntFromLeBytes BlackBoxFuncCall::BigIntFromLeBytes::bincodeDeserialize( + std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3118,48 +3275,51 @@ inline BlackBoxOp::Keccak256 BlackBoxOp::Keccak256::bincodeDeserialize(std::vect template <> template -void serde::Serializable::serialize(const Circuit::BlackBoxOp::Keccak256& obj, - Serializer& serializer) +void serde::Serializable::serialize( + const Circuit::BlackBoxFuncCall::BigIntFromLeBytes& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.message, serializer); + serde::Serializable::serialize(obj.inputs, serializer); + serde::Serializable::serialize(obj.modulus, serializer); serde::Serializable::serialize(obj.output, serializer); } template <> template -Circuit::BlackBoxOp::Keccak256 serde::Deserializable::deserialize( - Deserializer& deserializer) +Circuit::BlackBoxFuncCall::BigIntFromLeBytes serde::Deserializable< + Circuit::BlackBoxFuncCall::BigIntFromLeBytes>::deserialize(Deserializer& deserializer) { - Circuit::BlackBoxOp::Keccak256 obj; - obj.message = serde::Deserializable::deserialize(deserializer); + Circuit::BlackBoxFuncCall::BigIntFromLeBytes obj; + obj.inputs = serde::Deserializable::deserialize(deserializer); + obj.modulus = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Circuit { -inline bool operator==(const BlackBoxOp::Keccakf1600& lhs, const BlackBoxOp::Keccakf1600& rhs) +inline bool operator==(const BlackBoxFuncCall::BigIntToLeBytes& lhs, const BlackBoxFuncCall::BigIntToLeBytes& rhs) { - if (!(lhs.message == rhs.message)) { + if (!(lhs.input == rhs.input)) { return false; } - if (!(lhs.output == rhs.output)) { + if (!(lhs.outputs == rhs.outputs)) { return false; } return true; } -inline std::vector BlackBoxOp::Keccakf1600::bincodeSerialize() const +inline std::vector BlackBoxFuncCall::BigIntToLeBytes::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::Keccakf1600 BlackBoxOp::Keccakf1600::bincodeDeserialize(std::vector input) +inline BlackBoxFuncCall::BigIntToLeBytes BlackBoxFuncCall::BigIntToLeBytes::bincodeDeserialize( + std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3170,57 +3330,45 @@ inline BlackBoxOp::Keccakf1600 BlackBoxOp::Keccakf1600::bincodeDeserialize(std:: template <> template -void serde::Serializable::serialize(const Circuit::BlackBoxOp::Keccakf1600& obj, - Serializer& serializer) +void serde::Serializable::serialize( + const Circuit::BlackBoxFuncCall::BigIntToLeBytes& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.message, serializer); - serde::Serializable::serialize(obj.output, serializer); + serde::Serializable::serialize(obj.input, serializer); + serde::Serializable::serialize(obj.outputs, serializer); } template <> template -Circuit::BlackBoxOp::Keccakf1600 serde::Deserializable::deserialize( - Deserializer& deserializer) +Circuit::BlackBoxFuncCall::BigIntToLeBytes serde::Deserializable< + Circuit::BlackBoxFuncCall::BigIntToLeBytes>::deserialize(Deserializer& deserializer) { - Circuit::BlackBoxOp::Keccakf1600 obj; - obj.message = serde::Deserializable::deserialize(deserializer); - obj.output = serde::Deserializable::deserialize(deserializer); + Circuit::BlackBoxFuncCall::BigIntToLeBytes obj; + obj.input = serde::Deserializable::deserialize(deserializer); + obj.outputs = serde::Deserializable::deserialize(deserializer); return obj; } namespace Circuit { -inline bool operator==(const BlackBoxOp::EcdsaSecp256k1& lhs, const BlackBoxOp::EcdsaSecp256k1& rhs) +inline bool operator==(const BlackBoxOp& lhs, const BlackBoxOp& rhs) { - if (!(lhs.hashed_msg == rhs.hashed_msg)) { - return false; - } - if (!(lhs.public_key_x == rhs.public_key_x)) { - return false; - } - if (!(lhs.public_key_y == rhs.public_key_y)) { - return false; - } - if (!(lhs.signature == rhs.signature)) { - return false; - } - if (!(lhs.result == rhs.result)) { + if (!(lhs.value == rhs.value)) { return false; } return true; } -inline std::vector BlackBoxOp::EcdsaSecp256k1::bincodeSerialize() const +inline std::vector BlackBoxOp::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::EcdsaSecp256k1 BlackBoxOp::EcdsaSecp256k1::bincodeDeserialize(std::vector input) +inline BlackBoxOp BlackBoxOp::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3231,44 +3379,668 @@ inline BlackBoxOp::EcdsaSecp256k1 BlackBoxOp::EcdsaSecp256k1::bincodeDeserialize template <> template -void serde::Serializable::serialize(const Circuit::BlackBoxOp::EcdsaSecp256k1& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Circuit::BlackBoxOp& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.hashed_msg, serializer); - serde::Serializable::serialize(obj.public_key_x, serializer); - serde::Serializable::serialize(obj.public_key_y, serializer); - serde::Serializable::serialize(obj.signature, serializer); - serde::Serializable::serialize(obj.result, serializer); + serializer.increase_container_depth(); + serde::Serializable::serialize(obj.value, serializer); + serializer.decrease_container_depth(); } template <> template -Circuit::BlackBoxOp::EcdsaSecp256k1 serde::Deserializable::deserialize( - Deserializer& deserializer) +Circuit::BlackBoxOp serde::Deserializable::deserialize(Deserializer& deserializer) { - Circuit::BlackBoxOp::EcdsaSecp256k1 obj; - obj.hashed_msg = serde::Deserializable::deserialize(deserializer); - obj.public_key_x = serde::Deserializable::deserialize(deserializer); - obj.public_key_y = serde::Deserializable::deserialize(deserializer); - obj.signature = serde::Deserializable::deserialize(deserializer); - obj.result = serde::Deserializable::deserialize(deserializer); + deserializer.increase_container_depth(); + Circuit::BlackBoxOp obj; + obj.value = serde::Deserializable::deserialize(deserializer); + deserializer.decrease_container_depth(); return obj; } namespace Circuit { -inline bool operator==(const BlackBoxOp::EcdsaSecp256r1& lhs, const BlackBoxOp::EcdsaSecp256r1& rhs) +inline bool operator==(const BlackBoxOp::Sha256& lhs, const BlackBoxOp::Sha256& rhs) { - if (!(lhs.hashed_msg == rhs.hashed_msg)) { - return false; - } - if (!(lhs.public_key_x == rhs.public_key_x)) { + if (!(lhs.message == rhs.message)) { return false; } - if (!(lhs.public_key_y == rhs.public_key_y)) { + if (!(lhs.output == rhs.output)) { return false; } - if (!(lhs.signature == rhs.signature)) { + return true; +} + +inline std::vector BlackBoxOp::Sha256::bincodeSerialize() const +{ + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); +} + +inline BlackBoxOp::Sha256 BlackBoxOp::Sha256::bincodeDeserialize(std::vector input) +{ + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw_or_abort("Some input bytes were not read"); + } + return value; +} + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxOp::Sha256& obj, + Serializer& serializer) +{ + serde::Serializable::serialize(obj.message, serializer); + serde::Serializable::serialize(obj.output, serializer); +} + +template <> +template +Circuit::BlackBoxOp::Sha256 serde::Deserializable::deserialize(Deserializer& deserializer) +{ + Circuit::BlackBoxOp::Sha256 obj; + obj.message = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + +inline bool operator==(const BlackBoxOp::Blake2s& lhs, const BlackBoxOp::Blake2s& rhs) +{ + if (!(lhs.message == rhs.message)) { + return false; + } + if (!(lhs.output == rhs.output)) { + return false; + } + return true; +} + +inline std::vector BlackBoxOp::Blake2s::bincodeSerialize() const +{ + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); +} + +inline BlackBoxOp::Blake2s BlackBoxOp::Blake2s::bincodeDeserialize(std::vector input) +{ + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw_or_abort("Some input bytes were not read"); + } + return value; +} + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxOp::Blake2s& obj, + Serializer& serializer) +{ + serde::Serializable::serialize(obj.message, serializer); + serde::Serializable::serialize(obj.output, serializer); +} + +template <> +template +Circuit::BlackBoxOp::Blake2s serde::Deserializable::deserialize( + Deserializer& deserializer) +{ + Circuit::BlackBoxOp::Blake2s obj; + obj.message = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + +inline bool operator==(const BlackBoxOp::Blake3& lhs, const BlackBoxOp::Blake3& rhs) +{ + if (!(lhs.message == rhs.message)) { + return false; + } + if (!(lhs.output == rhs.output)) { + return false; + } + return true; +} + +inline std::vector BlackBoxOp::Blake3::bincodeSerialize() const +{ + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); +} + +inline BlackBoxOp::Blake3 BlackBoxOp::Blake3::bincodeDeserialize(std::vector input) +{ + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw_or_abort("Some input bytes were not read"); + } + return value; +} + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxOp::Blake3& obj, + Serializer& serializer) +{ + serde::Serializable::serialize(obj.message, serializer); + serde::Serializable::serialize(obj.output, serializer); +} + +template <> +template +Circuit::BlackBoxOp::Blake3 serde::Deserializable::deserialize(Deserializer& deserializer) +{ + Circuit::BlackBoxOp::Blake3 obj; + obj.message = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + +inline bool operator==(const BlackBoxOp::Keccak256& lhs, const BlackBoxOp::Keccak256& rhs) +{ + if (!(lhs.message == rhs.message)) { + return false; + } + if (!(lhs.output == rhs.output)) { + return false; + } + return true; +} + +inline std::vector BlackBoxOp::Keccak256::bincodeSerialize() const +{ + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); +} + +inline BlackBoxOp::Keccak256 BlackBoxOp::Keccak256::bincodeDeserialize(std::vector input) +{ + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw_or_abort("Some input bytes were not read"); + } + return value; +} + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxOp::Keccak256& obj, + Serializer& serializer) +{ + serde::Serializable::serialize(obj.message, serializer); + serde::Serializable::serialize(obj.output, serializer); +} + +template <> +template +Circuit::BlackBoxOp::Keccak256 serde::Deserializable::deserialize( + Deserializer& deserializer) +{ + Circuit::BlackBoxOp::Keccak256 obj; + obj.message = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + +inline bool operator==(const BlackBoxOp::Keccakf1600& lhs, const BlackBoxOp::Keccakf1600& rhs) +{ + if (!(lhs.message == rhs.message)) { + return false; + } + if (!(lhs.output == rhs.output)) { + return false; + } + return true; +} + +inline std::vector BlackBoxOp::Keccakf1600::bincodeSerialize() const +{ + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); +} + +inline BlackBoxOp::Keccakf1600 BlackBoxOp::Keccakf1600::bincodeDeserialize(std::vector input) +{ + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw_or_abort("Some input bytes were not read"); + } + return value; +} + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxOp::Keccakf1600& obj, + Serializer& serializer) +{ + serde::Serializable::serialize(obj.message, serializer); + serde::Serializable::serialize(obj.output, serializer); +} + +template <> +template +Circuit::BlackBoxOp::Keccakf1600 serde::Deserializable::deserialize( + Deserializer& deserializer) +{ + Circuit::BlackBoxOp::Keccakf1600 obj; + obj.message = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + +inline bool operator==(const BlackBoxOp::EcdsaSecp256k1& lhs, const BlackBoxOp::EcdsaSecp256k1& rhs) +{ + if (!(lhs.hashed_msg == rhs.hashed_msg)) { + return false; + } + if (!(lhs.public_key_x == rhs.public_key_x)) { + return false; + } + if (!(lhs.public_key_y == rhs.public_key_y)) { + return false; + } + if (!(lhs.signature == rhs.signature)) { + return false; + } + if (!(lhs.result == rhs.result)) { + return false; + } + return true; +} + +inline std::vector BlackBoxOp::EcdsaSecp256k1::bincodeSerialize() const +{ + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); +} + +inline BlackBoxOp::EcdsaSecp256k1 BlackBoxOp::EcdsaSecp256k1::bincodeDeserialize(std::vector input) +{ + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw_or_abort("Some input bytes were not read"); + } + return value; +} + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxOp::EcdsaSecp256k1& obj, + Serializer& serializer) +{ + serde::Serializable::serialize(obj.hashed_msg, serializer); + serde::Serializable::serialize(obj.public_key_x, serializer); + serde::Serializable::serialize(obj.public_key_y, serializer); + serde::Serializable::serialize(obj.signature, serializer); + serde::Serializable::serialize(obj.result, serializer); +} + +template <> +template +Circuit::BlackBoxOp::EcdsaSecp256k1 serde::Deserializable::deserialize( + Deserializer& deserializer) +{ + Circuit::BlackBoxOp::EcdsaSecp256k1 obj; + obj.hashed_msg = serde::Deserializable::deserialize(deserializer); + obj.public_key_x = serde::Deserializable::deserialize(deserializer); + obj.public_key_y = serde::Deserializable::deserialize(deserializer); + obj.signature = serde::Deserializable::deserialize(deserializer); + obj.result = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + +inline bool operator==(const BlackBoxOp::EcdsaSecp256r1& lhs, const BlackBoxOp::EcdsaSecp256r1& rhs) +{ + if (!(lhs.hashed_msg == rhs.hashed_msg)) { + return false; + } + if (!(lhs.public_key_x == rhs.public_key_x)) { + return false; + } + if (!(lhs.public_key_y == rhs.public_key_y)) { + return false; + } + if (!(lhs.signature == rhs.signature)) { + return false; + } + if (!(lhs.result == rhs.result)) { + return false; + } + return true; +} + +inline std::vector BlackBoxOp::EcdsaSecp256r1::bincodeSerialize() const +{ + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); +} + +inline BlackBoxOp::EcdsaSecp256r1 BlackBoxOp::EcdsaSecp256r1::bincodeDeserialize(std::vector input) +{ + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw_or_abort("Some input bytes were not read"); + } + return value; +} + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxOp::EcdsaSecp256r1& obj, + Serializer& serializer) +{ + serde::Serializable::serialize(obj.hashed_msg, serializer); + serde::Serializable::serialize(obj.public_key_x, serializer); + serde::Serializable::serialize(obj.public_key_y, serializer); + serde::Serializable::serialize(obj.signature, serializer); + serde::Serializable::serialize(obj.result, serializer); +} + +template <> +template +Circuit::BlackBoxOp::EcdsaSecp256r1 serde::Deserializable::deserialize( + Deserializer& deserializer) +{ + Circuit::BlackBoxOp::EcdsaSecp256r1 obj; + obj.hashed_msg = serde::Deserializable::deserialize(deserializer); + obj.public_key_x = serde::Deserializable::deserialize(deserializer); + obj.public_key_y = serde::Deserializable::deserialize(deserializer); + obj.signature = serde::Deserializable::deserialize(deserializer); + obj.result = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + +inline bool operator==(const BlackBoxOp::SchnorrVerify& lhs, const BlackBoxOp::SchnorrVerify& rhs) +{ + if (!(lhs.public_key_x == rhs.public_key_x)) { + return false; + } + if (!(lhs.public_key_y == rhs.public_key_y)) { + return false; + } + if (!(lhs.message == rhs.message)) { + return false; + } + if (!(lhs.signature == rhs.signature)) { + return false; + } + if (!(lhs.result == rhs.result)) { + return false; + } + return true; +} + +inline std::vector BlackBoxOp::SchnorrVerify::bincodeSerialize() const +{ + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); +} + +inline BlackBoxOp::SchnorrVerify BlackBoxOp::SchnorrVerify::bincodeDeserialize(std::vector input) +{ + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw_or_abort("Some input bytes were not read"); + } + return value; +} + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxOp::SchnorrVerify& obj, + Serializer& serializer) +{ + serde::Serializable::serialize(obj.public_key_x, serializer); + serde::Serializable::serialize(obj.public_key_y, serializer); + serde::Serializable::serialize(obj.message, serializer); + serde::Serializable::serialize(obj.signature, serializer); + serde::Serializable::serialize(obj.result, serializer); +} + +template <> +template +Circuit::BlackBoxOp::SchnorrVerify serde::Deserializable::deserialize( + Deserializer& deserializer) +{ + Circuit::BlackBoxOp::SchnorrVerify obj; + obj.public_key_x = serde::Deserializable::deserialize(deserializer); + obj.public_key_y = serde::Deserializable::deserialize(deserializer); + obj.message = serde::Deserializable::deserialize(deserializer); + obj.signature = serde::Deserializable::deserialize(deserializer); + obj.result = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + +inline bool operator==(const BlackBoxOp::PedersenCommitment& lhs, const BlackBoxOp::PedersenCommitment& rhs) +{ + if (!(lhs.inputs == rhs.inputs)) { + return false; + } + if (!(lhs.domain_separator == rhs.domain_separator)) { + return false; + } + if (!(lhs.output == rhs.output)) { + return false; + } + return true; +} + +inline std::vector BlackBoxOp::PedersenCommitment::bincodeSerialize() const +{ + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); +} + +inline BlackBoxOp::PedersenCommitment BlackBoxOp::PedersenCommitment::bincodeDeserialize(std::vector input) +{ + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw_or_abort("Some input bytes were not read"); + } + return value; +} + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize( + const Circuit::BlackBoxOp::PedersenCommitment& obj, Serializer& serializer) +{ + serde::Serializable::serialize(obj.inputs, serializer); + serde::Serializable::serialize(obj.domain_separator, serializer); + serde::Serializable::serialize(obj.output, serializer); +} + +template <> +template +Circuit::BlackBoxOp::PedersenCommitment serde::Deserializable::deserialize( + Deserializer& deserializer) +{ + Circuit::BlackBoxOp::PedersenCommitment obj; + obj.inputs = serde::Deserializable::deserialize(deserializer); + obj.domain_separator = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + +inline bool operator==(const BlackBoxOp::PedersenHash& lhs, const BlackBoxOp::PedersenHash& rhs) +{ + if (!(lhs.inputs == rhs.inputs)) { + return false; + } + if (!(lhs.domain_separator == rhs.domain_separator)) { + return false; + } + if (!(lhs.output == rhs.output)) { + return false; + } + return true; +} + +inline std::vector BlackBoxOp::PedersenHash::bincodeSerialize() const +{ + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); +} + +inline BlackBoxOp::PedersenHash BlackBoxOp::PedersenHash::bincodeDeserialize(std::vector input) +{ + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw_or_abort("Some input bytes were not read"); + } + return value; +} + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxOp::PedersenHash& obj, + Serializer& serializer) +{ + serde::Serializable::serialize(obj.inputs, serializer); + serde::Serializable::serialize(obj.domain_separator, serializer); + serde::Serializable::serialize(obj.output, serializer); +} + +template <> +template +Circuit::BlackBoxOp::PedersenHash serde::Deserializable::deserialize( + Deserializer& deserializer) +{ + Circuit::BlackBoxOp::PedersenHash obj; + obj.inputs = serde::Deserializable::deserialize(deserializer); + obj.domain_separator = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + +inline bool operator==(const BlackBoxOp::FixedBaseScalarMul& lhs, const BlackBoxOp::FixedBaseScalarMul& rhs) +{ + if (!(lhs.low == rhs.low)) { + return false; + } + if (!(lhs.high == rhs.high)) { + return false; + } + if (!(lhs.result == rhs.result)) { + return false; + } + return true; +} + +inline std::vector BlackBoxOp::FixedBaseScalarMul::bincodeSerialize() const +{ + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); +} + +inline BlackBoxOp::FixedBaseScalarMul BlackBoxOp::FixedBaseScalarMul::bincodeDeserialize(std::vector input) +{ + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw_or_abort("Some input bytes were not read"); + } + return value; +} + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize( + const Circuit::BlackBoxOp::FixedBaseScalarMul& obj, Serializer& serializer) +{ + serde::Serializable::serialize(obj.low, serializer); + serde::Serializable::serialize(obj.high, serializer); + serde::Serializable::serialize(obj.result, serializer); +} + +template <> +template +Circuit::BlackBoxOp::FixedBaseScalarMul serde::Deserializable::deserialize( + Deserializer& deserializer) +{ + Circuit::BlackBoxOp::FixedBaseScalarMul obj; + obj.low = serde::Deserializable::deserialize(deserializer); + obj.high = serde::Deserializable::deserialize(deserializer); + obj.result = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + +inline bool operator==(const BlackBoxOp::EmbeddedCurveAdd& lhs, const BlackBoxOp::EmbeddedCurveAdd& rhs) +{ + if (!(lhs.input1_x == rhs.input1_x)) { + return false; + } + if (!(lhs.input1_y == rhs.input1_y)) { + return false; + } + if (!(lhs.input2_x == rhs.input2_x)) { + return false; + } + if (!(lhs.input2_y == rhs.input2_y)) { return false; } if (!(lhs.result == rhs.result)) { @@ -3277,17 +4049,17 @@ inline bool operator==(const BlackBoxOp::EcdsaSecp256r1& lhs, const BlackBoxOp:: return true; } -inline std::vector BlackBoxOp::EcdsaSecp256r1::bincodeSerialize() const +inline std::vector BlackBoxOp::EmbeddedCurveAdd::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::EcdsaSecp256r1 BlackBoxOp::EcdsaSecp256r1::bincodeDeserialize(std::vector input) +inline BlackBoxOp::EmbeddedCurveAdd BlackBoxOp::EmbeddedCurveAdd::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3298,44 +4070,38 @@ inline BlackBoxOp::EcdsaSecp256r1 BlackBoxOp::EcdsaSecp256r1::bincodeDeserialize template <> template -void serde::Serializable::serialize(const Circuit::BlackBoxOp::EcdsaSecp256r1& obj, - Serializer& serializer) +void serde::Serializable::serialize( + const Circuit::BlackBoxOp::EmbeddedCurveAdd& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.hashed_msg, serializer); - serde::Serializable::serialize(obj.public_key_x, serializer); - serde::Serializable::serialize(obj.public_key_y, serializer); - serde::Serializable::serialize(obj.signature, serializer); + serde::Serializable::serialize(obj.input1_x, serializer); + serde::Serializable::serialize(obj.input1_y, serializer); + serde::Serializable::serialize(obj.input2_x, serializer); + serde::Serializable::serialize(obj.input2_y, serializer); serde::Serializable::serialize(obj.result, serializer); } template <> template -Circuit::BlackBoxOp::EcdsaSecp256r1 serde::Deserializable::deserialize( +Circuit::BlackBoxOp::EmbeddedCurveAdd serde::Deserializable::deserialize( Deserializer& deserializer) { - Circuit::BlackBoxOp::EcdsaSecp256r1 obj; - obj.hashed_msg = serde::Deserializable::deserialize(deserializer); - obj.public_key_x = serde::Deserializable::deserialize(deserializer); - obj.public_key_y = serde::Deserializable::deserialize(deserializer); - obj.signature = serde::Deserializable::deserialize(deserializer); + Circuit::BlackBoxOp::EmbeddedCurveAdd obj; + obj.input1_x = serde::Deserializable::deserialize(deserializer); + obj.input1_y = serde::Deserializable::deserialize(deserializer); + obj.input2_x = serde::Deserializable::deserialize(deserializer); + obj.input2_y = serde::Deserializable::deserialize(deserializer); obj.result = serde::Deserializable::deserialize(deserializer); return obj; } namespace Circuit { -inline bool operator==(const BlackBoxOp::SchnorrVerify& lhs, const BlackBoxOp::SchnorrVerify& rhs) +inline bool operator==(const BlackBoxOp::EmbeddedCurveDouble& lhs, const BlackBoxOp::EmbeddedCurveDouble& rhs) { - if (!(lhs.public_key_x == rhs.public_key_x)) { - return false; - } - if (!(lhs.public_key_y == rhs.public_key_y)) { - return false; - } - if (!(lhs.message == rhs.message)) { + if (!(lhs.input1_x == rhs.input1_x)) { return false; } - if (!(lhs.signature == rhs.signature)) { + if (!(lhs.input1_y == rhs.input1_y)) { return false; } if (!(lhs.result == rhs.result)) { @@ -3344,17 +4110,17 @@ inline bool operator==(const BlackBoxOp::SchnorrVerify& lhs, const BlackBoxOp::S return true; } -inline std::vector BlackBoxOp::SchnorrVerify::bincodeSerialize() const +inline std::vector BlackBoxOp::EmbeddedCurveDouble::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::SchnorrVerify BlackBoxOp::SchnorrVerify::bincodeDeserialize(std::vector input) +inline BlackBoxOp::EmbeddedCurveDouble BlackBoxOp::EmbeddedCurveDouble::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3365,38 +4131,34 @@ inline BlackBoxOp::SchnorrVerify BlackBoxOp::SchnorrVerify::bincodeDeserialize(s template <> template -void serde::Serializable::serialize(const Circuit::BlackBoxOp::SchnorrVerify& obj, - Serializer& serializer) +void serde::Serializable::serialize( + const Circuit::BlackBoxOp::EmbeddedCurveDouble& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.public_key_x, serializer); - serde::Serializable::serialize(obj.public_key_y, serializer); - serde::Serializable::serialize(obj.message, serializer); - serde::Serializable::serialize(obj.signature, serializer); + serde::Serializable::serialize(obj.input1_x, serializer); + serde::Serializable::serialize(obj.input1_y, serializer); serde::Serializable::serialize(obj.result, serializer); } template <> template -Circuit::BlackBoxOp::SchnorrVerify serde::Deserializable::deserialize( +Circuit::BlackBoxOp::EmbeddedCurveDouble serde::Deserializable::deserialize( Deserializer& deserializer) { - Circuit::BlackBoxOp::SchnorrVerify obj; - obj.public_key_x = serde::Deserializable::deserialize(deserializer); - obj.public_key_y = serde::Deserializable::deserialize(deserializer); - obj.message = serde::Deserializable::deserialize(deserializer); - obj.signature = serde::Deserializable::deserialize(deserializer); + Circuit::BlackBoxOp::EmbeddedCurveDouble obj; + obj.input1_x = serde::Deserializable::deserialize(deserializer); + obj.input1_y = serde::Deserializable::deserialize(deserializer); obj.result = serde::Deserializable::deserialize(deserializer); return obj; } namespace Circuit { -inline bool operator==(const BlackBoxOp::PedersenCommitment& lhs, const BlackBoxOp::PedersenCommitment& rhs) +inline bool operator==(const BlackBoxOp::BigIntAdd& lhs, const BlackBoxOp::BigIntAdd& rhs) { - if (!(lhs.inputs == rhs.inputs)) { + if (!(lhs.lhs == rhs.lhs)) { return false; } - if (!(lhs.domain_separator == rhs.domain_separator)) { + if (!(lhs.rhs == rhs.rhs)) { return false; } if (!(lhs.output == rhs.output)) { @@ -3405,17 +4167,17 @@ inline bool operator==(const BlackBoxOp::PedersenCommitment& lhs, const BlackBox return true; } -inline std::vector BlackBoxOp::PedersenCommitment::bincodeSerialize() const +inline std::vector BlackBoxOp::BigIntAdd::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::PedersenCommitment BlackBoxOp::PedersenCommitment::bincodeDeserialize(std::vector input) +inline BlackBoxOp::BigIntAdd BlackBoxOp::BigIntAdd::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3426,34 +4188,34 @@ inline BlackBoxOp::PedersenCommitment BlackBoxOp::PedersenCommitment::bincodeDes template <> template -void serde::Serializable::serialize( - const Circuit::BlackBoxOp::PedersenCommitment& obj, Serializer& serializer) +void serde::Serializable::serialize(const Circuit::BlackBoxOp::BigIntAdd& obj, + Serializer& serializer) { - serde::Serializable::serialize(obj.inputs, serializer); - serde::Serializable::serialize(obj.domain_separator, serializer); + serde::Serializable::serialize(obj.lhs, serializer); + serde::Serializable::serialize(obj.rhs, serializer); serde::Serializable::serialize(obj.output, serializer); } template <> template -Circuit::BlackBoxOp::PedersenCommitment serde::Deserializable::deserialize( +Circuit::BlackBoxOp::BigIntAdd serde::Deserializable::deserialize( Deserializer& deserializer) { - Circuit::BlackBoxOp::PedersenCommitment obj; - obj.inputs = serde::Deserializable::deserialize(deserializer); - obj.domain_separator = serde::Deserializable::deserialize(deserializer); + Circuit::BlackBoxOp::BigIntAdd obj; + obj.lhs = serde::Deserializable::deserialize(deserializer); + obj.rhs = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Circuit { -inline bool operator==(const BlackBoxOp::PedersenHash& lhs, const BlackBoxOp::PedersenHash& rhs) +inline bool operator==(const BlackBoxOp::BigIntNeg& lhs, const BlackBoxOp::BigIntNeg& rhs) { - if (!(lhs.inputs == rhs.inputs)) { + if (!(lhs.lhs == rhs.lhs)) { return false; } - if (!(lhs.domain_separator == rhs.domain_separator)) { + if (!(lhs.rhs == rhs.rhs)) { return false; } if (!(lhs.output == rhs.output)) { @@ -3462,17 +4224,17 @@ inline bool operator==(const BlackBoxOp::PedersenHash& lhs, const BlackBoxOp::Pe return true; } -inline std::vector BlackBoxOp::PedersenHash::bincodeSerialize() const +inline std::vector BlackBoxOp::BigIntNeg::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::PedersenHash BlackBoxOp::PedersenHash::bincodeDeserialize(std::vector input) +inline BlackBoxOp::BigIntNeg BlackBoxOp::BigIntNeg::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3483,53 +4245,53 @@ inline BlackBoxOp::PedersenHash BlackBoxOp::PedersenHash::bincodeDeserialize(std template <> template -void serde::Serializable::serialize(const Circuit::BlackBoxOp::PedersenHash& obj, - Serializer& serializer) +void serde::Serializable::serialize(const Circuit::BlackBoxOp::BigIntNeg& obj, + Serializer& serializer) { - serde::Serializable::serialize(obj.inputs, serializer); - serde::Serializable::serialize(obj.domain_separator, serializer); + serde::Serializable::serialize(obj.lhs, serializer); + serde::Serializable::serialize(obj.rhs, serializer); serde::Serializable::serialize(obj.output, serializer); } template <> template -Circuit::BlackBoxOp::PedersenHash serde::Deserializable::deserialize( +Circuit::BlackBoxOp::BigIntNeg serde::Deserializable::deserialize( Deserializer& deserializer) { - Circuit::BlackBoxOp::PedersenHash obj; - obj.inputs = serde::Deserializable::deserialize(deserializer); - obj.domain_separator = serde::Deserializable::deserialize(deserializer); + Circuit::BlackBoxOp::BigIntNeg obj; + obj.lhs = serde::Deserializable::deserialize(deserializer); + obj.rhs = serde::Deserializable::deserialize(deserializer); obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Circuit { -inline bool operator==(const BlackBoxOp::FixedBaseScalarMul& lhs, const BlackBoxOp::FixedBaseScalarMul& rhs) +inline bool operator==(const BlackBoxOp::BigIntMul& lhs, const BlackBoxOp::BigIntMul& rhs) { - if (!(lhs.low == rhs.low)) { + if (!(lhs.lhs == rhs.lhs)) { return false; } - if (!(lhs.high == rhs.high)) { + if (!(lhs.rhs == rhs.rhs)) { return false; } - if (!(lhs.result == rhs.result)) { + if (!(lhs.output == rhs.output)) { return false; } return true; } -inline std::vector BlackBoxOp::FixedBaseScalarMul::bincodeSerialize() const +inline std::vector BlackBoxOp::BigIntMul::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::FixedBaseScalarMul BlackBoxOp::FixedBaseScalarMul::bincodeDeserialize(std::vector input) +inline BlackBoxOp::BigIntMul BlackBoxOp::BigIntMul::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3540,59 +4302,110 @@ inline BlackBoxOp::FixedBaseScalarMul BlackBoxOp::FixedBaseScalarMul::bincodeDes template <> template -void serde::Serializable::serialize( - const Circuit::BlackBoxOp::FixedBaseScalarMul& obj, Serializer& serializer) +void serde::Serializable::serialize(const Circuit::BlackBoxOp::BigIntMul& obj, + Serializer& serializer) { - serde::Serializable::serialize(obj.low, serializer); - serde::Serializable::serialize(obj.high, serializer); - serde::Serializable::serialize(obj.result, serializer); + serde::Serializable::serialize(obj.lhs, serializer); + serde::Serializable::serialize(obj.rhs, serializer); + serde::Serializable::serialize(obj.output, serializer); } template <> template -Circuit::BlackBoxOp::FixedBaseScalarMul serde::Deserializable::deserialize( +Circuit::BlackBoxOp::BigIntMul serde::Deserializable::deserialize( Deserializer& deserializer) { - Circuit::BlackBoxOp::FixedBaseScalarMul obj; - obj.low = serde::Deserializable::deserialize(deserializer); - obj.high = serde::Deserializable::deserialize(deserializer); - obj.result = serde::Deserializable::deserialize(deserializer); + Circuit::BlackBoxOp::BigIntMul obj; + obj.lhs = serde::Deserializable::deserialize(deserializer); + obj.rhs = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Circuit { -inline bool operator==(const BlackBoxOp::EmbeddedCurveAdd& lhs, const BlackBoxOp::EmbeddedCurveAdd& rhs) +inline bool operator==(const BlackBoxOp::BigIntDiv& lhs, const BlackBoxOp::BigIntDiv& rhs) { - if (!(lhs.input1_x == rhs.input1_x)) { + if (!(lhs.lhs == rhs.lhs)) { return false; } - if (!(lhs.input1_y == rhs.input1_y)) { + if (!(lhs.rhs == rhs.rhs)) { return false; } - if (!(lhs.input2_x == rhs.input2_x)) { + if (!(lhs.output == rhs.output)) { return false; } - if (!(lhs.input2_y == rhs.input2_y)) { + return true; +} + +inline std::vector BlackBoxOp::BigIntDiv::bincodeSerialize() const +{ + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); +} + +inline BlackBoxOp::BigIntDiv BlackBoxOp::BigIntDiv::bincodeDeserialize(std::vector input) +{ + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw_or_abort("Some input bytes were not read"); + } + return value; +} + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxOp::BigIntDiv& obj, + Serializer& serializer) +{ + serde::Serializable::serialize(obj.lhs, serializer); + serde::Serializable::serialize(obj.rhs, serializer); + serde::Serializable::serialize(obj.output, serializer); +} + +template <> +template +Circuit::BlackBoxOp::BigIntDiv serde::Deserializable::deserialize( + Deserializer& deserializer) +{ + Circuit::BlackBoxOp::BigIntDiv obj; + obj.lhs = serde::Deserializable::deserialize(deserializer); + obj.rhs = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + +inline bool operator==(const BlackBoxOp::BigIntFromLeBytes& lhs, const BlackBoxOp::BigIntFromLeBytes& rhs) +{ + if (!(lhs.inputs == rhs.inputs)) { return false; } - if (!(lhs.result == rhs.result)) { + if (!(lhs.modulus == rhs.modulus)) { + return false; + } + if (!(lhs.output == rhs.output)) { return false; } return true; } -inline std::vector BlackBoxOp::EmbeddedCurveAdd::bincodeSerialize() const +inline std::vector BlackBoxOp::BigIntFromLeBytes::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::EmbeddedCurveAdd BlackBoxOp::EmbeddedCurveAdd::bincodeDeserialize(std::vector input) +inline BlackBoxOp::BigIntFromLeBytes BlackBoxOp::BigIntFromLeBytes::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3603,57 +4416,50 @@ inline BlackBoxOp::EmbeddedCurveAdd BlackBoxOp::EmbeddedCurveAdd::bincodeDeseria template <> template -void serde::Serializable::serialize( - const Circuit::BlackBoxOp::EmbeddedCurveAdd& obj, Serializer& serializer) +void serde::Serializable::serialize( + const Circuit::BlackBoxOp::BigIntFromLeBytes& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.input1_x, serializer); - serde::Serializable::serialize(obj.input1_y, serializer); - serde::Serializable::serialize(obj.input2_x, serializer); - serde::Serializable::serialize(obj.input2_y, serializer); - serde::Serializable::serialize(obj.result, serializer); + serde::Serializable::serialize(obj.inputs, serializer); + serde::Serializable::serialize(obj.modulus, serializer); + serde::Serializable::serialize(obj.output, serializer); } template <> template -Circuit::BlackBoxOp::EmbeddedCurveAdd serde::Deserializable::deserialize( +Circuit::BlackBoxOp::BigIntFromLeBytes serde::Deserializable::deserialize( Deserializer& deserializer) { - Circuit::BlackBoxOp::EmbeddedCurveAdd obj; - obj.input1_x = serde::Deserializable::deserialize(deserializer); - obj.input1_y = serde::Deserializable::deserialize(deserializer); - obj.input2_x = serde::Deserializable::deserialize(deserializer); - obj.input2_y = serde::Deserializable::deserialize(deserializer); - obj.result = serde::Deserializable::deserialize(deserializer); + Circuit::BlackBoxOp::BigIntFromLeBytes obj; + obj.inputs = serde::Deserializable::deserialize(deserializer); + obj.modulus = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); return obj; } namespace Circuit { -inline bool operator==(const BlackBoxOp::EmbeddedCurveDouble& lhs, const BlackBoxOp::EmbeddedCurveDouble& rhs) +inline bool operator==(const BlackBoxOp::BigIntToLeBytes& lhs, const BlackBoxOp::BigIntToLeBytes& rhs) { - if (!(lhs.input1_x == rhs.input1_x)) { - return false; - } - if (!(lhs.input1_y == rhs.input1_y)) { + if (!(lhs.input == rhs.input)) { return false; } - if (!(lhs.result == rhs.result)) { + if (!(lhs.output == rhs.output)) { return false; } return true; } -inline std::vector BlackBoxOp::EmbeddedCurveDouble::bincodeSerialize() const +inline std::vector BlackBoxOp::BigIntToLeBytes::bincodeSerialize() const { auto serializer = serde::BincodeSerializer(); - serde::Serializable::serialize(*this, serializer); + serde::Serializable::serialize(*this, serializer); return std::move(serializer).bytes(); } -inline BlackBoxOp::EmbeddedCurveDouble BlackBoxOp::EmbeddedCurveDouble::bincodeDeserialize(std::vector input) +inline BlackBoxOp::BigIntToLeBytes BlackBoxOp::BigIntToLeBytes::bincodeDeserialize(std::vector input) { auto deserializer = serde::BincodeDeserializer(input); - auto value = serde::Deserializable::deserialize(deserializer); + auto value = serde::Deserializable::deserialize(deserializer); if (deserializer.get_buffer_offset() < input.size()) { throw_or_abort("Some input bytes were not read"); } @@ -3664,23 +4470,21 @@ inline BlackBoxOp::EmbeddedCurveDouble BlackBoxOp::EmbeddedCurveDouble::bincodeD template <> template -void serde::Serializable::serialize( - const Circuit::BlackBoxOp::EmbeddedCurveDouble& obj, Serializer& serializer) +void serde::Serializable::serialize( + const Circuit::BlackBoxOp::BigIntToLeBytes& obj, Serializer& serializer) { - serde::Serializable::serialize(obj.input1_x, serializer); - serde::Serializable::serialize(obj.input1_y, serializer); - serde::Serializable::serialize(obj.result, serializer); + serde::Serializable::serialize(obj.input, serializer); + serde::Serializable::serialize(obj.output, serializer); } template <> template -Circuit::BlackBoxOp::EmbeddedCurveDouble serde::Deserializable::deserialize( +Circuit::BlackBoxOp::BigIntToLeBytes serde::Deserializable::deserialize( Deserializer& deserializer) { - Circuit::BlackBoxOp::EmbeddedCurveDouble obj; - obj.input1_x = serde::Deserializable::deserialize(deserializer); - obj.input1_y = serde::Deserializable::deserialize(deserializer); - obj.result = serde::Deserializable::deserialize(deserializer); + Circuit::BlackBoxOp::BigIntToLeBytes obj; + obj.input = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); return obj; } diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.cpp index 7c17e46d19bb..072540db80f7 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.cpp @@ -3,7 +3,6 @@ #include "barretenberg/common/throw_or_abort.hpp" #include "barretenberg/dsl/acir_format/acir_format.hpp" #include "barretenberg/dsl/types.hpp" -#include "barretenberg/goblin/mock_circuits.hpp" #include "barretenberg/plonk/proof_system/proving_key/serialize.hpp" #include "barretenberg/plonk/proof_system/verification_key/sol_gen.hpp" #include "barretenberg/plonk/proof_system/verification_key/verification_key.hpp" @@ -25,7 +24,7 @@ AcirComposer::AcirComposer(size_t size_hint, bool verbose) * @param witness */ template -void AcirComposer::create_circuit(acir_format::acir_format& constraint_system, WitnessVector const& witness) +void AcirComposer::create_circuit(acir_format::AcirFormat& constraint_system, WitnessVector const& witness) { vinfo("building circuit..."); builder_ = acir_format::create_circuit(constraint_system, size_hint_, witness); @@ -61,27 +60,6 @@ std::vector AcirComposer::create_proof(bool is_recursive) return proof; } -void AcirComposer::create_goblin_circuit(acir_format::acir_format& constraint_system, - acir_format::WitnessVector& witness) -{ - // Construct a builder using the witness and public input data from acir - goblin_builder_ = acir_format::GoblinBuilder{ - goblin.op_queue, witness, constraint_system.public_inputs, constraint_system.varnum - }; - - // Populate constraints in the builder via the data in constraint_system - acir_format::build_constraints(goblin_builder_, constraint_system, true); - - // TODO(https://github.com/AztecProtocol/barretenberg/issues/817): Add some arbitrary op gates to ensure the - // associated polynomials are non-zero and to give ECCVM and Translator some ECC ops to process. - GoblinMockCircuits::construct_goblin_ecc_op_circuit(goblin_builder_); -} - -std::vector AcirComposer::create_goblin_proof() -{ - return goblin.construct_proof(goblin_builder_); -} - std::shared_ptr AcirComposer::init_verification_key() { if (!proving_key_) { @@ -132,11 +110,6 @@ bool AcirComposer::verify_proof(std::vector const& proof, bool is_recur } } -bool AcirComposer::verify_goblin_proof(std::vector const& proof) -{ - return goblin.verify_proof({ proof }); -} - std::string AcirComposer::get_solidity_verifier() { std::ostringstream stream; @@ -176,7 +149,7 @@ std::vector AcirComposer::serialize_verification_key_into_fields() return acir_format::export_key_in_recursion_format(verification_key_); } -template void AcirComposer::create_circuit(acir_format::acir_format& constraint_system, +template void AcirComposer::create_circuit(acir_format::AcirFormat& constraint_system, WitnessVector const& witness); } // namespace acir_proofs diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.hpp index 7acad4ff622a..a83d7f85c951 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/acir_composer.hpp @@ -1,6 +1,5 @@ #pragma once #include -#include namespace acir_proofs { @@ -18,7 +17,7 @@ class AcirComposer { AcirComposer(size_t size_hint = 0, bool verbose = true); template - void create_circuit(acir_format::acir_format& constraint_system, WitnessVector const& witness = {}); + void create_circuit(acir_format::AcirFormat& constraint_system, WitnessVector const& witness = {}); std::shared_ptr init_proving_key(); @@ -38,15 +37,8 @@ class AcirComposer { std::vector serialize_verification_key_into_fields(); - // Goblin specific methods - void create_goblin_circuit(acir_format::acir_format& constraint_system, acir_format::WitnessVector& witness); - std::vector create_goblin_proof(); - bool verify_goblin_proof(std::vector const& proof); - private: acir_format::Builder builder_; - acir_format::GoblinBuilder goblin_builder_; - Goblin goblin; size_t size_hint_; std::shared_ptr proving_key_; std::shared_ptr verification_key_; diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp index 954fe16832e3..18d44941e567 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp @@ -6,6 +6,7 @@ #include "barretenberg/common/serialize.hpp" #include "barretenberg/common/slab_allocator.hpp" #include "barretenberg/dsl/acir_format/acir_format.hpp" +#include "barretenberg/dsl/acir_proofs/goblin_acir_composer.hpp" #include "barretenberg/plonk/proof_system/proving_key/serialize.hpp" #include "barretenberg/plonk/proof_system/verification_key/verification_key.hpp" #include "barretenberg/srs/global_crs.hpp" @@ -26,6 +27,11 @@ WASM_EXPORT void acir_new_acir_composer(uint32_t const* size_hint, out_ptr out) *out = new acir_proofs::AcirComposer(ntohl(*size_hint)); } +WASM_EXPORT void acir_new_goblin_acir_composer(out_ptr out) +{ + *out = new acir_proofs::GoblinAcirComposer(); +} + WASM_EXPORT void acir_delete_acir_composer(in_ptr acir_composer_ptr) { delete reinterpret_cast(*acir_composer_ptr); @@ -57,17 +63,31 @@ WASM_EXPORT void acir_create_proof(in_ptr acir_composer_ptr, *out = to_heap_buffer(proof_data); } -WASM_EXPORT void acir_create_goblin_proof(in_ptr acir_composer_ptr, - uint8_t const* acir_vec, - uint8_t const* witness_vec, - uint8_t** out) +WASM_EXPORT void acir_goblin_accumulate(in_ptr acir_composer_ptr, + uint8_t const* acir_vec, + uint8_t const* witness_vec, + uint8_t** out) { - auto acir_composer = reinterpret_cast(*acir_composer_ptr); + auto acir_composer = reinterpret_cast(*acir_composer_ptr); auto constraint_system = acir_format::circuit_buf_to_acir_format(from_buffer>(acir_vec)); auto witness = acir_format::witness_buf_to_witness_data(from_buffer>(witness_vec)); - acir_composer->create_goblin_circuit(constraint_system, witness); - auto proof_data = acir_composer->create_goblin_proof(); + acir_composer->create_circuit(constraint_system, witness); + auto proof_data = acir_composer->accumulate(); + *out = to_heap_buffer(proof_data); +} + +WASM_EXPORT void acir_goblin_prove(in_ptr acir_composer_ptr, + uint8_t const* acir_vec, + uint8_t const* witness_vec, + uint8_t** out) +{ + auto acir_composer = reinterpret_cast(*acir_composer_ptr); + auto constraint_system = acir_format::circuit_buf_to_acir_format(from_buffer>(acir_vec)); + auto witness = acir_format::witness_buf_to_witness_data(from_buffer>(witness_vec)); + + acir_composer->create_circuit(constraint_system, witness); + auto proof_data = acir_composer->accumulate_and_prove(); *out = to_heap_buffer(proof_data); } @@ -102,11 +122,18 @@ WASM_EXPORT void acir_get_proving_key(in_ptr acir_composer_ptr, uint8_t const* a *out = to_heap_buffer(to_buffer(*pk)); } -WASM_EXPORT void acir_verify_goblin_proof(in_ptr acir_composer_ptr, uint8_t const* proof_buf, bool* result) +WASM_EXPORT void acir_goblin_verify_accumulator(in_ptr acir_composer_ptr, uint8_t const* proof_buf, bool* result) { - auto acir_composer = reinterpret_cast(*acir_composer_ptr); + auto acir_composer = reinterpret_cast(*acir_composer_ptr); + auto proof = from_buffer>(proof_buf); + *result = acir_composer->verify_accumulator(proof); +} + +WASM_EXPORT void acir_goblin_verify(in_ptr acir_composer_ptr, uint8_t const* proof_buf, bool* result) +{ + auto acir_composer = reinterpret_cast(*acir_composer_ptr); auto proof = from_buffer>(proof_buf); - *result = acir_composer->verify_goblin_proof(proof); + *result = acir_composer->verify(proof); } WASM_EXPORT void acir_verify_proof(in_ptr acir_composer_ptr, diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.hpp index cb6b86435128..76b24886b1d4 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.hpp @@ -13,6 +13,8 @@ WASM_EXPORT void acir_get_circuit_sizes(uint8_t const* constraint_system_buf, WASM_EXPORT void acir_new_acir_composer(uint32_t const* size_hint, out_ptr out); +WASM_EXPORT void acir_new_goblin_acir_composer(out_ptr out); + WASM_EXPORT void acir_delete_acir_composer(in_ptr acir_composer_ptr); WASM_EXPORT void acir_create_circuit(in_ptr acir_composer_ptr, @@ -32,10 +34,25 @@ WASM_EXPORT void acir_create_proof(in_ptr acir_composer_ptr, bool const* is_recursive, uint8_t** out); -WASM_EXPORT void acir_create_goblin_proof(in_ptr acir_composer_ptr, - uint8_t const* constraint_system_buf, - uint8_t const* witness_buf, - uint8_t** out); +/** + * @brief Perform the goblin accumulate operation + * @details Constructs a GUH proof and possibly handles transcript merge logic + * + */ +WASM_EXPORT void acir_goblin_accumulate(in_ptr acir_composer_ptr, + uint8_t const* constraint_system_buf, + uint8_t const* witness_buf, + uint8_t** out); + +/** + * @brief Construct a full goblin proof + * @details Makes a call to accumulate to a final circuit before constructing a Goblin proof + * + */ +WASM_EXPORT void acir_goblin_prove(in_ptr acir_composer_ptr, + uint8_t const* constraint_system_buf, + uint8_t const* witness_buf, + uint8_t** out); WASM_EXPORT void acir_load_verification_key(in_ptr acir_composer_ptr, uint8_t const* vk_buf); @@ -50,7 +67,17 @@ WASM_EXPORT void acir_verify_proof(in_ptr acir_composer_ptr, bool const* is_recursive, bool* result); -WASM_EXPORT void acir_verify_goblin_proof(in_ptr acir_composer_ptr, uint8_t const* proof_buf, bool* result); +/** + * @brief Verifies a GUH proof produced during goblin accumulation + * + */ +WASM_EXPORT void acir_goblin_verify_accumulator(in_ptr acir_composer_ptr, uint8_t const* proof_buf, bool* result); + +/** + * @brief Verifies a full goblin proof (and the GUH proof produced by accumulation) + * + */ +WASM_EXPORT void acir_goblin_verify(in_ptr acir_composer_ptr, uint8_t const* proof_buf, bool* result); WASM_EXPORT void acir_get_solidity_verifier(in_ptr acir_composer_ptr, out_str_buf out); diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/goblin_acir_composer.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/goblin_acir_composer.cpp new file mode 100644 index 000000000000..3b0adc0ae5cb --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/goblin_acir_composer.cpp @@ -0,0 +1,65 @@ +#include "goblin_acir_composer.hpp" +#include "barretenberg/common/throw_or_abort.hpp" +#include "barretenberg/dsl/acir_format/acir_format.hpp" +#include "barretenberg/dsl/types.hpp" +#include "barretenberg/goblin/mock_circuits.hpp" + +namespace acir_proofs { + +void GoblinAcirComposer::create_circuit(acir_format::AcirFormat& constraint_system, acir_format::WitnessVector& witness) +{ + // Construct a builder using the witness and public input data from acir and with the goblin-owned op_queue + builder_ = acir_format::GoblinBuilder{ + goblin.op_queue, witness, constraint_system.public_inputs, constraint_system.varnum + }; + + // Populate constraints in the builder via the data in constraint_system + acir_format::build_constraints(builder_, constraint_system, true); + + // TODO(https://github.com/AztecProtocol/barretenberg/issues/817): Add some arbitrary op gates to ensure the + // associated polynomials are non-zero and to give ECCVM and Translator some ECC ops to process. + GoblinMockCircuits::construct_goblin_ecc_op_circuit(builder_); +} + +std::vector GoblinAcirComposer::accumulate() +{ + // // Construct a GUH proof for the circuit via the accumulate mechanism + // return goblin.accumulate_for_acir(builder_); + + // Construct one final GUH proof via the accumulate mechanism + std::vector ultra_proof = goblin.accumulate_for_acir(builder_); + + // Construct a Goblin proof (ECCVM, Translator, Merge); result stored internally + goblin.prove_for_acir(); + + return ultra_proof; +} + +bool GoblinAcirComposer::verify_accumulator(std::vector const& proof) +{ + return goblin.verify_accumulator_for_acir(proof); +} + +std::vector GoblinAcirComposer::accumulate_and_prove() +{ + // Construct one final GUH proof via the accumulate mechanism + std::vector ultra_proof = goblin.accumulate_for_acir(builder_); + + // Construct a Goblin proof (ECCVM, Translator, Merge); result stored internally + goblin.prove_for_acir(); + + return ultra_proof; +} + +bool GoblinAcirComposer::verify(std::vector const& proof) +{ + // Verify the final GUH proof + bool ultra_verified = goblin.verify_accumulator_for_acir(proof); + + // Verify the Goblin proof (ECCVM, Translator, Merge) + bool goblin_verified = goblin.verify_for_acir(); + + return ultra_verified && goblin_verified; +} + +} // namespace acir_proofs diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/goblin_acir_composer.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/goblin_acir_composer.hpp new file mode 100644 index 000000000000..6556b548045f --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/goblin_acir_composer.hpp @@ -0,0 +1,73 @@ +#pragma once +#include +#include + +namespace acir_proofs { + +/** + * @brief A class responsible for marshalling construction of keys and prover and verifier instances used to prove + * satisfiability of circuits written in ACIR. + * + */ +class GoblinAcirComposer { + + using WitnessVector = std::vector>; + + public: + GoblinAcirComposer() = default; + + /** + * @brief Create a GUH circuit from an acir constraint system and a witness + * + * @param constraint_system ACIR representation of the constraints defining the circuit + * @param witness The witness values known to ACIR during construction of the constraint system + */ + void create_circuit(acir_format::AcirFormat& constraint_system, acir_format::WitnessVector& witness); + + /** + * @brief Accumulate a circuit via Goblin + * @details For the present circuit, construct a GUH proof and the vkey needed to verify it + * + * @return std::vector The GUH proof bytes + */ + std::vector accumulate(); + + /** + * @brief Verify the Goblin accumulator (the GUH proof) using the vkey internal to Goblin + * + * @param proof + * @return bool Whether or not the proof was verified + */ + bool verify_accumulator(std::vector const& proof); + + /** + * @brief Accumulate a final circuit and construct a full Goblin proof + * @details Accumulation means constructing a GUH proof of a single (final) circuit. A full Goblin proof consists of + * a merge proof, an ECCVM proof and a Translator proof. The Goblin proof is only constructed at the end of the + * accumulation phase and establishes the correctness of the ECC operations written to the op queue throughout the + * accumulation phase. + * + */ + std::vector accumulate_and_prove(); + + /** + * @brief Verify the final GUH proof and the full Goblin proof + * + * @return bool verified + */ + bool verify(std::vector const& proof); + + private: + acir_format::GoblinBuilder builder_; + Goblin goblin; + bool verbose_ = true; + + template inline void vinfo(Args... args) + { + if (verbose_) { + info(args...); + } + } +}; + +} // namespace acir_proofs diff --git a/barretenberg/cpp/src/barretenberg/dsl/types.hpp b/barretenberg/cpp/src/barretenberg/dsl/types.hpp index 46e97b14db5b..b5bf296cbf53 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/types.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/types.hpp @@ -60,7 +60,7 @@ using secp256r1_ct = bb::stdlib::secp256r1; using hash_path_ct = bb::stdlib::merkle_tree::hash_path; -using schnorr_signature_bits_ct = bb::stdlib::schnorr::signature_bits; +using schnorr_signature_bits_ct = bb::stdlib::schnorr_signature_bits; // Ultra-composer specific typesv using rom_table_ct = bb::stdlib::rom_table; diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/bn254.hpp b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/bn254.hpp index 4b171066d862..37d42124c7ec 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/bn254.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/bn254.hpp @@ -6,7 +6,7 @@ #include "../bn254/g1.hpp" #include "../bn254/g2.hpp" -namespace curve { +namespace bb::curve { class BN254 { public: using ScalarField = bb::fr; @@ -23,4 +23,4 @@ class BN254 { // with stdlib types, and "native" verification will be acheived via a simulated builder. static constexpr bool is_stdlib_type = false; }; -} // namespace curve \ No newline at end of file +} // namespace bb::curve \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/g1.test.cpp b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/g1.test.cpp index bf7d05d14cef..e2171981250d 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/g1.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/g1.test.cpp @@ -3,7 +3,6 @@ using namespace bb; -namespace test_g1 { TEST(g1, RandomElement) { g1::element result = g1::element::random_element(); @@ -416,7 +415,6 @@ template void write(const T t) TEST(g1, InitializationCheck) { // NOLINTNEXTLINE not our fault googletest uses `goto`! - EXPECT_NO_THROW(write({})); + EXPECT_NO_THROW(write({})); } #endif -} // namespace test_g1 \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/g2.test.cpp b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/g2.test.cpp index 6905aeb10234..ce198af48a91 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/g2.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/bn254/g2.test.cpp @@ -385,6 +385,6 @@ template void write(const T t) TEST(g2, InitializationCheck) { // NOLINTNEXTLINE not our fault googletest uses `goto`! - EXPECT_NO_THROW(write({})); + EXPECT_NO_THROW(write({})); } #endif \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/grumpkin/grumpkin.hpp b/barretenberg/cpp/src/barretenberg/ecc/curves/grumpkin/grumpkin.hpp index c378aad9ee64..cfe12ad286f4 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/grumpkin/grumpkin.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/grumpkin/grumpkin.hpp @@ -30,7 +30,7 @@ using g1 = bb::group; }; // namespace grumpkin -namespace curve { +namespace bb::curve { class Grumpkin { public: using ScalarField = bb::fq; @@ -44,4 +44,4 @@ class Grumpkin { // with stdlib types, and "native" verification will be acheived via a simulated builder. static constexpr bool is_stdlib_type = false; }; -} // namespace curve \ No newline at end of file +} // namespace bb::curve \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/grumpkin/grumpkin.test.cpp b/barretenberg/cpp/src/barretenberg/ecc/curves/grumpkin/grumpkin.test.cpp index fefa6a6d0dcb..5573e08ea389 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/grumpkin/grumpkin.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/grumpkin/grumpkin.test.cpp @@ -2,12 +2,12 @@ #include #include -namespace test_grumpkin { +using namespace bb; TEST(grumpkin, CheckB) { auto b = grumpkin::g1::curve_b; - bb::fr seventeen = 17; + fr seventeen = 17; EXPECT_EQ(seventeen, -b); } @@ -329,4 +329,3 @@ TEST(grumpkin, BadPoints) } EXPECT_TRUE(res); } -} // namespace test_grumpkin \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/secp256k1/secp256k1.hpp b/barretenberg/cpp/src/barretenberg/ecc/curves/secp256k1/secp256k1.hpp index 8b4a4d673674..ce10122791cb 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/secp256k1/secp256k1.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/secp256k1/secp256k1.hpp @@ -121,7 +121,7 @@ struct Secp256k1G1Params { using g1 = bb::group, bb::field, Secp256k1G1Params>; } // namespace secp256k1 -namespace curve { +namespace bb::curve { class SECP256K1 { public: using ScalarField = secp256k1::fr; @@ -130,6 +130,6 @@ class SECP256K1 { using Element = typename Group::element; using AffineElement = typename Group::affine_element; }; -} // namespace curve +} // namespace bb::curve // NOLINTEND(cppcoreguidelines-avoid-c-arrays) diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/secp256k1/secp256k1.test.cpp b/barretenberg/cpp/src/barretenberg/ecc/curves/secp256k1/secp256k1.test.cpp index f89688ecbd75..7fa8bee9ae68 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/secp256k1/secp256k1.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/secp256k1/secp256k1.test.cpp @@ -2,11 +2,9 @@ #include "barretenberg/numeric/random/engine.hpp" #include -namespace test_secp256k1 { - +using namespace bb; namespace { -auto& engine = numeric::random::get_debug_engine(); -} +auto& engine = numeric::get_debug_randomness(); constexpr uint256_t test_fq_mod(secp256k1::Secp256k1FqParams::modulus_0, secp256k1::Secp256k1FqParams::modulus_1, @@ -21,6 +19,7 @@ uint256_t get_fq_element() } return res; } +} // namespace TEST(secp256k1, TestAdd) { @@ -504,5 +503,3 @@ TEST(secp256k1, MontgomeryMulBigBug) secp256k1::fq expected(uint256_t{ 0x60381e557e100000, 0x0, 0x0, 0x0 }); EXPECT_EQ((a_sqr == expected), true); } - -} // namespace test_secp256k1 diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/secp256r1/secp256r1.hpp b/barretenberg/cpp/src/barretenberg/ecc/curves/secp256r1/secp256r1.hpp index c4478e06b50d..e28e86c16758 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/secp256r1/secp256r1.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/secp256r1/secp256r1.hpp @@ -107,7 +107,7 @@ struct Secp256r1G1Params { using g1 = bb::group, bb::field, Secp256r1G1Params>; } // namespace secp256r1 -namespace curve { +namespace bb::curve { class SECP256R1 { public: using ScalarField = secp256r1::fr; @@ -116,6 +116,6 @@ class SECP256R1 { using Element = typename Group::element; using AffineElement = typename Group::affine_element; }; -} // namespace curve +} // namespace bb::curve // NOLINTEND(cppcoreguidelines-avoid-c-arrays) diff --git a/barretenberg/cpp/src/barretenberg/ecc/curves/secp256r1/secp256r1.test.cpp b/barretenberg/cpp/src/barretenberg/ecc/curves/secp256r1/secp256r1.test.cpp index 14c67245092b..03f5a4bc8d15 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/curves/secp256r1/secp256r1.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/curves/secp256r1/secp256r1.test.cpp @@ -2,11 +2,9 @@ #include "barretenberg/numeric/random/engine.hpp" #include -namespace test_secp256r1 { - +using namespace bb; namespace { -auto& engine = numeric::random::get_debug_engine(); -} +auto& engine = numeric::get_debug_randomness(); constexpr uint256_t test_fq_mod(secp256r1::Secp256r1FqParams::modulus_0, secp256r1::Secp256r1FqParams::modulus_1, @@ -21,6 +19,7 @@ uint256_t get_fq_element() } return res; } +} // namespace TEST(secp256r1, TestAdd) { @@ -446,5 +445,3 @@ TEST(secp256r1, MontgomeryMulBigBug) secp256r1::fr expected(uint256_t{ 0x57abc6aa0349c084, 0x65b21b232a4cb7a5, 0x5ba781948b0fcd6e, 0xd6e9e0644bda12f7 }); EXPECT_EQ((a_sqr == expected), true); } - -} // namespace test_secp256r1 diff --git a/barretenberg/cpp/src/barretenberg/ecc/fields/field12.hpp b/barretenberg/cpp/src/barretenberg/ecc/fields/field12.hpp index 77d6dab770d4..e69ba6888454 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/fields/field12.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/fields/field12.hpp @@ -238,7 +238,7 @@ template cl }; } - static constexpr field12 random_element(numeric::random::Engine* engine = nullptr) + static constexpr field12 random_element(numeric::RNG* engine = nullptr) { return { base_field::random_element(engine), diff --git a/barretenberg/cpp/src/barretenberg/ecc/fields/field2.hpp b/barretenberg/cpp/src/barretenberg/ecc/fields/field2.hpp index aa42dad75aa2..b0cad83f0fff 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/fields/field2.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/fields/field2.hpp @@ -190,7 +190,7 @@ template constexpr void field2::self_frobenius_ma c1.self_neg(); } -template field2 field2::random_element(numeric::random::Engine* engine) +template field2 field2::random_element(numeric::RNG* engine) { return { base::random_element(engine), base::random_element(engine) }; } diff --git a/barretenberg/cpp/src/barretenberg/ecc/fields/field2_declarations.hpp b/barretenberg/cpp/src/barretenberg/ecc/fields/field2_declarations.hpp index ba9a1281526f..d9607abfe89e 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/fields/field2_declarations.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/fields/field2_declarations.hpp @@ -2,9 +2,9 @@ #include "barretenberg/numeric/uint256/uint256.hpp" -// forward declare Engine -namespace numeric::random { -class Engine; +// forward declare RNG +namespace bb::numeric { +class RNG; } namespace bb { @@ -115,7 +115,7 @@ template struct alignas(32) field2 { constexpr field2 frobenius_map() const noexcept; constexpr void self_frobenius_map() noexcept; - static field2 random_element(numeric::random::Engine* engine = nullptr); + static field2 random_element(numeric::RNG* engine = nullptr); static void serialize_to_buffer(const field2& value, uint8_t* buffer) { base_field::serialize_to_buffer(value.c0, buffer); diff --git a/barretenberg/cpp/src/barretenberg/ecc/fields/field6.hpp b/barretenberg/cpp/src/barretenberg/ecc/fields/field6.hpp index b69df21e2a34..0ee982f3f373 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/fields/field6.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/fields/field6.hpp @@ -190,7 +190,7 @@ template class field6 { }; } - static constexpr field6 random_element(numeric::random::Engine* engine = nullptr) + static constexpr field6 random_element(numeric::RNG* engine = nullptr) { return { base_field::random_element(engine), diff --git a/barretenberg/cpp/src/barretenberg/ecc/fields/field_declarations.hpp b/barretenberg/cpp/src/barretenberg/ecc/fields/field_declarations.hpp index 192be60d0d28..217e2b42bd2a 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/fields/field_declarations.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/fields/field_declarations.hpp @@ -112,6 +112,13 @@ template struct alignas(32) field { *this = field(value); } + constexpr explicit operator bool() const + { + field out = from_montgomery_form(); + ASSERT(out.data[0] == 0 || out.data[0] == 1); + return static_cast(out.data[0]); + } + constexpr explicit operator uint32_t() const { field out = from_montgomery_form(); @@ -437,7 +444,7 @@ template struct alignas(32) field { src = T; } - static field random_element(numeric::random::Engine* engine = nullptr) noexcept; + static field random_element(numeric::RNG* engine = nullptr) noexcept; static constexpr field multiplicative_generator() noexcept; diff --git a/barretenberg/cpp/src/barretenberg/ecc/fields/field_impl.hpp b/barretenberg/cpp/src/barretenberg/ecc/fields/field_impl.hpp index ca322101b764..2149e131241c 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/fields/field_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/fields/field_impl.hpp @@ -561,10 +561,10 @@ template constexpr field field::get_root_of_unity(size_t subgrou return r; } -template field field::random_element(numeric::random::Engine* engine) noexcept +template field field::random_element(numeric::RNG* engine) noexcept { if (engine == nullptr) { - engine = &numeric::random::get_engine(); + engine = &numeric::get_randomness(); } uint512_t source = engine->get_random_uint512(); diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.hpp b/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.hpp index 528bed056d3c..44f29ab98a8c 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.hpp @@ -77,9 +77,9 @@ template class alignas(64) affine_el * * @return A randomly chosen point on the curve */ - static affine_element random_element(numeric::random::Engine* engine = nullptr) noexcept; - static constexpr affine_element hash_to_curve(const std::vector& seed, uint8_t attempt_count = 0) noexcept - requires SupportsHashToCurve; + static affine_element random_element(numeric::RNG* engine = nullptr) noexcept; + static constexpr affine_element hash_to_curve( + const std::vector& seed, uint8_t attempt_count = 0) noexcept requires SupportsHashToCurve; constexpr bool operator==(const affine_element& other) const noexcept; diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.test.cpp b/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.test.cpp index eb2bdfbbffa1..4dd06af4c38f 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.test.cpp @@ -7,7 +7,6 @@ #include "barretenberg/serialize/test_helper.hpp" #include -namespace TestAffineElement { template class TestAffineElement : public testing::Test { using element = typename G1::element; using affine_element = typename G1::affine_element; @@ -130,4 +129,3 @@ TEST(AffineElement, Msgpack) auto [actual, expected] = msgpack_roundtrip(secp256k1::g1::affine_element{ 1, 1 }); EXPECT_EQ(actual, expected); } -} // namespace TestAffineElement diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element_impl.hpp b/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element_impl.hpp index 3c8b0d8504fd..9a87eee6f119 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element_impl.hpp @@ -221,9 +221,8 @@ constexpr std::optional> affine_element::de * @return constexpr affine_element */ template -constexpr affine_element affine_element::hash_to_curve(const std::vector& seed, - uint8_t attempt_count) noexcept - requires SupportsHashToCurve +constexpr affine_element affine_element::hash_to_curve( + const std::vector& seed, uint8_t attempt_count) noexcept requires SupportsHashToCurve { std::vector target_seed(seed); @@ -263,10 +262,10 @@ constexpr affine_element affine_element::hash_to_curve(con } template -affine_element affine_element::random_element(numeric::random::Engine* engine) noexcept +affine_element affine_element::random_element(numeric::RNG* engine) noexcept { if (engine == nullptr) { - engine = &numeric::random::get_engine(); + engine = &numeric::get_randomness(); } Fq x; diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/element.hpp b/barretenberg/cpp/src/barretenberg/ecc/groups/element.hpp index 639b32b366ba..637d3dda0a48 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/element.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/element.hpp @@ -49,7 +49,7 @@ template class alignas(32) element { constexpr operator affine_element() const noexcept; - static element random_element(numeric::random::Engine* engine = nullptr) noexcept; + static element random_element(numeric::RNG* engine = nullptr) noexcept; constexpr element dbl() const noexcept; constexpr void self_dbl() noexcept; @@ -106,7 +106,7 @@ template class alignas(32) element { element mul_with_endomorphism(const Fr& exponent) const noexcept; template > - static element random_coordinates_on_curve(numeric::random::Engine* engine = nullptr) noexcept; + static element random_coordinates_on_curve(numeric::RNG* engine = nullptr) noexcept; // { // bool found_one = false; // Fq yy; diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/element_impl.hpp b/barretenberg/cpp/src/barretenberg/ecc/groups/element_impl.hpp index 6a7cb0ada760..422065e42734 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/element_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/element_impl.hpp @@ -574,7 +574,7 @@ constexpr bool element::operator==(const element& other) const noexce } template -element element::random_element(numeric::random::Engine* engine) noexcept +element element::random_element(numeric::RNG* engine) noexcept { if constexpr (T::can_hash_to_curve) { element result = random_coordinates_on_curve(engine); @@ -1145,7 +1145,7 @@ void element::batch_normalize(element* elements, const size_t num_ele template template -element element::random_coordinates_on_curve(numeric::random::Engine* engine) noexcept +element element::random_coordinates_on_curve(numeric::RNG* engine) noexcept { bool found_one = false; Fq yy; diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/wnaf.test.cpp b/barretenberg/cpp/src/barretenberg/ecc/groups/wnaf.test.cpp index 01916f4c2bb6..7890577d64c1 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/wnaf.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/wnaf.test.cpp @@ -6,7 +6,7 @@ using namespace bb; namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } // NOLINTBEGIN(cppcoreguidelines-avoid-c-arrays) @@ -60,7 +60,7 @@ TEST(wnaf, WnafTwoBitWindow) constexpr uint32_t num_quads = (num_bits >> 1) + 1; uint64_t wnaf[num_quads] = { 0 }; bool skew = false; - bb::wnaf::fixed_wnaf<256, 1, window>(&input.data[0], wnaf, skew, 0); + wnaf::fixed_wnaf<256, 1, window>(&input.data[0], wnaf, skew, 0); /** * For representing even numbers, we define a skew: diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.test.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.test.cpp index da81ec37eda3..bd9951553141 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_composer.test.cpp @@ -12,19 +12,18 @@ #include "barretenberg/relations/relation_parameters.hpp" #include "barretenberg/sumcheck/sumcheck_round.hpp" +using namespace bb; using namespace bb::honk; -namespace test_eccvm_composer { - template class ECCVMComposerTests : public ::testing::Test { protected: // TODO(640): The Standard Honk on Grumpkin test suite fails unless the SRS is initialized for every test. void SetUp() override { if constexpr (std::is_same::value) { - bb::srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); + srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); } else { - bb::srs::init_crs_factory("../srs_db/ignition"); + srs::init_crs_factory("../srs_db/ignition"); } }; }; @@ -33,11 +32,11 @@ using FlavorTypes = ::testing::Types; TYPED_TEST_SUITE(ECCVMComposerTests, FlavorTypes); namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } -template bb::ECCVMCircuitBuilder generate_trace(numeric::random::Engine* engine = nullptr) +template ECCVMCircuitBuilder generate_trace(numeric::RNG* engine = nullptr) { - bb::ECCVMCircuitBuilder result; + ECCVMCircuitBuilder result; using G1 = typename Flavor::CycleGroup; using Fr = typename G1::Fr; @@ -102,4 +101,3 @@ TYPED_TEST(ECCVMComposerTests, EqFails) bool verified = verifier.verify_proof(proof); ASSERT_FALSE(verified); } -} // namespace test_eccvm_composer diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_transcript.test.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_transcript.test.cpp index 653275023654..c513bc991c4b 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_transcript.test.cpp @@ -6,6 +6,7 @@ #include "barretenberg/transcript/transcript.hpp" #include +using namespace bb; using namespace bb::honk; template class ECCVMTranscriptTests : public ::testing::Test { @@ -13,9 +14,9 @@ template class ECCVMTranscriptTests : public ::testing::Test { void SetUp() override { if constexpr (std::is_same::value) { - bb::srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); + srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); } else { - bb::srs::init_crs_factory("../srs_db/ignition"); + srs::init_crs_factory("../srs_db/ignition"); } }; using FF = typename Flavor::FF; @@ -183,9 +184,9 @@ template class ECCVMTranscriptTests : public ::testing::Test { return manifest_expected; } - bb::ECCVMCircuitBuilder generate_trace(numeric::random::Engine* engine = nullptr) + ECCVMCircuitBuilder generate_trace(numeric::RNG* engine = nullptr) { - bb::ECCVMCircuitBuilder result; + ECCVMCircuitBuilder result; using G1 = typename Flavor::CycleGroup; using Fr = typename G1::Fr; @@ -219,7 +220,7 @@ template class ECCVMTranscriptTests : public ::testing::Test { } }; -numeric::random::Engine& engine = numeric::random::get_debug_engine(); +numeric::RNG& engine = numeric::get_debug_randomness(); using FlavorTypes = testing::Types; diff --git a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp index 6af3285b00cf..2bf24f727f64 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ecc_vm.hpp @@ -26,8 +26,7 @@ // NOLINTBEGIN(cppcoreguidelines-avoid-const-or-ref-data-members) -namespace bb::honk { -namespace flavor { +namespace bb::honk::flavor { template class ECCVMBase { public: @@ -929,5 +928,4 @@ class ECCVM : public ECCVMBase #include -namespace bb::test_flavor { +using namespace bb; + TEST(Flavor, Getters) { - using Flavor = bb::honk::flavor::Ultra; + using Flavor = honk::flavor::Ultra; using FF = Flavor::FF; using ProvingKey = typename Flavor::ProvingKey; @@ -42,7 +43,7 @@ TEST(Flavor, Getters) TEST(Flavor, AllEntitiesSpecialMemberFunctions) { - using Flavor = bb::honk::flavor::Ultra; + using Flavor = honk::flavor::Ultra; using FF = Flavor::FF; using PartiallyEvaluatedMultivariates = Flavor::PartiallyEvaluatedMultivariates; using Polynomial = bb::Polynomial; @@ -68,7 +69,7 @@ TEST(Flavor, AllEntitiesSpecialMemberFunctions) TEST(Flavor, GetRow) { - using Flavor = bb::honk::flavor::Ultra; + using Flavor = honk::flavor::Ultra; using FF = typename Flavor::FF; std::array, Flavor::NUM_ALL_ENTITIES> data; std::generate(data.begin(), data.end(), []() { @@ -83,4 +84,3 @@ TEST(Flavor, GetRow) EXPECT_EQ(row0.q_elliptic, prover_polynomials.q_elliptic[0]); EXPECT_EQ(row1.w_4_shift, prover_polynomials.w_4_shift[1]); } -} // namespace bb::test_flavor diff --git a/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp b/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp index f0ec7f92ee82..c1f672eb177d 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/generated/AvmMini_flavor.hpp @@ -13,6 +13,7 @@ #include "barretenberg/flavor/flavor_macros.hpp" #include "barretenberg/polynomials/evaluation_domain.hpp" #include "barretenberg/polynomials/polynomial.hpp" +#include "barretenberg/relations/generated/AvmMini/alu_chip.hpp" #include "barretenberg/relations/generated/AvmMini/avm_mini.hpp" #include "barretenberg/relations/generated/AvmMini/mem_trace.hpp" #include "barretenberg/transcript/transcript.hpp" @@ -36,13 +37,13 @@ class AvmMiniFlavor { using RelationSeparator = FF; static constexpr size_t NUM_PRECOMPUTED_ENTITIES = 2; - static constexpr size_t NUM_WITNESS_ENTITIES = 38; + static constexpr size_t NUM_WITNESS_ENTITIES = 64; static constexpr size_t NUM_WIRES = NUM_WITNESS_ENTITIES + NUM_PRECOMPUTED_ENTITIES; // We have two copies of the witness entities, so we subtract the number of fixed ones (they have no shift), one for // the unshifted and one for the shifted - static constexpr size_t NUM_ALL_ENTITIES = 46; + static constexpr size_t NUM_ALL_ENTITIES = 80; - using Relations = std::tuple, AvmMini_vm::avm_mini>; + using Relations = std::tuple, AvmMini_vm::avm_mini, AvmMini_vm::mem_trace>; static constexpr size_t MAX_PARTIAL_RELATION_LENGTH = compute_max_partial_relation_length(); @@ -87,6 +88,32 @@ class AvmMiniFlavor { memTrace_m_in_tag, memTrace_m_tag_err, memTrace_m_one_min_inv, + aluChip_alu_clk, + aluChip_alu_ia, + aluChip_alu_ib, + aluChip_alu_ic, + aluChip_alu_op_add, + aluChip_alu_op_sub, + aluChip_alu_op_mul, + aluChip_alu_op_div, + aluChip_alu_ff_tag, + aluChip_alu_u8_tag, + aluChip_alu_u16_tag, + aluChip_alu_u32_tag, + aluChip_alu_u64_tag, + aluChip_alu_u128_tag, + aluChip_alu_u8_r0, + aluChip_alu_u8_r1, + aluChip_alu_u16_r0, + aluChip_alu_u16_r1, + aluChip_alu_u16_r2, + aluChip_alu_u16_r3, + aluChip_alu_u16_r4, + aluChip_alu_u16_r5, + aluChip_alu_u16_r6, + aluChip_alu_u16_r7, + aluChip_alu_u64_r0, + aluChip_alu_cf, avmMini_pc, avmMini_internal_return_ptr, avmMini_sel_internal_call, @@ -128,6 +155,32 @@ class AvmMiniFlavor { memTrace_m_in_tag, memTrace_m_tag_err, memTrace_m_one_min_inv, + aluChip_alu_clk, + aluChip_alu_ia, + aluChip_alu_ib, + aluChip_alu_ic, + aluChip_alu_op_add, + aluChip_alu_op_sub, + aluChip_alu_op_mul, + aluChip_alu_op_div, + aluChip_alu_ff_tag, + aluChip_alu_u8_tag, + aluChip_alu_u16_tag, + aluChip_alu_u32_tag, + aluChip_alu_u64_tag, + aluChip_alu_u128_tag, + aluChip_alu_u8_r0, + aluChip_alu_u8_r1, + aluChip_alu_u16_r0, + aluChip_alu_u16_r1, + aluChip_alu_u16_r2, + aluChip_alu_u16_r3, + aluChip_alu_u16_r4, + aluChip_alu_u16_r5, + aluChip_alu_u16_r6, + aluChip_alu_u16_r7, + aluChip_alu_u64_r0, + aluChip_alu_cf, avmMini_pc, avmMini_internal_return_ptr, avmMini_sel_internal_call, @@ -175,6 +228,32 @@ class AvmMiniFlavor { memTrace_m_in_tag, memTrace_m_tag_err, memTrace_m_one_min_inv, + aluChip_alu_clk, + aluChip_alu_ia, + aluChip_alu_ib, + aluChip_alu_ic, + aluChip_alu_op_add, + aluChip_alu_op_sub, + aluChip_alu_op_mul, + aluChip_alu_op_div, + aluChip_alu_ff_tag, + aluChip_alu_u8_tag, + aluChip_alu_u16_tag, + aluChip_alu_u32_tag, + aluChip_alu_u64_tag, + aluChip_alu_u128_tag, + aluChip_alu_u8_r0, + aluChip_alu_u8_r1, + aluChip_alu_u16_r0, + aluChip_alu_u16_r1, + aluChip_alu_u16_r2, + aluChip_alu_u16_r3, + aluChip_alu_u16_r4, + aluChip_alu_u16_r5, + aluChip_alu_u16_r6, + aluChip_alu_u16_r7, + aluChip_alu_u64_r0, + aluChip_alu_cf, avmMini_pc, avmMini_internal_return_ptr, avmMini_sel_internal_call, @@ -202,12 +281,20 @@ class AvmMiniFlavor { avmMini_mem_idx_b, avmMini_mem_idx_c, avmMini_last, - memTrace_m_rw_shift, + aluChip_alu_u16_r1_shift, + aluChip_alu_u16_r0_shift, + aluChip_alu_u16_r4_shift, + aluChip_alu_u16_r7_shift, + aluChip_alu_u16_r5_shift, + aluChip_alu_u16_r2_shift, + aluChip_alu_u16_r6_shift, + aluChip_alu_u16_r3_shift, + avmMini_pc_shift, + avmMini_internal_return_ptr_shift, memTrace_m_tag_shift, memTrace_m_addr_shift, memTrace_m_val_shift, - avmMini_internal_return_ptr_shift, - avmMini_pc_shift) + memTrace_m_rw_shift) RefVector get_wires() { @@ -224,6 +311,32 @@ class AvmMiniFlavor { memTrace_m_in_tag, memTrace_m_tag_err, memTrace_m_one_min_inv, + aluChip_alu_clk, + aluChip_alu_ia, + aluChip_alu_ib, + aluChip_alu_ic, + aluChip_alu_op_add, + aluChip_alu_op_sub, + aluChip_alu_op_mul, + aluChip_alu_op_div, + aluChip_alu_ff_tag, + aluChip_alu_u8_tag, + aluChip_alu_u16_tag, + aluChip_alu_u32_tag, + aluChip_alu_u64_tag, + aluChip_alu_u128_tag, + aluChip_alu_u8_r0, + aluChip_alu_u8_r1, + aluChip_alu_u16_r0, + aluChip_alu_u16_r1, + aluChip_alu_u16_r2, + aluChip_alu_u16_r3, + aluChip_alu_u16_r4, + aluChip_alu_u16_r5, + aluChip_alu_u16_r6, + aluChip_alu_u16_r7, + aluChip_alu_u64_r0, + aluChip_alu_cf, avmMini_pc, avmMini_internal_return_ptr, avmMini_sel_internal_call, @@ -251,12 +364,20 @@ class AvmMiniFlavor { avmMini_mem_idx_b, avmMini_mem_idx_c, avmMini_last, - memTrace_m_rw_shift, + aluChip_alu_u16_r1_shift, + aluChip_alu_u16_r0_shift, + aluChip_alu_u16_r4_shift, + aluChip_alu_u16_r7_shift, + aluChip_alu_u16_r5_shift, + aluChip_alu_u16_r2_shift, + aluChip_alu_u16_r6_shift, + aluChip_alu_u16_r3_shift, + avmMini_pc_shift, + avmMini_internal_return_ptr_shift, memTrace_m_tag_shift, memTrace_m_addr_shift, memTrace_m_val_shift, - avmMini_internal_return_ptr_shift, - avmMini_pc_shift }; + memTrace_m_rw_shift }; }; RefVector get_unshifted() { @@ -273,6 +394,32 @@ class AvmMiniFlavor { memTrace_m_in_tag, memTrace_m_tag_err, memTrace_m_one_min_inv, + aluChip_alu_clk, + aluChip_alu_ia, + aluChip_alu_ib, + aluChip_alu_ic, + aluChip_alu_op_add, + aluChip_alu_op_sub, + aluChip_alu_op_mul, + aluChip_alu_op_div, + aluChip_alu_ff_tag, + aluChip_alu_u8_tag, + aluChip_alu_u16_tag, + aluChip_alu_u32_tag, + aluChip_alu_u64_tag, + aluChip_alu_u128_tag, + aluChip_alu_u8_r0, + aluChip_alu_u8_r1, + aluChip_alu_u16_r0, + aluChip_alu_u16_r1, + aluChip_alu_u16_r2, + aluChip_alu_u16_r3, + aluChip_alu_u16_r4, + aluChip_alu_u16_r5, + aluChip_alu_u16_r6, + aluChip_alu_u16_r7, + aluChip_alu_u64_r0, + aluChip_alu_cf, avmMini_pc, avmMini_internal_return_ptr, avmMini_sel_internal_call, @@ -303,17 +450,23 @@ class AvmMiniFlavor { }; RefVector get_to_be_shifted() { - return { memTrace_m_rw, memTrace_m_tag, memTrace_m_addr, memTrace_m_val, avmMini_internal_return_ptr, - avmMini_pc }; + return { aluChip_alu_u16_r1, aluChip_alu_u16_r0, + aluChip_alu_u16_r4, aluChip_alu_u16_r7, + aluChip_alu_u16_r5, aluChip_alu_u16_r2, + aluChip_alu_u16_r6, aluChip_alu_u16_r3, + avmMini_pc, avmMini_internal_return_ptr, + memTrace_m_tag, memTrace_m_addr, + memTrace_m_val, memTrace_m_rw }; }; RefVector get_shifted() { - return { memTrace_m_rw_shift, - memTrace_m_tag_shift, - memTrace_m_addr_shift, - memTrace_m_val_shift, - avmMini_internal_return_ptr_shift, - avmMini_pc_shift }; + return { aluChip_alu_u16_r1_shift, aluChip_alu_u16_r0_shift, + aluChip_alu_u16_r4_shift, aluChip_alu_u16_r7_shift, + aluChip_alu_u16_r5_shift, aluChip_alu_u16_r2_shift, + aluChip_alu_u16_r6_shift, aluChip_alu_u16_r3_shift, + avmMini_pc_shift, avmMini_internal_return_ptr_shift, + memTrace_m_tag_shift, memTrace_m_addr_shift, + memTrace_m_val_shift, memTrace_m_rw_shift }; }; }; @@ -326,8 +479,13 @@ class AvmMiniFlavor { RefVector get_to_be_shifted() { - return { memTrace_m_rw, memTrace_m_tag, memTrace_m_addr, memTrace_m_val, avmMini_internal_return_ptr, - avmMini_pc }; + return { aluChip_alu_u16_r1, aluChip_alu_u16_r0, + aluChip_alu_u16_r4, aluChip_alu_u16_r7, + aluChip_alu_u16_r5, aluChip_alu_u16_r2, + aluChip_alu_u16_r6, aluChip_alu_u16_r3, + avmMini_pc, avmMini_internal_return_ptr, + memTrace_m_tag, memTrace_m_addr, + memTrace_m_val, memTrace_m_rw }; }; // The plookup wires that store plookup read data. @@ -417,6 +575,32 @@ class AvmMiniFlavor { Base::memTrace_m_in_tag = "MEMTRACE_M_IN_TAG"; Base::memTrace_m_tag_err = "MEMTRACE_M_TAG_ERR"; Base::memTrace_m_one_min_inv = "MEMTRACE_M_ONE_MIN_INV"; + Base::aluChip_alu_clk = "ALUCHIP_ALU_CLK"; + Base::aluChip_alu_ia = "ALUCHIP_ALU_IA"; + Base::aluChip_alu_ib = "ALUCHIP_ALU_IB"; + Base::aluChip_alu_ic = "ALUCHIP_ALU_IC"; + Base::aluChip_alu_op_add = "ALUCHIP_ALU_OP_ADD"; + Base::aluChip_alu_op_sub = "ALUCHIP_ALU_OP_SUB"; + Base::aluChip_alu_op_mul = "ALUCHIP_ALU_OP_MUL"; + Base::aluChip_alu_op_div = "ALUCHIP_ALU_OP_DIV"; + Base::aluChip_alu_ff_tag = "ALUCHIP_ALU_FF_TAG"; + Base::aluChip_alu_u8_tag = "ALUCHIP_ALU_U8_TAG"; + Base::aluChip_alu_u16_tag = "ALUCHIP_ALU_U16_TAG"; + Base::aluChip_alu_u32_tag = "ALUCHIP_ALU_U32_TAG"; + Base::aluChip_alu_u64_tag = "ALUCHIP_ALU_U64_TAG"; + Base::aluChip_alu_u128_tag = "ALUCHIP_ALU_U128_TAG"; + Base::aluChip_alu_u8_r0 = "ALUCHIP_ALU_U8_R0"; + Base::aluChip_alu_u8_r1 = "ALUCHIP_ALU_U8_R1"; + Base::aluChip_alu_u16_r0 = "ALUCHIP_ALU_U16_R0"; + Base::aluChip_alu_u16_r1 = "ALUCHIP_ALU_U16_R1"; + Base::aluChip_alu_u16_r2 = "ALUCHIP_ALU_U16_R2"; + Base::aluChip_alu_u16_r3 = "ALUCHIP_ALU_U16_R3"; + Base::aluChip_alu_u16_r4 = "ALUCHIP_ALU_U16_R4"; + Base::aluChip_alu_u16_r5 = "ALUCHIP_ALU_U16_R5"; + Base::aluChip_alu_u16_r6 = "ALUCHIP_ALU_U16_R6"; + Base::aluChip_alu_u16_r7 = "ALUCHIP_ALU_U16_R7"; + Base::aluChip_alu_u64_r0 = "ALUCHIP_ALU_U64_R0"; + Base::aluChip_alu_cf = "ALUCHIP_ALU_CF"; Base::avmMini_pc = "AVMMINI_PC"; Base::avmMini_internal_return_ptr = "AVMMINI_INTERNAL_RETURN_PTR"; Base::avmMini_sel_internal_call = "AVMMINI_SEL_INTERNAL_CALL"; @@ -474,6 +658,32 @@ class AvmMiniFlavor { Commitment memTrace_m_in_tag; Commitment memTrace_m_tag_err; Commitment memTrace_m_one_min_inv; + Commitment aluChip_alu_clk; + Commitment aluChip_alu_ia; + Commitment aluChip_alu_ib; + Commitment aluChip_alu_ic; + Commitment aluChip_alu_op_add; + Commitment aluChip_alu_op_sub; + Commitment aluChip_alu_op_mul; + Commitment aluChip_alu_op_div; + Commitment aluChip_alu_ff_tag; + Commitment aluChip_alu_u8_tag; + Commitment aluChip_alu_u16_tag; + Commitment aluChip_alu_u32_tag; + Commitment aluChip_alu_u64_tag; + Commitment aluChip_alu_u128_tag; + Commitment aluChip_alu_u8_r0; + Commitment aluChip_alu_u8_r1; + Commitment aluChip_alu_u16_r0; + Commitment aluChip_alu_u16_r1; + Commitment aluChip_alu_u16_r2; + Commitment aluChip_alu_u16_r3; + Commitment aluChip_alu_u16_r4; + Commitment aluChip_alu_u16_r5; + Commitment aluChip_alu_u16_r6; + Commitment aluChip_alu_u16_r7; + Commitment aluChip_alu_u64_r0; + Commitment aluChip_alu_cf; Commitment avmMini_pc; Commitment avmMini_internal_return_ptr; Commitment avmMini_sel_internal_call; @@ -531,6 +741,32 @@ class AvmMiniFlavor { memTrace_m_in_tag = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); memTrace_m_tag_err = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); memTrace_m_one_min_inv = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); + aluChip_alu_clk = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); + aluChip_alu_ia = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); + aluChip_alu_ib = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); + aluChip_alu_ic = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); + aluChip_alu_op_add = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); + aluChip_alu_op_sub = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); + aluChip_alu_op_mul = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); + aluChip_alu_op_div = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); + aluChip_alu_ff_tag = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); + aluChip_alu_u8_tag = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); + aluChip_alu_u16_tag = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); + aluChip_alu_u32_tag = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); + aluChip_alu_u64_tag = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); + aluChip_alu_u128_tag = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); + aluChip_alu_u8_r0 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); + aluChip_alu_u8_r1 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); + aluChip_alu_u16_r0 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); + aluChip_alu_u16_r1 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); + aluChip_alu_u16_r2 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); + aluChip_alu_u16_r3 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); + aluChip_alu_u16_r4 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); + aluChip_alu_u16_r5 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); + aluChip_alu_u16_r6 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); + aluChip_alu_u16_r7 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); + aluChip_alu_u64_r0 = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); + aluChip_alu_cf = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); avmMini_pc = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); avmMini_internal_return_ptr = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); avmMini_sel_internal_call = deserialize_from_buffer(Transcript::proof_data, num_bytes_read); @@ -592,6 +828,32 @@ class AvmMiniFlavor { serialize_to_buffer(memTrace_m_in_tag, Transcript::proof_data); serialize_to_buffer(memTrace_m_tag_err, Transcript::proof_data); serialize_to_buffer(memTrace_m_one_min_inv, Transcript::proof_data); + serialize_to_buffer(aluChip_alu_clk, Transcript::proof_data); + serialize_to_buffer(aluChip_alu_ia, Transcript::proof_data); + serialize_to_buffer(aluChip_alu_ib, Transcript::proof_data); + serialize_to_buffer(aluChip_alu_ic, Transcript::proof_data); + serialize_to_buffer(aluChip_alu_op_add, Transcript::proof_data); + serialize_to_buffer(aluChip_alu_op_sub, Transcript::proof_data); + serialize_to_buffer(aluChip_alu_op_mul, Transcript::proof_data); + serialize_to_buffer(aluChip_alu_op_div, Transcript::proof_data); + serialize_to_buffer(aluChip_alu_ff_tag, Transcript::proof_data); + serialize_to_buffer(aluChip_alu_u8_tag, Transcript::proof_data); + serialize_to_buffer(aluChip_alu_u16_tag, Transcript::proof_data); + serialize_to_buffer(aluChip_alu_u32_tag, Transcript::proof_data); + serialize_to_buffer(aluChip_alu_u64_tag, Transcript::proof_data); + serialize_to_buffer(aluChip_alu_u128_tag, Transcript::proof_data); + serialize_to_buffer(aluChip_alu_u8_r0, Transcript::proof_data); + serialize_to_buffer(aluChip_alu_u8_r1, Transcript::proof_data); + serialize_to_buffer(aluChip_alu_u16_r0, Transcript::proof_data); + serialize_to_buffer(aluChip_alu_u16_r1, Transcript::proof_data); + serialize_to_buffer(aluChip_alu_u16_r2, Transcript::proof_data); + serialize_to_buffer(aluChip_alu_u16_r3, Transcript::proof_data); + serialize_to_buffer(aluChip_alu_u16_r4, Transcript::proof_data); + serialize_to_buffer(aluChip_alu_u16_r5, Transcript::proof_data); + serialize_to_buffer(aluChip_alu_u16_r6, Transcript::proof_data); + serialize_to_buffer(aluChip_alu_u16_r7, Transcript::proof_data); + serialize_to_buffer(aluChip_alu_u64_r0, Transcript::proof_data); + serialize_to_buffer(aluChip_alu_cf, Transcript::proof_data); serialize_to_buffer(avmMini_pc, Transcript::proof_data); serialize_to_buffer(avmMini_internal_return_ptr, Transcript::proof_data); serialize_to_buffer(avmMini_sel_internal_call, Transcript::proof_data); diff --git a/barretenberg/cpp/src/barretenberg/flavor/generated/Toy_flavor.hpp b/barretenberg/cpp/src/barretenberg/flavor/generated/Toy_flavor.hpp index 63554a740639..faac5550be00 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/generated/Toy_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/generated/Toy_flavor.hpp @@ -17,8 +17,7 @@ #include "barretenberg/relations/generated/Toy/two_column_perm.hpp" #include "barretenberg/transcript/transcript.hpp" -namespace bb::honk { -namespace flavor { +namespace bb::honk::flavor { class ToyFlavor { public: @@ -368,5 +367,4 @@ class ToyFlavor { }; }; -} // namespace flavor -} // namespace bb::honk +} // namespace bb::honk::flavor diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp index 8629356b7267..5f13c7ac66b1 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra.hpp @@ -155,7 +155,7 @@ class GoblinUltra { // GoblinUltra needs to expose more public classes than most flavors due to GoblinUltraRecursive reuse, but these // are internal: - private: + public: // WireEntities for basic witness entities template class WireEntities { public: @@ -418,42 +418,8 @@ class GoblinUltra { template class VerifierCommitments_ : public AllEntities { public: - VerifierCommitments_(const std::shared_ptr& verification_key) - { - this->q_m = verification_key->q_m; - this->q_l = verification_key->q_l; - this->q_r = verification_key->q_r; - this->q_o = verification_key->q_o; - this->q_4 = verification_key->q_4; - this->q_c = verification_key->q_c; - this->q_arith = verification_key->q_arith; - this->q_sort = verification_key->q_sort; - this->q_elliptic = verification_key->q_elliptic; - this->q_aux = verification_key->q_aux; - this->q_lookup = verification_key->q_lookup; - this->q_busread = verification_key->q_busread; - this->q_poseidon2_external = verification_key->q_poseidon2_external; - this->q_poseidon2_internal = verification_key->q_poseidon2_internal; - this->sigma_1 = verification_key->sigma_1; - this->sigma_2 = verification_key->sigma_2; - this->sigma_3 = verification_key->sigma_3; - this->sigma_4 = verification_key->sigma_4; - this->id_1 = verification_key->id_1; - this->id_2 = verification_key->id_2; - this->id_3 = verification_key->id_3; - this->id_4 = verification_key->id_4; - this->table_1 = verification_key->table_1; - this->table_2 = verification_key->table_2; - this->table_3 = verification_key->table_3; - this->table_4 = verification_key->table_4; - this->lagrange_first = verification_key->lagrange_first; - this->lagrange_last = verification_key->lagrange_last; - this->lagrange_ecc_op = verification_key->lagrange_ecc_op; - this->databus_id = verification_key->databus_id; - } - VerifierCommitments_(const std::shared_ptr& verification_key, - const WitnessCommitments& witness_commitments) + const std::optional>& witness_commitments = std::nullopt) { this->q_m = verification_key->q_m; this->q_l = verification_key->q_l; @@ -486,19 +452,22 @@ class GoblinUltra { this->lagrange_ecc_op = verification_key->lagrange_ecc_op; this->databus_id = verification_key->databus_id; - this->w_l = witness_commitments.w_l; - this->w_r = witness_commitments.w_r; - this->w_o = witness_commitments.w_o; - this->sorted_accum = witness_commitments.sorted_accum; - this->w_4 = witness_commitments.w_4; - this->z_perm = witness_commitments.z_perm; - this->z_lookup = witness_commitments.z_lookup; - this->ecc_op_wire_1 = witness_commitments.ecc_op_wire_1; - this->ecc_op_wire_2 = witness_commitments.ecc_op_wire_2; - this->ecc_op_wire_3 = witness_commitments.ecc_op_wire_3; - this->calldata = witness_commitments.calldata; - this->calldata = witness_commitments.calldata_read_counts; - this->lookup_inverses = witness_commitments.lookup_inverses; + if (witness_commitments.has_value()) { + auto commitments = witness_commitments.value(); + this->w_l = commitments.w_l; + this->w_r = commitments.w_r; + this->w_o = commitments.w_o; + this->sorted_accum = commitments.sorted_accum; + this->w_4 = commitments.w_4; + this->z_perm = commitments.z_perm; + this->z_lookup = commitments.z_lookup; + this->ecc_op_wire_1 = commitments.ecc_op_wire_1; + this->ecc_op_wire_2 = commitments.ecc_op_wire_2; + this->ecc_op_wire_3 = commitments.ecc_op_wire_3; + this->calldata = commitments.calldata; + this->calldata = commitments.calldata_read_counts; + this->lookup_inverses = commitments.lookup_inverses; + } } }; // Specialize for GoblinUltra (general case used in GoblinUltraRecursive). diff --git a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp index 8c47654f6fe2..e1146ea4b701 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/goblin_ultra_recursive.hpp @@ -67,12 +67,14 @@ template class GoblinUltraRecursive_ { using Relations = GoblinUltra::Relations_; static constexpr size_t MAX_PARTIAL_RELATION_LENGTH = compute_max_partial_relation_length(); + static constexpr size_t MAX_TOTAL_RELATION_LENGTH = compute_max_total_relation_length(); // BATCHED_RELATION_PARTIAL_LENGTH = algebraic degree of sumcheck relation *after* multiplying by the `pow_zeta` // random polynomial e.g. For \sum(x) [A(x) * B(x) + C(x)] * PowZeta(X), relation length = 2 and random relation // length = 3 static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH = MAX_PARTIAL_RELATION_LENGTH + 1; - static constexpr size_t NUM_RELATIONS = std::tuple_size::value; + static constexpr size_t BATCHED_RELATION_TOTAL_LENGTH = MAX_TOTAL_RELATION_LENGTH + 1; + static constexpr size_t NUM_RELATIONS = std::tuple_size_v; // For instances of this flavour, used in folding, we need a unique sumcheck batching challenge for each // subrelation. This is because using powers of alpha would increase the degree of Protogalaxy polynomial $G$ (the @@ -104,6 +106,12 @@ template class GoblinUltraRecursive_ { */ class VerificationKey : public VerificationKey_> { public: + VerificationKey(const size_t circuit_size, const size_t num_public_inputs) + { + this->circuit_size = circuit_size; + this->log_circuit_size = numeric::get_msb(circuit_size); + this->num_public_inputs = num_public_inputs; + }; /** * @brief Construct a new Verification Key with stdlib types from a provided native verification * key @@ -112,9 +120,10 @@ template class GoblinUltraRecursive_ { * @param native_key Native verification key from which to extract the precomputed commitments */ VerificationKey(CircuitBuilder* builder, const std::shared_ptr& native_key) - : VerificationKey_>(native_key->circuit_size, - native_key->num_public_inputs) { + this->circuit_size = native_key->circuit_size; + this->log_circuit_size = numeric::get_msb(this->circuit_size); + this->num_public_inputs = native_key->num_public_inputs; this->q_m = Commitment::from_witness(builder, native_key->q_m); this->q_l = Commitment::from_witness(builder, native_key->q_l); this->q_r = Commitment::from_witness(builder, native_key->q_r); @@ -148,6 +157,11 @@ template class GoblinUltraRecursive_ { }; }; + /** + * @brief A container for the witness commitments. + */ + using WitnessCommitments = GoblinUltra::WitnessEntities; + using CommitmentLabels = GoblinUltra::CommitmentLabels; // Reuse the VerifierCommitments from GoblinUltra using VerifierCommitments = GoblinUltra::VerifierCommitments_; diff --git a/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp b/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp index 3bf08e29b8f4..2fd21fab3517 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ultra.hpp @@ -412,37 +412,8 @@ class Ultra { */ class VerifierCommitments : public AllEntities { public: - VerifierCommitments(const std::shared_ptr& verification_key) - { - q_m = verification_key->q_m; - q_c = verification_key->q_c; - q_l = verification_key->q_l; - q_r = verification_key->q_r; - q_o = verification_key->q_o; - q_4 = verification_key->q_4; - q_arith = verification_key->q_arith; - q_sort = verification_key->q_sort; - q_elliptic = verification_key->q_elliptic; - q_aux = verification_key->q_aux; - q_lookup = verification_key->q_lookup; - sigma_1 = verification_key->sigma_1; - sigma_2 = verification_key->sigma_2; - sigma_3 = verification_key->sigma_3; - sigma_4 = verification_key->sigma_4; - id_1 = verification_key->id_1; - id_2 = verification_key->id_2; - id_3 = verification_key->id_3; - id_4 = verification_key->id_4; - table_1 = verification_key->table_1; - table_2 = verification_key->table_2; - table_3 = verification_key->table_3; - table_4 = verification_key->table_4; - lagrange_first = verification_key->lagrange_first; - lagrange_last = verification_key->lagrange_last; - } - VerifierCommitments(const std::shared_ptr& verification_key, - const WitnessCommitments& witness_commitments) + const std::optional& witness_commitments = std::nullopt) { q_m = verification_key->q_m; q_c = verification_key->q_c; @@ -470,13 +441,16 @@ class Ultra { lagrange_first = verification_key->lagrange_first; lagrange_last = verification_key->lagrange_last; - w_l = witness_commitments.w_l; - w_r = witness_commitments.w_r; - w_o = witness_commitments.w_o; - sorted_accum = witness_commitments.sorted_accum; - w_4 = witness_commitments.w_4; - z_perm = witness_commitments.z_perm; - z_lookup = witness_commitments.z_lookup; + if (witness_commitments.has_value()) { + auto commitments = witness_commitments.value(); + this->w_l = commitments.w_l; + this->w_r = commitments.w_r; + this->w_o = commitments.w_o; + this->sorted_accum = commitments.sorted_accum; + this->w_4 = commitments.w_4; + this->z_perm = commitments.z_perm; + this->z_lookup = commitments.z_lookup; + } } }; diff --git a/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp b/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp index ea9303c7c878..94955d72f759 100644 --- a/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp +++ b/barretenberg/cpp/src/barretenberg/flavor/ultra_recursive.hpp @@ -79,11 +79,15 @@ template class UltraRecursive_ { bb::AuxiliaryRelation>; static constexpr size_t MAX_PARTIAL_RELATION_LENGTH = compute_max_partial_relation_length(); + static_assert(MAX_PARTIAL_RELATION_LENGTH == 6); + static constexpr size_t MAX_TOTAL_RELATION_LENGTH = compute_max_total_relation_length(); + static_assert(MAX_TOTAL_RELATION_LENGTH == 12); // BATCHED_RELATION_PARTIAL_LENGTH = algebraic degree of sumcheck relation *after* multiplying by the `pow_zeta` // random polynomial e.g. For \sum(x) [A(x) * B(x) + C(x)] * PowZeta(X), relation length = 2 and random relation // length = 3 static constexpr size_t BATCHED_RELATION_PARTIAL_LENGTH = MAX_PARTIAL_RELATION_LENGTH + 1; + static constexpr size_t BATCHED_RELATION_TOTAL_LENGTH = MAX_TOTAL_RELATION_LENGTH + 1; static constexpr size_t NUM_RELATIONS = std::tuple_size::value; // For instances of this flavour, used in folding, we need a unique sumcheck batching challenges for each @@ -161,6 +165,12 @@ template class UltraRecursive_ { RefVector get_wires() { return { w_l, w_r, w_o, w_4 }; }; }; + public: + /** + * @brief A container for the witness commitments. + */ + using WitnessCommitments = WitnessEntities; + /** * @brief A base class labelling all entities (for instance, all of the polynomials used by the prover during * sumcheck) in this Honk variant along with particular subsets of interest @@ -229,6 +239,17 @@ template class UltraRecursive_ { }; }; + RefVector get_precomputed() + { + return { q_m, q_c, q_l, q_r, q_o, q_4, q_arith, q_sort, + q_elliptic, q_aux, q_lookup, sigma_1, sigma_2, sigma_3, sigma_4, id_1, + id_2, id_3, id_4, table_1, table_2, table_3, table_4, lagrange_first, + lagrange_last + + }; + } + + RefVector get_witness() { return { w_l, w_r, w_o, w_4, sorted_accum, z_perm, z_lookup }; }; RefVector get_to_be_shifted() { return { table_1, table_2, table_3, table_4, w_l, w_r, w_o, w_4, sorted_accum, z_perm, z_lookup }; @@ -251,6 +272,12 @@ template class UltraRecursive_ { */ class VerificationKey : public VerificationKey_> { public: + VerificationKey(const size_t circuit_size, const size_t num_public_inputs) + { + this->circuit_size = circuit_size; + this->log_circuit_size = numeric::get_msb(circuit_size); + this->num_public_inputs = num_public_inputs; + }; /** * @brief Construct a new Verification Key with stdlib types from a provided native verification key * @@ -258,8 +285,10 @@ template class UltraRecursive_ { * @param native_key Native verification key from which to extract the precomputed commitments */ VerificationKey(CircuitBuilder* builder, const std::shared_ptr& native_key) - : VerificationKey_>(native_key->circuit_size, native_key->num_public_inputs) { + this->circuit_size = native_key->circuit_size; + this->log_circuit_size = numeric::get_msb(this->circuit_size); + this->num_public_inputs = native_key->num_public_inputs; this->q_m = Commitment::from_witness(builder, native_key->q_m); this->q_l = Commitment::from_witness(builder, native_key->q_l); this->q_r = Commitment::from_witness(builder, native_key->q_r); @@ -317,38 +346,38 @@ template class UltraRecursive_ { this->z_lookup = "Z_LOOKUP"; this->sorted_accum = "SORTED_ACCUM"; - // The ones beginning with "__" are only used for debugging - this->q_c = "__Q_C"; - this->q_l = "__Q_L"; - this->q_r = "__Q_R"; - this->q_o = "__Q_O"; - this->q_4 = "__Q_4"; - this->q_m = "__Q_M"; - this->q_arith = "__Q_ARITH"; - this->q_sort = "__Q_SORT"; - this->q_elliptic = "__Q_ELLIPTIC"; - this->q_aux = "__Q_AUX"; - this->q_lookup = "__Q_LOOKUP"; - this->sigma_1 = "__SIGMA_1"; - this->sigma_2 = "__SIGMA_2"; - this->sigma_3 = "__SIGMA_3"; - this->sigma_4 = "__SIGMA_4"; - this->id_1 = "__ID_1"; - this->id_2 = "__ID_2"; - this->id_3 = "__ID_3"; - this->id_4 = "__ID_4"; - this->table_1 = "__TABLE_1"; - this->table_2 = "__TABLE_2"; - this->table_3 = "__TABLE_3"; - this->table_4 = "__TABLE_4"; - this->lagrange_first = "__LAGRANGE_FIRST"; - this->lagrange_last = "__LAGRANGE_LAST"; + this->q_c = "Q_C"; + this->q_l = "Q_L"; + this->q_r = "Q_R"; + this->q_o = "Q_O"; + this->q_4 = "Q_4"; + this->q_m = "Q_M"; + this->q_arith = "Q_ARITH"; + this->q_sort = "Q_SORT"; + this->q_elliptic = "Q_ELLIPTIC"; + this->q_aux = "Q_AUX"; + this->q_lookup = "Q_LOOKUP"; + this->sigma_1 = "SIGMA_1"; + this->sigma_2 = "SIGMA_2"; + this->sigma_3 = "SIGMA_3"; + this->sigma_4 = "SIGMA_4"; + this->id_1 = "ID_1"; + this->id_2 = "ID_2"; + this->id_3 = "ID_3"; + this->id_4 = "ID_4"; + this->table_1 = "TABLE_1"; + this->table_2 = "TABLE_2"; + this->table_3 = "TABLE_3"; + this->table_4 = "TABLE_4"; + this->lagrange_first = "LAGRANGE_FIRST"; + this->lagrange_last = "LAGRANGE_LAST"; }; }; class VerifierCommitments : public AllEntities { public: - VerifierCommitments(const std::shared_ptr& verification_key) + VerifierCommitments(const std::shared_ptr& verification_key, + const std::optional& witness_commitments = std::nullopt) { this->q_m = verification_key->q_m; this->q_l = verification_key->q_l; @@ -375,6 +404,17 @@ template class UltraRecursive_ { this->table_4 = verification_key->table_4; this->lagrange_first = verification_key->lagrange_first; this->lagrange_last = verification_key->lagrange_last; + + if (witness_commitments.has_value()) { + auto commitments = witness_commitments.value(); + this->w_l = commitments.w_l; + this->w_r = commitments.w_r; + this->w_o = commitments.w_o; + this->sorted_accum = commitments.sorted_accum; + this->w_4 = commitments.w_4; + this->z_perm = commitments.z_perm; + this->z_lookup = commitments.z_lookup; + } } }; diff --git a/barretenberg/cpp/src/barretenberg/goblin/full_goblin_recursion.test.cpp b/barretenberg/cpp/src/barretenberg/goblin/full_goblin_recursion.test.cpp index 088a341e29f5..5049b197e0ab 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/full_goblin_recursion.test.cpp +++ b/barretenberg/cpp/src/barretenberg/goblin/full_goblin_recursion.test.cpp @@ -10,21 +10,20 @@ #include "barretenberg/ultra_honk/ultra_composer.hpp" #include - +using namespace bb; using namespace bb::honk; -namespace goblin_recursion_tests { class GoblinRecursionTests : public ::testing::Test { protected: static void SetUpTestSuite() { - bb::srs::init_crs_factory("../srs_db/ignition"); - bb::srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); + srs::init_crs_factory("../srs_db/ignition"); + srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); } using Curve = curve::BN254; using FF = Curve::ScalarField; - using GoblinUltraBuilder = bb::GoblinUltraCircuitBuilder; + using GoblinUltraBuilder = GoblinUltraCircuitBuilder; using KernelInput = Goblin::AccumulationOutput; }; @@ -61,4 +60,3 @@ TEST_F(GoblinRecursionTests, Pseudo) } // TODO(https://github.com/AztecProtocol/barretenberg/issues/787) Expand these tests. -} // namespace goblin_recursion_tests diff --git a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp index 7ba019a6f8fe..aac0ef305ca9 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp +++ b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp @@ -84,12 +84,12 @@ class Goblin { std::unique_ptr eccvm_prover; std::unique_ptr translator_composer; - AccumulationOutput accumulator; // ACIRHACK - Proof proof_; // ACIRHACK + AccumulationOutput accumulator; // Used only for ACIR methods for now public: /** - * @brief If there is a previous merge proof, recursively verify it. Generate next accmulated proof and merge proof. + * @brief Construct a GUH proof and a merge proof for the present circuit. + * @details If there is a previous merge proof, recursively verify it. * * @param circuit_builder */ @@ -118,10 +118,12 @@ class Goblin { return { ultra_proof, instance->verification_key }; }; + /** + * @brief Construct an ECCVM proof and the translation polynomial evaluations + * + */ void prove_eccvm() { - goblin_proof.merge_proof = std::move(merge_proof); - eccvm_builder = std::make_unique(op_queue); eccvm_composer = std::make_unique(); eccvm_prover = std::make_unique(eccvm_composer->create_prover(*eccvm_builder)); @@ -129,6 +131,10 @@ class Goblin { goblin_proof.translation_evaluations = eccvm_prover->translation_evaluations; }; + /** + * @brief Construct a translator proof + * + */ void prove_translator() { translator_builder = std::make_unique( @@ -138,13 +144,28 @@ class Goblin { goblin_proof.translator_proof = translator_prover.construct_proof(); }; + /** + * @brief Constuct a full Goblin proof (ECCVM, Translator, merge) + * @details The merge proof is assumed to already have been constucted in the last accumulate step. It is simply + * moved into the final proof here. + * + * @return Proof + */ Proof prove() { + goblin_proof.merge_proof = std::move(merge_proof); prove_eccvm(); prove_translator(); return goblin_proof; }; + /** + * @brief Verify a full Goblin proof (ECCVM, Translator, merge) + * + * @param proof + * @return true + * @return false + */ bool verify(const Proof& proof) { MergeVerifier merge_verifier; @@ -162,14 +183,23 @@ class Goblin { return merge_verified && eccvm_verified && accumulator_construction_verified && translation_verified; }; - // ACIRHACK - AccumulationOutput accumulate_for_acir(GoblinUltraCircuitBuilder& circuit_builder) + // The methods below this point are to be used only for ACIR. They exist while the interface is in flux. Eventually + // there will be agreement and no acir-specific methods should be needed. + + /** + * @brief Construct a GUH proof for the given circuit. (No merge proof for now) + * + * @param circuit_builder + * @return std::vector + */ + std::vector accumulate_for_acir(GoblinUltraCircuitBuilder& circuit_builder) { - // Complete the circuit logic by recursively verifying previous merge proof if it exists - if (merge_proof_exists) { - RecursiveMergeVerifier merge_verifier{ &circuit_builder }; - [[maybe_unused]] auto pairing_points = merge_verifier.verify_proof(merge_proof); - } + // TODO(https://github.com/AztecProtocol/barretenberg/issues/811): no merge prover for now + // // Complete the circuit logic by recursively verifying previous merge proof if it exists + // if (merge_proof_exists) { + // RecursiveMergeVerifier merge_verifier{ &circuit_builder }; + // [[maybe_unused]] auto pairing_points = merge_verifier.verify_proof(merge_proof); + // } // Construct a Honk proof for the main circuit GoblinUltraComposer composer; @@ -177,6 +207,8 @@ class Goblin { auto prover = composer.create_prover(instance); auto ultra_proof = prover.construct_proof(); + accumulator = { ultra_proof, instance->verification_key }; + // TODO(https://github.com/AztecProtocol/barretenberg/issues/811): no merge prover for now since we're not // mocking the first set of ecc ops // // Construct and store the merge proof to be recursively verified on the next call to accumulate @@ -187,88 +219,56 @@ class Goblin { // merge_proof_exists = true; // } - accumulator = { ultra_proof, instance->verification_key }; - return accumulator; + return ultra_proof.proof_data; }; - // ACIRHACK - Proof prove_for_acir() + /** + * @brief Verify a GUH proof + * + * @param proof_buf + * @return true + * @return false + */ + bool verify_accumulator_for_acir(const std::vector& proof_buf) const { - Proof proof; - - proof.merge_proof = std::move(merge_proof); - - eccvm_builder = std::make_unique(op_queue); - eccvm_composer = std::make_unique(); - auto eccvm_prover = eccvm_composer->create_prover(*eccvm_builder); - proof.eccvm_proof = eccvm_prover.construct_proof(); - proof.translation_evaluations = eccvm_prover.translation_evaluations; + GoblinUltraVerifier verifier{ accumulator.verification_key }; + HonkProof proof{ proof_buf }; + bool verified = verifier.verify_proof(proof); - translator_builder = std::make_unique( - eccvm_prover.translation_batching_challenge_v, eccvm_prover.evaluation_challenge_x, op_queue); - translator_composer = std::make_unique(); - auto translator_prover = translator_composer->create_prover(*translator_builder, eccvm_prover.transcript); - proof.translator_proof = translator_prover.construct_proof(); + return verified; + } - proof_ = proof; // ACIRHACK - return proof; - }; + /** + * @brief Construct a Goblin proof + * + * @return Proof + */ + Proof prove_for_acir() { return prove(); }; - // ACIRHACK - bool verify_for_acir(const Proof& proof) const + /** + * @brief Verify a Goblin proof (excluding the merge proof for now) + * + * @return true + * @return false + */ + bool verify_for_acir() const { - // ACIRHACK + // TODO(https://github.com/AztecProtocol/barretenberg/issues/811): No merge proof for now // MergeVerifier merge_verifier; - // bool merge_verified = merge_verifier.verify_proof(proof.merge_proof); + // bool merge_verified = merge_verifier.verify_proof(goblin_proof.merge_proof); auto eccvm_verifier = eccvm_composer->create_verifier(*eccvm_builder); - bool eccvm_verified = eccvm_verifier.verify_proof(proof.eccvm_proof); + bool eccvm_verified = eccvm_verifier.verify_proof(goblin_proof.eccvm_proof); auto translator_verifier = translator_composer->create_verifier(*translator_builder, eccvm_verifier.transcript); - bool accumulator_construction_verified = translator_verifier.verify_proof(proof.translator_proof); + bool translation_accumulator_construction_verified = + translator_verifier.verify_proof(goblin_proof.translator_proof); // TODO(https://github.com/AztecProtocol/barretenberg/issues/799): Ensure translation_evaluations are passed // correctly - bool translation_verified = translator_verifier.verify_translation(proof.translation_evaluations); + bool translation_verified = translator_verifier.verify_translation(goblin_proof.translation_evaluations); - return /* merge_verified && */ eccvm_verified && accumulator_construction_verified && translation_verified; + return /* merge_verified && */ eccvm_verified && translation_accumulator_construction_verified && + translation_verified; }; - - // ACIRHACK - std::vector construct_proof(GoblinUltraCircuitBuilder& builder) - { - // Construct a GUH proof - accumulate_for_acir(builder); - - std::vector result(accumulator.proof.proof_data.size()); - - const auto insert = [&result](const std::vector& buf) { - result.insert(result.end(), buf.begin(), buf.end()); - }; - - insert(accumulator.proof.proof_data); - - // TODO(https://github.com/AztecProtocol/barretenberg/issues/819): Skip ECCVM/Translator proof for now - // std::vector goblin_proof = prove_for_acir().to_buffer(); - // insert(goblin_proof); - - return result; - } - - // ACIRHACK - bool verify_proof([[maybe_unused]] const bb::plonk::proof& proof) const - { - // ACIRHACK: to do this properly, extract the proof correctly or maybe share transcripts. - const auto extract_final_kernel_proof = [&]([[maybe_unused]] auto& input_proof) { return accumulator.proof; }; - - GoblinUltraVerifier verifier{ accumulator.verification_key }; - bool verified = verifier.verify_proof(extract_final_kernel_proof(proof)); - - // TODO(https://github.com/AztecProtocol/barretenberg/issues/819): Skip ECCVM/Translator verification for now - // const auto extract_goblin_proof = [&]([[maybe_unused]] auto& input_proof) { return proof_; }; - // auto goblin_proof = extract_goblin_proof(proof); - // verified = verified && verify_for_acir(goblin_proof); - - return verified; - } }; } // namespace bb \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/grumpkin_srs_gen/grumpkin_srs_gen.cpp b/barretenberg/cpp/src/barretenberg/grumpkin_srs_gen/grumpkin_srs_gen.cpp index f6e1f23c034b..ebd807012aab 100644 --- a/barretenberg/cpp/src/barretenberg/grumpkin_srs_gen/grumpkin_srs_gen.cpp +++ b/barretenberg/cpp/src/barretenberg/grumpkin_srs_gen/grumpkin_srs_gen.cpp @@ -72,7 +72,7 @@ int main(int argc, char** argv) bb::srs::Manifest manifest{ 0, 1, static_cast(subgroup_size), 0, static_cast(subgroup_size), 0, 0 }; - bb::srs::IO::write_transcript(&srs[0], manifest, srs_path); + bb::srs::IO::write_transcript(&srs[0], manifest, srs_path); return 0; } \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/constants.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/constants.hpp index b76efe183b04..395d85ef41a3 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/constants.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/constants.hpp @@ -4,7 +4,7 @@ #include #include -namespace join_split_example { +namespace bb::join_split_example { constexpr size_t DATA_TREE_DEPTH = 32; @@ -19,8 +19,8 @@ constexpr size_t MAX_NUM_ASSETS_BIT_LENGTH = 30; constexpr size_t MAX_NUM_ASSETS = 1 << MAX_NUM_ASSETS_BIT_LENGTH; constexpr size_t ALIAS_HASH_BIT_LENGTH = 224; -namespace ProofIds { +namespace proof_ids { enum { PADDING = 0, DEPOSIT = 1, WITHDRAW = 2, SEND = 3, ACCOUNT = 4, DEFI_DEPOSIT = 5, DEFI_CLAIM = 6 }; }; -} // namespace join_split_example +} // namespace bb::join_split_example diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/fixtures/user_context.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/fixtures/user_context.hpp index 5a9db57c0596..b5eb6901acea 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/fixtures/user_context.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/fixtures/user_context.hpp @@ -3,10 +3,9 @@ #include "barretenberg/ecc/curves/bn254/fr.hpp" #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" -namespace join_split_example { -namespace fixtures { +namespace bb::join_split_example::fixtures { -typedef crypto::schnorr::key_pair grumpkin_key_pair; +using grumpkin_key_pair = bb::crypto::schnorr_key_pair; struct user_context { bb::fr note_secret; @@ -18,18 +17,18 @@ struct user_context { inline bb::fr generate_alias_hash(std::string const& alias) { std::vector inputv(alias.begin(), alias.end()); - auto output = blake2::blake2s(inputv); + auto output = bb::crypto::blake2s(inputv); return bb::fr(uint256_t(from_buffer(output.data())) >> 32); } -inline grumpkin_key_pair create_key_pair(numeric::random::Engine* engine) +inline grumpkin_key_pair create_key_pair(numeric::RNG* engine) { grumpkin::fr priv_key = grumpkin::fr::random_element(engine); grumpkin::g1::affine_element pub_key = grumpkin::g1::one * priv_key; return { priv_key, pub_key }; } -inline user_context create_user_context(numeric::random::Engine* engine = nullptr) +inline user_context create_user_context(numeric::RNG* engine = nullptr) { uint8_t vk[] = { 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11 }; @@ -38,5 +37,4 @@ inline user_context create_user_context(numeric::random::Engine* engine = nullpt return { note_secret, create_key_pair(engine), { create_key_pair(engine), create_key_pair(engine) }, alias_hash }; } -} // namespace fixtures -} // namespace join_split_example +} // namespace bb::join_split_example::fixtures diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/compute_circuit_data.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/compute_circuit_data.hpp index 2a1f4b42343b..d3c9d30ab3e4 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/compute_circuit_data.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/compute_circuit_data.hpp @@ -13,8 +13,7 @@ #include #endif -namespace join_split_example { -namespace proofs { +namespace bb::join_split_example::proofs { struct circuit_data { circuit_data() @@ -83,7 +82,7 @@ circuit_data get_circuit_data(std::string const& name, info(name, ": Circuit size: ", builder.get_num_gates()); if (mock) { auto public_inputs = builder.get_public_inputs(); - ::join_split_example::proofs::mock::mock_circuit(mock_builder, public_inputs); + ::bb::join_split_example::proofs::mock::mock_circuit(mock_builder, public_inputs); info(name, ": Mock circuit size: ", mock_builder.get_num_gates()); benchmark_collator.benchmark_info_deferred(Composer::NAME_STRING, "Core", @@ -259,5 +258,4 @@ circuit_data get_circuit_data(std::string const& name, return data; } -} // namespace proofs -} // namespace join_split_example +} // namespace bb::join_split_example::proofs diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.cpp index f9f339d723eb..5224f662eac1 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.cpp @@ -1,29 +1,27 @@ #include "inner_proof_data.hpp" -namespace join_split_example { -namespace proofs { +namespace bb::join_split_example::proofs { using namespace bb; inner_proof_data::inner_proof_data(std::vector const& proof_data) { - proof_id = from_buffer(proof_data, InnerProofOffsets::PROOF_ID); - note_commitment1 = from_buffer(proof_data, InnerProofOffsets::NOTE_COMMITMENT1); - note_commitment2 = from_buffer(proof_data, InnerProofOffsets::NOTE_COMMITMENT2); - nullifier1 = from_buffer(proof_data, InnerProofOffsets::NULLIFIER1); - nullifier2 = from_buffer(proof_data, InnerProofOffsets::NULLIFIER2); - public_value = from_buffer(proof_data, InnerProofOffsets::PUBLIC_VALUE); - public_owner = from_buffer(proof_data, InnerProofOffsets::PUBLIC_OWNER); - asset_id = from_buffer(proof_data, InnerProofOffsets::PUBLIC_ASSET_ID); - merkle_root = from_buffer(proof_data, InnerProofOffsets::MERKLE_ROOT); - tx_fee = from_buffer(proof_data, InnerProofOffsets::TX_FEE); - tx_fee_asset_id = from_buffer(proof_data, InnerProofOffsets::TX_FEE_ASSET_ID); - bridge_call_data = from_buffer(proof_data, InnerProofOffsets::BRIDGE_CALL_DATA); - defi_deposit_value = from_buffer(proof_data, InnerProofOffsets::DEFI_DEPOSIT_VALUE); - defi_root = from_buffer(proof_data, InnerProofOffsets::DEFI_ROOT); - backward_link = from_buffer(proof_data, InnerProofOffsets::BACKWARD_LINK); - allow_chain = from_buffer(proof_data, InnerProofOffsets::ALLOW_CHAIN); + proof_id = from_buffer(proof_data, inner_proof_offsets::PROOF_ID); + note_commitment1 = from_buffer(proof_data, inner_proof_offsets::NOTE_COMMITMENT1); + note_commitment2 = from_buffer(proof_data, inner_proof_offsets::NOTE_COMMITMENT2); + nullifier1 = from_buffer(proof_data, inner_proof_offsets::NULLIFIER1); + nullifier2 = from_buffer(proof_data, inner_proof_offsets::NULLIFIER2); + public_value = from_buffer(proof_data, inner_proof_offsets::PUBLIC_VALUE); + public_owner = from_buffer(proof_data, inner_proof_offsets::PUBLIC_OWNER); + asset_id = from_buffer(proof_data, inner_proof_offsets::PUBLIC_ASSET_ID); + merkle_root = from_buffer(proof_data, inner_proof_offsets::MERKLE_ROOT); + tx_fee = from_buffer(proof_data, inner_proof_offsets::TX_FEE); + tx_fee_asset_id = from_buffer(proof_data, inner_proof_offsets::TX_FEE_ASSET_ID); + bridge_call_data = from_buffer(proof_data, inner_proof_offsets::BRIDGE_CALL_DATA); + defi_deposit_value = from_buffer(proof_data, inner_proof_offsets::DEFI_DEPOSIT_VALUE); + defi_root = from_buffer(proof_data, inner_proof_offsets::DEFI_ROOT); + backward_link = from_buffer(proof_data, inner_proof_offsets::BACKWARD_LINK); + allow_chain = from_buffer(proof_data, inner_proof_offsets::ALLOW_CHAIN); } -} // namespace proofs -} // namespace join_split_example +} // namespace bb::join_split_example::proofs diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.hpp index 7bc81c657b19..4778ed1eed48 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.hpp @@ -5,10 +5,9 @@ #include "barretenberg/numeric/uint256/uint256.hpp" #include -namespace join_split_example { -namespace proofs { +namespace bb::join_split_example::proofs { -namespace InnerProofFields { +namespace inner_proof_fields { enum { PROOF_ID, NOTE_COMMITMENT1, @@ -28,26 +27,26 @@ enum { ALLOW_CHAIN, NUM_FIELDS }; -} // namespace InnerProofFields +} // namespace inner_proof_fields -namespace InnerProofOffsets { +namespace inner_proof_offsets { enum { - PROOF_ID = InnerProofFields::PROOF_ID * 32, - NOTE_COMMITMENT1 = InnerProofFields::NOTE_COMMITMENT1 * 32, - NOTE_COMMITMENT2 = InnerProofFields::NOTE_COMMITMENT2 * 32, - NULLIFIER1 = InnerProofFields::NULLIFIER1 * 32, - NULLIFIER2 = InnerProofFields::NULLIFIER2 * 32, - PUBLIC_VALUE = InnerProofFields::PUBLIC_VALUE * 32, - PUBLIC_OWNER = InnerProofFields::PUBLIC_OWNER * 32, - PUBLIC_ASSET_ID = InnerProofFields::PUBLIC_ASSET_ID * 32, - MERKLE_ROOT = InnerProofFields::MERKLE_ROOT * 32, - TX_FEE = InnerProofFields::TX_FEE * 32, - TX_FEE_ASSET_ID = InnerProofFields::TX_FEE_ASSET_ID * 32, - BRIDGE_CALL_DATA = InnerProofFields::BRIDGE_CALL_DATA * 32, - DEFI_DEPOSIT_VALUE = InnerProofFields::DEFI_DEPOSIT_VALUE * 32, - DEFI_ROOT = InnerProofFields::DEFI_ROOT * 32, - BACKWARD_LINK = InnerProofFields::BACKWARD_LINK * 32, - ALLOW_CHAIN = InnerProofFields::ALLOW_CHAIN * 32, + PROOF_ID = inner_proof_fields::PROOF_ID * 32, + NOTE_COMMITMENT1 = inner_proof_fields::NOTE_COMMITMENT1 * 32, + NOTE_COMMITMENT2 = inner_proof_fields::NOTE_COMMITMENT2 * 32, + NULLIFIER1 = inner_proof_fields::NULLIFIER1 * 32, + NULLIFIER2 = inner_proof_fields::NULLIFIER2 * 32, + PUBLIC_VALUE = inner_proof_fields::PUBLIC_VALUE * 32, + PUBLIC_OWNER = inner_proof_fields::PUBLIC_OWNER * 32, + PUBLIC_ASSET_ID = inner_proof_fields::PUBLIC_ASSET_ID * 32, + MERKLE_ROOT = inner_proof_fields::MERKLE_ROOT * 32, + TX_FEE = inner_proof_fields::TX_FEE * 32, + TX_FEE_ASSET_ID = inner_proof_fields::TX_FEE_ASSET_ID * 32, + BRIDGE_CALL_DATA = inner_proof_fields::BRIDGE_CALL_DATA * 32, + DEFI_DEPOSIT_VALUE = inner_proof_fields::DEFI_DEPOSIT_VALUE * 32, + DEFI_ROOT = inner_proof_fields::DEFI_ROOT * 32, + BACKWARD_LINK = inner_proof_fields::BACKWARD_LINK * 32, + ALLOW_CHAIN = inner_proof_fields::ALLOW_CHAIN * 32, }; } @@ -98,5 +97,4 @@ inline std::ostream& operator<<(std::ostream& os, inner_proof_data const& data) // clang-format on } -} // namespace proofs -} // namespace join_split_example +} // namespace bb::join_split_example::proofs diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.test.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.test.cpp index f01df175b293..4721089cdc91 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.test.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/inner_proof_data/inner_proof_data.test.cpp @@ -2,10 +2,10 @@ #include using namespace bb; -using namespace join_split_example::proofs; +using namespace bb::join_split_example::proofs; namespace { -auto& rand_engine = numeric::random::get_debug_engine(); +auto& rand_engine = numeric::get_debug_randomness(); } TEST(client_proofs_inner_proof_data, test_proof_to_data) diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_circuit_data.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_circuit_data.cpp index c0bc5e6a6c3d..da7f5037d003 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_circuit_data.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_circuit_data.cpp @@ -5,13 +5,11 @@ #include "join_split_circuit.hpp" #include "sign_join_split_tx.hpp" -namespace join_split_example { -namespace proofs { -namespace join_split { +namespace bb::join_split_example::proofs::join_split { -using namespace join_split_example::proofs::join_split; +using namespace bb::join_split_example::proofs::join_split; using namespace bb::stdlib; -using namespace join_split_example::proofs::notes::native; +using namespace bb::join_split_example::proofs::notes::native; using namespace bb::stdlib::merkle_tree; join_split_tx noop_tx() @@ -29,7 +27,7 @@ join_split_tx noop_tx() auto gibberish_path = fr_hash_path(DATA_TREE_DEPTH, std::make_pair(fr::random_element(), fr::random_element())); join_split_tx tx; - tx.proof_id = ProofIds::DEPOSIT; + tx.proof_id = proof_ids::DEPOSIT; tx.public_value = 1; tx.public_owner = fr::one(); tx.asset_id = 0; @@ -72,6 +70,4 @@ circuit_data get_circuit_data(std::shared_ptr> const& srs, bool mock = false); -} // namespace join_split -} // namespace proofs -} // namespace join_split_example \ No newline at end of file +} // namespace bb::join_split_example::proofs::join_split \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_signing_data.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_signing_data.cpp index 4efcd5323dc6..4e8d063ba525 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_signing_data.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_signing_data.cpp @@ -2,18 +2,16 @@ #include "../notes/native/index.hpp" #include "barretenberg/crypto/pedersen_hash/pedersen.hpp" -namespace join_split_example { -namespace proofs { -namespace join_split { +namespace bb::join_split_example::proofs::join_split { using namespace notes::native; bb::fr compute_signing_data(join_split_tx const& tx) { auto proof_id = tx.proof_id; - auto is_deposit = proof_id == ProofIds::DEPOSIT; - auto is_withdraw = proof_id == ProofIds::WITHDRAW; - auto is_defi = proof_id == ProofIds::DEFI_DEPOSIT; + auto is_deposit = proof_id == proof_ids::DEPOSIT; + auto is_withdraw = proof_id == proof_ids::WITHDRAW; + auto is_defi = proof_id == proof_ids::DEFI_DEPOSIT; auto public_value = tx.public_value; auto public_asset_id = tx.asset_id * (is_deposit || is_withdraw); @@ -36,6 +34,4 @@ bb::fr compute_signing_data(join_split_tx const& tx) return crypto::pedersen_hash::hash(to_hash); } -} // namespace join_split -} // namespace proofs -} // namespace join_split_example +} // namespace bb::join_split_example::proofs::join_split diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_signing_data.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_signing_data.hpp index 6a6836220dd1..badab3da9fa8 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_signing_data.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/compute_signing_data.hpp @@ -1,12 +1,8 @@ #pragma once #include "join_split_tx.hpp" -namespace join_split_example { -namespace proofs { -namespace join_split { +namespace bb::join_split_example::proofs::join_split { bb::fr compute_signing_data(join_split_tx const& tx); -} // namespace join_split -} // namespace proofs -} // namespace join_split_example \ No newline at end of file +} \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/create_proof.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/create_proof.hpp index 2c3c3aa3ba15..b0f1ddd6c8f1 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/create_proof.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/create_proof.hpp @@ -4,9 +4,7 @@ #include "join_split_circuit.hpp" #include "sign_join_split_tx.hpp" -namespace join_split_example { -namespace proofs { -namespace join_split { +namespace bb::join_split_example::proofs::join_split { inline std::vector create_proof(join_split_tx const& tx, circuit_data const& cd) { @@ -24,6 +22,4 @@ inline std::vector create_proof(join_split_tx const& tx, circuit_data c return proof.proof_data; } -} // namespace join_split -} // namespace proofs -} // namespace join_split_example +} // namespace bb::join_split_example::proofs::join_split diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.cpp index 60b693723b4c..5eae28bf8de1 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.cpp @@ -4,9 +4,7 @@ #include "compute_circuit_data.hpp" #include "join_split_circuit.hpp" -namespace join_split_example { -namespace proofs { -namespace join_split { +namespace bb::join_split_example::proofs::join_split { using namespace bb::plonk; using namespace bb::stdlib::merkle_tree; @@ -32,7 +30,7 @@ void init_proving_key(bool mock) Builder builder; join_split_circuit(builder, tx); Composer composer; - join_split_example::proofs::mock::mock_circuit(builder, builder.get_public_inputs()); + bb::join_split_example::proofs::mock::mock_circuit(builder, builder.get_public_inputs()); proving_key = composer.compute_proving_key(builder); } } @@ -70,7 +68,7 @@ Prover new_join_split_prover(join_split_tx const& tx, bool mock) return composer.create_prover(builder); } else { Composer mock_proof_composer(proving_key, nullptr); - join_split_example::proofs::mock::mock_circuit(builder, builder.get_public_inputs()); + bb::join_split_example::proofs::mock::mock_circuit(builder, builder.get_public_inputs()); info("mock composer gates: ", builder.get_num_gates()); return mock_proof_composer.create_prover(builder); } @@ -97,6 +95,4 @@ std::shared_ptr get_verification_key() return verification_key; } -} // namespace join_split -} // namespace proofs -} // namespace join_split_example +} // namespace bb::join_split_example::proofs::join_split diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.hpp index a436d99f884a..42419078aba4 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.hpp @@ -3,9 +3,7 @@ #include "barretenberg/srs/factories/crs_factory.hpp" #include "join_split_tx.hpp" -namespace join_split_example { -namespace proofs { -namespace join_split { +namespace bb::join_split_example::proofs::join_split { void init_proving_key(bool mock); @@ -21,6 +19,4 @@ std::shared_ptr get_proving_key(); std::shared_ptr get_verification_key(); -} // namespace join_split -} // namespace proofs -} // namespace join_split_example +} // namespace bb::join_split_example::proofs::join_split diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.test.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.test.cpp index 2ae8253681a2..5d110351dbb8 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.test.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split.test.cpp @@ -11,7 +11,7 @@ #include "index.hpp" #include "join_split_circuit.hpp" -namespace join_split_example::proofs::join_split { +namespace bb::join_split_example::proofs::join_split { using namespace bb::stdlib::merkle_tree; @@ -28,7 +28,7 @@ constexpr bool CIRCUIT_CHANGE_EXPECTED = false; using namespace bb; using namespace bb::stdlib; using namespace bb::stdlib::merkle_tree; -using namespace join_split_example::proofs::notes::native; +using namespace bb::join_split_example::proofs::notes::native; using key_pair = join_split_example::fixtures::grumpkin_key_pair; auto create_account_leaf_data(fr const& account_alias_hash, @@ -43,7 +43,7 @@ class join_split_tests : public ::testing::Test { static constexpr size_t ACCOUNT_INDEX = 14; static void SetUpTestCase() { - bb::srs::init_crs_factory("../srs_db/ignition"); + srs::init_crs_factory("../srs_db/ignition"); init_proving_key(false); auto crs_factory = std::make_unique>("../srs_db/ignition"); init_verification_key(); @@ -179,7 +179,7 @@ class join_split_tests : public ::testing::Test { .input_nullifier = input_nullifier2 }; join_split_tx tx; - tx.proof_id = ProofIds::SEND; + tx.proof_id = proof_ids::SEND; tx.public_value = 0; tx.num_input_notes = 2; tx.input_index = input_indices; @@ -195,7 +195,7 @@ class join_split_tests : public ::testing::Test { tx.account_private_key = user.owner.private_key; tx.partial_claim_note.input_nullifier = 0; tx.alias_hash = - !account_required ? join_split_example::fixtures::generate_alias_hash("penguin") : user.alias_hash; + !account_required ? bb::join_split_example::fixtures::generate_alias_hash("penguin") : user.alias_hash; tx.account_required = account_required; // default to no chaining: tx.backward_link = 0; @@ -242,7 +242,7 @@ class join_split_tests : public ::testing::Test { value::value_note output_note2 = { 0, 0, 0, user.owner.public_key, user.note_secret, 0, input_nullifier2 }; join_split_tx tx; - tx.proof_id = ProofIds::SEND; + tx.proof_id = proof_ids::SEND; tx.public_value = 0; tx.public_owner = 0; tx.asset_id = 0; @@ -458,7 +458,7 @@ TEST_F(join_split_tests, test_invalid_num_input_notes_fails) TEST_F(join_split_tests, test_deposit_public_value_invalid_fails) { join_split_tx tx = zero_input_setup(); - tx.proof_id = ProofIds::DEPOSIT; + tx.proof_id = proof_ids::DEPOSIT; tx.public_value = 0; // <-- invalid, should be nonzero tx.public_owner = fr::random_element(); @@ -481,7 +481,7 @@ TEST_F(join_split_tests, test_send_public_value_invalid_fails) TEST_F(join_split_tests, test_withdraw_public_value_invalid_fails) { join_split_tx tx = simple_setup(); - tx.proof_id = ProofIds::WITHDRAW; + tx.proof_id = proof_ids::WITHDRAW; tx.public_value = 0; // <-- invalid - should be nonzero tx.public_owner = fr::random_element(); @@ -493,7 +493,7 @@ TEST_F(join_split_tests, test_withdraw_public_value_invalid_fails) TEST_F(join_split_tests, test_defi_deposit_public_value_invalid_fails) { join_split_tx tx = simple_setup(); - tx.proof_id = ProofIds::DEFI_DEPOSIT; + tx.proof_id = proof_ids::DEFI_DEPOSIT; tx.output_note[0].value = 0; tx.output_note[1].value = 99; tx.partial_claim_note.deposit_value = 50; @@ -512,7 +512,7 @@ TEST_F(join_split_tests, test_defi_deposit_public_value_invalid_fails) TEST_F(join_split_tests, test_deposit_public_owner_invalid_fails) { join_split_tx tx = zero_input_setup(); - tx.proof_id = ProofIds::DEPOSIT; + tx.proof_id = proof_ids::DEPOSIT; tx.public_value = 10; tx.public_owner = 0; // <-- invalid - should be nonzero @@ -535,7 +535,7 @@ TEST_F(join_split_tests, test_send_public_owner_invalid_fails) TEST_F(join_split_tests, test_withdraw_public_owner_invalid_fails) { join_split_tx tx = simple_setup(); - tx.proof_id = ProofIds::WITHDRAW; + tx.proof_id = proof_ids::WITHDRAW; tx.public_value = 10; tx.public_owner = 0; // <-- invalid - should be nonzero @@ -547,7 +547,7 @@ TEST_F(join_split_tests, test_withdraw_public_owner_invalid_fails) TEST_F(join_split_tests, test_defi_deposit_public_owner_invalid_fails) { join_split_tx tx = simple_setup(); - tx.proof_id = ProofIds::DEFI_DEPOSIT; + tx.proof_id = proof_ids::DEFI_DEPOSIT; tx.output_note[0].value = 0; tx.output_note[1].value = 99; tx.partial_claim_note.deposit_value = 50; @@ -566,7 +566,7 @@ TEST_F(join_split_tests, test_defi_deposit_public_owner_invalid_fails) TEST_F(join_split_tests, test_wrong_proof_id) { join_split_tx tx = zero_input_setup(); - tx.proof_id = ProofIds::DEFI_CLAIM; + tx.proof_id = proof_ids::DEFI_CLAIM; auto result = sign_and_verify_logic(tx, user.owner); EXPECT_FALSE(result.valid); @@ -593,7 +593,7 @@ TEST_F(join_split_tests, test_send_with_0_input_notes_fails) TEST_F(join_split_tests, test_withdraw_with_0_input_notes_fails) { join_split_tx tx = zero_input_setup(); - tx.proof_id = ProofIds::WITHDRAW; + tx.proof_id = proof_ids::WITHDRAW; tx.public_value = 10; tx.public_owner = fr::random_element(); @@ -605,7 +605,7 @@ TEST_F(join_split_tests, test_withdraw_with_0_input_notes_fails) TEST_F(join_split_tests, test_defi_deposit_with_0_input_notes_fails) { join_split_tx tx = zero_input_setup(); - tx.proof_id = ProofIds::DEFI_DEPOSIT; + tx.proof_id = proof_ids::DEFI_DEPOSIT; auto result = sign_and_verify_logic(tx, user.owner); EXPECT_FALSE(result.valid); @@ -655,7 +655,7 @@ TEST_F(join_split_tests, test_different_output_note_2_asset_id_fails) TEST_F(join_split_tests, test_deposit_but_different_input_note_2_asset_id_fails) { join_split_tx tx = simple_setup(); - tx.proof_id = ProofIds::DEPOSIT; + tx.proof_id = proof_ids::DEPOSIT; tx.public_value = 10; tx.public_owner = fr::random_element(); tx.input_note[1].asset_id = 3; @@ -678,7 +678,7 @@ TEST_F(join_split_tests, test_send_but_different_input_note_2_asset_id_fails) TEST_F(join_split_tests, test_withdraw_but_different_input_note_2_asset_id_fails) { join_split_tx tx = simple_setup(); - tx.proof_id = ProofIds::WITHDRAW; + tx.proof_id = proof_ids::WITHDRAW; tx.public_value = 10; tx.public_owner = fr::random_element(); tx.input_note[1].asset_id = 3; @@ -695,7 +695,7 @@ TEST_F(join_split_tests, test_withdraw_but_different_input_note_2_asset_id_fails TEST_F(join_split_tests, test_0_input_notes_and_detect_circuit_change) { join_split_tx tx = zero_input_setup(); - tx.proof_id = ProofIds::DEPOSIT; + tx.proof_id = proof_ids::DEPOSIT; tx.public_value = 30; tx.public_owner = fr::random_element(); tx.output_note[0].value = 30; @@ -731,7 +731,7 @@ TEST_F(join_split_tests, test_0_input_notes_create_dupicate_output_notes_fails) { join_split_tx tx = zero_input_setup(); - tx.proof_id = ProofIds::DEPOSIT; + tx.proof_id = proof_ids::DEPOSIT; tx.public_value = 30; tx.public_owner = fr::random_element(); tx.output_note[0].value = 15; @@ -748,7 +748,7 @@ TEST_F(join_split_tests, test_0_input_notes_create_dupicate_output_notes_fails_2 { join_split_tx tx = zero_input_setup(); - tx.proof_id = ProofIds::DEPOSIT; + tx.proof_id = proof_ids::DEPOSIT; tx.public_value = 30; tx.public_owner = fr::random_element(); tx.output_note[0].value = 15; @@ -767,7 +767,7 @@ TEST_F(join_split_tests, test_dummy_input_note_1_non_0_value_fails) { // Note: `tx.num_input_notes = 0` implies both inputs are 'dummy' join_split_tx tx = zero_input_setup(); - tx.proof_id = ProofIds::DEPOSIT; + tx.proof_id = proof_ids::DEPOSIT; tx.public_value = 10; tx.public_owner = fr::random_element(); tx.input_note[0].value = 10; @@ -782,7 +782,7 @@ TEST_F(join_split_tests, test_dummy_input_note_2_non_0_value_fails) { // Note: `tx.num_input_notes = 0` implies both inputs are 'dummy' join_split_tx tx = zero_input_setup(); - tx.proof_id = ProofIds::DEPOSIT; + tx.proof_id = proof_ids::DEPOSIT; tx.public_value = 10; tx.public_owner = fr::random_element(); tx.input_note[1].value = 10; @@ -826,13 +826,13 @@ TEST_F(join_split_tests, test_2_input_notes) join_split_tx tx = simple_setup(); auto result = sign_and_verify_logic(tx, user.owner); EXPECT_TRUE(result.valid); - EXPECT_EQ(result.public_inputs.size(), InnerProofFields::NUM_FIELDS); + EXPECT_EQ(result.public_inputs.size(), inner_proof_fields::NUM_FIELDS); } TEST_F(join_split_tests, test_0_output_notes) { join_split_tx tx = simple_setup(); - tx.proof_id = ProofIds::WITHDRAW; + tx.proof_id = proof_ids::WITHDRAW; tx.output_note[0].value = 0; tx.output_note[1].value = 0; tx.public_value = tx.input_note[0].value + tx.input_note[1].value; @@ -853,7 +853,7 @@ TEST_P(test_valid_allow_chain_permutations, ) tx.allow_chain = GetParam(); auto result = sign_and_verify_logic(tx, user.owner); EXPECT_TRUE(result.valid); - EXPECT_EQ(result.public_inputs[InnerProofFields::ALLOW_CHAIN], GetParam()); + EXPECT_EQ(result.public_inputs[inner_proof_fields::ALLOW_CHAIN], GetParam()); } INSTANTIATE_TEST_SUITE_P(join_split_tests, test_valid_allow_chain_permutations, ::testing::Values(0, 1, 2, 3)); @@ -900,7 +900,7 @@ void assign_backward_link(join_split_tx& tx, size_t& indicator) tx.backward_link = tx.input_note[1].commit(); break; default: - tx.backward_link = bb::fr::random_element(); + tx.backward_link = fr::random_element(); } } @@ -950,7 +950,7 @@ TEST_F(join_split_tests, test_propagated_input_note1_no_double_spend) TEST_F(join_split_tests, test_max_public_input) { join_split_tx tx = zero_input_setup(); - tx.proof_id = ProofIds::DEPOSIT; + tx.proof_id = proof_ids::DEPOSIT; tx.public_value = max_value; tx.output_note[0].value = max_value; tx.public_owner = fr::random_element(); @@ -961,7 +961,7 @@ TEST_F(join_split_tests, test_max_public_input) TEST_F(join_split_tests, test_overflow_public_value_fails) { join_split_tx tx = zero_input_setup(); - tx.proof_id = ProofIds::DEPOSIT; + tx.proof_id = proof_ids::DEPOSIT; tx.public_value = max_value + 1; tx.public_owner = fr::random_element(); @@ -977,13 +977,13 @@ TEST_F(join_split_tests, test_overflow_public_value_fails) TEST_F(join_split_tests, test_non_zero_tx_fee) { join_split_tx tx = zero_input_setup(); - tx.proof_id = ProofIds::DEPOSIT; + tx.proof_id = proof_ids::DEPOSIT; tx.public_value += 10; tx.public_owner = fr::random_element(); auto result = sign_and_verify_logic(tx, user.owner); EXPECT_TRUE(result.valid); - EXPECT_EQ(result.public_inputs[InnerProofFields::TX_FEE], 10); + EXPECT_EQ(result.public_inputs[inner_proof_fields::TX_FEE], 10); } TEST_F(join_split_tests, test_non_zero_tx_fee_zero_public_values) @@ -993,27 +993,27 @@ TEST_F(join_split_tests, test_non_zero_tx_fee_zero_public_values) auto result = sign_and_verify_logic(tx, user.owner); EXPECT_TRUE(result.valid); - EXPECT_EQ(result.public_inputs[InnerProofFields::TX_FEE], 10); + EXPECT_EQ(result.public_inputs[inner_proof_fields::TX_FEE], 10); } TEST_F(join_split_tests, test_max_tx_fee) { join_split_tx tx = zero_input_setup(); - auto tx_fee = (uint256_t(1) << join_split_example::TX_FEE_BIT_LENGTH) - 1; - tx.proof_id = ProofIds::DEPOSIT; + auto tx_fee = (uint256_t(1) << bb::join_split_example::TX_FEE_BIT_LENGTH) - 1; + tx.proof_id = proof_ids::DEPOSIT; tx.public_value += tx_fee; tx.public_owner = fr::random_element(); auto result = sign_and_verify_logic(tx, user.owner); EXPECT_TRUE(result.valid); - EXPECT_EQ(result.public_inputs[InnerProofFields::TX_FEE], fr(tx_fee)); + EXPECT_EQ(result.public_inputs[inner_proof_fields::TX_FEE], fr(tx_fee)); } TEST_F(join_split_tests, test_overflow_tx_fee_fails) { join_split_tx tx = simple_setup(); - auto tx_fee = uint256_t(1) << join_split_example::TX_FEE_BIT_LENGTH; - tx.proof_id = ProofIds::DEPOSIT; + auto tx_fee = uint256_t(1) << bb::join_split_example::TX_FEE_BIT_LENGTH; + tx.proof_id = proof_ids::DEPOSIT; tx.public_value += tx_fee; tx.public_owner = fr::random_element(); @@ -1104,7 +1104,7 @@ TEST_F(join_split_tests, test_random_output_note_owners) TEST_F(join_split_tests, test_tainted_output_owner_fails) { join_split_tx tx = simple_setup(); - tx.proof_id = ProofIds::DEPOSIT; + tx.proof_id = proof_ids::DEPOSIT; tx.public_value = 1; tx.signing_pub_key = user.owner.public_key; uint8_t public_owner[32] = { 0x01, 0xaa, 0x42, 0xd4, 0x72, 0x88, 0x8e, 0xae, 0xa5, 0x56, 0x39, @@ -1116,8 +1116,8 @@ TEST_F(join_split_tests, test_tainted_output_owner_fails) auto prover = new_join_split_prover(tx, false); auto proof = prover.construct_proof(); - EXPECT_EQ(proof.proof_data[InnerProofOffsets::PUBLIC_OWNER], 0x01); - proof.proof_data[InnerProofFields::PUBLIC_OWNER] = 0x02; + EXPECT_EQ(proof.proof_data[inner_proof_offsets::PUBLIC_OWNER], 0x01); + proof.proof_data[inner_proof_fields::PUBLIC_OWNER] = 0x02; EXPECT_FALSE(verify_proof(proof)); } @@ -1139,7 +1139,7 @@ TEST_F(join_split_tests, test_wrong_account_private_key_fails) TEST_F(join_split_tests, test_wrong_public_owner_sig_fail) { join_split_tx tx = simple_setup(); - tx.proof_id = ProofIds::DEPOSIT; + tx.proof_id = proof_ids::DEPOSIT; tx.public_value = 1; tx.public_owner = fr::random_element(); @@ -1265,7 +1265,7 @@ TEST_F(join_split_tests, test_defi_deposit_one_virtual_input) tx.output_note[1].input_nullifier = compute_nullifier(tx.input_note[1].commit(), user.owner.private_key, false); // input note 2 is a dummy note - tx.proof_id = ProofIds::DEFI_DEPOSIT; + tx.proof_id = proof_ids::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1289,7 +1289,7 @@ TEST_F(join_split_tests, test_defi_deposit_one_real_one_virtual_inputs) { join_split_tx tx = simple_setup({ 0, 11 }); - tx.proof_id = ProofIds::DEFI_DEPOSIT; + tx.proof_id = proof_ids::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1316,7 +1316,7 @@ TEST_F(join_split_tests, test_defi_deposit_one_virtual_one_real_inputs) { join_split_tx tx = simple_setup({ 10, 7 }); - tx.proof_id = ProofIds::DEFI_DEPOSIT; + tx.proof_id = proof_ids::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 110; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1342,7 +1342,7 @@ TEST_F(join_split_tests, test_defi_deposit_one_real_one_virtual_inputs_same_asse { join_split_tx tx = simple_setup({ 0, 12 }); - tx.proof_id = ProofIds::DEFI_DEPOSIT; + tx.proof_id = proof_ids::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1369,7 +1369,7 @@ TEST_F(join_split_tests, test_defi_deposit_two_real_inputs_different_asset_ids) { join_split_tx tx = simple_setup({ 0, 6 }); - tx.proof_id = ProofIds::DEFI_DEPOSIT; + tx.proof_id = proof_ids::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1396,7 +1396,7 @@ TEST_F(join_split_tests, test_defi_deposit_two_virtual_inputs_different_asset_id { join_split_tx tx = simple_setup({ 4, 9 }); - tx.proof_id = ProofIds::DEFI_DEPOSIT; + tx.proof_id = proof_ids::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1424,7 +1424,7 @@ TEST_F(join_split_tests, { join_split_tx tx = simple_setup({ 4, 10 }); - tx.proof_id = ProofIds::DEFI_DEPOSIT; + tx.proof_id = proof_ids::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1453,7 +1453,7 @@ TEST_F(join_split_tests, test_defi_deposit_two_real_inputs_different_asset_ids_a { join_split_tx tx = simple_setup({ 0, 7 }); - tx.proof_id = ProofIds::DEFI_DEPOSIT; + tx.proof_id = proof_ids::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1482,7 +1482,7 @@ TEST_F(join_split_tests, test_defi_deposit_two_real_inputs_different_asset_ids_a { join_split_tx tx = simple_setup({ 0, 6 }); - tx.proof_id = ProofIds::DEFI_DEPOSIT; + tx.proof_id = proof_ids::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 95; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1511,7 +1511,7 @@ TEST_F(join_split_tests, test_defi_invalid_tx_fee_asset_id_fails) { join_split_tx tx = simple_setup({ 0, 11 }); - tx.proof_id = ProofIds::DEFI_DEPOSIT; + tx.proof_id = proof_ids::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1541,7 +1541,7 @@ TEST_F(join_split_tests, test_defi_deposit_of_zero_fails) { join_split_tx tx = simple_setup(); - tx.proof_id = ProofIds::DEFI_DEPOSIT; + tx.proof_id = proof_ids::DEFI_DEPOSIT; tx.output_note[0].value = 0; tx.output_note[1].value = 0; tx.partial_claim_note.deposit_value = 0; // <-- should be > 0 @@ -1558,7 +1558,7 @@ TEST_F(join_split_tests, test_defi_deposit_of_zero_fails) TEST_F(join_split_tests, test_defi_non_zero_output_note_1_ignored) { join_split_tx tx = simple_setup(); - tx.proof_id = ProofIds::DEFI_DEPOSIT; + tx.proof_id = proof_ids::DEFI_DEPOSIT; tx.output_note[0].value = 10; // This should be ignored in fee calculation. tx.output_note[1].value = 100; tx.partial_claim_note.deposit_value = 50; @@ -1584,7 +1584,7 @@ TEST_F(join_split_tests, test_defi_non_zero_output_note_1_ignored) TEST_F(join_split_tests, test_defi_allow_chain_1_fails) { join_split_tx tx = simple_setup(); - tx.proof_id = ProofIds::DEFI_DEPOSIT; + tx.proof_id = proof_ids::DEFI_DEPOSIT; tx.output_note[1].value = 100; tx.partial_claim_note.deposit_value = 50; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1618,7 +1618,7 @@ TEST_F(join_split_tests, test_defi_deposit_incorrect_input_nullifier_in_partial_ tx.output_note[1].input_nullifier = compute_nullifier(tx.input_note[1].commit(), user.owner.private_key, false); // input note 2 is a dummy note - tx.proof_id = ProofIds::DEFI_DEPOSIT; + tx.proof_id = proof_ids::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = 1; // incorrect nullifier @@ -1647,7 +1647,7 @@ TEST_F(join_split_tests, test_defi_deposit_bridge_call_data_second_bridge_input_ { join_split_tx tx = simple_setup({ 0, 11 }); - tx.proof_id = ProofIds::DEFI_DEPOSIT; + tx.proof_id = proof_ids::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1679,7 +1679,7 @@ TEST_F(join_split_tests, test_defi_deposit_bridge_call_data_second_bridge_output tx.output_note[1].input_nullifier = compute_nullifier(tx.input_note[1].commit(), user.owner.private_key, false); // input note 2 is a dummy note - tx.proof_id = ProofIds::DEFI_DEPOSIT; + tx.proof_id = proof_ids::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1707,7 +1707,7 @@ TEST_F(join_split_tests, test_defi_deposit_second_bridge_input_in_use_but_same_b { join_split_tx tx = simple_setup(); - tx.proof_id = ProofIds::DEFI_DEPOSIT; + tx.proof_id = proof_ids::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 50; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; tx.output_note[1].value = 90; @@ -1742,7 +1742,7 @@ TEST_F(join_split_tests, test_defi_deposit_second_bridge_output_in_use_and_same_ tx.output_note[1].input_nullifier = compute_nullifier(tx.input_note[1].commit(), user.owner.private_key, false); // input note 2 is a dummy note - tx.proof_id = ProofIds::DEFI_DEPOSIT; + tx.proof_id = proof_ids::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1775,7 +1775,7 @@ TEST_F(join_split_tests, test_defi_deposit_second_bridge_output_in_use_but_same_ tx.output_note[1].input_nullifier = compute_nullifier(tx.input_note[1].commit(), user.owner.private_key, false); // input note 2 is a dummy note - tx.proof_id = ProofIds::DEFI_DEPOSIT; + tx.proof_id = proof_ids::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1809,7 +1809,7 @@ TEST_F(join_split_tests, test_defi_deposit_first_bridge_output_asset_id_virtual_ tx.output_note[1].input_nullifier = compute_nullifier(tx.input_note[1].commit(), user.owner.private_key, false); // input note 2 is a dummy note - tx.proof_id = ProofIds::DEFI_DEPOSIT; + tx.proof_id = proof_ids::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1840,7 +1840,7 @@ TEST_F(join_split_tests, test_defi_deposit_second_bridge_output_asset_id_virtual tx.output_note[1].input_nullifier = compute_nullifier(tx.input_note[1].commit(), user.owner.private_key, false); // input note 2 is a dummy note - tx.proof_id = ProofIds::DEFI_DEPOSIT; + tx.proof_id = proof_ids::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1877,7 +1877,7 @@ TEST_F(join_split_tests, test_defi_wrong_first_asset_id_in_bridge_call_data_fail tx.output_note[1].input_nullifier = compute_nullifier(tx.input_note[1].commit(), user.owner.private_key, false); // input note 2 is a dummy note - tx.proof_id = ProofIds::DEFI_DEPOSIT; + tx.proof_id = proof_ids::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1907,7 +1907,7 @@ TEST_F(join_split_tests, test_defi_bridge_call_data_config_second_input_in_use_b tx.output_note[1].input_nullifier = compute_nullifier(tx.input_note[1].commit(), user.owner.private_key, false); // input note 2 is a dummy note - tx.proof_id = ProofIds::DEFI_DEPOSIT; + tx.proof_id = proof_ids::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1934,7 +1934,7 @@ TEST_F(join_split_tests, test_defi_missing_second_asset_in_bridge_call_data_fail { join_split_tx tx = simple_setup({ 0, 11 }); - tx.proof_id = ProofIds::DEFI_DEPOSIT; + tx.proof_id = proof_ids::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1962,7 +1962,7 @@ TEST_F(join_split_tests, test_defi_wrong_second_asset_id_in_bridge_call_data_fai { join_split_tx tx = simple_setup({ 4, 9 }); - tx.proof_id = ProofIds::DEFI_DEPOSIT; + tx.proof_id = proof_ids::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -1996,7 +1996,7 @@ TEST_F(join_split_tests, test_repayment_logic) { join_split_tx tx = simple_setup({ 0, 11 }); - tx.proof_id = ProofIds::DEFI_DEPOSIT; + tx.proof_id = proof_ids::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; tx.output_note[1].value = 10; // <-- repaying some value back to the defi-depositor @@ -2023,7 +2023,7 @@ TEST_F(join_split_tests, test_virtual_note_repay_different_asset_id_fail) { join_split_tx tx = simple_setup({ 0, 11 }); - tx.proof_id = ProofIds::DEFI_DEPOSIT; + tx.proof_id = proof_ids::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; tx.output_note[1].asset_id = 3; // <-- different from any of the input notes' asset_ids @@ -2051,7 +2051,7 @@ TEST_F(join_split_tests, test_virtual_note_repay_different_asset_id_fail) TEST_F(join_split_tests, test_real_input_value_lt_virtual_input_value_fails) { join_split_tx tx = simple_setup({ 1, 11 }); - tx.proof_id = ProofIds::DEFI_DEPOSIT; + tx.proof_id = proof_ids::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; @@ -2222,7 +2222,7 @@ TEST_F(join_split_tests, test_incorrect_output_note_creator_pubkey_x) TEST_F(join_split_tests, test_deposit_construct_proof) { join_split_tx tx = zero_input_setup(); - tx.proof_id = ProofIds::DEPOSIT; + tx.proof_id = proof_ids::DEPOSIT; tx.public_value = 10; tx.public_owner = fr::random_element(); tx.output_note[0].value = 7; @@ -2244,7 +2244,7 @@ TEST_F(join_split_tests, test_deposit_construct_proof) auto output_note1_commitment = tx.output_note[0].commit(); auto output_note2_commitment = tx.output_note[1].commit(); - EXPECT_EQ(proof_data.proof_id, ProofIds::DEPOSIT); + EXPECT_EQ(proof_data.proof_id, proof_ids::DEPOSIT); EXPECT_EQ(proof_data.note_commitment1, output_note1_commitment); EXPECT_EQ(proof_data.note_commitment2, output_note2_commitment); EXPECT_EQ(proof_data.nullifier1, nullifier1); @@ -2265,7 +2265,7 @@ TEST_F(join_split_tests, test_deposit_construct_proof) TEST_F(join_split_tests, test_withdraw_full_proof) { join_split_tx tx = simple_setup(); - tx.proof_id = ProofIds::WITHDRAW; + tx.proof_id = proof_ids::WITHDRAW; tx.public_value = 10; tx.public_owner = fr::random_element(); tx.output_note[0].value -= 13; @@ -2289,7 +2289,7 @@ TEST_F(join_split_tests, test_withdraw_full_proof) auto output_note1_commitment = tx.output_note[0].commit(); auto output_note2_commitment = tx.output_note[1].commit(); - EXPECT_EQ(proof_data.proof_id, ProofIds::WITHDRAW); + EXPECT_EQ(proof_data.proof_id, proof_ids::WITHDRAW); EXPECT_EQ(proof_data.note_commitment1, output_note1_commitment); EXPECT_EQ(proof_data.note_commitment2, output_note2_commitment); EXPECT_EQ(proof_data.nullifier1, nullifier1); @@ -2330,7 +2330,7 @@ TEST_F(join_split_tests, test_private_send_full_proof) uint256_t nullifier1 = compute_nullifier(input_note1_commitment, user.owner.private_key, true); uint256_t nullifier2 = compute_nullifier(input_note2_commitment, user.owner.private_key, true); - EXPECT_EQ(proof_data.proof_id, ProofIds::SEND); + EXPECT_EQ(proof_data.proof_id, proof_ids::SEND); EXPECT_EQ(proof_data.note_commitment1, output_note1_commitment); EXPECT_EQ(proof_data.note_commitment2, output_note2_commitment); EXPECT_EQ(proof_data.nullifier1, nullifier1); @@ -2354,7 +2354,7 @@ TEST_F(join_split_tests, test_defi_deposit_full_proof) { join_split_tx tx = simple_setup(); - tx.proof_id = ProofIds::DEFI_DEPOSIT; + tx.proof_id = proof_ids::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 50; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; tx.output_note[1].value = 90; @@ -2394,7 +2394,7 @@ TEST_F(join_split_tests, test_defi_deposit_full_proof) uint256_t nullifier1 = compute_nullifier(input_note1_commitment, user.owner.private_key, true); uint256_t nullifier2 = compute_nullifier(input_note2_commitment, user.owner.private_key, true); - EXPECT_EQ(proof_data.proof_id, ProofIds::DEFI_DEPOSIT); + EXPECT_EQ(proof_data.proof_id, proof_ids::DEFI_DEPOSIT); EXPECT_EQ(proof_data.note_commitment1, output_note1_commitment); EXPECT_EQ(proof_data.note_commitment2, output_note2_commitment); EXPECT_EQ(proof_data.nullifier1, nullifier1); @@ -2416,7 +2416,7 @@ TEST_F(join_split_tests, test_repayment_full_proof) { join_split_tx tx = simple_setup({ 0, 11 }); - tx.proof_id = ProofIds::DEFI_DEPOSIT; + tx.proof_id = proof_ids::DEFI_DEPOSIT; tx.partial_claim_note.deposit_value = 90; tx.partial_claim_note.input_nullifier = tx.output_note[0].input_nullifier; tx.output_note[1].value = 10; // <-- repaying some value back to the defi-depositor @@ -2456,7 +2456,7 @@ TEST_F(join_split_tests, test_repayment_full_proof) uint256_t nullifier1 = compute_nullifier(input_note1_commitment, user.owner.private_key, true); uint256_t nullifier2 = compute_nullifier(input_note2_commitment, user.owner.private_key, true); - EXPECT_EQ(proof_data.proof_id, ProofIds::DEFI_DEPOSIT); + EXPECT_EQ(proof_data.proof_id, proof_ids::DEFI_DEPOSIT); EXPECT_EQ(proof_data.note_commitment1, output_note1_commitment); EXPECT_EQ(proof_data.note_commitment2, output_note2_commitment); EXPECT_EQ(proof_data.nullifier1, nullifier1); @@ -2497,7 +2497,7 @@ TEST_F(join_split_tests, test_send_two_virtual_notes_full_proof) uint256_t nullifier1 = compute_nullifier(input_note1_commitment, user.owner.private_key, true); uint256_t nullifier2 = compute_nullifier(input_note2_commitment, user.owner.private_key, true); - EXPECT_EQ(proof_data.proof_id, ProofIds::SEND); + EXPECT_EQ(proof_data.proof_id, proof_ids::SEND); EXPECT_EQ(proof_data.note_commitment1, output_note1_commitment); EXPECT_EQ(proof_data.note_commitment2, output_note2_commitment); EXPECT_EQ(proof_data.nullifier1, nullifier1); @@ -2514,4 +2514,4 @@ TEST_F(join_split_tests, test_send_two_virtual_notes_full_proof) EXPECT_TRUE(verify_proof(proof)); } -} // namespace join_split_example::proofs::join_split +} // namespace bb::join_split_example::proofs::join_split diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_circuit.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_circuit.cpp index 8a4523432b3b..847e7d15cff7 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_circuit.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_circuit.cpp @@ -8,14 +8,12 @@ #include "barretenberg/stdlib/merkle_tree/membership.hpp" #include "verify_signature.hpp" -namespace join_split_example { -namespace proofs { -namespace join_split { +namespace bb::join_split_example::proofs::join_split { using namespace bb::plonk; using namespace notes::circuit; using namespace bb::stdlib::merkle_tree; -using namespace crypto::schnorr; +using namespace bb::crypto; /** * Check that the input note data, follows the given hash paths, to the publically given merkle root. @@ -43,10 +41,10 @@ field_ct process_input_note(field_ct const& account_private_key, join_split_outputs join_split_circuit_component(join_split_inputs const& inputs) { - const bool_ct is_deposit = inputs.proof_id == field_ct(ProofIds::DEPOSIT); - const bool_ct is_withdraw = inputs.proof_id == field_ct(ProofIds::WITHDRAW); - const bool_ct is_send = inputs.proof_id == field_ct(ProofIds::SEND); - const bool_ct is_defi_deposit = inputs.proof_id == field_ct(ProofIds::DEFI_DEPOSIT); + const bool_ct is_deposit = inputs.proof_id == field_ct(proof_ids::DEPOSIT); + const bool_ct is_withdraw = inputs.proof_id == field_ct(proof_ids::WITHDRAW); + const bool_ct is_send = inputs.proof_id == field_ct(proof_ids::SEND); + const bool_ct is_defi_deposit = inputs.proof_id == field_ct(proof_ids::DEFI_DEPOSIT); const bool_ct not_defi_deposit = !is_defi_deposit; const bool_ct is_public_tx = is_deposit || is_withdraw; @@ -88,10 +86,10 @@ join_split_outputs join_split_circuit_component(join_split_inputs const& inputs) (is_public_tx == inputs.public_owner.is_zero()).assert_equal(false, "public owner invalid"); // Constrain the proof id. - inputs.proof_id.assert_is_in_set({ field_ct(ProofIds::DEPOSIT), - field_ct(ProofIds::WITHDRAW), - field_ct(ProofIds::SEND), - field_ct(ProofIds::DEFI_DEPOSIT) }, + inputs.proof_id.assert_is_in_set({ field_ct(proof_ids::DEPOSIT), + field_ct(proof_ids::WITHDRAW), + field_ct(proof_ids::SEND), + field_ct(proof_ids::DEFI_DEPOSIT) }, "invalid proof id"); // Check we're not joining the same input note. @@ -288,7 +286,7 @@ void join_split_circuit(Builder& builder, join_split_tx const& tx) // many constraints on the bridge_call_data's format and the bit_config's format: .partial_claim_note = claim::partial_claim_note_witness_data(builder, tx.partial_claim_note), .signing_pub_key = group_ct::from_witness(&builder, tx.signing_pub_key), - .signature = stdlib::schnorr::convert_signature(&builder, tx.signature), + .signature = stdlib::schnorr_convert_signature(&builder, tx.signature), .merkle_root = witness_ct(&builder, tx.old_data_root), .input_path1 = stdlib::merkle_tree::create_witness_hash_path(builder, tx.input_path[0]), .input_path2 = stdlib::merkle_tree::create_witness_hash_path(builder, tx.input_path[1]), @@ -327,6 +325,4 @@ void join_split_circuit(Builder& builder, join_split_tx const& tx) inputs.allow_chain.set_public(); } // namespace join_split -} // namespace join_split -} // namespace proofs -} // namespace join_split_example +} // namespace bb::join_split_example::proofs::join_split diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_circuit.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_circuit.hpp index 82e338fb3c0d..799f0228bfd5 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_circuit.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_circuit.hpp @@ -5,9 +5,7 @@ #include "barretenberg/join_split_example/types.hpp" #include "join_split_tx.hpp" -namespace join_split_example { -namespace proofs { -namespace join_split { +namespace bb::join_split_example::proofs::join_split { struct join_split_inputs { @@ -24,7 +22,7 @@ struct join_split_inputs { notes::circuit::value::witness_data output_note2; notes::circuit::claim::partial_claim_note_witness_data partial_claim_note; group_ct signing_pub_key; - schnorr::signature_bits signature; + schnorr_signature_bits signature; field_ct merkle_root; hash_path_ct input_path1; hash_path_ct input_path2; @@ -52,6 +50,4 @@ join_split_outputs join_split_circuit_component(join_split_inputs const& inputs) void join_split_circuit(Builder& builder, join_split_tx const& tx); -} // namespace join_split -} // namespace proofs -} // namespace join_split_example +} // namespace bb::join_split_example::proofs::join_split diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_js_parity.test.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_js_parity.test.cpp index 9891530b991f..6754c48cbd0d 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_js_parity.test.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_js_parity.test.cpp @@ -8,14 +8,12 @@ #include "barretenberg/stdlib/merkle_tree/index.hpp" #include "index.hpp" -namespace join_split_example { -namespace proofs { -namespace join_split { +namespace bb::join_split_example::proofs::join_split { using namespace bb; // using namespace bb::stdlib::types; using namespace bb::stdlib::merkle_tree; -using namespace join_split_example::proofs::notes::native; +using namespace bb::join_split_example::proofs::notes::native; using key_pair = join_split_example::fixtures::grumpkin_key_pair; /** @@ -104,7 +102,7 @@ TEST_F(join_split_js_parity_tests, test_full_proof) value::value_note output_note2 = { 50, 0, 0, public_key, note_secret, 0, input_note2_nullifier }; join_split_tx tx; - tx.proof_id = ProofIds::SEND; + tx.proof_id = proof_ids::SEND; tx.public_value = 0; tx.public_owner = 0; tx.asset_id = 0; @@ -138,7 +136,7 @@ TEST_F(join_split_js_parity_tests, test_full_proof) auto output_note1_commitment = tx.output_note[0].commit(); auto output_note2_commitment = tx.output_note[1].commit(); - EXPECT_EQ(proof_data.proof_id, ProofIds::SEND); + EXPECT_EQ(proof_data.proof_id, proof_ids::SEND); EXPECT_EQ(proof_data.note_commitment1, output_note1_commitment); EXPECT_EQ(proof_data.note_commitment2, output_note2_commitment); EXPECT_EQ(proof_data.nullifier1, uint256_t(input_note1_nullifier)); @@ -161,6 +159,4 @@ TEST_F(join_split_js_parity_tests, test_full_proof) // } } -} // namespace join_split -} // namespace proofs -} // namespace join_split_example +} // namespace bb::join_split_example::proofs::join_split diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.cpp index d1543e0123f0..9f7adae976d7 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.cpp @@ -1,9 +1,7 @@ #include "join_split_tx.hpp" #include "barretenberg/crypto/pedersen_commitment/pedersen.hpp" -namespace join_split_example { -namespace proofs { -namespace join_split { +namespace bb::join_split_example::proofs::join_split { using namespace bb; @@ -91,6 +89,4 @@ std::ostream& operator<<(std::ostream& os, join_split_tx const& tx) << "signature: " << tx.signature << "\n"; } -} // namespace join_split -} // namespace proofs -} // namespace join_split_example +} // namespace bb::join_split_example::proofs::join_split diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.hpp index 3a530778e9bf..eb1282f00065 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.hpp @@ -5,9 +5,7 @@ #include "barretenberg/join_split_example/types.hpp" #include "barretenberg/stdlib/merkle_tree/hash_path.hpp" -namespace join_split_example { -namespace proofs { -namespace join_split { +namespace bb::join_split_example::proofs::join_split { struct join_split_tx { uint32_t proof_id; @@ -33,7 +31,7 @@ struct join_split_tx { bb::fr backward_link; // 0: no link, otherwise: any commitment. uint32_t allow_chain; // 0: none, 1: output_note1, 2: output_note2 - crypto::schnorr::signature signature; + crypto::schnorr_signature signature; bool operator==(join_split_tx const&) const = default; }; @@ -43,6 +41,4 @@ void write(std::vector& buf, join_split_tx const& tx); std::ostream& operator<<(std::ostream& os, join_split_tx const& tx); -} // namespace join_split -} // namespace proofs -} // namespace join_split_example +} // namespace bb::join_split_example::proofs::join_split diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.test.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.test.cpp index 0c3c90bd9fd8..758ae4c1a30e 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.test.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/join_split_tx.test.cpp @@ -11,10 +11,10 @@ #include using namespace bb; -using namespace join_split_example::proofs::join_split; +using namespace bb::join_split_example::proofs::join_split; namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } TEST(client_proofs_join_split_tx, test_serialization) diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/sign_join_split_tx.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/sign_join_split_tx.cpp index cf379621bf79..f4ec6e2525d1 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/sign_join_split_tx.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/sign_join_split_tx.cpp @@ -2,29 +2,25 @@ #include "barretenberg/crypto/schnorr/schnorr.hpp" #include "compute_signing_data.hpp" -namespace join_split_example { -namespace proofs { -namespace join_split { +namespace bb::join_split_example::proofs::join_split { -using namespace crypto::schnorr; +using namespace bb::crypto; -signature sign_join_split_tx(join_split_tx const& tx, key_pair const& keys) +schnorr_signature sign_join_split_tx(join_split_tx const& tx, schnorr_key_pair const& keys) { fr hashed = compute_signing_data(tx); std::vector message(sizeof(fr)); fr::serialize_to_buffer(hashed, &message[0]); - crypto::schnorr::signature signature = - crypto::schnorr::construct_signature( + crypto::schnorr_signature signature = + crypto::schnorr_construct_signature( std::string(message.begin(), message.end()), keys); - auto result = crypto::schnorr::verify_signature( + auto result = crypto::schnorr_verify_signature( std::string(message.begin(), message.end()), keys.public_key, signature); ASSERT(result == true); return signature; } -} // namespace join_split -} // namespace proofs -} // namespace join_split_example +} // namespace bb::join_split_example::proofs::join_split diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/sign_join_split_tx.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/sign_join_split_tx.hpp index af100ddc9126..a02a35f2f295 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/sign_join_split_tx.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/sign_join_split_tx.hpp @@ -3,13 +3,9 @@ #include "barretenberg/crypto/schnorr/schnorr.hpp" #include "join_split_tx.hpp" -namespace join_split_example { -namespace proofs { -namespace join_split { +namespace bb::join_split_example::proofs::join_split { -crypto::schnorr::signature sign_join_split_tx(proofs::join_split::join_split_tx const& tx, - crypto::schnorr::key_pair const& keys); +crypto::schnorr_signature sign_join_split_tx(proofs::join_split::join_split_tx const& tx, + crypto::schnorr_key_pair const& keys); -} // namespace join_split -} // namespace proofs -} // namespace join_split_example +} diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/verify_signature.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/verify_signature.hpp index 2836c1cfbba1..2b39536a1357 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/verify_signature.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/join_split/verify_signature.hpp @@ -1,9 +1,7 @@ #include "barretenberg/stdlib/encryption/schnorr/schnorr.hpp" #include "barretenberg/stdlib/hash/pedersen/pedersen.hpp" -namespace join_split_example { -namespace proofs { -namespace join_split { +namespace bb::join_split_example::proofs::join_split { using namespace notes; @@ -17,16 +15,14 @@ inline void verify_signature(field_ct const& public_value, group_ct const& owner_pub_key, field_ct const& backward_link, field_ct const& allow_chain, - schnorr::signature_bits const& signature) + schnorr_signature_bits const& signature) { std::vector to_compress = { public_value, public_owner, public_asset_id, output_note1_commitment, output_note2_commitment, nullifier1, nullifier2, backward_link, allow_chain, }; byte_array_ct message = pedersen_hash::hash(to_compress); - verify_signature(message, owner_pub_key, signature); + schnorr_verify_signature(message, owner_pub_key, signature); } -} // namespace join_split -} // namespace proofs -} // namespace join_split_example +} // namespace bb::join_split_example::proofs::join_split diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/mock/mock_circuit.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/mock/mock_circuit.hpp index 3cfe9bbf57e8..0bd3b9bb7241 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/mock/mock_circuit.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/mock/mock_circuit.hpp @@ -2,9 +2,7 @@ #include "barretenberg/common/map.hpp" #include "barretenberg/stdlib/hash/pedersen/pedersen.hpp" #include "barretenberg/stdlib/primitives/field/field.hpp" -namespace join_split_example { -namespace proofs { -namespace mock { +namespace bb::join_split_example::proofs::mock { using namespace bb::plonk; @@ -19,6 +17,4 @@ template void mock_circuit(Builder& builder, std::vector deflag_asset_id(suint_ct const& asset_id); bool_ct get_asset_id_flag(suint_ct const& asset_id); -} // namespace join_split_example::proofs::notes::circuit +} // namespace bb::join_split_example::proofs::notes::circuit diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/bridge_call_data.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/bridge_call_data.hpp index 2ed9f244f554..d0d3015d9741 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/bridge_call_data.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/bridge_call_data.hpp @@ -4,10 +4,7 @@ #include "./asset_id.hpp" #include "barretenberg/join_split_example/types.hpp" -namespace join_split_example { -namespace proofs { -namespace notes { -namespace circuit { +namespace bb::join_split_example::proofs::notes::circuit { using namespace bb::stdlib; @@ -216,7 +213,4 @@ inline std::ostream& operator<<(std::ostream& os, bridge_call_data const& bridge return os; } -} // namespace circuit -} // namespace notes -} // namespace proofs -} // namespace join_split_example +} // namespace bb::join_split_example::proofs::notes::circuit diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/claim_note.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/claim_note.hpp index 832b47d1ccd3..385c99ae6300 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/claim_note.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/claim_note.hpp @@ -7,11 +7,7 @@ #include "create_partial_commitment.hpp" #include "witness_data.hpp" -namespace join_split_example { -namespace proofs { -namespace notes { -namespace circuit { -namespace claim { +namespace bb::join_split_example::proofs::notes::circuit::claim { using namespace bb::stdlib; @@ -62,8 +58,4 @@ struct claim_note { operator byte_array_ct() const { return byte_array_ct(commitment); } }; -} // namespace claim -} // namespace circuit -} // namespace notes -} // namespace proofs -} // namespace join_split_example +} // namespace bb::join_split_example::proofs::notes::circuit::claim diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/complete_partial_commitment.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/complete_partial_commitment.hpp index 9272b17abec3..a9ec8b999200 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/complete_partial_commitment.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/complete_partial_commitment.hpp @@ -3,11 +3,7 @@ #include "barretenberg/join_split_example/types.hpp" #include "barretenberg/stdlib/hash/pedersen/pedersen.hpp" -namespace join_split_example { -namespace proofs { -namespace notes { -namespace circuit { -namespace claim { +namespace bb::join_split_example::proofs::notes::circuit::claim { using namespace bb::stdlib; @@ -19,8 +15,4 @@ inline auto complete_partial_commitment(field_ct const& partial_commitment, GeneratorIndex::CLAIM_NOTE_COMMITMENT); } -} // namespace claim -} // namespace circuit -} // namespace notes -} // namespace proofs -} // namespace join_split_example +} // namespace bb::join_split_example::proofs::notes::circuit::claim diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/compute_nullifier.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/compute_nullifier.hpp index f7bb38511432..cc07f1f4e163 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/compute_nullifier.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/compute_nullifier.hpp @@ -4,11 +4,7 @@ #include "barretenberg/join_split_example/types.hpp" #include "barretenberg/stdlib/hash/pedersen/pedersen.hpp" -namespace join_split_example { -namespace proofs { -namespace notes { -namespace circuit { -namespace claim { +namespace bb::join_split_example::proofs::notes::circuit::claim { inline field_ct compute_nullifier(field_ct const& note_commitment) { @@ -23,8 +19,4 @@ inline field_ct compute_nullifier(field_ct const& note_commitment) // later spent, the value note nullifiers will not reveal that it is those notes being spent. } -} // namespace claim -} // namespace circuit -} // namespace notes -} // namespace proofs -} // namespace join_split_example +} // namespace bb::join_split_example::proofs::notes::circuit::claim diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/create_partial_commitment.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/create_partial_commitment.hpp index ce45e40600cb..5217deb70e1a 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/create_partial_commitment.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/create_partial_commitment.hpp @@ -3,11 +3,7 @@ #include "barretenberg/join_split_example/types.hpp" #include "barretenberg/stdlib/hash/pedersen/pedersen.hpp" -namespace join_split_example { -namespace proofs { -namespace notes { -namespace circuit { -namespace claim { +namespace bb::join_split_example::proofs::notes::circuit::claim { inline auto create_partial_commitment(field_ct const& deposit_value, field_ct const& bridge_call_data, @@ -18,8 +14,4 @@ inline auto create_partial_commitment(field_ct const& deposit_value, GeneratorIndex::CLAIM_NOTE_PARTIAL_COMMITMENT); } -} // namespace claim -} // namespace circuit -} // namespace notes -} // namespace proofs -} // namespace join_split_example +} // namespace bb::join_split_example::proofs::notes::circuit::claim diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/witness_data.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/witness_data.hpp index f84ccdd5132d..32cb510348e6 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/witness_data.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/claim/witness_data.hpp @@ -6,7 +6,7 @@ #include "../bridge_call_data.hpp" #include "barretenberg/join_split_example/types.hpp" -namespace join_split_example::proofs::notes::circuit::claim { +namespace bb::join_split_example::proofs::notes::circuit::claim { using namespace bb::stdlib; @@ -62,4 +62,4 @@ inline std::ostream& operator<<(std::ostream& os, partial_claim_note_witness_dat return os << "{ deposit_value: " << tx.deposit_value << ", bridge_call_data: " << tx.bridge_call_data_local.to_safe_uint() << " }"; } -} // namespace join_split_example::proofs::notes::circuit::claim +} // namespace bb::join_split_example::proofs::notes::circuit::claim diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/commit.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/commit.hpp index 07864e8fc9ca..b02dea089d29 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/commit.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/commit.hpp @@ -3,7 +3,7 @@ #include "create_partial_commitment.hpp" #include "witness_data.hpp" -namespace join_split_example::proofs::notes::circuit::value { +namespace bb::join_split_example::proofs::notes::circuit::value { inline auto commit(const witness_data& plaintext) { @@ -13,4 +13,4 @@ inline auto commit(const witness_data& plaintext) partial_commitment, plaintext.value, plaintext.asset_id, plaintext.input_nullifier); } -} // namespace join_split_example::proofs::notes::circuit::value \ No newline at end of file +} // namespace bb::join_split_example::proofs::notes::circuit::value \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/complete_partial_commitment.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/complete_partial_commitment.hpp index 73ad51bc7c6d..4ba7092534d1 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/complete_partial_commitment.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/complete_partial_commitment.hpp @@ -3,7 +3,7 @@ #include "../../constants.hpp" #include "barretenberg/join_split_example/types.hpp" #include "barretenberg/stdlib/hash/pedersen/pedersen.hpp" -namespace join_split_example::proofs::notes::circuit::value { +namespace bb::join_split_example::proofs::notes::circuit::value { inline auto complete_partial_commitment(field_ct const& value_note_partial_commitment, suint_ct const& value, @@ -14,4 +14,4 @@ inline auto complete_partial_commitment(field_ct const& value_note_partial_commi GeneratorIndex::VALUE_NOTE_COMMITMENT); } -} // namespace join_split_example::proofs::notes::circuit::value +} // namespace bb::join_split_example::proofs::notes::circuit::value diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.cpp index 29a8567aefd2..6a17318dfb1a 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.cpp @@ -2,7 +2,7 @@ #include "../../constants.hpp" #include "barretenberg/join_split_example/types.hpp" -namespace join_split_example::proofs::notes::circuit { +namespace bb::join_split_example::proofs::notes::circuit { using namespace bb; using namespace bb::stdlib; @@ -44,4 +44,4 @@ field_ct compute_nullifier(field_ct const& note_commitment, return field_ct(blake_result); } -} // namespace join_split_example::proofs::notes::circuit +} // namespace bb::join_split_example::proofs::notes::circuit diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.hpp index 6d20fd5ada9b..d2c26d6b2f8e 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.hpp @@ -1,10 +1,10 @@ #pragma once #include "barretenberg/join_split_example/types.hpp" -namespace join_split_example::proofs::notes::circuit { +namespace bb::join_split_example::proofs::notes::circuit { field_ct compute_nullifier(field_ct const& note_commitment, field_ct const& account_private_key, bool_ct const& is_note_in_use); -} // namespace join_split_example::proofs::notes::circuit +} // namespace bb::join_split_example::proofs::notes::circuit diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.test.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.test.cpp index 406fe7b7ed00..adb6b5aed9e0 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/compute_nullifier.test.cpp @@ -6,8 +6,8 @@ #include "barretenberg/join_split_example/types.hpp" #include -namespace join_split_example { -using namespace join_split_example::proofs::notes; +namespace bb::join_split_example { +using namespace bb::join_split_example::proofs::notes; TEST(compute_nullifier_circuit, native_consistency) { @@ -26,4 +26,4 @@ TEST(compute_nullifier_circuit, native_consistency) EXPECT_EQ(circuit_nullifier.get_value(), native_nullifier); } -} // namespace join_split_example \ No newline at end of file +} // namespace bb::join_split_example \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/create_partial_commitment.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/create_partial_commitment.hpp index 00ab2a189bf5..76247b194bcf 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/create_partial_commitment.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/create_partial_commitment.hpp @@ -3,7 +3,7 @@ #include "barretenberg/join_split_example/types.hpp" #include "barretenberg/stdlib/hash/pedersen/pedersen.hpp" -namespace join_split_example::proofs::notes::circuit::value { +namespace bb::join_split_example::proofs::notes::circuit::value { inline auto create_partial_commitment(field_ct const& secret, group_ct const& owner, @@ -14,4 +14,4 @@ inline auto create_partial_commitment(field_ct const& secret, GeneratorIndex::VALUE_NOTE_PARTIAL_COMMITMENT); } -} // namespace join_split_example::proofs::notes::circuit::value +} // namespace bb::join_split_example::proofs::notes::circuit::value diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/value_note.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/value_note.hpp index fbd70519be56..64af0f9cb416 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/value_note.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/value_note.hpp @@ -3,7 +3,7 @@ #include "commit.hpp" #include "witness_data.hpp" -namespace join_split_example::proofs::notes::circuit::value { +namespace bb::join_split_example::proofs::notes::circuit::value { using namespace bb::stdlib; @@ -31,4 +31,4 @@ struct value_note { operator byte_array_ct() const { return byte_array_ct(commitment); } }; -} // namespace join_split_example::proofs::notes::circuit::value +} // namespace bb::join_split_example::proofs::notes::circuit::value diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/value_note.test.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/value_note.test.cpp index 5e4acc727f1c..1353b58e8d71 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/value_note.test.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/value_note.test.cpp @@ -5,11 +5,11 @@ #include "value_note.hpp" #include -namespace join_split_example { +namespace bb::join_split_example { using namespace bb; using namespace bb::stdlib; -using namespace join_split_example::proofs::notes; -using namespace join_split_example::proofs::notes::circuit::value; +using namespace bb::join_split_example::proofs::notes; +using namespace bb::join_split_example::proofs::notes::circuit::value; class ValueNote : public ::testing::Test { protected: @@ -120,4 +120,4 @@ TEST_F(ValueNote, CommitWithOversizedAssetIdFails) bool proof_result = verifier.verify_proof(proof); EXPECT_EQ(proof_result, false); } -} // namespace join_split_example \ No newline at end of file +} // namespace bb::join_split_example \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/witness_data.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/witness_data.hpp index dba13cf16241..91cbb5128969 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/witness_data.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/circuit/value/witness_data.hpp @@ -2,7 +2,7 @@ #include "../../native/value/value_note.hpp" #include "barretenberg/join_split_example/types.hpp" -namespace join_split_example::proofs::notes::circuit::value { +namespace bb::join_split_example::proofs::notes::circuit::value { using namespace bb::stdlib; @@ -29,4 +29,4 @@ struct witness_data { } }; -} // namespace join_split_example::proofs::notes::circuit::value +} // namespace bb::join_split_example::proofs::notes::circuit::value diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/constants.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/constants.hpp index 02dd07b98fcc..9a081fd32499 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/constants.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/constants.hpp @@ -3,9 +3,7 @@ #include "barretenberg/numeric/uint256/uint256.hpp" #include -namespace join_split_example { -namespace proofs { -namespace notes { +namespace bb::join_split_example::proofs::notes { constexpr size_t ASSET_ID_BIT_LENGTH = 30; constexpr size_t NONCE_BIT_LENGTH = 32; @@ -40,6 +38,4 @@ constexpr uint32_t DEFI_BRIDGE_OUTPUT_B_ASSET_ID_LEN = MAX_NUM_ASSETS_BIT_LENGTH constexpr uint32_t DEFI_BRIDGE_BITCONFIG_LEN = 32; constexpr uint32_t DEFI_BRIDGE_AUX_DATA = 64; -} // namespace notes -} // namespace proofs -} // namespace join_split_example +} // namespace bb::join_split_example::proofs::notes diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/account_note.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/account_note.cpp index 24f19552897e..893602921a09 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/account_note.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/account_note.cpp @@ -2,11 +2,11 @@ #include "../../constants.hpp" #include "barretenberg/crypto/pedersen_hash/pedersen.hpp" -namespace join_split_example::proofs::notes::native::account { +namespace bb::join_split_example::proofs::notes::native::account { grumpkin::fq generate_account_commitment(const bb::fr& alias_hash, const bb::fr& owner_x, const bb::fr& signing_x) { - return crypto::pedersen_hash::hash({ alias_hash, owner_x, signing_x }, GeneratorIndex::ACCOUNT_NOTE_COMMITMENT); + return bb::crypto::pedersen_hash::hash({ alias_hash, owner_x, signing_x }, GeneratorIndex::ACCOUNT_NOTE_COMMITMENT); } grumpkin::fq account_note::commit() const @@ -14,4 +14,4 @@ grumpkin::fq account_note::commit() const return generate_account_commitment(alias_hash, owner_key.x, signing_key.x); } -} // namespace join_split_example::proofs::notes::native::account +} // namespace bb::join_split_example::proofs::notes::native::account diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/account_note.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/account_note.hpp index 25674ca4876d..b7970ab88418 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/account_note.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/account_note.hpp @@ -3,11 +3,7 @@ #include "barretenberg/crypto/pedersen_commitment/pedersen.hpp" #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" -namespace join_split_example { -namespace proofs { -namespace notes { -namespace native { -namespace account { +namespace bb::join_split_example::proofs::notes::native::account { grumpkin::fq generate_account_commitment(const bb::fr& alias_hash, const bb::fr& owner_x, const bb::fr& signing_x); @@ -19,8 +15,4 @@ struct account_note { grumpkin::fq commit() const; }; -} // namespace account -} // namespace native -} // namespace notes -} // namespace proofs -} // namespace join_split_example +} // namespace bb::join_split_example::proofs::notes::native::account diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/compute_account_alias_hash_nullifier.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/compute_account_alias_hash_nullifier.hpp index 0dbcdcfac8f9..a5b6c805f6f7 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/compute_account_alias_hash_nullifier.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/compute_account_alias_hash_nullifier.hpp @@ -3,7 +3,7 @@ #include "account_note.hpp" #include "barretenberg/crypto/pedersen_hash/pedersen.hpp" -namespace join_split_example::proofs::notes::native::account { +namespace bb::join_split_example::proofs::notes::native::account { using fr = bb::fr; @@ -14,4 +14,4 @@ inline fr compute_account_alias_hash_nullifier(fr const& alias_hash) crypto::GeneratorContext(notes::GeneratorIndex::ACCOUNT_ALIAS_HASH_NULLIFIER)); } -} // namespace join_split_example::proofs::notes::native::account +} // namespace bb::join_split_example::proofs::notes::native::account diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/compute_account_public_key_nullifier.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/compute_account_public_key_nullifier.hpp index d2bdc842f842..83ee8a6d1e3b 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/compute_account_public_key_nullifier.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/account/compute_account_public_key_nullifier.hpp @@ -3,7 +3,7 @@ #include "account_note.hpp" #include "barretenberg/crypto/pedersen_hash/pedersen.hpp" -namespace join_split_example::proofs::notes::native::account { +namespace bb::join_split_example::proofs::notes::native::account { using namespace bb; @@ -13,4 +13,4 @@ inline fr compute_account_public_key_nullifier(grumpkin::g1::affine_element cons notes::GeneratorIndex::ACCOUNT_PUBLIC_KEY_NULLIFIER); } -} // namespace join_split_example::proofs::notes::native::account +} // namespace bb::join_split_example::proofs::notes::native::account diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/asset_id.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/asset_id.cpp index 9749ad14cffe..06b1387e7934 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/asset_id.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/asset_id.cpp @@ -1,6 +1,6 @@ #include "../constants.hpp" -namespace join_split_example::proofs::notes::native { +namespace bb::join_split_example::proofs::notes::native { std::pair deflag_asset_id(uint32_t const& asset_id) { @@ -18,4 +18,4 @@ bool get_asset_id_flag(uint32_t const& asset_id) return is_virtual; } -} // namespace join_split_example::proofs::notes::native \ No newline at end of file +} // namespace bb::join_split_example::proofs::notes::native \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/asset_id.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/asset_id.hpp index dd1b21d59cd5..64046424d465 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/asset_id.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/asset_id.hpp @@ -2,10 +2,10 @@ #include #include -namespace join_split_example::proofs::notes::native { +namespace bb::join_split_example::proofs::notes::native { std::pair deflag_asset_id(uint32_t const& asset_id); bool get_asset_id_flag(uint32_t const& asset_id); -} // namespace join_split_example::proofs::notes::native \ No newline at end of file +} // namespace bb::join_split_example::proofs::notes::native \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/bridge_call_data.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/bridge_call_data.hpp index bfd852ba30dc..b27953722b19 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/bridge_call_data.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/bridge_call_data.hpp @@ -5,10 +5,7 @@ #include "barretenberg/crypto/pedersen_commitment/pedersen.hpp" #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" -namespace join_split_example { -namespace proofs { -namespace notes { -namespace native { +namespace bb::join_split_example::proofs::notes::native { /** * The bridge_call_data structure (with bit-lengths) is defined as follows: @@ -179,7 +176,4 @@ inline std::ostream& operator<<(std::ostream& os, bridge_call_data const& bridge return os; } -} // namespace native -} // namespace notes -} // namespace proofs -} // namespace join_split_example +} // namespace bb::join_split_example::proofs::notes::native diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/claim_note.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/claim_note.hpp index e023e426262e..b0574cad662c 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/claim_note.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/claim_note.hpp @@ -6,7 +6,7 @@ #include "complete_partial_commitment.hpp" #include "create_partial_commitment.hpp" -namespace join_split_example::proofs::notes::native::claim { +namespace bb::join_split_example::proofs::notes::native::claim { struct claim_note { uint256_t deposit_value; @@ -64,4 +64,4 @@ inline std::ostream& operator<<(std::ostream& os, claim_note const& note) " }"); } -} // namespace join_split_example::proofs::notes::native::claim +} // namespace bb::join_split_example::proofs::notes::native::claim diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/claim_note_tx_data.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/claim_note_tx_data.hpp index f15bc431e20d..ed3e72e58985 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/claim_note_tx_data.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/claim_note_tx_data.hpp @@ -4,11 +4,7 @@ #include "barretenberg/crypto/pedersen_commitment/pedersen.hpp" #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" -namespace join_split_example { -namespace proofs { -namespace notes { -namespace native { -namespace claim { +namespace bb::join_split_example::proofs::notes::native::claim { struct partial_claim_note_data { uint256_t deposit_value; @@ -43,8 +39,4 @@ inline void write(std::vector& buf, partial_claim_note_data const& note write(buf, note.input_nullifier); } -} // namespace claim -} // namespace native -} // namespace notes -} // namespace proofs -} // namespace join_split_example +} // namespace bb::join_split_example::proofs::notes::native::claim diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/complete_partial_commitment.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/complete_partial_commitment.hpp index 99dfa52da161..28a859634689 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/complete_partial_commitment.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/complete_partial_commitment.hpp @@ -4,7 +4,7 @@ #include "barretenberg/crypto/pedersen_hash/pedersen.hpp" #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" -namespace join_split_example::proofs::notes::native::claim { +namespace bb::join_split_example::proofs::notes::native::claim { inline auto complete_partial_commitment(grumpkin::fq const& claim_note_partial_commitment, uint32_t interaction_nonce, @@ -14,4 +14,4 @@ inline auto complete_partial_commitment(grumpkin::fq const& claim_note_partial_c GeneratorIndex::CLAIM_NOTE_COMMITMENT); } -} // namespace join_split_example::proofs::notes::native::claim +} // namespace bb::join_split_example::proofs::notes::native::claim diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/compute_nullifier.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/compute_nullifier.hpp index 86fa9a76dfaa..5273720b6d94 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/compute_nullifier.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/compute_nullifier.hpp @@ -4,11 +4,11 @@ #include "barretenberg/crypto/pedersen_hash/pedersen.hpp" #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" -namespace join_split_example::proofs::notes::native::claim { +namespace bb::join_split_example::proofs::notes::native::claim { inline auto compute_nullifier(grumpkin::fq const& note_commitment) { return crypto::pedersen_hash::hash({ note_commitment }, GeneratorIndex::CLAIM_NOTE_NULLIFIER); } -} // namespace join_split_example::proofs::notes::native::claim +} // namespace bb::join_split_example::proofs::notes::native::claim diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/create_partial_commitment.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/create_partial_commitment.hpp index ca0a5a549707..ef969a328057 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/create_partial_commitment.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/claim/create_partial_commitment.hpp @@ -3,7 +3,7 @@ #include "barretenberg/crypto/pedersen_hash/pedersen.hpp" #include "claim_note.hpp" -namespace join_split_example::proofs::notes::native::claim { +namespace bb::join_split_example::proofs::notes::native::claim { inline auto create_partial_commitment(uint256_t const& deposit_value, uint256_t const& bridge_call_data, @@ -15,4 +15,4 @@ inline auto create_partial_commitment(uint256_t const& deposit_value, GeneratorIndex::CLAIM_NOTE_PARTIAL_COMMITMENT); } -} // namespace join_split_example::proofs::notes::native::claim +} // namespace bb::join_split_example::proofs::notes::native::claim diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/complete_partial_commitment.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/complete_partial_commitment.hpp index 3efd99219e67..570ac1d21832 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/complete_partial_commitment.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/complete_partial_commitment.hpp @@ -2,15 +2,15 @@ #include "../../constants.hpp" #include "barretenberg/crypto/pedersen_hash/pedersen.hpp" -namespace join_split_example::proofs::notes::native::value { +namespace bb::join_split_example::proofs::notes::native::value { inline auto complete_partial_commitment(grumpkin::fq const& partial_commitment, uint256_t const& value, uint32_t asset_id, grumpkin::fq input_nullifier) { - return crypto::pedersen_hash::hash({ partial_commitment, value, asset_id, input_nullifier }, - GeneratorIndex::VALUE_NOTE_COMMITMENT); + return bb::crypto::pedersen_hash::hash({ partial_commitment, value, asset_id, input_nullifier }, + GeneratorIndex::VALUE_NOTE_COMMITMENT); }; -} // namespace join_split_example::proofs::notes::native::value +} // namespace bb::join_split_example::proofs::notes::native::value diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/compute_nullifier.cpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/compute_nullifier.cpp index 827690d6f6dc..92b7843902fd 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/compute_nullifier.cpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/compute_nullifier.cpp @@ -4,7 +4,7 @@ #include "barretenberg/crypto/pedersen_commitment/pedersen.hpp" #include "barretenberg/crypto/pedersen_hash/pedersen.hpp" -namespace join_split_example::proofs::notes::native { +namespace bb::join_split_example::proofs::notes::native { using namespace bb; @@ -26,9 +26,9 @@ fr compute_nullifier(grumpkin::fq const& note_commitment, }; auto hashed_inputs = crypto::pedersen_hash::hash(buf, GeneratorIndex::JOIN_SPLIT_NULLIFIER); - auto blake_result = blake2::blake2s(to_buffer(hashed_inputs)); + auto blake_result = bb::crypto::blake2s(to_buffer(hashed_inputs)); return from_buffer(blake_result); } -} // namespace join_split_example::proofs::notes::native +} // namespace bb::join_split_example::proofs::notes::native diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/compute_nullifier.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/compute_nullifier.hpp index 66f913d263d9..2f5c36eea5fe 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/compute_nullifier.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/compute_nullifier.hpp @@ -1,16 +1,10 @@ #pragma once #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" -namespace join_split_example { -namespace proofs { -namespace notes { -namespace native { +namespace bb::join_split_example::proofs::notes::native { bb::fr compute_nullifier(grumpkin::fq const& note_commitment, grumpkin::fr const& account_private_key, const bool is_note_in_use); -} // namespace native -} // namespace notes -} // namespace proofs -} // namespace join_split_example +} // namespace bb::join_split_example::proofs::notes::native diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/create_partial_commitment.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/create_partial_commitment.hpp index 56829f920061..3ffdeca198b7 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/create_partial_commitment.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/create_partial_commitment.hpp @@ -4,15 +4,15 @@ #include "barretenberg/crypto/pedersen_hash/pedersen.hpp" #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" -namespace join_split_example::proofs::notes::native::value { +namespace bb::join_split_example::proofs::notes::native::value { inline auto create_partial_commitment(bb::fr const& secret, grumpkin::g1::affine_element const& owner, bool account_required, bb::fr const& creator_pubkey) { - return crypto::pedersen_hash::hash({ secret, owner.x, owner.y, account_required, creator_pubkey }, - GeneratorIndex::VALUE_NOTE_PARTIAL_COMMITMENT); + return bb::crypto::pedersen_hash::hash({ secret, owner.x, owner.y, account_required, creator_pubkey }, + GeneratorIndex::VALUE_NOTE_PARTIAL_COMMITMENT); } -} // namespace join_split_example::proofs::notes::native::value +} // namespace bb::join_split_example::proofs::notes::native::value diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/value_note.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/value_note.hpp index 4010f060f84b..4912fa22cabb 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/value_note.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/notes/native/value/value_note.hpp @@ -5,11 +5,7 @@ #include "complete_partial_commitment.hpp" #include "create_partial_commitment.hpp" -namespace join_split_example { -namespace proofs { -namespace notes { -namespace native { -namespace value { +namespace bb::join_split_example::proofs::notes::native::value { using namespace bb; @@ -63,8 +59,4 @@ inline void write(std::vector& buf, value_note const& note) write(buf, note.input_nullifier); } -} // namespace value -} // namespace native -} // namespace notes -} // namespace proofs -} // namespace join_split_example +} // namespace bb::join_split_example::proofs::notes::native::value diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/verify.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/verify.hpp index 9d48d13f06b2..ba78fba3a5b5 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/proofs/verify.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/proofs/verify.hpp @@ -5,8 +5,7 @@ #include "barretenberg/stdlib/recursion/aggregation_state/aggregation_state.hpp" #include "barretenberg/stdlib/recursion/verifier/verifier.hpp" -namespace join_split_example { -namespace proofs { +namespace bb::join_split_example::proofs { template struct verify_result { verify_result() @@ -70,5 +69,4 @@ auto verify_logic_internal(Builder& builder, Tx& tx, CircuitData const& cd, char return result; } -} // namespace proofs -} // namespace join_split_example +} // namespace bb::join_split_example::proofs diff --git a/barretenberg/cpp/src/barretenberg/join_split_example/types.hpp b/barretenberg/cpp/src/barretenberg/join_split_example/types.hpp index 7d419cef5d05..68b0e79363d7 100644 --- a/barretenberg/cpp/src/barretenberg/join_split_example/types.hpp +++ b/barretenberg/cpp/src/barretenberg/join_split_example/types.hpp @@ -15,7 +15,7 @@ #include "barretenberg/stdlib/primitives/uint/uint.hpp" #include "barretenberg/stdlib/primitives/witness/witness.hpp" -namespace join_split_example { +namespace bb::join_split_example { using Builder = bb::UltraCircuitBuilder; using Composer = plonk::UltraComposer; @@ -39,8 +39,6 @@ using bn254 = bb::stdlib::bn254; using hash_path_ct = bb::stdlib::merkle_tree::hash_path; -namespace schnorr { -using signature_bits = bb::stdlib::schnorr::signature_bits; -} // namespace schnorr +using schnorr_signature_bits = bb::stdlib::schnorr_signature_bits; -} // namespace join_split_example \ No newline at end of file +} // namespace bb::join_split_example diff --git a/barretenberg/cpp/src/barretenberg/numeric/bitop/count_leading_zeros.hpp b/barretenberg/cpp/src/barretenberg/numeric/bitop/count_leading_zeros.hpp index c41877610c14..acf8179af94e 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/bitop/count_leading_zeros.hpp +++ b/barretenberg/cpp/src/barretenberg/numeric/bitop/count_leading_zeros.hpp @@ -3,7 +3,7 @@ #include "../uint256/uint256.hpp" #include -namespace numeric { +namespace bb::numeric { /** * Returns the number of leading 0 bits for a given integer type. @@ -49,4 +49,4 @@ template <> constexpr inline size_t count_leading_zeros(uint256_t con return 256; } -} // namespace numeric +} // namespace bb::numeric diff --git a/barretenberg/cpp/src/barretenberg/numeric/bitop/count_leading_zeros.test.cpp b/barretenberg/cpp/src/barretenberg/numeric/bitop/count_leading_zeros.test.cpp index c482c7d0a755..0849a881d08e 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/bitop/count_leading_zeros.test.cpp +++ b/barretenberg/cpp/src/barretenberg/numeric/bitop/count_leading_zeros.test.cpp @@ -1,6 +1,8 @@ #include "count_leading_zeros.hpp" #include +using namespace bb; + TEST(bitop, ClzUint3231) { uint32_t a = 0b00000000000000000000000000000001; diff --git a/barretenberg/cpp/src/barretenberg/numeric/bitop/get_msb.hpp b/barretenberg/cpp/src/barretenberg/numeric/bitop/get_msb.hpp index d3df553401b0..fc456a68a8e0 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/bitop/get_msb.hpp +++ b/barretenberg/cpp/src/barretenberg/numeric/bitop/get_msb.hpp @@ -2,7 +2,7 @@ #include #include #include -namespace numeric { +namespace bb::numeric { // from http://supertech.csail.mit.edu/papers/debruijn.pdf constexpr inline uint32_t get_msb32(const uint32_t in) @@ -43,4 +43,4 @@ template constexpr inline T get_msb(const T in) return (sizeof(T) <= 4) ? get_msb32(in) : get_msb64(in); } -} // namespace numeric \ No newline at end of file +} // namespace bb::numeric \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/numeric/bitop/get_msb.test.cpp b/barretenberg/cpp/src/barretenberg/numeric/bitop/get_msb.test.cpp index 044fb3bbfd9a..3abdd73b155e 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/bitop/get_msb.test.cpp +++ b/barretenberg/cpp/src/barretenberg/numeric/bitop/get_msb.test.cpp @@ -1,6 +1,8 @@ #include "get_msb.hpp" #include +using namespace bb; + TEST(bitop, GetMsbUint640Value) { uint64_t a = 0b00000000000000000000000000000000; diff --git a/barretenberg/cpp/src/barretenberg/numeric/bitop/keep_n_lsb.hpp b/barretenberg/cpp/src/barretenberg/numeric/bitop/keep_n_lsb.hpp index ee9859eecb6a..c03a3154e37f 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/bitop/keep_n_lsb.hpp +++ b/barretenberg/cpp/src/barretenberg/numeric/bitop/keep_n_lsb.hpp @@ -1,11 +1,11 @@ #pragma once #include -namespace numeric { +namespace bb::numeric { template inline T keep_n_lsb(T const& input, size_t num_bits) { return num_bits >= sizeof(T) * 8 ? input : input & ((T(1) << num_bits) - 1); } -} // namespace numeric +} // namespace bb::numeric diff --git a/barretenberg/cpp/src/barretenberg/numeric/bitop/pow.hpp b/barretenberg/cpp/src/barretenberg/numeric/bitop/pow.hpp index 295a5e5b4c7d..2e67afffc9a1 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/bitop/pow.hpp +++ b/barretenberg/cpp/src/barretenberg/numeric/bitop/pow.hpp @@ -3,7 +3,7 @@ #include "./get_msb.hpp" #include -namespace numeric { +namespace bb::numeric { constexpr uint64_t pow64(const uint64_t input, const uint64_t exponent) { if (input == 0) { @@ -31,4 +31,4 @@ constexpr bool is_power_of_two(uint64_t x) return (x != 0U) && ((x & (x - 1)) == 0U); } -} // namespace numeric \ No newline at end of file +} // namespace bb::numeric \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/numeric/bitop/rotate.hpp b/barretenberg/cpp/src/barretenberg/numeric/bitop/rotate.hpp index 1fc0cd1cfddf..5be15b96e385 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/bitop/rotate.hpp +++ b/barretenberg/cpp/src/barretenberg/numeric/bitop/rotate.hpp @@ -2,7 +2,7 @@ #include #include -namespace numeric { +namespace bb::numeric { constexpr inline uint64_t rotate64(const uint64_t value, const uint64_t rotation) { @@ -13,4 +13,4 @@ constexpr inline uint32_t rotate32(const uint32_t value, const uint32_t rotation { return rotation != 0U ? (value >> rotation) + (value << (32 - rotation)) : value; } -} // namespace numeric \ No newline at end of file +} // namespace bb::numeric \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/numeric/bitop/sparse_form.hpp b/barretenberg/cpp/src/barretenberg/numeric/bitop/sparse_form.hpp index dcc4a13315d3..c2a17193831e 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/bitop/sparse_form.hpp +++ b/barretenberg/cpp/src/barretenberg/numeric/bitop/sparse_form.hpp @@ -7,7 +7,7 @@ #include "../uint256/uint256.hpp" -namespace numeric { +namespace bb::numeric { inline std::vector slice_input(const uint256_t& input, const uint64_t base, const size_t num_slices) { @@ -154,4 +154,4 @@ template class sparse_int { uint64_t sparse_value; }; -} // namespace numeric +} // namespace bb::numeric diff --git a/barretenberg/cpp/src/barretenberg/numeric/random/engine.cpp b/barretenberg/cpp/src/barretenberg/numeric/random/engine.cpp index ff31c6136d8f..e8b5c4a940a8 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/random/engine.cpp +++ b/barretenberg/cpp/src/barretenberg/numeric/random/engine.cpp @@ -4,7 +4,7 @@ #include #include -namespace numeric::random { +namespace bb::numeric { namespace { auto generate_random_data() @@ -16,7 +16,7 @@ auto generate_random_data() } } // namespace -class RandomEngine : public Engine { +class RandomEngine : public RNG { public: uint8_t get_random_uint8() override { @@ -71,7 +71,7 @@ class RandomEngine : public Engine { } }; -class DebugEngine : public Engine { +class DebugEngine : public RNG { public: DebugEngine() // disable linting for this line: we want the DEBUG engine to produce predictable pseudorandom numbers! @@ -116,7 +116,7 @@ class DebugEngine : public Engine { /** * Used by tests to ensure consistent behavior. */ -Engine& get_debug_engine(bool reset) +RNG& get_debug_randomness(bool reset) { // static std::seed_seq seed({ 1, 2, 3, 4, 5 }); static DebugEngine debug_engine; @@ -129,11 +129,11 @@ Engine& get_debug_engine(bool reset) /** * Default engine. If wanting consistent proof construction, uncomment the line to return the debug engine. */ -Engine& get_engine() +RNG& get_randomness() { - // return get_debug_engine(); + // return get_debug_randomness(); static RandomEngine engine; return engine; } -} // namespace numeric::random +} // namespace bb::numeric diff --git a/barretenberg/cpp/src/barretenberg/numeric/random/engine.hpp b/barretenberg/cpp/src/barretenberg/numeric/random/engine.hpp index 9721f69886e1..aad7932bbbfb 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/random/engine.hpp +++ b/barretenberg/cpp/src/barretenberg/numeric/random/engine.hpp @@ -5,9 +5,9 @@ #include "unistd.h" #include -namespace numeric::random { +namespace bb::numeric { -class Engine { +class RNG { public: virtual uint8_t get_random_uint8() = 0; @@ -21,12 +21,12 @@ class Engine { virtual uint256_t get_random_uint256() = 0; - virtual ~Engine() = default; - Engine() noexcept = default; - Engine(const Engine& other) = default; - Engine(Engine&& other) = default; - Engine& operator=(const Engine& other) = default; - Engine& operator=(Engine&& other) = default; + virtual ~RNG() = default; + RNG() noexcept = default; + RNG(const RNG& other) = default; + RNG(RNG&& other) = default; + RNG& operator=(const RNG& other) = default; + RNG& operator=(RNG&& other) = default; uint512_t get_random_uint512() { @@ -45,7 +45,7 @@ class Engine { } }; -Engine& get_debug_engine(bool reset = false); -Engine& get_engine(); +RNG& get_debug_randomness(bool reset = false); +RNG& get_randomness(); -} // namespace numeric::random +} // namespace bb::numeric diff --git a/barretenberg/cpp/src/barretenberg/numeric/random/engine.test.cpp b/barretenberg/cpp/src/barretenberg/numeric/random/engine.test.cpp index 83c9c47f099a..494246a07e80 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/random/engine.test.cpp +++ b/barretenberg/cpp/src/barretenberg/numeric/random/engine.test.cpp @@ -3,9 +3,11 @@ #include "barretenberg/common/streams.hpp" #include +using namespace bb; + TEST(engine, GetRandomUint64) { - auto& engine = numeric::random::get_engine(); + auto& engine = numeric::get_randomness(); auto a = engine.get_random_uint64(); auto b = engine.get_random_uint64(); EXPECT_NE(a, 0U); @@ -15,25 +17,25 @@ TEST(engine, GetRandomUint64) TEST(engine, ResetDebugEngine) { - auto& debug_engine = numeric::random::get_debug_engine(); + auto& debug_engine = numeric::get_debug_randomness(); auto a = debug_engine.get_random_uint64(); auto b = debug_engine.get_random_uint64(); EXPECT_NE(a, b); - debug_engine = numeric::random::get_debug_engine(true); + debug_engine = numeric::get_debug_randomness(true); auto c = debug_engine.get_random_uint64(); auto d = debug_engine.get_random_uint64(); EXPECT_EQ(a, c); EXPECT_EQ(b, d); - auto e = numeric::random::get_engine().get_random_uint64(); + auto e = numeric::get_randomness().get_random_uint64(); EXPECT_NE(a, e); } TEST(engine, GetExpectedDebugValue) { - auto& debug_engine = numeric::random::get_debug_engine(true); + auto& debug_engine = numeric::get_debug_randomness(true); auto a = debug_engine.get_random_uint1024(); auto expected = from_buffer(std::vector{ 0x69, 0x1f, 0x71, 0xcb, 0xcd, 0xdb, 0x45, 0x74, 0xe5, 0x17, 0x17, 0xa7, 0x29, 0x02, 0x21, 0x4a, diff --git a/barretenberg/cpp/src/barretenberg/numeric/uint128/uint128.hpp b/barretenberg/cpp/src/barretenberg/numeric/uint128/uint128.hpp index e229f9b7d237..363ee4f9a1b9 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/uint128/uint128.hpp +++ b/barretenberg/cpp/src/barretenberg/numeric/uint128/uint128.hpp @@ -7,7 +7,7 @@ #include "barretenberg/common/serialize.hpp" #include -namespace numeric { +namespace bb::numeric { class alignas(32) uint128_t { public: @@ -187,7 +187,7 @@ template inline void write(B& it, uint128_t const& value) write(it, value.data[0]); } -} // namespace numeric +} // namespace bb::numeric #include "./uint128_impl.hpp" diff --git a/barretenberg/cpp/src/barretenberg/numeric/uint128/uint128.test.cpp b/barretenberg/cpp/src/barretenberg/numeric/uint128/uint128.test.cpp index 14c4c843ce4b..ecf457ad9756 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/uint128/uint128.test.cpp +++ b/barretenberg/cpp/src/barretenberg/numeric/uint128/uint128.test.cpp @@ -2,12 +2,14 @@ #include "../random/engine.hpp" #include #ifdef __i386__ + +using namespace bb; +using namespace bb::numeric; + namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } -using namespace numeric; - TEST(uint128, GetBit) { constexpr uint128_t a{ 0b0110011001110010011001100, diff --git a/barretenberg/cpp/src/barretenberg/numeric/uint128/uint128_impl.hpp b/barretenberg/cpp/src/barretenberg/numeric/uint128/uint128_impl.hpp index 8fa503c95e31..5bc5f72c7586 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/uint128/uint128_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/numeric/uint128/uint128_impl.hpp @@ -3,7 +3,7 @@ #include "../bitop/get_msb.hpp" #include "./uint128.hpp" #include "barretenberg/common/assert.hpp" -namespace numeric { +namespace bb::numeric { constexpr std::pair uint128_t::mul_wide(const uint32_t a, const uint32_t b) { @@ -410,5 +410,5 @@ constexpr uint128_t uint128_t::operator<<(const uint128_t& other) const return result; } -} // namespace numeric +} // namespace bb::numeric #endif diff --git a/barretenberg/cpp/src/barretenberg/numeric/uint256/uint256.hpp b/barretenberg/cpp/src/barretenberg/numeric/uint256/uint256.hpp index 5ddaa9713aeb..fe9e759adaaa 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/uint256/uint256.hpp +++ b/barretenberg/cpp/src/barretenberg/numeric/uint256/uint256.hpp @@ -20,7 +20,7 @@ #include #include -namespace numeric { +namespace bb::numeric { class alignas(32) uint256_t { public: @@ -242,10 +242,10 @@ template inline void write(B& it, uint256_t const& value) write(it, value.data[0]); } -} // namespace numeric +} // namespace bb::numeric #include "./uint256_impl.hpp" // disable linter errors; we want to expose a global uint256_t type to mimic uint64_t, uint32_t etc // NOLINTNEXTLINE(tidymisc-unused-using-decls, google-global-names-in-headers, misc-unused-using-decls) -using numeric::uint256_t; +using bb::numeric::uint256_t; diff --git a/barretenberg/cpp/src/barretenberg/numeric/uint256/uint256.test.cpp b/barretenberg/cpp/src/barretenberg/numeric/uint256/uint256.test.cpp index 28234d0c2796..ae72524449cd 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/uint256/uint256.test.cpp +++ b/barretenberg/cpp/src/barretenberg/numeric/uint256/uint256.test.cpp @@ -2,12 +2,12 @@ #include "../random/engine.hpp" #include +using namespace bb; +using namespace bb::numeric; namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } -using namespace numeric; - TEST(uint256, TestStringConstructors) { std::string input = "9a807b615c4d3e2fa0b1c2d3e4f56789fedcba9876543210abcdef0123456789"; diff --git a/barretenberg/cpp/src/barretenberg/numeric/uint256/uint256_impl.hpp b/barretenberg/cpp/src/barretenberg/numeric/uint256/uint256_impl.hpp index 9f4d4daa33df..ee51adc763ad 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/uint256/uint256_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/numeric/uint256/uint256_impl.hpp @@ -2,7 +2,7 @@ #include "../bitop/get_msb.hpp" #include "./uint256.hpp" #include "barretenberg/common/assert.hpp" -namespace numeric { +namespace bb::numeric { constexpr std::pair uint256_t::mul_wide(const uint64_t a, const uint64_t b) { @@ -409,4 +409,4 @@ constexpr uint256_t uint256_t::operator<<(const uint256_t& other) const return result; } -} // namespace numeric +} // namespace bb::numeric diff --git a/barretenberg/cpp/src/barretenberg/numeric/uintx/uintx.hpp b/barretenberg/cpp/src/barretenberg/numeric/uintx/uintx.hpp index aa5fc07b097d..2ac1b886604c 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/uintx/uintx.hpp +++ b/barretenberg/cpp/src/barretenberg/numeric/uintx/uintx.hpp @@ -18,7 +18,7 @@ #include #include -namespace numeric { +namespace bb::numeric { template class uintx { public: @@ -187,9 +187,9 @@ template inline std::ostream& operator<<(std::ostream& os, uin using uint512_t = uintx; using uint1024_t = uintx; -} // namespace numeric +} // namespace bb::numeric #include "./uintx_impl.hpp" -using numeric::uint1024_t; // NOLINT -using numeric::uint512_t; // NOLINT +using bb::numeric::uint1024_t; // NOLINT +using bb::numeric::uint512_t; // NOLINT diff --git a/barretenberg/cpp/src/barretenberg/numeric/uintx/uintx.test.cpp b/barretenberg/cpp/src/barretenberg/numeric/uintx/uintx.test.cpp index 32e5cc6da5f8..036470ed975a 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/uintx/uintx.test.cpp +++ b/barretenberg/cpp/src/barretenberg/numeric/uintx/uintx.test.cpp @@ -2,8 +2,10 @@ #include "../random/engine.hpp" #include +using namespace bb; + namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } // namespace TEST(uintx, GetBit) @@ -67,27 +69,27 @@ TEST(uintx, DivAndMod) TEST(uintx, DISABLEDMulmod) { /* - bb::fq a = bb::fq::random_element(); - bb::fq b = bb::fq::random_element(); - // bb::fq a_converted = a.from_montgomery_form(); - // bb::fq b_converted = b.from_montgomery_form(); + fq a = fq::random_element(); + fq b = fq::random_element(); + // fq a_converted = a.from_montgomery_form(); + // fq b_converted = b.from_montgomery_form(); uint256_t a_uint = uint256_t(a); // { a_converted.data[0], a_converted.data[1], a_converted.data[2], a_converted.data[3] }; uint256_t b_uint = uint256_t(b); // { b_converted.data[0], b_converted.data[1], b_converted.data[2], b_converted.data[3] }; uint256_t modulus_uint{ bb::Bn254FqParams::modulus_0, - bb::Bn254FqParams::modulus_1, - bb::Bn254FqParams::modulus_2, - bb::Bn254FqParams::modulus_3 }; + Bn254FqParams::modulus_1, + Bn254FqParams::modulus_2, + Bn254FqParams::modulus_3 }; uint1024_t a_uintx = uint1024_t(uint512_t(a_uint)); uint1024_t b_uintx = uint1024_t(uint512_t(b_uint)); uint1024_t modulus_uintx = uint1024_t(uint512_t(modulus_uint)); const auto [quotient, remainder] = (a_uintx * b_uintx).divmod(modulus_uintx); - // bb::fq expected_a = a_converted.to_montgomery_form(); - // bb::fq expected_b = b_converted.to_montgomery_form(); - bb::fq expected = (a * b).from_montgomery_form(); + // fq expected_a = a_converted.to_montgomery_form(); + // fq expected_b = b_converted.to_montgomery_form(); + fq expected = (a * b).from_montgomery_form(); EXPECT_EQ(remainder.lo.lo.data[0], expected.data[0]); EXPECT_EQ(remainder.lo.lo.data[1], expected.data[1]); diff --git a/barretenberg/cpp/src/barretenberg/numeric/uintx/uintx_impl.hpp b/barretenberg/cpp/src/barretenberg/numeric/uintx/uintx_impl.hpp index 314a754b6aef..91c6c9ea0702 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/uintx/uintx_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/numeric/uintx/uintx_impl.hpp @@ -2,7 +2,7 @@ #include "./uintx.hpp" #include "barretenberg/common/assert.hpp" -namespace numeric { +namespace bb::numeric { template constexpr std::pair, uintx> uintx::divmod(const uintx& b) const { @@ -336,4 +336,4 @@ template constexpr uintx uintx::operator } return result; } -} // namespace numeric \ No newline at end of file +} // namespace bb::numeric \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/plonk/composer/standard_composer.test.cpp b/barretenberg/cpp/src/barretenberg/plonk/composer/standard_composer.test.cpp index e99f9a2144c6..952997d0e00c 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/composer/standard_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/composer/standard_composer.test.cpp @@ -5,12 +5,11 @@ #include "barretenberg/proof_system/circuit_builder/standard_circuit_builder.hpp" #include -using namespace bb; using namespace bb; using namespace bb::plonk; namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } class StandardPlonkComposer : public ::testing::Test { diff --git a/barretenberg/cpp/src/barretenberg/plonk/composer/ultra_composer.test.cpp b/barretenberg/cpp/src/barretenberg/plonk/composer/ultra_composer.test.cpp index 0a5dea87edcb..0fd5c17b8acd 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/composer/ultra_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/composer/ultra_composer.test.cpp @@ -9,14 +9,11 @@ #include "barretenberg/proof_system/plookup_tables/sha256.hpp" #include "barretenberg/stdlib/primitives/plookup/plookup.hpp" -using namespace bb; using namespace bb; using namespace bb::plonk; -namespace bb::plonk::test_ultra_plonk_composer { - namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } using plookup::ColumnIdx; @@ -66,10 +63,10 @@ TYPED_TEST_SUITE(ultra_plonk_composer, BooleanTypes); TYPED_TEST(ultra_plonk_composer, create_gates_from_plookup_accumulators) { - auto circuit_builder = bb::UltraCircuitBuilder(); + auto circuit_builder = UltraCircuitBuilder(); auto composer = UltraComposer(); - bb::fr input_value = fr::random_element(); + fr input_value = fr::random_element(); const fr input_lo = static_cast(input_value).slice(0, plookup::fixed_base::table::BITS_PER_LO_SCALAR); const auto input_lo_index = circuit_builder.add_variable(input_lo); @@ -647,7 +644,7 @@ TYPED_TEST(ultra_plonk_composer, non_native_field_multiplication) const auto q_indices = get_limb_witness_indices(split_into_limbs(uint256_t(q))); const auto r_indices = get_limb_witness_indices(split_into_limbs(uint256_t(r))); - bb::non_native_field_witnesses inputs{ + non_native_field_witnesses inputs{ a_indices, b_indices, q_indices, r_indices, modulus_limbs, fr(uint256_t(modulus)), }; const auto [lo_1_idx, hi_1_idx] = builder.evaluate_non_native_field_multiplication(inputs); @@ -823,5 +820,3 @@ TEST(ultra_plonk_composer, range_constraint_small_variable) bool result = verifier.verify_proof(proof); EXPECT_EQ(result, true); } - -} // namespace bb::plonk::test_ultra_plonk_composer diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/commitment_scheme/commitment_scheme.test.cpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/commitment_scheme/commitment_scheme.test.cpp index bd446e47c10c..299b1f83e1be 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/commitment_scheme/commitment_scheme.test.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/commitment_scheme/commitment_scheme.test.cpp @@ -35,7 +35,7 @@ TEST(commitment_scheme, kate_open) transcript::StandardTranscript inp_tx = transcript::StandardTranscript(transcript::Manifest()); plonk::KateCommitmentScheme newKate; - // std::shared_ptr> crs_factory = (new + // std::shared_ptr> crs_factory = (new // FileReferenceStringFactory("../srs_db/ignition")); auto file_crs = std::make_shared>("../srs_db/ignition"); auto crs = file_crs->get_prover_crs(n); diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/prover/prover.test.cpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/prover/prover.test.cpp index f7b92b5bdafe..0e9dbb679ce3 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/prover/prover.test.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/prover/prover.test.cpp @@ -113,8 +113,7 @@ plonk::Prover generate_test_data(const size_t n) // even indices = mul gates, odd incides = add gates - auto reference_string = - std::make_shared>(n + 1, "../srs_db/ignition"); + auto reference_string = std::make_shared>(n + 1, "../srs_db/ignition"); std::shared_ptr key = std::make_shared(n, 0, reference_string, CircuitType::STANDARD); polynomial w_l(n); diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.test.cpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.test.cpp index 9353566f712d..846d04951f19 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.test.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/proving_key/proving_key.test.cpp @@ -11,7 +11,6 @@ #include #endif -using namespace bb; using namespace bb; using namespace bb::plonk; @@ -141,8 +140,8 @@ StandardComposer(); fr a = fr::one(); builder.add_public_variable(a); bool all_polys_are_equal{ true }; for (size_t i = 0; i < precomputed_poly_list.size(); ++i) { std::string poly_id = precomputed_poly_list[i]; - bb::polynomial& input_poly = p_key.polynomial_store.get(poly_id); - bb::polynomial& output_poly = pk_data.polynomial_store.get(poly_id); + polynomial& input_poly = p_key.polynomial_store.get(poly_id); + polynomial& output_poly = pk_data.polynomial_store.get(poly_id); all_polys_are_equal = all_polys_are_equal && (input_poly == output_poly); } diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/public_inputs/public_inputs.test.cpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/public_inputs/public_inputs.test.cpp index 9e9923a02204..c9e7fdeb57ee 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/public_inputs/public_inputs.test.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/public_inputs/public_inputs.test.cpp @@ -138,7 +138,7 @@ TEST(test_public_inputs, compute_delta) for (size_t i = 0; i < num_public_inputs; ++i) { public_inputs.push_back(left[i]); } - fr target_delta = bb::plonk::compute_public_input_delta(public_inputs, beta, gamma, domain.root); + fr target_delta = plonk::compute_public_input_delta(public_inputs, beta, gamma, domain.root); EXPECT_EQ((modified_result == target_delta), true); } diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.test.cpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.test.cpp index 088d5142f56c..caf2e4c49725 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.test.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verification_key/verification_key.test.cpp @@ -3,14 +3,11 @@ #include "barretenberg/common/test.hpp" #include "barretenberg/numeric/random/engine.hpp" -namespace { -auto& engine = numeric::random::get_debug_engine(); -} // namespace - using namespace bb; using namespace bb::plonk; - -namespace bb::plonk::test_verification_key { +namespace { +auto& engine = numeric::get_debug_randomness(); +} // namespace /** * @brief generate a random vk data for use in tests @@ -154,4 +151,3 @@ TEST(VerificationKey, HashEqualityDifferentRecursiveProofPublicInputIndices) vk1_data.recursive_proof_public_input_indices.push_back(42); expect_hashes_eq(vk0_data, vk1_data); } -} // namespace bb::plonk::test_verification_key diff --git a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.test.cpp b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.test.cpp index 13e997110c0d..10a50a38edb5 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/proof_system/verifier/verifier.test.cpp @@ -28,7 +28,7 @@ plonk::Verifier generate_verifier(std::shared_ptr circuit_proving_k poly_coefficients[6] = circuit_proving_key->polynomial_store.get("sigma_2").data(); poly_coefficients[7] = circuit_proving_key->polynomial_store.get("sigma_3").data(); - std::vector commitments; + std::vector commitments; scalar_multiplication::pippenger_runtime_state state(circuit_proving_key->circuit_size); commitments.resize(8); diff --git a/barretenberg/cpp/src/barretenberg/plonk/transcript/transcript.cpp b/barretenberg/cpp/src/barretenberg/plonk/transcript/transcript.cpp index 5447a0480a6f..168ad725affa 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/transcript/transcript.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/transcript/transcript.cpp @@ -46,7 +46,7 @@ std::array Keccak256Hasher::hash(std std::array Blake3sHasher::hash(std::vector const& buffer) { grumpkin::fq input = grumpkin::fq::serialize_from_buffer(&buffer[0]); - grumpkin::fq hashed = crypto::pedersen_hash::hash({ input }); + grumpkin::fq hashed = bb::crypto::pedersen_hash::hash({ input }); std::vector res = to_buffer(hashed); std::array result; for (size_t i = 0; i < PRNG_OUTPUT_SIZE; ++i) { @@ -217,7 +217,7 @@ void Transcript::apply_fiat_shamir(const std::string& challenge_name /*, const b break; } case HashType::PedersenBlake3s: { - std::vector hashed_buffer = to_buffer(crypto::pedersen_hash::hash_buffer(buffer)); + std::vector hashed_buffer = to_buffer(bb::crypto::pedersen_hash::hash_buffer(buffer)); base_hash = Blake3sHasher::hash(hashed_buffer); break; } diff --git a/barretenberg/cpp/src/barretenberg/plonk/transcript/transcript.test.cpp b/barretenberg/cpp/src/barretenberg/plonk/transcript/transcript.test.cpp index 49f6bf9bee05..37ef74ff9a87 100644 --- a/barretenberg/cpp/src/barretenberg/plonk/transcript/transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/plonk/transcript/transcript.test.cpp @@ -5,6 +5,8 @@ #include #include +using namespace bb; + namespace { transcript::Manifest create_manifest(const size_t num_public_inputs) { @@ -135,8 +137,8 @@ TEST(transcript, univariate_serialization) constexpr size_t num_public_inputs = 0; constexpr size_t LENGTH = 8; - using Fr = bb::fr; - using Univariate = bb::Univariate; + using Fr = fr; + using Univariate = Univariate; using Transcript = transcript::StandardTranscript; std::vector g1_vector(64); diff --git a/barretenberg/cpp/src/barretenberg/polynomials/barycentric.test.cpp b/barretenberg/cpp/src/barretenberg/polynomials/barycentric.test.cpp index 10efc3916d76..a481f9fc64e1 100644 --- a/barretenberg/cpp/src/barretenberg/polynomials/barycentric.test.cpp +++ b/barretenberg/cpp/src/barretenberg/polynomials/barycentric.test.cpp @@ -2,7 +2,7 @@ #include "univariate.hpp" #include -namespace bb::test_barycentric { +using namespace bb; template class BarycentricDataTests : public testing::Test {}; @@ -86,5 +86,3 @@ TYPED_TEST(BarycentricDataTests, BarycentricData5to6) Univariate expected{ { 1, 3, 25, 109, 321, 751 } }; EXPECT_EQ(ext1, expected); } - -} // namespace bb::test_barycentric diff --git a/barretenberg/cpp/src/barretenberg/polynomials/polynomial.hpp b/barretenberg/cpp/src/barretenberg/polynomials/polynomial.hpp index 70e080bdfa4f..d1b6112eef87 100644 --- a/barretenberg/cpp/src/barretenberg/polynomials/polynomial.hpp +++ b/barretenberg/cpp/src/barretenberg/polynomials/polynomial.hpp @@ -90,34 +90,28 @@ template class Polynomial { Fr evaluate(const Fr& z, size_t target_size) const; Fr evaluate(const Fr& z) const; - Fr compute_barycentric_evaluation(const Fr& z, const EvaluationDomain& domain) - requires polynomial_arithmetic::SupportsFFT; + Fr compute_barycentric_evaluation(const Fr& z, const EvaluationDomain& domain) requires + polynomial_arithmetic::SupportsFFT; Fr evaluate_from_fft(const EvaluationDomain& large_domain, const Fr& z, - const EvaluationDomain& small_domain) - requires polynomial_arithmetic::SupportsFFT; - void fft(const EvaluationDomain& domain) - requires polynomial_arithmetic::SupportsFFT; - void partial_fft(const EvaluationDomain& domain, Fr constant = 1, bool is_coset = false) - requires polynomial_arithmetic::SupportsFFT; - void coset_fft(const EvaluationDomain& domain) - requires polynomial_arithmetic::SupportsFFT; + const EvaluationDomain& small_domain) requires polynomial_arithmetic::SupportsFFT; + void fft(const EvaluationDomain& domain) requires polynomial_arithmetic::SupportsFFT; + void partial_fft(const EvaluationDomain& domain, + Fr constant = 1, + bool is_coset = false) requires polynomial_arithmetic::SupportsFFT; + void coset_fft(const EvaluationDomain& domain) requires polynomial_arithmetic::SupportsFFT; void coset_fft(const EvaluationDomain& domain, const EvaluationDomain& large_domain, - size_t domain_extension) - requires polynomial_arithmetic::SupportsFFT; - void coset_fft_with_constant(const EvaluationDomain& domain, const Fr& constant) - requires polynomial_arithmetic::SupportsFFT; - void coset_fft_with_generator_shift(const EvaluationDomain& domain, const Fr& constant) - requires polynomial_arithmetic::SupportsFFT; - void ifft(const EvaluationDomain& domain) - requires polynomial_arithmetic::SupportsFFT; - void ifft_with_constant(const EvaluationDomain& domain, const Fr& constant) - requires polynomial_arithmetic::SupportsFFT; - void coset_ifft(const EvaluationDomain& domain) - requires polynomial_arithmetic::SupportsFFT; - Fr compute_kate_opening_coefficients(const Fr& z) - requires polynomial_arithmetic::SupportsFFT; + size_t domain_extension) requires polynomial_arithmetic::SupportsFFT; + void coset_fft_with_constant(const EvaluationDomain& domain, + const Fr& constant) requires polynomial_arithmetic::SupportsFFT; + void coset_fft_with_generator_shift(const EvaluationDomain& domain, + const Fr& constant) requires polynomial_arithmetic::SupportsFFT; + void ifft(const EvaluationDomain& domain) requires polynomial_arithmetic::SupportsFFT; + void ifft_with_constant(const EvaluationDomain& domain, + const Fr& constant) requires polynomial_arithmetic::SupportsFFT; + void coset_ifft(const EvaluationDomain& domain) requires polynomial_arithmetic::SupportsFFT; + Fr compute_kate_opening_coefficients(const Fr& z) requires polynomial_arithmetic::SupportsFFT; bool is_empty() const { return size_ == 0; } @@ -231,6 +225,13 @@ template class Polynomial { std::size_t size() const { return size_; } std::size_t capacity() const { return size_ + MAXIMUM_COEFFICIENT_SHIFT; } + static Polynomial random(const size_t num_coeffs) + { + Polynomial p(num_coeffs); + std::generate_n(p.begin(), num_coeffs, []() { return Fr::random_element(); }); + return p; + } + private: // allocate a fresh memory pointer for backing memory // DOES NOT initialize memory diff --git a/barretenberg/cpp/src/barretenberg/polynomials/polynomial_arithmetic.test.cpp b/barretenberg/cpp/src/barretenberg/polynomials/polynomial_arithmetic.test.cpp index 6e2cc6aab796..16281c3a650e 100644 --- a/barretenberg/cpp/src/barretenberg/polynomials/polynomial_arithmetic.test.cpp +++ b/barretenberg/cpp/src/barretenberg/polynomials/polynomial_arithmetic.test.cpp @@ -1043,7 +1043,7 @@ TYPED_TEST(PolynomialTests, evaluate_mle) using FF = TypeParam; auto test_case = [](size_t N) { - auto& engine = numeric::random::get_debug_engine(); + auto& engine = numeric::get_debug_randomness(); const size_t m = numeric::get_msb(N); EXPECT_EQ(N, 1 << m); Polynomial poly(N); diff --git a/barretenberg/cpp/src/barretenberg/polynomials/pow.test.cpp b/barretenberg/cpp/src/barretenberg/polynomials/pow.test.cpp index b6aeff91265a..a9da061ba733 100644 --- a/barretenberg/cpp/src/barretenberg/polynomials/pow.test.cpp +++ b/barretenberg/cpp/src/barretenberg/polynomials/pow.test.cpp @@ -2,29 +2,27 @@ #include "barretenberg/ecc/curves/bn254/fr.hpp" #include -namespace bb::test_pow { - -using FF = bb::fr; +using namespace bb; TEST(PowPolynomial, FullPowConsistency) { constexpr size_t d = 5; - std::vector betas(d); + std::vector betas(d); for (auto& beta : betas) { - beta = FF::random_element(); + beta = fr::random_element(); } - PowPolynomial pow_polynomial(betas); - std::array variables{}; + PowPolynomial pow_polynomial(betas); + std::array variables{}; for (auto& u_i : variables) { - u_i = FF::random_element(); + u_i = fr::random_element(); pow_polynomial.partially_evaluate(u_i); } size_t beta_idx = 0; - FF expected_eval = 1; + fr expected_eval = 1; for (auto& u_i : variables) { - expected_eval *= FF(1) - u_i + u_i * pow_polynomial.betas[beta_idx]; + expected_eval *= fr(1) - u_i + u_i * pow_polynomial.betas[beta_idx]; beta_idx++; } @@ -33,10 +31,9 @@ TEST(PowPolynomial, FullPowConsistency) TEST(PowPolynomial, PowPolynomialsOnPowers) { - auto betas = std::vector{ 2, 4, 16 }; + auto betas = std::vector{ 2, 4, 16 }; auto pow = PowPolynomial(betas); pow.compute_values(); - auto expected_values = std::vector{ 1, 2, 4, 8, 16, 32, 64, 128 }; + auto expected_values = std::vector{ 1, 2, 4, 8, 16, 32, 64, 128 }; EXPECT_EQ(expected_values, pow.pow_betas); } -} // namespace bb::test_pow diff --git a/barretenberg/cpp/src/barretenberg/polynomials/univariate.test.cpp b/barretenberg/cpp/src/barretenberg/polynomials/univariate.test.cpp index 5b35de5e68a3..10bcd0abb07b 100644 --- a/barretenberg/cpp/src/barretenberg/polynomials/univariate.test.cpp +++ b/barretenberg/cpp/src/barretenberg/polynomials/univariate.test.cpp @@ -2,30 +2,23 @@ #include "barretenberg/ecc/curves/bn254/fr.hpp" #include -namespace bb::test_univariate { +using namespace bb; template class UnivariateTest : public testing::Test { public: template using UnivariateView = UnivariateView; }; -using FieldTypes = testing::Types; +using FieldTypes = testing::Types; TYPED_TEST_SUITE(UnivariateTest, FieldTypes); -#define UNIVARIATE_TESTS_ALIASES using FF = TypeParam; -// IMPROVEMENT: Can't make alias for Univariate for some reason. -// Might be convenient to solve boilerplate or repeated type aliasing -// using this or some other means. - TYPED_TEST(UnivariateTest, Constructors) { - UNIVARIATE_TESTS_ALIASES - - FF a0 = FF::random_element(); - FF a1 = FF::random_element(); - FF a2 = FF::random_element(); + fr a0 = fr::random_element(); + fr a1 = fr::random_element(); + fr a2 = fr::random_element(); - Univariate uni({ a0, a1, a2 }); + Univariate uni({ a0, a1, a2 }); EXPECT_EQ(uni.value_at(0), a0); EXPECT_EQ(uni.value_at(1), a1); @@ -34,124 +27,111 @@ TYPED_TEST(UnivariateTest, Constructors) TYPED_TEST(UnivariateTest, Addition) { - UNIVARIATE_TESTS_ALIASES - - Univariate f1{ { 1, 2 } }; - Univariate f2{ { 3, 4 } }; + Univariate f1{ { 1, 2 } }; + Univariate f2{ { 3, 4 } }; // output should be {4, 6} - Univariate expected_result{ { 4, 6 } }; + Univariate expected_result{ { 4, 6 } }; auto f1f2 = f1 + f2; EXPECT_EQ(f1f2, expected_result); } TYPED_TEST(UnivariateTest, Multiplication) { - UNIVARIATE_TESTS_ALIASES - Univariate f1 = Univariate{ { 1, 2 } }.template extend_to<3>(); - Univariate f2 = Univariate{ { 3, 4 } }.template extend_to<3>(); + Univariate f1 = Univariate{ { 1, 2 } }.template extend_to<3>(); + Univariate f2 = Univariate{ { 3, 4 } }.template extend_to<3>(); // output should be {3, 8, 15} - Univariate expected_result{ { 3, 8, 15 } }; - Univariate f1f2 = f1 * f2; + Univariate expected_result{ { 3, 8, 15 } }; + Univariate f1f2 = f1 * f2; EXPECT_EQ(f1f2, expected_result); } TYPED_TEST(UnivariateTest, ConstructUnivariateViewFromUnivariate) { - UNIVARIATE_TESTS_ALIASES - Univariate f{ { 1, 2, 3 } }; - UnivariateView g(f); + Univariate f{ { 1, 2, 3 } }; + UnivariateView g(f); EXPECT_EQ(g.value_at(0), f.value_at(0)); EXPECT_EQ(g.value_at(1), f.value_at(1)); } TYPED_TEST(UnivariateTest, ConstructUnivariateFromUnivariateView) { - UNIVARIATE_TESTS_ALIASES - Univariate f{ { 1, 2, 3 } }; - UnivariateView g(f); - Univariate h(g); + Univariate f{ { 1, 2, 3 } }; + UnivariateView g(f); + Univariate h(g); EXPECT_EQ(h.value_at(0), g.value_at(0)); EXPECT_EQ(h.value_at(1), g.value_at(1)); } TYPED_TEST(UnivariateTest, UnivariateViewAddition) { - UNIVARIATE_TESTS_ALIASES + Univariate f1{ { 1, 2, 3 } }; + Univariate f2{ { 3, 4, 3 } }; - Univariate f1{ { 1, 2, 3 } }; - Univariate f2{ { 3, 4, 3 } }; + UnivariateView g1(f1); + UnivariateView g2(f2); - UnivariateView g1(f1); - UnivariateView g2(f2); - - Univariate expected_result{ { 4, 6 } }; - Univariate result = g1 + g2; + Univariate expected_result{ { 4, 6 } }; + Univariate result = g1 + g2; EXPECT_EQ(result, expected_result); - Univariate result2 = result + g1; - Univariate expected_result2{ { 5, 8 } }; + Univariate result2 = result + g1; + Univariate expected_result2{ { 5, 8 } }; EXPECT_EQ(result2, expected_result2); } TYPED_TEST(UnivariateTest, UnivariateViewSubtraction) { - UNIVARIATE_TESTS_ALIASES - - Univariate f1{ { 1, 2, 3 } }; - Univariate f2{ { 3, 4, 3 } }; + Univariate f1{ { 1, 2, 3 } }; + Univariate f2{ { 3, 4, 3 } }; - UnivariateView g1(f1); - UnivariateView g2(f2); + UnivariateView g1(f1); + UnivariateView g2(f2); - Univariate expected_result{ { -2, -2 } }; - Univariate result = g1 - g2; + Univariate expected_result{ { -2, -2 } }; + Univariate result = g1 - g2; EXPECT_EQ(result, expected_result); - Univariate result2 = result - g1; - Univariate expected_result2{ { -3, -4 } }; + Univariate result2 = result - g1; + Univariate expected_result2{ { -3, -4 } }; EXPECT_EQ(result2, expected_result2); } TYPED_TEST(UnivariateTest, UnivariateViewMultiplication) { - UNIVARIATE_TESTS_ALIASES + Univariate f1{ { 1, 2, 3 } }; + Univariate f2{ { 3, 4, 3 } }; - Univariate f1{ { 1, 2, 3 } }; - Univariate f2{ { 3, 4, 3 } }; + UnivariateView g1(f1); + UnivariateView g2(f2); - UnivariateView g1(f1); - UnivariateView g2(f2); - - Univariate expected_result{ { 3, 8 } }; - Univariate result = g1 * g2; + Univariate expected_result{ { 3, 8 } }; + Univariate result = g1 * g2; EXPECT_EQ(result, expected_result); - Univariate result2 = result * g1; - Univariate expected_result2{ { 3, 16 } }; + Univariate result2 = result * g1; + Univariate expected_result2{ { 3, 16 } }; EXPECT_EQ(result2, expected_result2); } TYPED_TEST(UnivariateTest, Serialization) { - UNIVARIATE_TESTS_ALIASES - const size_t LENGTH = 4; - std::array evaluations; + std::array evaluations; for (size_t i = 0; i < LENGTH; ++i) { - evaluations[i] = FF::random_element(); + evaluations[i] = fr::random_element(); } // Instantiate a Univariate from the evaluations - auto univariate = Univariate(evaluations); + auto univariate = Univariate(evaluations); // Serialize univariate to buffer std::vector buffer = univariate.to_buffer(); // Deserialize - auto deserialized_univariate = Univariate::serialize_from_buffer(&buffer[0]); + auto deserialized_univariate = Univariate::serialize_from_buffer(&buffer[0]); for (size_t i = 0; i < LENGTH; ++i) { EXPECT_EQ(univariate.value_at(i), deserialized_univariate.value_at(i)); @@ -160,17 +140,13 @@ TYPED_TEST(UnivariateTest, Serialization) TYPED_TEST(UnivariateTest, EvaluationCustomDomain) { - UNIVARIATE_TESTS_ALIASES - []() { - auto poly = Univariate(std::array{ 1, 2 }); - EXPECT_EQ(poly.evaluate(FF(5)), FF(5)); + auto poly = Univariate(std::array{ 1, 2 }); + EXPECT_EQ(poly.evaluate(fr(5)), fr(5)); }(); []() { - auto poly = Univariate(std::array{ 1, 11, 111, 1111, 11111 }); - EXPECT_EQ(poly.evaluate(FF(2)), FF(294330751)); + auto poly = Univariate(std::array{ 1, 11, 111, 1111, 11111 }); + EXPECT_EQ(poly.evaluate(fr(2)), fr(294330751)); }(); } - -} // namespace bb::test_univariate diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_builder_types.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_builder_types.hpp index d01d92ce5d60..99f7103afcfa 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_builder_types.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_builder_types.hpp @@ -2,7 +2,7 @@ #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" -namespace bb_eccvm { +namespace bb::eccvm { static constexpr size_t NUM_SCALAR_BITS = 128; static constexpr size_t WNAF_SLICE_BITS = 4; @@ -44,4 +44,4 @@ template struct ScalarMul { template using MSM = std::vector>; -} // namespace bb_eccvm \ No newline at end of file +} // namespace bb::eccvm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.hpp index b73b18897102..7569275796e1 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.hpp @@ -24,21 +24,21 @@ template class ECCVMCircuitBuilder { using Element = typename CycleGroup::element; using AffineElement = typename CycleGroup::affine_element; - static constexpr size_t NUM_SCALAR_BITS = bb_eccvm::NUM_SCALAR_BITS; - static constexpr size_t WNAF_SLICE_BITS = bb_eccvm::WNAF_SLICE_BITS; - static constexpr size_t NUM_WNAF_SLICES = bb_eccvm::NUM_WNAF_SLICES; - static constexpr uint64_t WNAF_MASK = bb_eccvm::WNAF_MASK; - static constexpr size_t POINT_TABLE_SIZE = bb_eccvm::POINT_TABLE_SIZE; - static constexpr size_t WNAF_SLICES_PER_ROW = bb_eccvm::WNAF_SLICES_PER_ROW; - static constexpr size_t ADDITIONS_PER_ROW = bb_eccvm::ADDITIONS_PER_ROW; + static constexpr size_t NUM_SCALAR_BITS = bb::eccvm::NUM_SCALAR_BITS; + static constexpr size_t WNAF_SLICE_BITS = bb::eccvm::WNAF_SLICE_BITS; + static constexpr size_t NUM_WNAF_SLICES = bb::eccvm::NUM_WNAF_SLICES; + static constexpr uint64_t WNAF_MASK = bb::eccvm::WNAF_MASK; + static constexpr size_t POINT_TABLE_SIZE = bb::eccvm::POINT_TABLE_SIZE; + static constexpr size_t WNAF_SLICES_PER_ROW = bb::eccvm::WNAF_SLICES_PER_ROW; + static constexpr size_t ADDITIONS_PER_ROW = bb::eccvm::ADDITIONS_PER_ROW; static constexpr size_t NUM_POLYNOMIALS = Flavor::NUM_ALL_ENTITIES; static constexpr size_t NUM_WIRES = Flavor::NUM_WIRES; - using MSM = bb_eccvm::MSM; - using VMOperation = bb_eccvm::VMOperation; + using MSM = bb::eccvm::MSM; + using VMOperation = bb::eccvm::VMOperation; std::shared_ptr op_queue; - using ScalarMul = bb_eccvm::ScalarMul; + using ScalarMul = bb::eccvm::ScalarMul; using ProverPolynomials = typename Flavor::ProverPolynomials; ECCVMCircuitBuilder() diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.test.cpp index 013e9a3c0864..18bacda13efc 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.test.cpp @@ -6,11 +6,9 @@ using namespace bb; namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } -namespace eccvm_circuit_builder_tests { - template class ECCVMCircuitBuilderTests : public ::testing::Test {}; using FlavorTypes = ::testing::Types; @@ -21,7 +19,7 @@ TYPED_TEST(ECCVMCircuitBuilderTests, BaseCase) using Flavor = TypeParam; using G1 = typename Flavor::CycleGroup; using Fr = typename G1::Fr; - bb::ECCVMCircuitBuilder circuit; + ECCVMCircuitBuilder circuit; auto generators = G1::derive_generators("test generators", 3); typename G1::element a = generators[0]; typename G1::element b = generators[1]; @@ -55,7 +53,7 @@ TYPED_TEST(ECCVMCircuitBuilderTests, Add) { using Flavor = TypeParam; using G1 = typename Flavor::CycleGroup; - bb::ECCVMCircuitBuilder circuit; + ECCVMCircuitBuilder circuit; auto generators = G1::derive_generators("test generators", 3); typename G1::element a = generators[0]; @@ -71,7 +69,7 @@ TYPED_TEST(ECCVMCircuitBuilderTests, Mul) using Flavor = TypeParam; using G1 = typename Flavor::CycleGroup; using Fr = typename G1::Fr; - bb::ECCVMCircuitBuilder circuit; + ECCVMCircuitBuilder circuit; auto generators = G1::derive_generators("test generators", 3); typename G1::element a = generators[0]; Fr x = Fr::random_element(&engine); @@ -87,7 +85,7 @@ TYPED_TEST(ECCVMCircuitBuilderTests, ShortMul) using Flavor = TypeParam; using G1 = typename Flavor::CycleGroup; using Fr = typename G1::Fr; - bb::ECCVMCircuitBuilder circuit; + ECCVMCircuitBuilder circuit; auto generators = G1::derive_generators("test generators", 3); typename G1::element a = generators[0]; @@ -109,7 +107,7 @@ TYPED_TEST(ECCVMCircuitBuilderTests, EqFails) using Flavor = TypeParam; using G1 = typename Flavor::CycleGroup; using Fr = typename G1::Fr; - bb::ECCVMCircuitBuilder circuit; + ECCVMCircuitBuilder circuit; auto generators = G1::derive_generators("test generators", 3); typename G1::element a = generators[0]; @@ -124,7 +122,7 @@ TYPED_TEST(ECCVMCircuitBuilderTests, EqFails) TYPED_TEST(ECCVMCircuitBuilderTests, EmptyRow) { using Flavor = TypeParam; - bb::ECCVMCircuitBuilder circuit; + ECCVMCircuitBuilder circuit; circuit.empty_row(); @@ -137,7 +135,7 @@ TYPED_TEST(ECCVMCircuitBuilderTests, EmptyRowBetweenOps) using Flavor = TypeParam; using G1 = typename Flavor::CycleGroup; using Fr = typename G1::Fr; - bb::ECCVMCircuitBuilder circuit; + ECCVMCircuitBuilder circuit; auto generators = G1::derive_generators("test generators", 3); typename G1::element a = generators[0]; @@ -158,7 +156,7 @@ TYPED_TEST(ECCVMCircuitBuilderTests, EndWithEq) using Flavor = TypeParam; using G1 = typename Flavor::CycleGroup; using Fr = typename G1::Fr; - bb::ECCVMCircuitBuilder circuit; + ECCVMCircuitBuilder circuit; auto generators = G1::derive_generators("test generators", 3); typename G1::element a = generators[0]; @@ -178,7 +176,7 @@ TYPED_TEST(ECCVMCircuitBuilderTests, EndWithAdd) using Flavor = TypeParam; using G1 = typename Flavor::CycleGroup; using Fr = typename G1::Fr; - bb::ECCVMCircuitBuilder circuit; + ECCVMCircuitBuilder circuit; auto generators = G1::derive_generators("test generators", 3); typename G1::element a = generators[0]; @@ -199,7 +197,7 @@ TYPED_TEST(ECCVMCircuitBuilderTests, EndWithMul) using Flavor = TypeParam; using G1 = typename Flavor::CycleGroup; using Fr = typename G1::Fr; - bb::ECCVMCircuitBuilder circuit; + ECCVMCircuitBuilder circuit; auto generators = G1::derive_generators("test generators", 3); typename G1::element a = generators[0]; @@ -218,7 +216,7 @@ TYPED_TEST(ECCVMCircuitBuilderTests, EndWithNoop) using Flavor = TypeParam; using G1 = typename Flavor::CycleGroup; using Fr = typename G1::Fr; - bb::ECCVMCircuitBuilder circuit; + ECCVMCircuitBuilder circuit; auto generators = G1::derive_generators("test generators", 3); typename G1::element a = generators[0]; @@ -257,17 +255,16 @@ TYPED_TEST(ECCVMCircuitBuilderTests, MSM) // single msms for (size_t j = 1; j < max_num_msms; ++j) { using Flavor = TypeParam; - bb::ECCVMCircuitBuilder circuit; + ECCVMCircuitBuilder circuit; try_msms(j, circuit); bool result = circuit.check_circuit(); EXPECT_EQ(result, true); } // chain msms - bb::ECCVMCircuitBuilder circuit; + ECCVMCircuitBuilder circuit; for (size_t j = 1; j < 9; ++j) { try_msms(j, circuit); } bool result = circuit.check_circuit(); EXPECT_EQ(result, true); } -} // namespace eccvm_circuit_builder_tests \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/msm_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/msm_builder.hpp index c47f818ff304..6f0c45e37441 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/msm_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/msm_builder.hpp @@ -13,9 +13,9 @@ template class ECCVMMSMMBuilder { using Element = typename CycleGroup::element; using AffineElement = typename CycleGroup::affine_element; - static constexpr size_t ADDITIONS_PER_ROW = bb_eccvm::ADDITIONS_PER_ROW; - static constexpr size_t NUM_SCALAR_BITS = bb_eccvm::NUM_SCALAR_BITS; - static constexpr size_t WNAF_SLICE_BITS = bb_eccvm::WNAF_SLICE_BITS; + static constexpr size_t ADDITIONS_PER_ROW = bb::eccvm::ADDITIONS_PER_ROW; + static constexpr size_t NUM_SCALAR_BITS = bb::eccvm::NUM_SCALAR_BITS; + static constexpr size_t WNAF_SLICE_BITS = bb::eccvm::WNAF_SLICE_BITS; struct MSMState { uint32_t pc = 0; @@ -53,7 +53,7 @@ template class ECCVMMSMMBuilder { * @param total_number_of_muls * @return std::vector */ - static std::vector compute_msm_state(const std::vector>& msms, + static std::vector compute_msm_state(const std::vector>& msms, std::array, 2>& point_table_read_counts, const uint32_t total_number_of_muls) { diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/precomputed_tables_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/precomputed_tables_builder.hpp index ca583c8de412..1c7d2bb443e3 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/precomputed_tables_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/precomputed_tables_builder.hpp @@ -11,9 +11,9 @@ template class ECCVMPrecomputedTablesBuilder { using Element = typename CycleGroup::element; using AffineElement = typename CycleGroup::affine_element; - static constexpr size_t NUM_WNAF_SLICES = bb_eccvm::NUM_WNAF_SLICES; - static constexpr size_t WNAF_SLICES_PER_ROW = bb_eccvm::WNAF_SLICES_PER_ROW; - static constexpr size_t WNAF_SLICE_BITS = bb_eccvm::WNAF_SLICE_BITS; + static constexpr size_t NUM_WNAF_SLICES = bb::eccvm::NUM_WNAF_SLICES; + static constexpr size_t WNAF_SLICES_PER_ROW = bb::eccvm::WNAF_SLICES_PER_ROW; + static constexpr size_t WNAF_SLICE_BITS = bb::eccvm::WNAF_SLICE_BITS; struct PrecomputeState { int s1 = 0; @@ -34,7 +34,7 @@ template class ECCVMPrecomputedTablesBuilder { }; static std::vector compute_precompute_state( - const std::vector>& ecc_muls) + const std::vector>& ecc_muls) { std::vector precompute_state; @@ -101,7 +101,7 @@ template class ECCVMPrecomputedTablesBuilder { row.precompute_double = d2; // fill accumulator in reverse order i.e. first row = 15[P], then 13[P], ..., 1[P] - row.precompute_accumulator = entry.precomputed_table[bb_eccvm::POINT_TABLE_SIZE - 1 - i]; + row.precompute_accumulator = entry.precomputed_table[bb::eccvm::POINT_TABLE_SIZE - 1 - i]; precompute_state.emplace_back(row); } } diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/transcript_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/transcript_builder.hpp index 5d0c693eac69..1ff3d8b4cbac 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/transcript_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/eccvm/transcript_builder.hpp @@ -58,7 +58,7 @@ template class ECCVMTranscriptBuilder { } }; static std::vector compute_transcript_state( - const std::vector>& vm_operations, const uint32_t total_number_of_muls) + const std::vector>& vm_operations, const uint32_t total_number_of_muls) { std::vector transcript_state; VMState state{ @@ -74,7 +74,7 @@ template class ECCVMTranscriptBuilder { transcript_state.emplace_back(TranscriptState{}); for (size_t i = 0; i < vm_operations.size(); ++i) { TranscriptState row; - const bb_eccvm::VMOperation& entry = vm_operations[i]; + const bb::eccvm::VMOperation& entry = vm_operations[i]; const bool is_mul = entry.mul; const bool z1_zero = (entry.mul) ? entry.z1 == 0 : true; diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/AvmMini_circuit_builder.hpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/AvmMini_circuit_builder.hpp index de70d2c08579..baef5adc8560 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/AvmMini_circuit_builder.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/generated/AvmMini_circuit_builder.hpp @@ -12,6 +12,7 @@ #include "barretenberg/relations/generic_permutation/generic_permutation_relation.hpp" #include "barretenberg/flavor/generated/AvmMini_flavor.hpp" +#include "barretenberg/relations/generated/AvmMini/alu_chip.hpp" #include "barretenberg/relations/generated/AvmMini/avm_mini.hpp" #include "barretenberg/relations/generated/AvmMini/mem_trace.hpp" @@ -33,6 +34,32 @@ template struct AvmMiniFullRow { FF memTrace_m_in_tag{}; FF memTrace_m_tag_err{}; FF memTrace_m_one_min_inv{}; + FF aluChip_alu_clk{}; + FF aluChip_alu_ia{}; + FF aluChip_alu_ib{}; + FF aluChip_alu_ic{}; + FF aluChip_alu_op_add{}; + FF aluChip_alu_op_sub{}; + FF aluChip_alu_op_mul{}; + FF aluChip_alu_op_div{}; + FF aluChip_alu_ff_tag{}; + FF aluChip_alu_u8_tag{}; + FF aluChip_alu_u16_tag{}; + FF aluChip_alu_u32_tag{}; + FF aluChip_alu_u64_tag{}; + FF aluChip_alu_u128_tag{}; + FF aluChip_alu_u8_r0{}; + FF aluChip_alu_u8_r1{}; + FF aluChip_alu_u16_r0{}; + FF aluChip_alu_u16_r1{}; + FF aluChip_alu_u16_r2{}; + FF aluChip_alu_u16_r3{}; + FF aluChip_alu_u16_r4{}; + FF aluChip_alu_u16_r5{}; + FF aluChip_alu_u16_r6{}; + FF aluChip_alu_u16_r7{}; + FF aluChip_alu_u64_r0{}; + FF aluChip_alu_cf{}; FF avmMini_pc{}; FF avmMini_internal_return_ptr{}; FF avmMini_sel_internal_call{}; @@ -60,12 +87,20 @@ template struct AvmMiniFullRow { FF avmMini_mem_idx_b{}; FF avmMini_mem_idx_c{}; FF avmMini_last{}; - FF memTrace_m_rw_shift{}; + FF aluChip_alu_u16_r1_shift{}; + FF aluChip_alu_u16_r0_shift{}; + FF aluChip_alu_u16_r4_shift{}; + FF aluChip_alu_u16_r7_shift{}; + FF aluChip_alu_u16_r5_shift{}; + FF aluChip_alu_u16_r2_shift{}; + FF aluChip_alu_u16_r6_shift{}; + FF aluChip_alu_u16_r3_shift{}; + FF avmMini_pc_shift{}; + FF avmMini_internal_return_ptr_shift{}; FF memTrace_m_tag_shift{}; FF memTrace_m_addr_shift{}; FF memTrace_m_val_shift{}; - FF avmMini_internal_return_ptr_shift{}; - FF avmMini_pc_shift{}; + FF memTrace_m_rw_shift{}; }; class AvmMiniCircuitBuilder { @@ -78,8 +113,8 @@ class AvmMiniCircuitBuilder { using Polynomial = Flavor::Polynomial; using ProverPolynomials = Flavor::ProverPolynomials; - static constexpr size_t num_fixed_columns = 46; - static constexpr size_t num_polys = 40; + static constexpr size_t num_fixed_columns = 80; + static constexpr size_t num_polys = 66; std::vector rows; void set_trace(std::vector&& trace) { rows = std::move(trace); } @@ -108,6 +143,32 @@ class AvmMiniCircuitBuilder { polys.memTrace_m_in_tag[i] = rows[i].memTrace_m_in_tag; polys.memTrace_m_tag_err[i] = rows[i].memTrace_m_tag_err; polys.memTrace_m_one_min_inv[i] = rows[i].memTrace_m_one_min_inv; + polys.aluChip_alu_clk[i] = rows[i].aluChip_alu_clk; + polys.aluChip_alu_ia[i] = rows[i].aluChip_alu_ia; + polys.aluChip_alu_ib[i] = rows[i].aluChip_alu_ib; + polys.aluChip_alu_ic[i] = rows[i].aluChip_alu_ic; + polys.aluChip_alu_op_add[i] = rows[i].aluChip_alu_op_add; + polys.aluChip_alu_op_sub[i] = rows[i].aluChip_alu_op_sub; + polys.aluChip_alu_op_mul[i] = rows[i].aluChip_alu_op_mul; + polys.aluChip_alu_op_div[i] = rows[i].aluChip_alu_op_div; + polys.aluChip_alu_ff_tag[i] = rows[i].aluChip_alu_ff_tag; + polys.aluChip_alu_u8_tag[i] = rows[i].aluChip_alu_u8_tag; + polys.aluChip_alu_u16_tag[i] = rows[i].aluChip_alu_u16_tag; + polys.aluChip_alu_u32_tag[i] = rows[i].aluChip_alu_u32_tag; + polys.aluChip_alu_u64_tag[i] = rows[i].aluChip_alu_u64_tag; + polys.aluChip_alu_u128_tag[i] = rows[i].aluChip_alu_u128_tag; + polys.aluChip_alu_u8_r0[i] = rows[i].aluChip_alu_u8_r0; + polys.aluChip_alu_u8_r1[i] = rows[i].aluChip_alu_u8_r1; + polys.aluChip_alu_u16_r0[i] = rows[i].aluChip_alu_u16_r0; + polys.aluChip_alu_u16_r1[i] = rows[i].aluChip_alu_u16_r1; + polys.aluChip_alu_u16_r2[i] = rows[i].aluChip_alu_u16_r2; + polys.aluChip_alu_u16_r3[i] = rows[i].aluChip_alu_u16_r3; + polys.aluChip_alu_u16_r4[i] = rows[i].aluChip_alu_u16_r4; + polys.aluChip_alu_u16_r5[i] = rows[i].aluChip_alu_u16_r5; + polys.aluChip_alu_u16_r6[i] = rows[i].aluChip_alu_u16_r6; + polys.aluChip_alu_u16_r7[i] = rows[i].aluChip_alu_u16_r7; + polys.aluChip_alu_u64_r0[i] = rows[i].aluChip_alu_u64_r0; + polys.aluChip_alu_cf[i] = rows[i].aluChip_alu_cf; polys.avmMini_pc[i] = rows[i].avmMini_pc; polys.avmMini_internal_return_ptr[i] = rows[i].avmMini_internal_return_ptr; polys.avmMini_sel_internal_call[i] = rows[i].avmMini_sel_internal_call; @@ -137,12 +198,20 @@ class AvmMiniCircuitBuilder { polys.avmMini_last[i] = rows[i].avmMini_last; } - polys.memTrace_m_rw_shift = Polynomial(polys.memTrace_m_rw.shifted()); + polys.aluChip_alu_u16_r1_shift = Polynomial(polys.aluChip_alu_u16_r1.shifted()); + polys.aluChip_alu_u16_r0_shift = Polynomial(polys.aluChip_alu_u16_r0.shifted()); + polys.aluChip_alu_u16_r4_shift = Polynomial(polys.aluChip_alu_u16_r4.shifted()); + polys.aluChip_alu_u16_r7_shift = Polynomial(polys.aluChip_alu_u16_r7.shifted()); + polys.aluChip_alu_u16_r5_shift = Polynomial(polys.aluChip_alu_u16_r5.shifted()); + polys.aluChip_alu_u16_r2_shift = Polynomial(polys.aluChip_alu_u16_r2.shifted()); + polys.aluChip_alu_u16_r6_shift = Polynomial(polys.aluChip_alu_u16_r6.shifted()); + polys.aluChip_alu_u16_r3_shift = Polynomial(polys.aluChip_alu_u16_r3.shifted()); + polys.avmMini_pc_shift = Polynomial(polys.avmMini_pc.shifted()); + polys.avmMini_internal_return_ptr_shift = Polynomial(polys.avmMini_internal_return_ptr.shifted()); polys.memTrace_m_tag_shift = Polynomial(polys.memTrace_m_tag.shifted()); polys.memTrace_m_addr_shift = Polynomial(polys.memTrace_m_addr.shifted()); polys.memTrace_m_val_shift = Polynomial(polys.memTrace_m_val.shifted()); - polys.avmMini_internal_return_ptr_shift = Polynomial(polys.avmMini_internal_return_ptr.shifted()); - polys.avmMini_pc_shift = Polynomial(polys.avmMini_pc.shifted()); + polys.memTrace_m_rw_shift = Polynomial(polys.memTrace_m_rw.shifted()); return polys; } @@ -180,14 +249,18 @@ class AvmMiniCircuitBuilder { return true; }; - if (!evaluate_relation.template operator()>( - "mem_trace", AvmMini_vm::get_relation_label_mem_trace)) { + if (!evaluate_relation.template operator()>("alu_chip", + AvmMini_vm::get_relation_label_alu_chip)) { return false; } if (!evaluate_relation.template operator()>("avm_mini", AvmMini_vm::get_relation_label_avm_mini)) { return false; } + if (!evaluate_relation.template operator()>( + "mem_trace", AvmMini_vm::get_relation_label_mem_trace)) { + return false; + } return true; } diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.test.cpp index acfdad1c165f..e08938d19579 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.test.cpp @@ -7,10 +7,8 @@ using namespace bb; namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } -namespace bb { - /** * @brief Check that a single accumulation gate is created correctly * @@ -78,9 +76,9 @@ TEST(GoblinTranslatorCircuitBuilder, CircuitBuilderBaseCase) */ TEST(GoblinTranslatorCircuitBuilder, SeveralOperationCorrectness) { - using point = bb::g1::affine_element; - using scalar = bb::fr; - using Fq = bb::fq; + using point = g1::affine_element; + using scalar = fr; + using Fq = fq; auto P1 = point::random_element(); auto P2 = point::random_element(); @@ -128,5 +126,4 @@ TEST(GoblinTranslatorCircuitBuilder, SeveralOperationCorrectness) EXPECT_TRUE(circuit_builder.check_circuit()); // Check the computation result is in line with what we've computed EXPECT_EQ(result, circuit_builder.get_computation_result()); -} -} // namespace bb \ No newline at end of file +} \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_translator_mini.fuzzer.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_translator_mini.fuzzer.cpp index ee34d21262b0..f390dd0b8eff 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_translator_mini.fuzzer.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_translator_mini.fuzzer.cpp @@ -1,7 +1,10 @@ #include "barretenberg/numeric/uint256/uint256.hpp" #include "goblin_translator_circuit_builder.hpp" -using Fr = ::curve::BN254::ScalarField; -using Fq = ::curve::BN254::BaseField; + +using namespace bb; + +using Fr = curve::BN254::ScalarField; +using Fq = curve::BN254::BaseField; extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data, size_t size) { diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.cpp index 84a6b0b5105c..428409bf73f0 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.cpp @@ -6,7 +6,7 @@ #include using namespace bb; -using namespace crypto; +using namespace bb::crypto; namespace bb { diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.test.cpp index 927f563626cf..4e2b85667154 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.test.cpp @@ -4,7 +4,7 @@ using namespace bb; namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } namespace bb { diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/standard_circuit_builder.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/standard_circuit_builder.test.cpp index 9a05d8fea16a..aec2887e552b 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/standard_circuit_builder.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/standard_circuit_builder.test.cpp @@ -3,15 +3,12 @@ #include "barretenberg/crypto/pedersen_commitment/pedersen.hpp" #include -using namespace bb; using namespace bb; namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } -namespace standard_circuit_constructor_tests { - TEST(standard_circuit_constructor, base_case) { StandardCircuitBuilder circuit_constructor = StandardCircuitBuilder(); @@ -468,5 +465,3 @@ TEST(standard_circuit_constructor, test_check_circuit_broken) bool result = circuit_constructor.check_circuit(); EXPECT_EQ(result, false); } - -} // namespace standard_circuit_constructor_tests diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/toy_avm/toy_avm_circuit_builder.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/toy_avm/toy_avm_circuit_builder.test.cpp index 2049cf001a3c..25e182c0a46a 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/toy_avm/toy_avm_circuit_builder.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/toy_avm/toy_avm_circuit_builder.test.cpp @@ -8,11 +8,9 @@ using namespace bb; namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } -namespace toy_avm_circuit_builder_tests { - /** * @brief A test explaining the work of the permutations in Toy AVM * @@ -20,8 +18,8 @@ namespace toy_avm_circuit_builder_tests { TEST(ToyAVMCircuitBuilder, BaseCase) { - using FF = bb::honk::flavor::ToyFlavor::FF; - using Builder = bb::ToyCircuitBuilder; + using FF = honk::flavor::ToyFlavor::FF; + using Builder = ToyCircuitBuilder; using Row = Builder::Row; Builder circuit_builder; @@ -118,4 +116,3 @@ TEST(ToyAVMCircuitBuilder, BaseCase) circuit_builder.rows[2].toy_xor_a = tmp; EXPECT_EQ(circuit_builder.check_circuit(), true); } -} // namespace toy_avm_circuit_builder_tests \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.test.cpp index 8605db48b4ab..16e1252712af 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/ultra_circuit_builder.test.cpp @@ -5,7 +5,7 @@ using namespace bb; namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } namespace bb { using plookup::ColumnIdx; @@ -44,7 +44,7 @@ TEST(ultra_circuit_constructor, create_gates_from_plookup_accumulators) UltraCircuitBuilder circuit_builder = UltraCircuitBuilder(); - bb::fr input_value = fr::random_element(); + fr input_value = fr::random_element(); const fr input_lo = static_cast(input_value).slice(0, plookup::fixed_base::table::BITS_PER_LO_SCALAR); const auto input_lo_index = circuit_builder.add_variable(input_lo); @@ -648,7 +648,7 @@ TEST(ultra_circuit_constructor, non_native_field_multiplication) const auto q_indices = get_limb_witness_indices(split_into_limbs(uint256_t(q))); const auto r_indices = get_limb_witness_indices(split_into_limbs(uint256_t(r))); - bb::non_native_field_witnesses inputs{ + non_native_field_witnesses inputs{ a_indices, b_indices, q_indices, r_indices, modulus_limbs, fr(uint256_t(modulus)), }; const auto [lo_1_idx, hi_1_idx] = circuit_constructor.evaluate_non_native_field_multiplication(inputs); diff --git a/barretenberg/cpp/src/barretenberg/proof_system/composer/composer_lib.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/composer/composer_lib.test.cpp index 1f2aac2b46f0..aad304526642 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/composer/composer_lib.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/composer/composer_lib.test.cpp @@ -6,7 +6,7 @@ #include #include -namespace bb::test_composer_lib { +using namespace bb; class ComposerLibTests : public ::testing::Test { protected: @@ -14,7 +14,7 @@ class ComposerLibTests : public ::testing::Test { using FF = typename Flavor::FF; Flavor::CircuitBuilder circuit_constructor; Flavor::ProvingKey proving_key = []() { - auto crs_factory = bb::srs::factories::CrsFactory(); + auto crs_factory = srs::factories::CrsFactory(); auto crs = crs_factory.get_prover_crs(4); return Flavor::ProvingKey(/*circuit_size=*/8, /*num_public_inputs=*/0); }(); @@ -59,5 +59,3 @@ TEST_F(ComposerLibTests, ConstructSelectors) EXPECT_EQ(proving_key.q_c[2 + offset], 19); EXPECT_EQ(proving_key.q_c[3 + offset], 20); } - -} // namespace bb::test_composer_lib diff --git a/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.test.cpp index 0ebd08ea3821..3fc4d2bcb3c6 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/composer/permutation_lib.test.cpp @@ -6,7 +6,7 @@ #include #include -namespace bb::test_composer_lib { +using namespace bb; class PermutationHelperTests : public ::testing::Test { protected: @@ -14,7 +14,7 @@ class PermutationHelperTests : public ::testing::Test { using FF = typename Flavor::FF; using ProvingKey = Flavor::ProvingKey; Flavor::CircuitBuilder circuit_constructor; - bb::srs::factories::CrsFactory crs_factory = bb::srs::factories::CrsFactory(); + srs::factories::CrsFactory crs_factory = srs::factories::CrsFactory(); std::shared_ptr proving_key; virtual void SetUp() @@ -89,5 +89,3 @@ TEST_F(PermutationHelperTests, ComputeStandardAuxPolynomials) // TODO(#425) Flesh out these tests compute_first_and_last_lagrange_polynomials(proving_key); } - -} // namespace bb::test_composer_lib diff --git a/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.test.cpp index e78684c82c7c..7e78b77e3cd7 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/library/grand_product_library.test.cpp @@ -6,9 +6,8 @@ #include "barretenberg/srs/factories/file_crs_factory.hpp" #include - +using namespace bb; using namespace bb::honk; -namespace grand_product_library_tests { template class GrandProductTests : public testing::Test { @@ -81,7 +80,7 @@ template class GrandProductTests : public testing::Test { auto beta = FF::random_element(); auto gamma = FF::random_element(); - bb::RelationParameters params{ + RelationParameters params{ .eta = 0, .beta = beta, .gamma = gamma, @@ -91,8 +90,7 @@ template class GrandProductTests : public testing::Test { typename Flavor::ProverPolynomials prover_polynomials; for (auto [prover_poly, key_poly] : zip_view(prover_polynomials.get_unshifted(), proving_key->get_all())) { - ASSERT(bb::flavor_get_label(prover_polynomials, prover_poly) == - bb::flavor_get_label(*proving_key, key_poly)); + ASSERT(flavor_get_label(prover_polynomials, prover_poly) == flavor_get_label(*proving_key, key_poly)); prover_poly = key_poly.share(); } @@ -232,7 +230,7 @@ template class GrandProductTests : public testing::Test { auto gamma = FF::random_element(); auto eta = FF::random_element(); - bb::RelationParameters params{ + RelationParameters params{ .eta = eta, .beta = beta, .gamma = gamma, @@ -242,14 +240,13 @@ template class GrandProductTests : public testing::Test { typename Flavor::ProverPolynomials prover_polynomials; for (auto [prover_poly, key_poly] : zip_view(prover_polynomials.get_unshifted(), proving_key->get_all())) { - ASSERT(bb::flavor_get_label(prover_polynomials, prover_poly) == - bb::flavor_get_label(*proving_key, key_poly)); + ASSERT(flavor_get_label(prover_polynomials, prover_poly) == flavor_get_label(*proving_key, key_poly)); prover_poly = key_poly.share(); } for (auto [prover_poly, key_poly] : zip_view(prover_polynomials.get_shifted(), proving_key->get_to_be_shifted())) { - ASSERT(bb::flavor_get_label(prover_polynomials, prover_poly) == - bb::flavor_get_label(*proving_key, key_poly) + "_shift"); + ASSERT(flavor_get_label(prover_polynomials, prover_poly) == + flavor_get_label(*proving_key, key_poly) + "_shift"); prover_poly = key_poly.shifted(); } // Test a few assignments @@ -260,7 +257,7 @@ template class GrandProductTests : public testing::Test { // Method 1: Compute z_lookup using the prover library method constexpr size_t LOOKUP_RELATION_INDEX = 1; using LHS = typename std::tuple_element::type; - using RHS = bb::LookupRelation; + using RHS = LookupRelation; static_assert(std::same_as); grand_product_library::compute_grand_product( proving_key->circuit_size, prover_polynomials, params); @@ -351,5 +348,3 @@ TYPED_TEST(GrandProductTests, GrandProductLookup) { TestFixture::test_lookup_grand_product_construction(); } - -} // namespace grand_product_library_tests diff --git a/barretenberg/cpp/src/barretenberg/proof_system/op_queue/ecc_op_queue.hpp b/barretenberg/cpp/src/barretenberg/proof_system/op_queue/ecc_op_queue.hpp index 1caa057f8584..a4d5d3642ebc 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/op_queue/ecc_op_queue.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/op_queue/ecc_op_queue.hpp @@ -26,7 +26,7 @@ class ECCOpQueue { Point accumulator = point_at_infinity; public: - using ECCVMOperation = bb_eccvm::VMOperation; + using ECCVMOperation = bb::eccvm::VMOperation; std::vector raw_ops; std::array, 4> ultra_ops; // ops encoded in the width-4 Ultra format diff --git a/barretenberg/cpp/src/barretenberg/proof_system/op_queue/ecc_op_queue.test.cpp b/barretenberg/cpp/src/barretenberg/proof_system/op_queue/ecc_op_queue.test.cpp index 2df97e0e8100..7b13cce43f3f 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/op_queue/ecc_op_queue.test.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/op_queue/ecc_op_queue.test.cpp @@ -1,7 +1,8 @@ #include "barretenberg/proof_system/op_queue/ecc_op_queue.hpp" #include -namespace bb::test_flavor { +using namespace bb; + TEST(ECCOpQueueTest, Basic) { ECCOpQueue op_queue; @@ -13,8 +14,8 @@ TEST(ECCOpQueueTest, Basic) TEST(ECCOpQueueTest, InternalAccumulatorCorrectness) { - using point = bb::g1::affine_element; - using scalar = bb::fr; + using point = g1::affine_element; + using scalar = fr; // Compute a simple point accumulation natively auto P1 = point::random_element(); @@ -36,5 +37,3 @@ TEST(ECCOpQueueTest, InternalAccumulatorCorrectness) // Adding an equality op should reset the accumulator to zero (the point at infinity) EXPECT_TRUE(op_queue.get_accumulator().is_point_at_infinity()); } - -} // namespace bb::test_flavor diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/aes128.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/aes128.hpp index 3306338e9b9b..f3102bbfd18e 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/aes128.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/aes128.hpp @@ -8,8 +8,7 @@ #include "sparse.hpp" #include "types.hpp" -namespace plookup { -namespace aes128_tables { +namespace bb::plookup::aes128_tables { static constexpr uint64_t AES_BASE = 9; static constexpr uint64_t aes_normalization_table[AES_BASE]{ 1, 0, 0, 0, 0, 0, 0, 0, 0, @@ -127,7 +126,7 @@ inline MultiTable get_aes_input_table(const MultiTableId id = AES_INPUT) inline std::array get_aes_sbox_values_from_key(const std::array key) { const auto byte = numeric::map_from_sparse_form(key[0]); - uint8_t sbox_value = crypto::aes128::sbox[(uint8_t)byte]; + uint8_t sbox_value = crypto::aes128_sbox[(uint8_t)byte]; uint8_t swizzled = ((uint8_t)(sbox_value << 1) ^ (uint8_t)(((sbox_value >> 7) & 1) * 0x1b)); return { bb::fr(numeric::map_into_sparse_form(sbox_value)), bb::fr(numeric::map_into_sparse_form((uint8_t)(sbox_value ^ swizzled))) }; @@ -142,7 +141,7 @@ inline BasicTable generate_aes_sbox_table(BasicTableId id, const size_t table_in table.use_twin_keys = false; for (uint64_t i = 0; i < table.size; ++i) { const auto first = numeric::map_into_sparse_form((uint8_t)i); - uint8_t sbox_value = crypto::aes128::sbox[(uint8_t)i]; + uint8_t sbox_value = crypto::aes128_sbox[(uint8_t)i]; uint8_t swizzled = ((uint8_t)(sbox_value << 1) ^ (uint8_t)(((sbox_value >> 7) & 1) * 0x1b)); const auto second = numeric::map_into_sparse_form(sbox_value); const auto third = numeric::map_into_sparse_form((uint8_t)(sbox_value ^ swizzled)); @@ -173,5 +172,4 @@ inline MultiTable get_aes_sbox_table(const MultiTableId id = AES_SBOX) } return table; } -} // namespace aes128_tables -} // namespace plookup +} // namespace bb::plookup::aes128_tables diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/blake2s.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/blake2s.hpp index 4cea760b45ec..10a56396e6be 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/blake2s.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/blake2s.hpp @@ -5,8 +5,7 @@ #include "sparse.hpp" #include "types.hpp" -namespace plookup { -namespace blake2s_tables { +namespace bb::plookup::blake2s_tables { static constexpr size_t BITS_IN_LAST_SLICE = 5UL; static constexpr size_t SIZE_OF_LAST_SLICE = (1UL << BITS_IN_LAST_SLICE); @@ -212,5 +211,4 @@ inline MultiTable get_blake2s_xor_rotate_7_table(const MultiTableId id = BLAKE_X return table; } -} // namespace blake2s_tables -} // namespace plookup +} // namespace bb::plookup::blake2s_tables diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/dummy.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/dummy.hpp index 50ba5fa83f8e..f49409c9bbc6 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/dummy.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/dummy.hpp @@ -9,8 +9,7 @@ #include "types.hpp" -namespace plookup { -namespace dummy_tables { +namespace bb::plookup::dummy_tables { /** * @brief Lookup the value corresponding to a specific key @@ -93,5 +92,4 @@ inline MultiTable get_honk_dummy_multitable() table.get_table_values.emplace_back(&get_value_from_key); return table; } -} // namespace dummy_tables -} // namespace plookup \ No newline at end of file +} // namespace bb::plookup::dummy_tables \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/fixed_base/fixed_base.cpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/fixed_base/fixed_base.cpp index 1309aafb5d56..6a470eb835c6 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/fixed_base/fixed_base.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/fixed_base/fixed_base.cpp @@ -6,7 +6,7 @@ #include "barretenberg/numeric/bitop/pow.hpp" #include "barretenberg/numeric/bitop/rotate.hpp" #include "barretenberg/numeric/bitop/sparse_form.hpp" -namespace plookup::fixed_base { +namespace bb::plookup::fixed_base { /** * @brief Given a base_point [P] and an offset_generator [G], compute a lookup table of MAX_TABLE_SIZE that contains the @@ -287,4 +287,4 @@ const std::array table::generate_generator_offset(rhs_base_point_hi), }; -} // namespace plookup::fixed_base \ No newline at end of file +} // namespace bb::plookup::fixed_base \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/fixed_base/fixed_base.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/fixed_base/fixed_base.hpp index d147b3e90746..11922a0433d4 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/fixed_base/fixed_base.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/fixed_base/fixed_base.hpp @@ -6,7 +6,7 @@ #include "barretenberg/crypto/pedersen_hash/pedersen.hpp" #include "barretenberg/ecc/curves/grumpkin/grumpkin.hpp" -namespace plookup::fixed_base { +namespace bb::plookup::fixed_base { /** * @brief Generates plookup tables required to perform fixed-base scalar multiplication over a fixed number of points. @@ -84,4 +84,4 @@ class table : public FixedBaseParams { } }; -} // namespace plookup::fixed_base +} // namespace bb::plookup::fixed_base diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/fixed_base/fixed_base_params.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/fixed_base/fixed_base_params.hpp index 45570b50f23d..94f7a7d9414b 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/fixed_base/fixed_base_params.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/fixed_base/fixed_base_params.hpp @@ -6,7 +6,7 @@ #include #include -namespace plookup { +namespace bb::plookup { /** * @brief Parameters definitions for our fixed-base-scalar-multiplication lookup tables * @@ -73,4 +73,4 @@ struct FixedBaseParams { return MULTI_TABLE_BIT_LENGTHS[multitable_index]; } }; -} // namespace plookup \ No newline at end of file +} // namespace bb::plookup \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_chi.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_chi.hpp index f1a75bd31504..0e5b4a8a5c38 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_chi.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_chi.hpp @@ -4,8 +4,7 @@ #include "barretenberg/common/constexpr_utils.hpp" #include "barretenberg/numeric/bitop/pow.hpp" -namespace plookup { -namespace keccak_tables { +namespace bb::plookup::keccak_tables { /** * @brief Generates plookup tables required for CHI round of Keccak hash function @@ -249,5 +248,4 @@ class Chi { return table; } }; -} // namespace keccak_tables -} // namespace plookup +} // namespace bb::plookup::keccak_tables diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_input.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_input.hpp index 8fdc116f99fb..c3b6d20ae980 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_input.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_input.hpp @@ -5,8 +5,7 @@ #include "barretenberg/numeric/bitop/pow.hpp" #include "barretenberg/numeric/bitop/sparse_form.hpp" -namespace plookup { -namespace keccak_tables { +namespace bb::plookup::keccak_tables { /** * @brief Generates plookup tables used convert 64-bit integers into a sparse representation used for Keccak hash @@ -140,5 +139,4 @@ class KeccakInput { } }; -} // namespace keccak_tables -} // namespace plookup +} // namespace bb::plookup::keccak_tables diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_output.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_output.hpp index 6c5d57429b88..53f2fc9a53f0 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_output.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_output.hpp @@ -7,8 +7,7 @@ #include "../sparse.hpp" #include "../types.hpp" -namespace plookup { -namespace keccak_tables { +namespace bb::plookup::keccak_tables { /** * @brief Converts a base-11 sparse integer representation into a regular base-2 binary integer. @@ -171,5 +170,4 @@ class KeccakOutput { } }; -} // namespace keccak_tables -} // namespace plookup +} // namespace bb::plookup::keccak_tables diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_rho.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_rho.hpp index 96dd0f99ff68..c16085aca8a0 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_rho.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_rho.hpp @@ -4,8 +4,7 @@ #include "barretenberg/common/constexpr_utils.hpp" #include "barretenberg/numeric/bitop/pow.hpp" -namespace plookup { -namespace keccak_tables { +namespace bb::plookup::keccak_tables { /** * @brief Generate the plookup tables used for the RHO round of the Keccak hash algorithm @@ -292,5 +291,4 @@ template class Rho { } }; -} // namespace keccak_tables -} // namespace plookup +} // namespace bb::plookup::keccak_tables diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_theta.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_theta.hpp index c9137f0b3dcc..9f05cf94267a 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_theta.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/keccak/keccak_theta.hpp @@ -4,8 +4,7 @@ #include "barretenberg/common/constexpr_utils.hpp" #include "barretenberg/numeric/bitop/pow.hpp" -namespace plookup { -namespace keccak_tables { +namespace bb::plookup::keccak_tables { /** * @brief Generates plookup tables required for THETA round of Keccak hash function @@ -251,5 +250,4 @@ class Theta { return table; } }; -} // namespace keccak_tables -} // namespace plookup +} // namespace bb::plookup::keccak_tables diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/non_native_group_generator.cpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/non_native_group_generator.cpp index 3e12005d314c..ed172573e24c 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/non_native_group_generator.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/non_native_group_generator.cpp @@ -1,7 +1,6 @@ #include "non_native_group_generator.hpp" -namespace plookup { -namespace ecc_generator_tables { +namespace bb::plookup::ecc_generator_tables { /** * Init 8-bit generator lookup tables @@ -488,5 +487,4 @@ MultiTable ecc_generator_table::get_xyprime_endo_table(const MultiTableId id template class ecc_generator_table; template class ecc_generator_table; -} // namespace ecc_generator_tables -} // namespace plookup \ No newline at end of file +} // namespace bb::plookup::ecc_generator_tables \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/non_native_group_generator.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/non_native_group_generator.hpp index 16fd12a8686d..b57e9247e651 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/non_native_group_generator.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/non_native_group_generator.hpp @@ -6,8 +6,7 @@ #include "barretenberg/ecc/curves/secp256k1/secp256k1.hpp" #include -namespace plookup { -namespace ecc_generator_tables { +namespace bb::plookup::ecc_generator_tables { template class ecc_generator_table { public: @@ -56,5 +55,4 @@ template class ecc_generator_table { static MultiTable get_xyprime_endo_table(const MultiTableId id, const BasicTableId basic_id); }; -} // namespace ecc_generator_tables -} // namespace plookup +} // namespace bb::plookup::ecc_generator_tables diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/plookup_tables.cpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/plookup_tables.cpp index c8f1f83de007..6a2257bf1029 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/plookup_tables.cpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/plookup_tables.cpp @@ -1,7 +1,7 @@ #include "plookup_tables.hpp" #include "barretenberg/common/constexpr_utils.hpp" -namespace plookup { +namespace bb::plookup { using namespace bb; @@ -201,4 +201,4 @@ ReadData get_lookup_accumulators(const MultiTableId id, return lookup; } -} // namespace plookup +} // namespace bb::plookup diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/plookup_tables.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/plookup_tables.hpp index b4fcaeac1a18..492793150d3b 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/plookup_tables.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/plookup_tables.hpp @@ -16,7 +16,7 @@ #include "types.hpp" #include "uint.hpp" -namespace plookup { +namespace bb::plookup { const MultiTable& create_table(MultiTableId id); @@ -213,4 +213,4 @@ inline BasicTable create_basic_table(const BasicTableId id, const size_t index) } } } -} // namespace plookup +} // namespace bb::plookup diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/sha256.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/sha256.hpp index 31316ae56d73..02465bc15d83 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/sha256.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/sha256.hpp @@ -8,8 +8,7 @@ #include "sparse.hpp" #include "types.hpp" -namespace plookup { -namespace sha256_tables { +namespace bb::plookup::sha256_tables { static constexpr uint64_t choose_normalization_table[28]{ /* xor result = 0 */ @@ -390,5 +389,4 @@ inline MultiTable get_majority_input_table(const MultiTableId id = SHA256_MAJ_IN return table; } -} // namespace sha256_tables -} // namespace plookup +} // namespace bb::plookup::sha256_tables diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/sparse.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/sparse.hpp index 5664c8cb4fa2..35c858e30a3d 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/sparse.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/sparse.hpp @@ -7,8 +7,7 @@ #include "barretenberg/numeric/bitop/rotate.hpp" #include "barretenberg/numeric/bitop/sparse_form.hpp" -namespace plookup { -namespace sparse_tables { +namespace bb::plookup::sparse_tables { template inline std::array get_sparse_table_with_rotation_values(const std::array key) @@ -115,5 +114,4 @@ inline BasicTable generate_sparse_normalization_table(BasicTableId id, const siz table.column_3_step_size = bb::fr(0); return table; } -} // namespace sparse_tables -} // namespace plookup +} // namespace bb::plookup::sparse_tables diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/types.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/types.hpp index 181844ea163e..489d9e600716 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/types.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/types.hpp @@ -6,7 +6,7 @@ #include "./fixed_base/fixed_base_params.hpp" #include "barretenberg/ecc/curves/bn254/fr.hpp" -namespace plookup { +namespace bb::plookup { enum BasicTableId { XOR, @@ -325,4 +325,4 @@ template class ReadData { std::array, 3> columns; }; -} // namespace plookup +} // namespace bb::plookup diff --git a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/uint.hpp b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/uint.hpp index dcf02fe79f7e..1ccfecdd2a5b 100644 --- a/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/uint.hpp +++ b/barretenberg/cpp/src/barretenberg/proof_system/plookup_tables/uint.hpp @@ -4,8 +4,7 @@ #include "barretenberg/numeric/bitop/rotate.hpp" -namespace plookup { -namespace uint_tables { +namespace bb::plookup::uint_tables { template inline std::array get_xor_rotate_values_from_key(const std::array key) @@ -103,5 +102,4 @@ inline MultiTable get_uint32_and_table(const MultiTableId id = UINT32_AND) return table; } -} // namespace uint_tables -} // namespace plookup +} // namespace bb::plookup::uint_tables diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/combiner.test.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/combiner.test.cpp index c1367e624141..132ba6144987 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/combiner.test.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/combiner.test.cpp @@ -6,13 +6,12 @@ #include "barretenberg/sumcheck/instance/instances.hpp" #include +using namespace bb; using namespace bb::honk; -namespace bb::test_protogalaxy_prover { -using Flavor = bb::honk::flavor::Ultra; + +using Flavor = honk::flavor::Ultra; using Polynomial = typename Flavor::Polynomial; using FF = typename Flavor::FF; -using RelationParameters = bb::RelationParameters; -using PowPolynomial = bb::PowPolynomial; // TODO(https://github.com/AztecProtocol/barretenberg/issues/780): Improve combiner tests to check more than the // arithmetic relation so we more than unit test folding relation parameters and alpha as well. @@ -43,7 +42,7 @@ TEST(Protogalaxy, CombinerOn2Instances) for (size_t idx = 0; idx < NUM_INSTANCES; idx++) { auto instance = std::make_shared(); - auto prover_polynomials = bb::honk::get_sequential_prover_polynomials( + auto prover_polynomials = honk::get_sequential_prover_polynomials( /*log_circuit_size=*/1, idx * 128); restrict_to_standard_arithmetic_relation(prover_polynomials); instance->prover_polynomials = std::move(prover_polynomials); @@ -52,22 +51,22 @@ TEST(Protogalaxy, CombinerOn2Instances) } ProverInstances instances{ instance_data }; - instances.alphas.fill(Univariate(FF(0))); // focus on the arithmetic relation only + instances.alphas.fill(bb::Univariate(FF(0))); // focus on the arithmetic relation only auto pow_polynomial = PowPolynomial(std::vector{ 2 }); auto result = prover.compute_combiner(instances, pow_polynomial); - auto expected_result = bb::Univariate(std::array{ 87706, - 13644570, - 76451738, - 226257946, - static_cast(500811930), - static_cast(937862426), - static_cast(1575158170), - static_cast(2450447898), - static_cast(3601480346), - static_cast(5066004250), - static_cast(6881768346), - static_cast(9086521370), - static_cast(11718012058) }); + auto expected_result = Univariate(std::array{ 87706, + 13644570, + 76451738, + 226257946, + static_cast(500811930), + static_cast(937862426), + static_cast(1575158170), + static_cast(2450447898), + static_cast(3601480346), + static_cast(5066004250), + static_cast(6881768346), + static_cast(9086521370), + static_cast(11718012058) }); EXPECT_EQ(result, expected_result); } else { std::vector> instance_data(NUM_INSTANCES); @@ -75,7 +74,7 @@ TEST(Protogalaxy, CombinerOn2Instances) for (size_t idx = 0; idx < NUM_INSTANCES; idx++) { auto instance = std::make_shared(); - auto prover_polynomials = bb::honk::get_zero_prover_polynomials( + auto prover_polynomials = honk::get_zero_prover_polynomials( /*log_circuit_size=*/1); restrict_to_standard_arithmetic_relation(prover_polynomials); instance->prover_polynomials = std::move(prover_polynomials); @@ -84,7 +83,7 @@ TEST(Protogalaxy, CombinerOn2Instances) } ProverInstances instances{ instance_data }; - instances.alphas.fill(Univariate(FF(0))); // focus on the arithmetic relation only + instances.alphas.fill(bb::Univariate(FF(0))); // focus on the arithmetic relation only const auto create_add_gate = [](auto& polys, const size_t idx, FF w_l, FF w_r) { polys.w_l[idx] = w_l; @@ -133,7 +132,7 @@ TEST(Protogalaxy, CombinerOn2Instances) auto pow_polynomial = PowPolynomial(std::vector{ 2 }); auto result = prover.compute_combiner(instances, pow_polynomial); auto expected_result = - bb::Univariate(std::array{ 0, 0, 12, 36, 72, 120, 180, 252, 336, 432, 540, 660, 792 }); + Univariate(std::array{ 0, 0, 12, 36, 72, 120, 180, 252, 336, 432, 540, 660, 792 }); EXPECT_EQ(result, expected_result); } @@ -166,7 +165,7 @@ TEST(Protogalaxy, CombinerOn4Instances) for (size_t idx = 0; idx < NUM_INSTANCES; idx++) { auto instance = std::make_shared(); - auto prover_polynomials = bb::honk::get_zero_prover_polynomials( + auto prover_polynomials = honk::get_zero_prover_polynomials( /*log_circuit_size=*/1); instance->prover_polynomials = std::move(prover_polynomials); instance->instance_size = 2; @@ -174,7 +173,7 @@ TEST(Protogalaxy, CombinerOn4Instances) } ProverInstances instances{ instance_data }; - instances.alphas.fill(Univariate(FF(0))); // focus on the arithmetic relation only + instances.alphas.fill(bb::Univariate(FF(0))); // focus on the arithmetic relation only zero_all_selectors(instances[0]->prover_polynomials); zero_all_selectors(instances[1]->prover_polynomials); @@ -185,10 +184,8 @@ TEST(Protogalaxy, CombinerOn4Instances) auto result = prover.compute_combiner(instances, pow_polynomial); std::array zeroes; std::fill(zeroes.begin(), zeroes.end(), 0); - auto expected_result = bb::Univariate(zeroes); + auto expected_result = Univariate(zeroes); EXPECT_EQ(result, expected_result); }; run_test(); }; - -} // namespace bb::test_protogalaxy_prover \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp index ca78b8706045..6a138c51a516 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover.cpp @@ -269,14 +269,10 @@ std::shared_ptr ProtoGalaxyProver_ FoldingResult ProtoGalaxyProver_::fold_instances() { prepare_for_folding(); - - // TODO(#https://github.com/AztecProtocol/barretenberg/issues/740): Handle the case where we are folding for the - // first time and accumulator is 0 FF delta = transcript->get_challenge("delta"); auto accumulator = get_accumulator(); diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp index 0e33b27cd77d..bf7d4c50117c 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp @@ -6,17 +6,20 @@ template void ProtoGalaxyVerifier_::receive_accumulator(const std::shared_ptr& inst, const std::string& domain_separator) { + // Get circuit parameters inst->instance_size = transcript->template receive_from_prover(domain_separator + "_instance_size"); inst->log_instance_size = static_cast(numeric::get_msb(inst->instance_size)); inst->public_input_size = transcript->template receive_from_prover(domain_separator + "_public_input_size"); + // Get folded public inputs for (size_t i = 0; i < inst->public_input_size; ++i) { auto public_input_i = transcript->template receive_from_prover(domain_separator + "_public_input_" + std::to_string(i)); inst->public_inputs.emplace_back(public_input_i); } + // Get folded relation parameters auto eta = transcript->template receive_from_prover(domain_separator + "_eta"); auto beta = transcript->template receive_from_prover(domain_separator + "_beta"); auto gamma = transcript->template receive_from_prover(domain_separator + "_gamma"); @@ -26,6 +29,7 @@ void ProtoGalaxyVerifier_::receive_accumulator(const std::sha inst->relation_parameters = RelationParameters{ eta, beta, gamma, public_input_delta, lookup_grand_product_delta }; + // Get the folded relation separator challenges \vec{α} for (size_t idx = 0; idx < NUM_SUBRELATIONS - 1; idx++) { inst->alphas[idx] = transcript->template receive_from_prover(domain_separator + "_alpha_" + std::to_string(idx)); @@ -33,11 +37,14 @@ void ProtoGalaxyVerifier_::receive_accumulator(const std::sha inst->target_sum = transcript->template receive_from_prover(domain_separator + "_target_sum"); + // Get the folded gate challenges, \vec{β} in the paper inst->gate_challenges = std::vector(inst->log_instance_size); for (size_t idx = 0; idx < inst->log_instance_size; idx++) { inst->gate_challenges[idx] = transcript->template receive_from_prover(domain_separator + "_gate_challenge_" + std::to_string(idx)); } + + // Get the folded commitments to all witness polynomials auto comm_view = inst->witness_commitments.get_all(); auto witness_labels = inst->commitment_labels.get_witness(); for (size_t idx = 0; idx < witness_labels.size(); idx++) { @@ -45,6 +52,7 @@ void ProtoGalaxyVerifier_::receive_accumulator(const std::sha transcript->template receive_from_prover(domain_separator + "_" + witness_labels[idx]); } + // Get the folded commitments to selector polynomials inst->verification_key = std::make_shared(inst->instance_size, inst->public_input_size); auto vk_view = inst->verification_key->get_all(); auto vk_labels = inst->commitment_labels.get_precomputed(); @@ -57,6 +65,7 @@ template void ProtoGalaxyVerifier_::receive_and_finalise_instance(const std::shared_ptr& inst, const std::string& domain_separator) { + // Get circuit parameters and the public inputs inst->instance_size = transcript->template receive_from_prover(domain_separator + "_instance_size"); inst->log_instance_size = static_cast(numeric::get_msb(inst->instance_size)); inst->public_input_size = @@ -71,33 +80,39 @@ void ProtoGalaxyVerifier_::receive_and_finalise_instance(cons inst->pub_inputs_offset = transcript->template receive_from_prover(domain_separator + "_pub_inputs_offset"); + // Get commitments to first three wire polynomials auto labels = inst->commitment_labels; auto& witness_commitments = inst->witness_commitments; witness_commitments.w_l = transcript->template receive_from_prover(domain_separator + "_" + labels.w_l); witness_commitments.w_r = transcript->template receive_from_prover(domain_separator + "_" + labels.w_r); witness_commitments.w_o = transcript->template receive_from_prover(domain_separator + "_" + labels.w_o); + // Get challenge for sorted list batching and wire four memory records commitment auto eta = transcript->get_challenge(domain_separator + "_eta"); witness_commitments.sorted_accum = transcript->template receive_from_prover(domain_separator + "_" + labels.sorted_accum); witness_commitments.w_4 = transcript->template receive_from_prover(domain_separator + "_" + labels.w_4); + // Get permutation challenges and commitment to permutation and lookup grand products auto [beta, gamma] = transcript->get_challenges(domain_separator + "_beta", domain_separator + "_gamma"); witness_commitments.z_perm = transcript->template receive_from_prover(domain_separator + "_" + labels.z_perm); witness_commitments.z_lookup = transcript->template receive_from_prover(domain_separator + "_" + labels.z_lookup); + // Compute correction terms for grand products const FF public_input_delta = compute_public_input_delta( inst->public_inputs, beta, gamma, inst->instance_size, inst->pub_inputs_offset); const FF lookup_grand_product_delta = compute_lookup_grand_product_delta(beta, gamma, inst->instance_size); inst->relation_parameters = RelationParameters{ eta, beta, gamma, public_input_delta, lookup_grand_product_delta }; + // Get the relation separation challenges for (size_t idx = 0; idx < NUM_SUBRELATIONS - 1; idx++) { inst->alphas[idx] = transcript->get_challenge(domain_separator + "_alpha_" + std::to_string(idx)); } + // Get the commitments to the selector polynomials for the given instance inst->verification_key = std::make_shared(inst->instance_size, inst->public_input_size); auto vk_view = inst->verification_key->get_all(); auto vk_labels = labels.get_precomputed(); diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/AvmMini/alu_chip.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/AvmMini/alu_chip.hpp new file mode 100644 index 000000000000..c1cd8a6e9703 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/relations/generated/AvmMini/alu_chip.hpp @@ -0,0 +1,280 @@ + +#pragma once +#include "../../relation_parameters.hpp" +#include "../../relation_types.hpp" +#include "./declare_views.hpp" + +namespace bb::AvmMini_vm { + +template struct Alu_chipRow { + FF aluChip_alu_u16_r0{}; + FF aluChip_alu_u16_r3{}; + FF aluChip_alu_u16_r5{}; + FF aluChip_alu_u16_r1_shift{}; + FF aluChip_alu_u16_r0_shift{}; + FF aluChip_alu_op_add{}; + FF aluChip_alu_ia{}; + FF aluChip_alu_u16_r4_shift{}; + FF aluChip_alu_ib{}; + FF aluChip_alu_u16_r7{}; + FF aluChip_alu_u8_r0{}; + FF aluChip_alu_u16_r7_shift{}; + FF aluChip_alu_op_sub{}; + FF aluChip_alu_u16_r6{}; + FF aluChip_alu_u16_r5_shift{}; + FF aluChip_alu_op_mul{}; + FF aluChip_alu_u64_tag{}; + FF aluChip_alu_u16_r2_shift{}; + FF aluChip_alu_u64_r0{}; + FF aluChip_alu_ff_tag{}; + FF aluChip_alu_u32_tag{}; + FF aluChip_alu_u16_tag{}; + FF aluChip_alu_u16_r4{}; + FF aluChip_alu_u16_r6_shift{}; + FF aluChip_alu_u16_r2{}; + FF aluChip_alu_ic{}; + FF aluChip_alu_u8_tag{}; + FF aluChip_alu_cf{}; + FF aluChip_alu_u16_r3_shift{}; + FF aluChip_alu_u8_r1{}; + FF aluChip_alu_u16_r1{}; + FF aluChip_alu_u128_tag{}; +}; + +inline std::string get_relation_label_alu_chip(int index) +{ + switch (index) { + case 9: + return "ALU_MUL_COMMON_1"; + + case 8: + return "ALU_MULTIPLICATION_FF"; + + case 6: + return "ALU_ADD_SUB_1"; + + case 7: + return "ALU_ADD_SUB_2"; + + case 10: + return "ALU_MUL_COMMON_2"; + + case 13: + return "ALU_MULTIPLICATION_OUT_U128"; + } + return std::to_string(index); +} + +template class alu_chipImpl { + public: + using FF = FF_; + + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ + 3, 3, 3, 3, 3, 3, 4, 5, 5, 5, 5, 6, 6, 8, + }; + + template + void static accumulate(ContainerOverSubrelations& evals, + const AllEntities& new_term, + [[maybe_unused]] const RelationParameters&, + [[maybe_unused]] const FF& scaling_factor) + { + + // Contribution 0 + { + AvmMini_DECLARE_VIEWS(0); + + auto tmp = (aluChip_alu_ff_tag * (-aluChip_alu_ff_tag + FF(1))); + tmp *= scaling_factor; + std::get<0>(evals) += tmp; + } + // Contribution 1 + { + AvmMini_DECLARE_VIEWS(1); + + auto tmp = (aluChip_alu_u8_tag * (-aluChip_alu_u8_tag + FF(1))); + tmp *= scaling_factor; + std::get<1>(evals) += tmp; + } + // Contribution 2 + { + AvmMini_DECLARE_VIEWS(2); + + auto tmp = (aluChip_alu_u16_tag * (-aluChip_alu_u16_tag + FF(1))); + tmp *= scaling_factor; + std::get<2>(evals) += tmp; + } + // Contribution 3 + { + AvmMini_DECLARE_VIEWS(3); + + auto tmp = (aluChip_alu_u32_tag * (-aluChip_alu_u32_tag + FF(1))); + tmp *= scaling_factor; + std::get<3>(evals) += tmp; + } + // Contribution 4 + { + AvmMini_DECLARE_VIEWS(4); + + auto tmp = (aluChip_alu_u64_tag * (-aluChip_alu_u64_tag + FF(1))); + tmp *= scaling_factor; + std::get<4>(evals) += tmp; + } + // Contribution 5 + { + AvmMini_DECLARE_VIEWS(5); + + auto tmp = (aluChip_alu_u128_tag * (-aluChip_alu_u128_tag + FF(1))); + tmp *= scaling_factor; + std::get<5>(evals) += tmp; + } + // Contribution 6 + { + AvmMini_DECLARE_VIEWS(6); + + auto tmp = + (((aluChip_alu_op_add + aluChip_alu_op_sub) * + ((((((((((aluChip_alu_u8_r0 + (aluChip_alu_u8_r1 * FF(256))) + (aluChip_alu_u16_r0 * FF(65536))) + + (aluChip_alu_u16_r1 * FF(4294967296UL))) + + (aluChip_alu_u16_r2 * FF(281474976710656UL))) + + (aluChip_alu_u16_r3 * FF(uint256_t{ 0, 1, 0, 0 }))) + + (aluChip_alu_u16_r4 * FF(uint256_t{ 0, 65536, 0, 0 }))) + + (aluChip_alu_u16_r5 * FF(uint256_t{ 0, 4294967296, 0, 0 }))) + + (aluChip_alu_u16_r6 * FF(uint256_t{ 0, 281474976710656, 0, 0 }))) - + aluChip_alu_ia) + + (aluChip_alu_ff_tag * aluChip_alu_ic))) + + ((aluChip_alu_op_add - aluChip_alu_op_sub) * + ((aluChip_alu_cf * FF(uint256_t{ 0, 0, 1, 0 })) - aluChip_alu_ib))); + tmp *= scaling_factor; + std::get<6>(evals) += tmp; + } + // Contribution 7 + { + AvmMini_DECLARE_VIEWS(7); + + auto tmp = + (((aluChip_alu_op_add + aluChip_alu_op_sub) * + (((((((aluChip_alu_u8_tag * aluChip_alu_u8_r0) + + (aluChip_alu_u16_tag * (aluChip_alu_u8_r0 + (aluChip_alu_u8_r1 * FF(256))))) + + (aluChip_alu_u32_tag * + ((aluChip_alu_u8_r0 + (aluChip_alu_u8_r1 * FF(256))) + (aluChip_alu_u16_r0 * FF(65536))))) + + (aluChip_alu_u64_tag * + ((((aluChip_alu_u8_r0 + (aluChip_alu_u8_r1 * FF(256))) + (aluChip_alu_u16_r0 * FF(65536))) + + (aluChip_alu_u16_r1 * FF(4294967296UL))) + + (aluChip_alu_u16_r2 * FF(281474976710656UL))))) + + (aluChip_alu_u128_tag * + ((((((((aluChip_alu_u8_r0 + (aluChip_alu_u8_r1 * FF(256))) + (aluChip_alu_u16_r0 * FF(65536))) + + (aluChip_alu_u16_r1 * FF(4294967296UL))) + + (aluChip_alu_u16_r2 * FF(281474976710656UL))) + + (aluChip_alu_u16_r3 * FF(uint256_t{ 0, 1, 0, 0 }))) + + (aluChip_alu_u16_r4 * FF(uint256_t{ 0, 65536, 0, 0 }))) + + (aluChip_alu_u16_r5 * FF(uint256_t{ 0, 4294967296, 0, 0 }))) + + (aluChip_alu_u16_r6 * FF(uint256_t{ 0, 281474976710656, 0, 0 }))))) + + (aluChip_alu_ff_tag * aluChip_alu_ia)) - + aluChip_alu_ic)) + + ((aluChip_alu_ff_tag * (aluChip_alu_op_add - aluChip_alu_op_sub)) * aluChip_alu_ib)); + tmp *= scaling_factor; + std::get<7>(evals) += tmp; + } + // Contribution 8 + { + AvmMini_DECLARE_VIEWS(8); + + auto tmp = + ((aluChip_alu_ff_tag * aluChip_alu_op_mul) * ((aluChip_alu_ia * aluChip_alu_ib) - aluChip_alu_ic)); + tmp *= scaling_factor; + std::get<8>(evals) += tmp; + } + // Contribution 9 + { + AvmMini_DECLARE_VIEWS(9); + + auto tmp = + ((((-aluChip_alu_ff_tag + FF(1)) - aluChip_alu_u128_tag) * aluChip_alu_op_mul) * + (((((((((aluChip_alu_u8_r0 + (aluChip_alu_u8_r1 * FF(256))) + (aluChip_alu_u16_r0 * FF(65536))) + + (aluChip_alu_u16_r1 * FF(4294967296UL))) + + (aluChip_alu_u16_r2 * FF(281474976710656UL))) + + (aluChip_alu_u16_r3 * FF(uint256_t{ 0, 1, 0, 0 }))) + + (aluChip_alu_u16_r4 * FF(uint256_t{ 0, 65536, 0, 0 }))) + + (aluChip_alu_u16_r5 * FF(uint256_t{ 0, 4294967296, 0, 0 }))) + + (aluChip_alu_u16_r6 * FF(uint256_t{ 0, 281474976710656, 0, 0 }))) - + (aluChip_alu_ia * aluChip_alu_ib))); + tmp *= scaling_factor; + std::get<9>(evals) += tmp; + } + // Contribution 10 + { + AvmMini_DECLARE_VIEWS(10); + + auto tmp = (aluChip_alu_op_mul * + (((((aluChip_alu_u8_tag * aluChip_alu_u8_r0) + + (aluChip_alu_u16_tag * (aluChip_alu_u8_r0 + (aluChip_alu_u8_r1 * FF(256))))) + + (aluChip_alu_u32_tag * + ((aluChip_alu_u8_r0 + (aluChip_alu_u8_r1 * FF(256))) + (aluChip_alu_u16_r0 * FF(65536))))) + + (aluChip_alu_u64_tag * + ((((aluChip_alu_u8_r0 + (aluChip_alu_u8_r1 * FF(256))) + (aluChip_alu_u16_r0 * FF(65536))) + + (aluChip_alu_u16_r1 * FF(4294967296UL))) + + (aluChip_alu_u16_r2 * FF(281474976710656UL))))) - + (((-aluChip_alu_ff_tag + FF(1)) - aluChip_alu_u128_tag) * aluChip_alu_ic))); + tmp *= scaling_factor; + std::get<10>(evals) += tmp; + } + // Contribution 11 + { + AvmMini_DECLARE_VIEWS(11); + + auto tmp = ((aluChip_alu_u128_tag * aluChip_alu_op_mul) * + (((((aluChip_alu_u16_r0 + (aluChip_alu_u16_r1 * FF(65536))) + + (aluChip_alu_u16_r2 * FF(4294967296UL))) + + (aluChip_alu_u16_r3 * FF(281474976710656UL))) + + ((((aluChip_alu_u16_r4 + (aluChip_alu_u16_r5 * FF(65536))) + + (aluChip_alu_u16_r6 * FF(4294967296UL))) + + (aluChip_alu_u16_r7 * FF(281474976710656UL))) * + FF(uint256_t{ 0, 1, 0, 0 }))) - + aluChip_alu_ia)); + tmp *= scaling_factor; + std::get<11>(evals) += tmp; + } + // Contribution 12 + { + AvmMini_DECLARE_VIEWS(12); + + auto tmp = ((aluChip_alu_u128_tag * aluChip_alu_op_mul) * + (((((aluChip_alu_u16_r0_shift + (aluChip_alu_u16_r1_shift * FF(65536))) + + (aluChip_alu_u16_r2_shift * FF(4294967296UL))) + + (aluChip_alu_u16_r3_shift * FF(281474976710656UL))) + + ((((aluChip_alu_u16_r4_shift + (aluChip_alu_u16_r5_shift * FF(65536))) + + (aluChip_alu_u16_r6_shift * FF(4294967296UL))) + + (aluChip_alu_u16_r7_shift * FF(281474976710656UL))) * + FF(uint256_t{ 0, 1, 0, 0 }))) - + aluChip_alu_ib)); + tmp *= scaling_factor; + std::get<12>(evals) += tmp; + } + // Contribution 13 + { + AvmMini_DECLARE_VIEWS(13); + + auto tmp = ((aluChip_alu_u128_tag * aluChip_alu_op_mul) * + ((((aluChip_alu_ia * (((aluChip_alu_u16_r0_shift + (aluChip_alu_u16_r1_shift * FF(65536))) + + (aluChip_alu_u16_r2_shift * FF(4294967296UL))) + + (aluChip_alu_u16_r3_shift * FF(281474976710656UL)))) + + (((((aluChip_alu_u16_r0 + (aluChip_alu_u16_r1 * FF(65536))) + + (aluChip_alu_u16_r2 * FF(4294967296UL))) + + (aluChip_alu_u16_r3 * FF(281474976710656UL))) * + (((aluChip_alu_u16_r4_shift + (aluChip_alu_u16_r5_shift * FF(65536))) + + (aluChip_alu_u16_r6_shift * FF(4294967296UL))) + + (aluChip_alu_u16_r7_shift * FF(281474976710656UL)))) * + FF(uint256_t{ 0, 1, 0, 0 }))) - + (((aluChip_alu_cf * FF(uint256_t{ 0, 1, 0, 0 })) + aluChip_alu_u64_r0) * + FF(uint256_t{ 0, 0, 1, 0 }))) - + aluChip_alu_ic)); + tmp *= scaling_factor; + std::get<13>(evals) += tmp; + } + } +}; + +template using alu_chip = Relation>; + +} // namespace bb::AvmMini_vm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/AvmMini/avm_mini.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/AvmMini/avm_mini.hpp index d78c623933c9..3347e38ff96d 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/AvmMini/avm_mini.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/AvmMini/avm_mini.hpp @@ -7,70 +7,61 @@ namespace bb::AvmMini_vm { template struct Avm_miniRow { - FF avmMini_rwa{}; + FF avmMini_sel_op_sub{}; + FF avmMini_inv{}; + FF avmMini_first{}; + FF avmMini_tag_err{}; + FF avmMini_pc_shift{}; FF avmMini_mem_op_a{}; - FF avmMini_sel_op_mul{}; + FF avmMini_rwb{}; FF avmMini_mem_op_c{}; FF avmMini_internal_return_ptr_shift{}; + FF avmMini_rwc{}; FF avmMini_sel_op_div{}; - FF avmMini_rwb{}; - FF avmMini_pc_shift{}; FF avmMini_internal_return_ptr{}; - FF avmMini_sel_internal_call{}; + FF avmMini_pc{}; FF avmMini_ia{}; - FF avmMini_mem_idx_a{}; - FF avmMini_sel_op_add{}; + FF avmMini_sel_op_mul{}; FF avmMini_mem_op_b{}; - FF avmMini_inv{}; - FF avmMini_tag_err{}; - FF avmMini_op_err{}; FF avmMini_ib{}; - FF avmMini_pc{}; - FF avmMini_sel_internal_return{}; FF avmMini_sel_jump{}; - FF avmMini_rwc{}; - FF avmMini_first{}; FF avmMini_sel_halt{}; - FF avmMini_ic{}; + FF avmMini_sel_internal_return{}; + FF avmMini_op_err{}; + FF avmMini_mem_idx_a{}; FF avmMini_mem_idx_b{}; - FF avmMini_sel_op_sub{}; + FF avmMini_sel_internal_call{}; + FF avmMini_sel_op_add{}; + FF avmMini_rwa{}; + FF avmMini_ic{}; }; inline std::string get_relation_label_avm_mini(int index) { switch (index) { - case 19: - return "SUBOP_ADDITION_FF"; + case 20: + return "SUBOP_DIVISION_ZERO_ERR1"; - case 21: - return "SUBOP_MULTIPLICATION_FF"; + case 22: + return "SUBOP_ERROR_RELEVANT_OP"; - case 33: + case 30: return "RETURN_POINTER_DECREMENT"; - case 39: + case 36: return "INTERNAL_RETURN_POINTER_CONSISTENCY"; - case 27: - return "RETURN_POINTER_INCREMENT"; - - case 24: + case 21: return "SUBOP_DIVISION_ZERO_ERR2"; - case 20: - return "SUBOP_SUBTRACTION_FF"; - - case 22: - return "SUBOP_DIVISION_FF"; - - case 25: - return "SUBOP_ERROR_RELEVANT_OP"; + case 35: + return "PC_INCREMENT"; - case 23: - return "SUBOP_DIVISION_ZERO_ERR1"; + case 24: + return "RETURN_POINTER_INCREMENT"; - case 38: - return "PC_INCREMENT"; + case 19: + return "SUBOP_DIVISION_FF"; } return std::to_string(index); } @@ -79,9 +70,8 @@ template class avm_miniImpl { public: using FF = FF_; - static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 4, 5, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 3, + static constexpr std::array SUBRELATION_PARTIAL_LENGTHS{ + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 3, }; template @@ -247,7 +237,7 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(19); - auto tmp = (avmMini_sel_op_add * ((avmMini_ia + avmMini_ib) - avmMini_ic)); + auto tmp = ((avmMini_sel_op_div * (-avmMini_op_err + FF(1))) * ((avmMini_ic * avmMini_ib) - avmMini_ia)); tmp *= scaling_factor; std::get<19>(evals) += tmp; } @@ -255,7 +245,7 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(20); - auto tmp = (avmMini_sel_op_sub * ((avmMini_ia - avmMini_ib) - avmMini_ic)); + auto tmp = (avmMini_sel_op_div * (((avmMini_ib * avmMini_inv) - FF(1)) + avmMini_op_err)); tmp *= scaling_factor; std::get<20>(evals) += tmp; } @@ -263,7 +253,7 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(21); - auto tmp = (avmMini_sel_op_mul * ((avmMini_ia * avmMini_ib) - avmMini_ic)); + auto tmp = ((avmMini_sel_op_div * avmMini_op_err) * (-avmMini_inv + FF(1))); tmp *= scaling_factor; std::get<21>(evals) += tmp; } @@ -271,7 +261,7 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(22); - auto tmp = ((avmMini_sel_op_div * (-avmMini_op_err + FF(1))) * ((avmMini_ic * avmMini_ib) - avmMini_ia)); + auto tmp = (avmMini_op_err * (avmMini_sel_op_div - FF(1))); tmp *= scaling_factor; std::get<22>(evals) += tmp; } @@ -279,7 +269,7 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(23); - auto tmp = (avmMini_sel_op_div * (((avmMini_ib * avmMini_inv) - FF(1)) + avmMini_op_err)); + auto tmp = (avmMini_sel_jump * (avmMini_pc_shift - avmMini_ia)); tmp *= scaling_factor; std::get<23>(evals) += tmp; } @@ -287,7 +277,8 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(24); - auto tmp = ((avmMini_sel_op_div * avmMini_op_err) * (-avmMini_inv + FF(1))); + auto tmp = (avmMini_sel_internal_call * + (avmMini_internal_return_ptr_shift - (avmMini_internal_return_ptr + FF(1)))); tmp *= scaling_factor; std::get<24>(evals) += tmp; } @@ -295,7 +286,7 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(25); - auto tmp = (avmMini_op_err * (avmMini_sel_op_div - FF(1))); + auto tmp = (avmMini_sel_internal_call * (avmMini_internal_return_ptr - avmMini_mem_idx_b)); tmp *= scaling_factor; std::get<25>(evals) += tmp; } @@ -303,7 +294,7 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(26); - auto tmp = (avmMini_sel_jump * (avmMini_pc_shift - avmMini_ia)); + auto tmp = (avmMini_sel_internal_call * (avmMini_pc_shift - avmMini_ia)); tmp *= scaling_factor; std::get<26>(evals) += tmp; } @@ -311,8 +302,7 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(27); - auto tmp = (avmMini_sel_internal_call * - (avmMini_internal_return_ptr_shift - (avmMini_internal_return_ptr + FF(1)))); + auto tmp = (avmMini_sel_internal_call * ((avmMini_pc + FF(1)) - avmMini_ib)); tmp *= scaling_factor; std::get<27>(evals) += tmp; } @@ -320,7 +310,7 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(28); - auto tmp = (avmMini_sel_internal_call * (avmMini_internal_return_ptr - avmMini_mem_idx_b)); + auto tmp = (avmMini_sel_internal_call * (avmMini_rwb - FF(1))); tmp *= scaling_factor; std::get<28>(evals) += tmp; } @@ -328,7 +318,7 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(29); - auto tmp = (avmMini_sel_internal_call * (avmMini_pc_shift - avmMini_ia)); + auto tmp = (avmMini_sel_internal_call * (avmMini_mem_op_b - FF(1))); tmp *= scaling_factor; std::get<29>(evals) += tmp; } @@ -336,7 +326,8 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(30); - auto tmp = (avmMini_sel_internal_call * ((avmMini_pc + FF(1)) - avmMini_ib)); + auto tmp = (avmMini_sel_internal_return * + (avmMini_internal_return_ptr_shift - (avmMini_internal_return_ptr - FF(1)))); tmp *= scaling_factor; std::get<30>(evals) += tmp; } @@ -344,7 +335,7 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(31); - auto tmp = (avmMini_sel_internal_call * (avmMini_rwb - FF(1))); + auto tmp = (avmMini_sel_internal_return * ((avmMini_internal_return_ptr - FF(1)) - avmMini_mem_idx_a)); tmp *= scaling_factor; std::get<31>(evals) += tmp; } @@ -352,7 +343,7 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(32); - auto tmp = (avmMini_sel_internal_call * (avmMini_mem_op_b - FF(1))); + auto tmp = (avmMini_sel_internal_return * (avmMini_pc_shift - avmMini_ia)); tmp *= scaling_factor; std::get<32>(evals) += tmp; } @@ -360,8 +351,7 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(33); - auto tmp = (avmMini_sel_internal_return * - (avmMini_internal_return_ptr_shift - (avmMini_internal_return_ptr - FF(1)))); + auto tmp = (avmMini_sel_internal_return * avmMini_rwa); tmp *= scaling_factor; std::get<33>(evals) += tmp; } @@ -369,7 +359,7 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(34); - auto tmp = (avmMini_sel_internal_return * ((avmMini_internal_return_ptr - FF(1)) - avmMini_mem_idx_a)); + auto tmp = (avmMini_sel_internal_return * (avmMini_mem_op_a - FF(1))); tmp *= scaling_factor; std::get<34>(evals) += tmp; } @@ -377,46 +367,22 @@ template class avm_miniImpl { { AvmMini_DECLARE_VIEWS(35); - auto tmp = (avmMini_sel_internal_return * (avmMini_pc_shift - avmMini_ia)); - tmp *= scaling_factor; - std::get<35>(evals) += tmp; - } - // Contribution 36 - { - AvmMini_DECLARE_VIEWS(36); - - auto tmp = (avmMini_sel_internal_return * avmMini_rwa); - tmp *= scaling_factor; - std::get<36>(evals) += tmp; - } - // Contribution 37 - { - AvmMini_DECLARE_VIEWS(37); - - auto tmp = (avmMini_sel_internal_return * (avmMini_mem_op_a - FF(1))); - tmp *= scaling_factor; - std::get<37>(evals) += tmp; - } - // Contribution 38 - { - AvmMini_DECLARE_VIEWS(38); - auto tmp = ((((-avmMini_first + FF(1)) * (-avmMini_sel_halt + FF(1))) * (((avmMini_sel_op_add + avmMini_sel_op_sub) + avmMini_sel_op_div) + avmMini_sel_op_mul)) * (avmMini_pc_shift - (avmMini_pc + FF(1)))); tmp *= scaling_factor; - std::get<38>(evals) += tmp; + std::get<35>(evals) += tmp; } - // Contribution 39 + // Contribution 36 { - AvmMini_DECLARE_VIEWS(39); + AvmMini_DECLARE_VIEWS(36); auto tmp = ((-(((avmMini_first + avmMini_sel_internal_call) + avmMini_sel_internal_return) + avmMini_sel_halt) + FF(1)) * (avmMini_internal_return_ptr_shift - avmMini_internal_return_ptr)); tmp *= scaling_factor; - std::get<39>(evals) += tmp; + std::get<36>(evals) += tmp; } } }; diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/AvmMini/declare_views.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/AvmMini/declare_views.hpp index bf4df9cb83e5..1b036e259194 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/AvmMini/declare_views.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/AvmMini/declare_views.hpp @@ -15,6 +15,32 @@ [[maybe_unused]] auto memTrace_m_in_tag = View(new_term.memTrace_m_in_tag); \ [[maybe_unused]] auto memTrace_m_tag_err = View(new_term.memTrace_m_tag_err); \ [[maybe_unused]] auto memTrace_m_one_min_inv = View(new_term.memTrace_m_one_min_inv); \ + [[maybe_unused]] auto aluChip_alu_clk = View(new_term.aluChip_alu_clk); \ + [[maybe_unused]] auto aluChip_alu_ia = View(new_term.aluChip_alu_ia); \ + [[maybe_unused]] auto aluChip_alu_ib = View(new_term.aluChip_alu_ib); \ + [[maybe_unused]] auto aluChip_alu_ic = View(new_term.aluChip_alu_ic); \ + [[maybe_unused]] auto aluChip_alu_op_add = View(new_term.aluChip_alu_op_add); \ + [[maybe_unused]] auto aluChip_alu_op_sub = View(new_term.aluChip_alu_op_sub); \ + [[maybe_unused]] auto aluChip_alu_op_mul = View(new_term.aluChip_alu_op_mul); \ + [[maybe_unused]] auto aluChip_alu_op_div = View(new_term.aluChip_alu_op_div); \ + [[maybe_unused]] auto aluChip_alu_ff_tag = View(new_term.aluChip_alu_ff_tag); \ + [[maybe_unused]] auto aluChip_alu_u8_tag = View(new_term.aluChip_alu_u8_tag); \ + [[maybe_unused]] auto aluChip_alu_u16_tag = View(new_term.aluChip_alu_u16_tag); \ + [[maybe_unused]] auto aluChip_alu_u32_tag = View(new_term.aluChip_alu_u32_tag); \ + [[maybe_unused]] auto aluChip_alu_u64_tag = View(new_term.aluChip_alu_u64_tag); \ + [[maybe_unused]] auto aluChip_alu_u128_tag = View(new_term.aluChip_alu_u128_tag); \ + [[maybe_unused]] auto aluChip_alu_u8_r0 = View(new_term.aluChip_alu_u8_r0); \ + [[maybe_unused]] auto aluChip_alu_u8_r1 = View(new_term.aluChip_alu_u8_r1); \ + [[maybe_unused]] auto aluChip_alu_u16_r0 = View(new_term.aluChip_alu_u16_r0); \ + [[maybe_unused]] auto aluChip_alu_u16_r1 = View(new_term.aluChip_alu_u16_r1); \ + [[maybe_unused]] auto aluChip_alu_u16_r2 = View(new_term.aluChip_alu_u16_r2); \ + [[maybe_unused]] auto aluChip_alu_u16_r3 = View(new_term.aluChip_alu_u16_r3); \ + [[maybe_unused]] auto aluChip_alu_u16_r4 = View(new_term.aluChip_alu_u16_r4); \ + [[maybe_unused]] auto aluChip_alu_u16_r5 = View(new_term.aluChip_alu_u16_r5); \ + [[maybe_unused]] auto aluChip_alu_u16_r6 = View(new_term.aluChip_alu_u16_r6); \ + [[maybe_unused]] auto aluChip_alu_u16_r7 = View(new_term.aluChip_alu_u16_r7); \ + [[maybe_unused]] auto aluChip_alu_u64_r0 = View(new_term.aluChip_alu_u64_r0); \ + [[maybe_unused]] auto aluChip_alu_cf = View(new_term.aluChip_alu_cf); \ [[maybe_unused]] auto avmMini_pc = View(new_term.avmMini_pc); \ [[maybe_unused]] auto avmMini_internal_return_ptr = View(new_term.avmMini_internal_return_ptr); \ [[maybe_unused]] auto avmMini_sel_internal_call = View(new_term.avmMini_sel_internal_call); \ @@ -42,9 +68,17 @@ [[maybe_unused]] auto avmMini_mem_idx_b = View(new_term.avmMini_mem_idx_b); \ [[maybe_unused]] auto avmMini_mem_idx_c = View(new_term.avmMini_mem_idx_c); \ [[maybe_unused]] auto avmMini_last = View(new_term.avmMini_last); \ - [[maybe_unused]] auto memTrace_m_rw_shift = View(new_term.memTrace_m_rw_shift); \ + [[maybe_unused]] auto aluChip_alu_u16_r1_shift = View(new_term.aluChip_alu_u16_r1_shift); \ + [[maybe_unused]] auto aluChip_alu_u16_r0_shift = View(new_term.aluChip_alu_u16_r0_shift); \ + [[maybe_unused]] auto aluChip_alu_u16_r4_shift = View(new_term.aluChip_alu_u16_r4_shift); \ + [[maybe_unused]] auto aluChip_alu_u16_r7_shift = View(new_term.aluChip_alu_u16_r7_shift); \ + [[maybe_unused]] auto aluChip_alu_u16_r5_shift = View(new_term.aluChip_alu_u16_r5_shift); \ + [[maybe_unused]] auto aluChip_alu_u16_r2_shift = View(new_term.aluChip_alu_u16_r2_shift); \ + [[maybe_unused]] auto aluChip_alu_u16_r6_shift = View(new_term.aluChip_alu_u16_r6_shift); \ + [[maybe_unused]] auto aluChip_alu_u16_r3_shift = View(new_term.aluChip_alu_u16_r3_shift); \ + [[maybe_unused]] auto avmMini_pc_shift = View(new_term.avmMini_pc_shift); \ + [[maybe_unused]] auto avmMini_internal_return_ptr_shift = View(new_term.avmMini_internal_return_ptr_shift); \ [[maybe_unused]] auto memTrace_m_tag_shift = View(new_term.memTrace_m_tag_shift); \ [[maybe_unused]] auto memTrace_m_addr_shift = View(new_term.memTrace_m_addr_shift); \ [[maybe_unused]] auto memTrace_m_val_shift = View(new_term.memTrace_m_val_shift); \ - [[maybe_unused]] auto avmMini_internal_return_ptr_shift = View(new_term.avmMini_internal_return_ptr_shift); \ - [[maybe_unused]] auto avmMini_pc_shift = View(new_term.avmMini_pc_shift); + [[maybe_unused]] auto memTrace_m_rw_shift = View(new_term.memTrace_m_rw_shift); diff --git a/barretenberg/cpp/src/barretenberg/relations/generated/AvmMini/mem_trace.hpp b/barretenberg/cpp/src/barretenberg/relations/generated/AvmMini/mem_trace.hpp index abb9e8539782..49cc8062e820 100644 --- a/barretenberg/cpp/src/barretenberg/relations/generated/AvmMini/mem_trace.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/generated/AvmMini/mem_trace.hpp @@ -8,18 +8,18 @@ namespace bb::AvmMini_vm { template struct Mem_traceRow { FF memTrace_m_val{}; - FF memTrace_m_lastAccess{}; - FF memTrace_m_tag_err{}; - FF memTrace_m_rw_shift{}; + FF memTrace_m_last{}; FF memTrace_m_in_tag{}; + FF memTrace_m_tag{}; FF memTrace_m_rw{}; FF memTrace_m_tag_shift{}; - FF memTrace_m_last{}; FF memTrace_m_addr_shift{}; - FF memTrace_m_tag{}; + FF memTrace_m_tag_err{}; FF memTrace_m_one_min_inv{}; FF memTrace_m_val_shift{}; + FF memTrace_m_lastAccess{}; FF memTrace_m_addr{}; + FF memTrace_m_rw_shift{}; }; inline std::string get_relation_label_mem_trace(int index) @@ -28,11 +28,8 @@ inline std::string get_relation_label_mem_trace(int index) case 8: return "MEM_IN_TAG_CONSISTENCY_1"; - case 7: - return "MEM_ZERO_INIT"; - - case 6: - return "MEM_READ_WRITE_TAG_CONSISTENCY"; + case 9: + return "MEM_IN_TAG_CONSISTENCY_2"; case 5: return "MEM_READ_WRITE_VAL_CONSISTENCY"; @@ -40,8 +37,11 @@ inline std::string get_relation_label_mem_trace(int index) case 4: return "MEM_LAST_ACCESS_DELIMITER"; - case 9: - return "MEM_IN_TAG_CONSISTENCY_2"; + case 6: + return "MEM_READ_WRITE_TAG_CONSISTENCY"; + + case 7: + return "MEM_ZERO_INIT"; } return std::to_string(index); } diff --git a/barretenberg/cpp/src/barretenberg/relations/nested_containers.test.cpp b/barretenberg/cpp/src/barretenberg/relations/nested_containers.test.cpp index 6a6e08d0ddff..730125f0bc9a 100644 --- a/barretenberg/cpp/src/barretenberg/relations/nested_containers.test.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/nested_containers.test.cpp @@ -5,9 +5,7 @@ using namespace bb; -namespace bb::nested_contianers_tests { - -using FF = bb::fr; +using FF = fr; class NestedContainers : public testing::Test {}; @@ -15,12 +13,10 @@ TEST_F(NestedContainers, Univariate) { static constexpr std::array LENGTHS = { 0, 1, 2 }; static constexpr TupleOfUnivariates tuple; - static constexpr auto result0 = bb::Univariate(); - static constexpr auto result1 = bb::Univariate(); - static constexpr auto result2 = bb::Univariate(); + static constexpr auto result0 = Univariate(); + static constexpr auto result1 = Univariate(); + static constexpr auto result2 = Univariate(); EXPECT_EQ(std::get<0>(tuple), result0); EXPECT_EQ(std::get<1>(tuple), result1); EXPECT_EQ(std::get<2>(tuple), result2); } - -} // namespace bb::nested_contianers_tests diff --git a/barretenberg/cpp/src/barretenberg/relations/relation_manual.test.cpp b/barretenberg/cpp/src/barretenberg/relations/relation_manual.test.cpp index efe920903b92..099a7c3f25de 100644 --- a/barretenberg/cpp/src/barretenberg/relations/relation_manual.test.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/relation_manual.test.cpp @@ -4,16 +4,16 @@ #include "barretenberg/relations/relation_parameters.hpp" #include -namespace bb::relation_manual_tests { +using namespace bb; -using FF = bb::fr; +using FF = fr; class RelationManual : public testing::Test {}; TEST_F(RelationManual, Poseidon2ExternalRelationZeros) { using Accumulator = std::array; - using Relation = Poseidon2ExternalRelation; + using Relation = bb::Poseidon2ExternalRelation; Accumulator acc{ 0, 0, 0, 0 }; struct AllPoseidonValues { @@ -44,7 +44,7 @@ TEST_F(RelationManual, Poseidon2ExternalRelationZeros) TEST_F(RelationManual, Poseidon2ExternalRelationRandom) { using Accumulator = std::array; - using Relation = Poseidon2ExternalRelation; + using Relation = bb::Poseidon2ExternalRelation; Accumulator acc{ 0, 0, 0, 0 }; struct AllPoseidonValues { @@ -90,7 +90,7 @@ TEST_F(RelationManual, Poseidon2ExternalRelationRandom) TEST_F(RelationManual, Poseidon2InternalRelationZeros) { using Accumulator = std::array; - using Relation = Poseidon2InternalRelation; + using Relation = bb::Poseidon2InternalRelation; Accumulator acc{ 0, 0, 0, 0 }; struct AllPoseidonValues { @@ -121,7 +121,7 @@ TEST_F(RelationManual, Poseidon2InternalRelationZeros) TEST_F(RelationManual, Poseidon2InternalRelationRandom) { using Accumulator = std::array; - using Relation = Poseidon2InternalRelation; + using Relation = bb::Poseidon2InternalRelation; Accumulator acc{ 0, 0, 0, 0 }; struct AllPoseidonValues { @@ -164,5 +164,4 @@ TEST_F(RelationManual, Poseidon2InternalRelationRandom) EXPECT_EQ(acc[1], 0); EXPECT_EQ(acc[2], 0); EXPECT_EQ(acc[3], 0); -} -}; // namespace bb::relation_manual_tests \ No newline at end of file +} \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp b/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp index 617a6b49e8c2..4f8093f9ad89 100644 --- a/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/translator_vm/goblin_translator_relation_consistency.test.cpp @@ -16,8 +16,6 @@ using namespace bb; -namespace bb::ultra_relation_consistency_tests { - using Flavor = honk::flavor::GoblinTranslator; using FF = typename Flavor::FF; using InputElements = typename Flavor::AllValues; @@ -947,5 +945,3 @@ TEST_F(GoblinTranslatorRelationConsistency, NonNativeFieldRelation) run_test(/*random_inputs=*/false); run_test(/*random_inputs=*/true); }; - -} // namespace bb::ultra_relation_consistency_tests diff --git a/barretenberg/cpp/src/barretenberg/relations/ultra_relation_consistency.test.cpp b/barretenberg/cpp/src/barretenberg/relations/ultra_relation_consistency.test.cpp index 8af4e374f349..731725d6ee25 100644 --- a/barretenberg/cpp/src/barretenberg/relations/ultra_relation_consistency.test.cpp +++ b/barretenberg/cpp/src/barretenberg/relations/ultra_relation_consistency.test.cpp @@ -26,9 +26,7 @@ using namespace bb; -namespace bb::ultra_relation_consistency_tests { - -using FF = bb::fr; +using FF = fr; struct InputElements { static constexpr size_t NUM_ELEMENTS = 45; std::array _data; @@ -680,5 +678,3 @@ TEST_F(UltraRelationConsistency, Poseidon2InternalRelation) run_test(/*random_inputs=*/false); run_test(/*random_inputs=*/true); }; - -} // namespace bb::ultra_relation_consistency_tests diff --git a/barretenberg/cpp/src/barretenberg/serialize/msgpack_schema.test.cpp b/barretenberg/cpp/src/barretenberg/serialize/msgpack_schema.test.cpp index 3979e8919be2..33a8454dac31 100644 --- a/barretenberg/cpp/src/barretenberg/serialize/msgpack_schema.test.cpp +++ b/barretenberg/cpp/src/barretenberg/serialize/msgpack_schema.test.cpp @@ -3,37 +3,38 @@ #include +using namespace bb; + // Sanity checking for msgpack -// TODO eventually move to barretenberg struct GoodExample { - bb::fr a; - bb::fr b; + fr a; + fr b; MSGPACK_FIELDS(a, b); } good_example; struct BadExampleOverlap { - bb::fr a; - bb::fr b; + fr a; + fr b; MSGPACK_FIELDS(a, a); } bad_example_overlap; struct BadExampleIncomplete { - bb::fr a; - bb::fr b; + fr a; + fr b; MSGPACK_FIELDS(a); } bad_example_incomplete; struct BadExampleCompileTimeError { std::vector a; - bb::fr b; + fr b; MSGPACK_FIELDS(b); // Type mismatch, expect 'a', will catch at compile-time } bad_example_compile_time_error; struct BadExampleOutOfObject { - bb::fr a; - bb::fr b; + fr a; + fr b; void msgpack(auto ar) { BadExampleOutOfObject other_object; @@ -66,9 +67,9 @@ TEST(msgpack_tests, msgpack_sanity_sanity) } struct ComplicatedSchema { - std::vector> array; + std::vector> array; std::optional good_or_not; - bb::fr bare; + fr bare; std::variant huh; MSGPACK_FIELDS(array, good_or_not, bare, huh); } complicated_schema; diff --git a/barretenberg/cpp/src/barretenberg/smt_verification/smt_bigfield.test.cpp b/barretenberg/cpp/src/barretenberg/smt_verification/smt_bigfield.test.cpp index e40b9b0019ae..1f1abe570e2f 100644 --- a/barretenberg/cpp/src/barretenberg/smt_verification/smt_bigfield.test.cpp +++ b/barretenberg/cpp/src/barretenberg/smt_verification/smt_bigfield.test.cpp @@ -30,9 +30,9 @@ using namespace smt_circuit; using namespace bb; using namespace bb::plonk; -using field_ct = bb::stdlib::field_t; -using witness_t = bb::stdlib::witness_t; -using pub_witness_t = bb::stdlib::public_witness_t; +using field_ct = stdlib::field_t; +using witness_t = stdlib::witness_t; +using pub_witness_t = stdlib::public_witness_t; using bn254 = stdlib::bn254; diff --git a/barretenberg/cpp/src/barretenberg/smt_verification/smt_examples.test.cpp b/barretenberg/cpp/src/barretenberg/smt_verification/smt_examples.test.cpp index fd3b98ddd15b..81e31bec0f93 100644 --- a/barretenberg/cpp/src/barretenberg/smt_verification/smt_examples.test.cpp +++ b/barretenberg/cpp/src/barretenberg/smt_verification/smt_examples.test.cpp @@ -8,16 +8,15 @@ #include "barretenberg/smt_verification/circuit/circuit.hpp" -using namespace bb; using namespace bb; namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } -using field_t = bb::stdlib::field_t; -using witness_t = bb::stdlib::witness_t; -using pub_witness_t = bb::stdlib::public_witness_t; +using field_t = stdlib::field_t; +using witness_t = stdlib::witness_t; +using pub_witness_t = stdlib::public_witness_t; TEST(circuit_verification, multiplication_true) { diff --git a/barretenberg/cpp/src/barretenberg/smt_verification/smt_polynomials.test.cpp b/barretenberg/cpp/src/barretenberg/smt_verification/smt_polynomials.test.cpp index 61048a444698..3e15583a71ae 100644 --- a/barretenberg/cpp/src/barretenberg/smt_verification/smt_polynomials.test.cpp +++ b/barretenberg/cpp/src/barretenberg/smt_verification/smt_polynomials.test.cpp @@ -13,17 +13,16 @@ #include "barretenberg/serialize/cbind.hpp" #include "barretenberg/smt_verification/circuit/circuit.hpp" -using namespace bb; using namespace bb; using namespace smt_circuit; -using field_ct = bb::stdlib::field_t; -using witness_t = bb::stdlib::witness_t; -using pub_witness_t = bb::stdlib::public_witness_t; +using field_ct = stdlib::field_t; +using witness_t = stdlib::witness_t; +using pub_witness_t = stdlib::public_witness_t; // TODO(alex): z1 = z2, s1=s2, but coefficients are not public namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } msgpack::sbuffer create_circuit(size_t n, bool pub_coeffs) diff --git a/barretenberg/cpp/src/barretenberg/solidity_helpers/circuits/ecdsa_circuit.hpp b/barretenberg/cpp/src/barretenberg/solidity_helpers/circuits/ecdsa_circuit.hpp index 3b069e4a8a78..a20ab1c4bbe3 100644 --- a/barretenberg/cpp/src/barretenberg/solidity_helpers/circuits/ecdsa_circuit.hpp +++ b/barretenberg/cpp/src/barretenberg/solidity_helpers/circuits/ecdsa_circuit.hpp @@ -12,10 +12,6 @@ #include "barretenberg/stdlib/primitives/field/field.hpp" #include "barretenberg/stdlib/primitives/witness/witness.hpp" -using namespace bb::plonk; -using namespace stdlib; -using numeric::uint256_t; - template class EcdsaCircuit { public: using field_ct = stdlib::field_t; @@ -47,18 +43,18 @@ template class EcdsaCircuit { } // UNCONSTRAINED: create a random keypair to sign with - crypto::ecdsa::key_pair account; + crypto::ecdsa_key_pair account; account.private_key = curve::fr::random_element(); account.public_key = curve::g1::one * account.private_key; // UNCONSTRAINED: create a sig - crypto::ecdsa::signature signature = crypto::ecdsa:: - construct_signature( + crypto::ecdsa_signature signature = + crypto::ecdsa_construct_signature( message_string, account); // UNCONSTRAINED: verify the created signature bool dry_run = - crypto::ecdsa::verify_signature( + crypto::ecdsa_verify_signature( message_string, account.public_key, signature); if (!dry_run) { throw_or_abort("[non circuit]: Sig verification failed"); @@ -72,16 +68,16 @@ template class EcdsaCircuit { uint8_t vv = signature.v; // IN CIRCUIT: create a witness with the sig in our circuit - stdlib::ecdsa::signature sig{ typename curve::byte_array_ct(&builder, rr), - typename curve::byte_array_ct(&builder, ss), - stdlib::uint8(&builder, vv) }; + stdlib::ecdsa_signature sig{ typename curve::byte_array_ct(&builder, rr), + typename curve::byte_array_ct(&builder, ss), + stdlib::uint8(&builder, vv) }; // IN CIRCUIT: verify the signature - typename curve::bool_ct signature_result = stdlib::ecdsa::verify_signature( + typename curve::bool_ct signature_result = stdlib::ecdsa_verify_signature( // input_buffer, public_key, sig); input_buffer, public_key, diff --git a/barretenberg/cpp/src/barretenberg/solidity_helpers/proof_gen.cpp b/barretenberg/cpp/src/barretenberg/solidity_helpers/proof_gen.cpp index 97e82644e88a..10b54e88b7a9 100644 --- a/barretenberg/cpp/src/barretenberg/solidity_helpers/proof_gen.cpp +++ b/barretenberg/cpp/src/barretenberg/solidity_helpers/proof_gen.cpp @@ -11,7 +11,7 @@ #include "circuits/recursive_circuit.hpp" #include "utils/utils.hpp" -using namespace numeric; +using namespace bb::numeric; using numeric::uint256_t; template typename Circuit> void generate_proof(uint256_t inputs[]) diff --git a/barretenberg/cpp/src/barretenberg/srs/factories/mem_crs_factory.test.cpp b/barretenberg/cpp/src/barretenberg/srs/factories/mem_crs_factory.test.cpp index 46dfdecc57a4..bfdab78e996e 100644 --- a/barretenberg/cpp/src/barretenberg/srs/factories/mem_crs_factory.test.cpp +++ b/barretenberg/cpp/src/barretenberg/srs/factories/mem_crs_factory.test.cpp @@ -9,7 +9,7 @@ using namespace bb; using namespace bb::srs::factories; -using namespace curve; +using namespace bb::curve; TEST(reference_string, mem_bn254_file_consistency) { @@ -41,7 +41,7 @@ TEST(reference_string, mem_bn254_file_consistency) EXPECT_EQ(memcmp(mem_verifier_crs->get_precomputed_g2_lines(), file_verifier_crs->get_precomputed_g2_lines(), - sizeof(bb::pairing::miller_lines) * 2), + sizeof(pairing::miller_lines) * 2), 0); } diff --git a/barretenberg/cpp/src/barretenberg/srs/factories/mem_grumpkin_crs_factory.cpp b/barretenberg/cpp/src/barretenberg/srs/factories/mem_grumpkin_crs_factory.cpp index d9ab3b28f592..1001c9519a49 100644 --- a/barretenberg/cpp/src/barretenberg/srs/factories/mem_grumpkin_crs_factory.cpp +++ b/barretenberg/cpp/src/barretenberg/srs/factories/mem_grumpkin_crs_factory.cpp @@ -7,7 +7,7 @@ namespace { -using namespace curve; +using namespace bb::curve; using namespace bb; using namespace bb::srs::factories; diff --git a/barretenberg/cpp/src/barretenberg/srs/global_crs.cpp b/barretenberg/cpp/src/barretenberg/srs/global_crs.cpp index 6bf83a86b442..f6ac2e05c71d 100644 --- a/barretenberg/cpp/src/barretenberg/srs/global_crs.cpp +++ b/barretenberg/cpp/src/barretenberg/srs/global_crs.cpp @@ -6,8 +6,8 @@ namespace { // TODO(#637): As a PoC we have two global variables for the two CRS but this could be improved to avoid duplication. -std::shared_ptr> crs_factory; -std::shared_ptr> grumpkin_crs_factory; +std::shared_ptr> crs_factory; +std::shared_ptr> grumpkin_crs_factory; } // namespace namespace bb::srs { @@ -21,11 +21,11 @@ void init_crs_factory(std::vector const& points, g2::affine_ // Initializes crs from a file path this we use in the entire codebase void init_crs_factory(std::string crs_path) { - crs_factory = std::make_shared>(crs_path); + crs_factory = std::make_shared>(crs_path); } // Initializes the crs using the memory buffers -void init_grumpkin_crs_factory(std::vector const& points) +void init_grumpkin_crs_factory(std::vector const& points) { grumpkin_crs_factory = std::make_shared(points); } diff --git a/barretenberg/cpp/src/barretenberg/srs/scalar_multiplication.test.cpp b/barretenberg/cpp/src/barretenberg/srs/scalar_multiplication.test.cpp index b9805c7c7d1c..d5c257ada4ed 100644 --- a/barretenberg/cpp/src/barretenberg/srs/scalar_multiplication.test.cpp +++ b/barretenberg/cpp/src/barretenberg/srs/scalar_multiplication.test.cpp @@ -20,12 +20,12 @@ #include #include +using namespace bb; + namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } -using namespace bb; - template class ScalarMultiplicationTests : public ::testing::Test { public: const std::string SRS_PATH = []() { @@ -36,8 +36,7 @@ template class ScalarMultiplicationTests : public ::testing::Te } }(); - static void read_transcript_g2(std::string const& srs_path) - requires srs::HasG2 + static void read_transcript_g2(std::string const& srs_path) requires srs::HasG2 { typename Curve::G2AffineElement g2_x; srs::IO::read_transcript_g2(g2_x, srs_path); @@ -231,14 +230,14 @@ TYPED_TEST(ScalarMultiplicationTests, ReduceBucketsSimple) std::array bucket_counts; std::array bit_offsets = { 0 }; - bb::scalar_multiplication::affine_product_runtime_state product_state{ + scalar_multiplication::affine_product_runtime_state product_state{ &monomials[0], &point_pairs[0], &output_buckets[0], &scratch_space[0], &bucket_counts[0], &bit_offsets[0], &point_schedule[0], num_points, 2, &bucket_empty_status[0] }; - AffineElement* output = bb::scalar_multiplication::reduce_buckets(product_state, true); + AffineElement* output = scalar_multiplication::reduce_buckets(product_state, true); for (size_t i = 0; i < product_state.num_buckets; ++i) { expected[i] = expected[i].normalize(); @@ -274,7 +273,7 @@ TYPED_TEST(ScalarMultiplicationTests, ReduceBuckets) TestFixture::read_transcript(monomials, num_initial_points, TestFixture::SRS_PATH); - bb::scalar_multiplication::generate_pippenger_point_table(monomials, monomials, num_initial_points); + scalar_multiplication::generate_pippenger_point_table(monomials, monomials, num_initial_points); Fr* scalars = (Fr*)(aligned_alloc(64, sizeof(Fr) * num_initial_points)); @@ -282,21 +281,21 @@ TYPED_TEST(ScalarMultiplicationTests, ReduceBuckets) scalars[i] = Fr::random_element(); } - bb::scalar_multiplication::pippenger_runtime_state state(num_initial_points); + scalar_multiplication::pippenger_runtime_state state(num_initial_points); std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now(); - bb::scalar_multiplication::compute_wnaf_states( + scalar_multiplication::compute_wnaf_states( state.point_schedule, state.skew_table, state.round_counts, scalars, num_initial_points); std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now(); std::chrono::milliseconds diff = std::chrono::duration_cast(end - start); std::cout << "wnaf time: " << diff.count() << "ms" << std::endl; start = std::chrono::steady_clock::now(); - bb::scalar_multiplication::organize_buckets(state.point_schedule, num_points); + scalar_multiplication::organize_buckets(state.point_schedule, num_points); end = std::chrono::steady_clock::now(); diff = std::chrono::duration_cast(end - start); std::cout << "organize bucket time: " << diff.count() << "ms" << std::endl; - const size_t max_num_buckets = bb::scalar_multiplication::get_num_buckets(num_points * 2); + const size_t max_num_buckets = scalar_multiplication::get_num_buckets(num_points * 2); uint32_t* bucket_counts = static_cast(aligned_alloc(64, max_num_buckets * 100 * sizeof(uint32_t))); memset((void*)bucket_counts, 0x00, max_num_buckets * sizeof(uint32_t)); @@ -312,19 +311,19 @@ TYPED_TEST(ScalarMultiplicationTests, ReduceBuckets) const size_t last_bucket = point_schedule_copy[num_points - 1] & 0x7fffffffULL; const size_t num_buckets = last_bucket - first_bucket + 1; - bb::scalar_multiplication::affine_product_runtime_state product_state{ monomials, - point_pairs, - scratch_points, - scratch_field, - bucket_counts, - &bit_offsets[0], - &state.point_schedule[num_points], - num_points, - static_cast(num_buckets), - bucket_empty_status }; + scalar_multiplication::affine_product_runtime_state product_state{ monomials, + point_pairs, + scratch_points, + scratch_field, + bucket_counts, + &bit_offsets[0], + &state.point_schedule[num_points], + num_points, + static_cast(num_buckets), + bucket_empty_status }; start = std::chrono::steady_clock::now(); - // bb::scalar_multiplication::scalar_multiplication_internal(state, monomials); + // scalar_multiplication::scalar_multiplication_internal(state, monomials); end = std::chrono::steady_clock::now(); diff = std::chrono::duration_cast(end - start); std::cout << "scalar mul: " << diff.count() << "ms" << std::endl; @@ -345,7 +344,7 @@ TYPED_TEST(ScalarMultiplicationTests, ReduceBuckets) size_t it = 0; - AffineElement* result_buckets = bb::scalar_multiplication::reduce_buckets(product_state, true); + AffineElement* result_buckets = scalar_multiplication::reduce_buckets(product_state, true); printf("num buckets = %zu \n", num_buckets); for (size_t i = 0; i < num_buckets; ++i) { @@ -401,22 +400,22 @@ TYPED_TEST(ScalarMultiplicationTests, DISABLED_ReduceBucketsBasic) Fr::__copy(source_scalar, scalars[i]); } - bb::scalar_multiplication::pippenger_runtime_state state(num_initial_points); - bb::scalar_multiplication::generate_pippenger_point_table(monomials, monomials, num_initial_points); + scalar_multiplication::pippenger_runtime_state state(num_initial_points); + scalar_multiplication::generate_pippenger_point_table(monomials, monomials, num_initial_points); std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now(); - bb::scalar_multiplication::compute_wnaf_states( + scalar_multiplication::compute_wnaf_states( state.point_schedule, state.skew_table, state.round_counts, scalars, num_initial_points); std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now(); std::chrono::milliseconds diff = std::chrono::duration_cast(end - start); std::cout << "wnaf time: " << diff.count() << "ms" << std::endl; start = std::chrono::steady_clock::now(); - bb::scalar_multiplication::organize_buckets(state.point_schedule, num_points); + scalar_multiplication::organize_buckets(state.point_schedule, num_points); end = std::chrono::steady_clock::now(); diff = std::chrono::duration_cast(end - start); std::cout << "organize bucket time: " << diff.count() << "ms" << std::endl; - const size_t max_num_buckets = bb::scalar_multiplication::get_num_buckets(num_points * 2); + const size_t max_num_buckets = scalar_multiplication::get_num_buckets(num_points * 2); uint32_t* bucket_counts = static_cast(aligned_alloc(64, max_num_buckets * sizeof(uint32_t))); memset((void*)bucket_counts, 0x00, max_num_buckets * sizeof(uint32_t)); @@ -425,20 +424,20 @@ TYPED_TEST(ScalarMultiplicationTests, DISABLED_ReduceBucketsBasic) const size_t last_bucket = state.point_schedule[num_points - 1] & 0x7fffffffULL; const size_t num_buckets = last_bucket - first_bucket + 1; - bb::scalar_multiplication::affine_product_runtime_state product_state{ monomials, - point_pairs, - scratch_points, - scratch_field, - bucket_counts, - &bit_offsets[0], - state.point_schedule, - (uint32_t)state.round_counts[0], - static_cast(num_buckets), - bucket_empty_status }; + scalar_multiplication::affine_product_runtime_state product_state{ monomials, + point_pairs, + scratch_points, + scratch_field, + bucket_counts, + &bit_offsets[0], + state.point_schedule, + (uint32_t)state.round_counts[0], + static_cast(num_buckets), + bucket_empty_status }; start = std::chrono::steady_clock::now(); - bb::scalar_multiplication::reduce_buckets(product_state, true); - // bb::scalar_multiplication::scalar_multiplication_internal(state, monomials); + scalar_multiplication::reduce_buckets(product_state, true); + // scalar_multiplication::scalar_multiplication_internal(state, monomials); end = std::chrono::steady_clock::now(); diff = std::chrono::duration_cast(end - start); std::cout << "scalar mul: " << diff.count() << "ms" << std::endl; @@ -478,7 +477,7 @@ TYPED_TEST(ScalarMultiplicationTests, AddAffinePoints) points_copy[count + 1] = points_copy[count + 1].normalize(); } - bb::scalar_multiplication::add_affine_points(points, num_points, scratch_space); + scalar_multiplication::add_affine_points(points, num_points, scratch_space); for (size_t i = num_points - 1; i > num_points - 1 - (num_points / 2); --i) { EXPECT_EQ((points[i].x == points_copy[i].x), true); EXPECT_EQ((points[i].y == points_copy[i].y), true); @@ -509,22 +508,22 @@ TYPED_TEST(ScalarMultiplicationTests, ConstructAdditionChains) Fr::__copy(source_scalar, scalars[i]); } - bb::scalar_multiplication::pippenger_runtime_state state(num_initial_points); - bb::scalar_multiplication::generate_pippenger_point_table(monomials, monomials, num_initial_points); + scalar_multiplication::pippenger_runtime_state state(num_initial_points); + scalar_multiplication::generate_pippenger_point_table(monomials, monomials, num_initial_points); std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now(); - bb::scalar_multiplication::compute_wnaf_states( + scalar_multiplication::compute_wnaf_states( state.point_schedule, state.skew_table, state.round_counts, scalars, num_initial_points); std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now(); std::chrono::milliseconds diff = std::chrono::duration_cast(end - start); std::cout << "wnaf time: " << diff.count() << "ms" << std::endl; start = std::chrono::steady_clock::now(); - bb::scalar_multiplication::organize_buckets(state.point_schedule, num_points); + scalar_multiplication::organize_buckets(state.point_schedule, num_points); end = std::chrono::steady_clock::now(); diff = std::chrono::duration_cast(end - start); std::cout << "organize bucket time: " << diff.count() << "ms" << std::endl; - const size_t max_num_buckets = bb::scalar_multiplication::get_num_buckets(num_points * 2); + const size_t max_num_buckets = scalar_multiplication::get_num_buckets(num_points * 2); bool* bucket_empty_status = static_cast(aligned_alloc(64, num_points * sizeof(bool))); uint32_t* bucket_counts = static_cast(aligned_alloc(64, max_num_buckets * sizeof(uint32_t))); memset((void*)bucket_counts, 0x00, max_num_buckets * sizeof(uint32_t)); @@ -533,20 +532,20 @@ TYPED_TEST(ScalarMultiplicationTests, ConstructAdditionChains) const size_t last_bucket = state.point_schedule[state.round_counts[0] - 1] & 0x7fffffffULL; const size_t num_buckets = last_bucket - first_bucket + 1; - bb::scalar_multiplication::affine_product_runtime_state product_state{ monomials, - monomials, - monomials, - nullptr, - bucket_counts, - &bit_offsets[0], - state.point_schedule, - static_cast( - state.round_counts[0]), - static_cast(num_buckets), - bucket_empty_status }; + scalar_multiplication::affine_product_runtime_state product_state{ monomials, + monomials, + monomials, + nullptr, + bucket_counts, + &bit_offsets[0], + state.point_schedule, + static_cast( + state.round_counts[0]), + static_cast(num_buckets), + bucket_empty_status }; start = std::chrono::steady_clock::now(); - bb::scalar_multiplication::construct_addition_chains(product_state, true); + scalar_multiplication::construct_addition_chains(product_state, true); end = std::chrono::steady_clock::now(); diff = std::chrono::duration_cast(end - start); info("construct addition chains: ", diff.count(), "ms"); @@ -608,7 +607,7 @@ TYPED_TEST(ScalarMultiplicationTests, RadixSort) // check that our radix sort correctly sorts! constexpr size_t target_degree = 1 << 8; - constexpr size_t num_rounds = bb::scalar_multiplication::get_num_rounds(target_degree * 2); + constexpr size_t num_rounds = scalar_multiplication::get_num_rounds(target_degree * 2); Fr* scalars = (Fr*)(aligned_alloc(64, sizeof(Fr) * target_degree)); Fr source_scalar = Fr::random_element(); @@ -617,14 +616,14 @@ TYPED_TEST(ScalarMultiplicationTests, RadixSort) Fr::__copy(source_scalar, scalars[i]); } - bb::scalar_multiplication::pippenger_runtime_state state(target_degree); - bb::scalar_multiplication::compute_wnaf_states( + scalar_multiplication::pippenger_runtime_state state(target_degree); + scalar_multiplication::compute_wnaf_states( state.point_schedule, state.skew_table, state.round_counts, scalars, target_degree); uint64_t* wnaf_copy = (uint64_t*)(aligned_alloc(64, sizeof(uint64_t) * target_degree * 2 * num_rounds)); memcpy((void*)wnaf_copy, (void*)state.point_schedule, sizeof(uint64_t) * target_degree * 2 * num_rounds); - bb::scalar_multiplication::organize_buckets(state.point_schedule, target_degree * 2); + scalar_multiplication::organize_buckets(state.point_schedule, target_degree * 2); for (size_t i = 0; i < num_rounds; ++i) { uint64_t* unsorted_wnaf = &wnaf_copy[i * target_degree * 2]; uint64_t* sorted_wnaf = &state.point_schedule[i * target_degree * 2]; @@ -668,7 +667,7 @@ TYPED_TEST(ScalarMultiplicationTests, OversizedInputs) memcpy((void*)(monomials + (2 * transcript_degree)), (void*)monomials, ((2 * target_degree - 2 * transcript_degree) * sizeof(AffineElement))); - bb::scalar_multiplication::generate_pippenger_point_table(monomials, monomials, target_degree); + scalar_multiplication::generate_pippenger_point_table(monomials, monomials, target_degree); Fr* scalars = (Fr*)(aligned_alloc(64, sizeof(Fr) * target_degree)); @@ -678,17 +677,17 @@ TYPED_TEST(ScalarMultiplicationTests, OversizedInputs) accumulator *= source_scalar; Fr::__copy(accumulator, scalars[i]); } - bb::scalar_multiplication::pippenger_runtime_state state(target_degree); + scalar_multiplication::pippenger_runtime_state state(target_degree); - Element first = bb::scalar_multiplication::pippenger(scalars, monomials, target_degree, state); + Element first = scalar_multiplication::pippenger(scalars, monomials, target_degree, state); first = first.normalize(); for (size_t i = 0; i < target_degree; ++i) { scalars[i].self_neg(); } - bb::scalar_multiplication::pippenger_runtime_state state_2(target_degree); + scalar_multiplication::pippenger_runtime_state state_2(target_degree); - Element second = bb::scalar_multiplication::pippenger(scalars, monomials, target_degree, state_2); + Element second = scalar_multiplication::pippenger(scalars, monomials, target_degree, state_2); second = second.normalize(); EXPECT_EQ((first.z == second.z), true); @@ -727,11 +726,11 @@ TYPED_TEST(ScalarMultiplicationTests, UndersizedInputs) expected += temp; } expected = expected.normalize(); - bb::scalar_multiplication::generate_pippenger_point_table(points, points, num_points); + scalar_multiplication::generate_pippenger_point_table(points, points, num_points); - bb::scalar_multiplication::pippenger_runtime_state state(num_points); + scalar_multiplication::pippenger_runtime_state state(num_points); - Element result = bb::scalar_multiplication::pippenger(scalars, points, num_points, state); + Element result = scalar_multiplication::pippenger(scalars, points, num_points, state); result = result.normalize(); aligned_free(scalars); @@ -765,10 +764,10 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerSmall) expected += temp; } expected = expected.normalize(); - bb::scalar_multiplication::generate_pippenger_point_table(points, points, num_points); - bb::scalar_multiplication::pippenger_runtime_state state(num_points); + scalar_multiplication::generate_pippenger_point_table(points, points, num_points); + scalar_multiplication::pippenger_runtime_state state(num_points); - Element result = bb::scalar_multiplication::pippenger(scalars, points, num_points, state); + Element result = scalar_multiplication::pippenger(scalars, points, num_points, state); result = result.normalize(); aligned_free(scalars); @@ -805,9 +804,9 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerEdgeCaseDbl) if (!expected.is_point_at_infinity()) { expected = expected.normalize(); } - bb::scalar_multiplication::generate_pippenger_point_table(points, points, num_points); - bb::scalar_multiplication::pippenger_runtime_state state(num_points); - Element result = bb::scalar_multiplication::pippenger(scalars, points, num_points, state); + scalar_multiplication::generate_pippenger_point_table(points, points, num_points); + scalar_multiplication::pippenger_runtime_state state(num_points); + Element result = scalar_multiplication::pippenger(scalars, points, num_points, state); result = result.normalize(); aligned_free(scalars); @@ -827,7 +826,7 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerShortInputs) Fr* scalars = (Fr*)aligned_alloc(32, sizeof(Fr) * num_points); - auto points = bb::scalar_multiplication::point_table_alloc(num_points); + auto points = scalar_multiplication::point_table_alloc(num_points); for (std::ptrdiff_t i = 0; i < (std::ptrdiff_t)num_points; ++i) { points[i] = AffineElement(Element::random_element()); @@ -862,10 +861,10 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerShortInputs) expected += temp; } expected = expected.normalize(); - bb::scalar_multiplication::generate_pippenger_point_table(points.get(), points.get(), num_points); - bb::scalar_multiplication::pippenger_runtime_state state(num_points); + scalar_multiplication::generate_pippenger_point_table(points.get(), points.get(), num_points); + scalar_multiplication::pippenger_runtime_state state(num_points); - Element result = bb::scalar_multiplication::pippenger(scalars, points.get(), num_points, state); + Element result = scalar_multiplication::pippenger(scalars, points.get(), num_points, state); result = result.normalize(); aligned_free(scalars); @@ -884,7 +883,7 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerUnsafe) Fr* scalars = (Fr*)aligned_alloc(32, sizeof(Fr) * num_points); - auto points = bb::scalar_multiplication::point_table_alloc(num_points); + auto points = scalar_multiplication::point_table_alloc(num_points); for (std::ptrdiff_t i = 0; i < (std::ptrdiff_t)num_points; ++i) { scalars[i] = Fr::random_element(); @@ -898,10 +897,10 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerUnsafe) expected += temp; } expected = expected.normalize(); - bb::scalar_multiplication::generate_pippenger_point_table(points.get(), points.get(), num_points); + scalar_multiplication::generate_pippenger_point_table(points.get(), points.get(), num_points); - bb::scalar_multiplication::pippenger_runtime_state state(num_points); - Element result = bb::scalar_multiplication::pippenger_unsafe(scalars, points.get(), num_points, state); + scalar_multiplication::pippenger_runtime_state state(num_points); + Element result = scalar_multiplication::pippenger_unsafe(scalars, points.get(), num_points, state); result = result.normalize(); aligned_free(scalars); @@ -955,10 +954,10 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerUnsafeShortInputs) expected += temp; } expected = expected.normalize(); - bb::scalar_multiplication::generate_pippenger_point_table(points, points, num_points); - bb::scalar_multiplication::pippenger_runtime_state state(num_points); + scalar_multiplication::generate_pippenger_point_table(points, points, num_points); + scalar_multiplication::pippenger_runtime_state state(num_points); - Element result = bb::scalar_multiplication::pippenger_unsafe(scalars, points, num_points, state); + Element result = scalar_multiplication::pippenger_unsafe(scalars, points, num_points, state); result = result.normalize(); aligned_free(scalars); @@ -992,10 +991,10 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerOne) expected += temp; } expected = expected.normalize(); - bb::scalar_multiplication::generate_pippenger_point_table(points, points, num_points); - bb::scalar_multiplication::pippenger_runtime_state state(num_points); + scalar_multiplication::generate_pippenger_point_table(points, points, num_points); + scalar_multiplication::pippenger_runtime_state state(num_points); - Element result = bb::scalar_multiplication::pippenger(scalars, points, num_points, state); + Element result = scalar_multiplication::pippenger(scalars, points, num_points, state); result = result.normalize(); aligned_free(scalars); @@ -1015,8 +1014,8 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerZeroPoints) AffineElement* points = (AffineElement*)aligned_alloc(32, sizeof(AffineElement) * (2 + 1)); - bb::scalar_multiplication::pippenger_runtime_state state(0); - Element result = bb::scalar_multiplication::pippenger(scalars, points, 0, state); + scalar_multiplication::pippenger_runtime_state state(0); + Element result = scalar_multiplication::pippenger(scalars, points, 0, state); aligned_free(scalars); aligned_free(points); @@ -1038,10 +1037,10 @@ TYPED_TEST(ScalarMultiplicationTests, PippengerMulByZero) scalars[0] = Fr::zero(); points[0] = Group::affine_one; - bb::scalar_multiplication::generate_pippenger_point_table(points, points, 1); + scalar_multiplication::generate_pippenger_point_table(points, points, 1); - bb::scalar_multiplication::pippenger_runtime_state state(1); - Element result = bb::scalar_multiplication::pippenger(scalars, points, 1, state); + scalar_multiplication::pippenger_runtime_state state(1); + Element result = scalar_multiplication::pippenger(scalars, points, 1, state); aligned_free(scalars); aligned_free(points); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/commitment/pedersen/pedersen.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/commitment/pedersen/pedersen.test.cpp index 5e0f37f2dba6..bced7a462562 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/commitment/pedersen/pedersen.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/commitment/pedersen/pedersen.test.cpp @@ -6,10 +6,9 @@ #include "barretenberg/stdlib/primitives/curves/bn254.hpp" #include "pedersen.hpp" -namespace test_StdlibPedersen { using namespace bb; namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } template class StdlibPedersen : public testing::Test { @@ -61,7 +60,7 @@ template class StdlibPedersen : public testing::Test { { Builder builder; - std::vector inputs; + std::vector inputs; std::vector> witness_inputs; for (size_t i = 0; i < 8; ++i) { @@ -94,5 +93,3 @@ TYPED_TEST(StdlibPedersen, HashConstants) { TestFixture::test_hash_constants(); }; - -} // namespace test_StdlibPedersen diff --git a/barretenberg/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.cpp b/barretenberg/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.cpp index 003ab78e3b2f..232e21c1cc3d 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.cpp @@ -7,11 +7,11 @@ #include "barretenberg/stdlib/primitives/circuit_builders/circuit_builders.hpp" #include "barretenberg/stdlib/primitives/plookup/plookup.hpp" -using namespace crypto::aes128; +using namespace bb::crypto; namespace bb::stdlib::aes128 { template using byte_pair = std::pair, field_t>; -using namespace plookup; +using namespace bb::plookup; constexpr uint32_t AES128_BASE = 9; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.test.cpp index 743a1eb80be8..76b52fbc27e3 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/encryption/aes128/aes128.test.cpp @@ -8,7 +8,7 @@ using namespace bb; TEST(stdlib_aes128, encrypt_64_bytes) { - typedef stdlib::field_t field_pt; + typedef stdlib::field_t field_pt; typedef stdlib::witness_t witness_pt; uint8_t key[16]{ 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c }; @@ -31,7 +31,7 @@ TEST(stdlib_aes128, encrypt_64_bytes) return converted; }; - auto builder = bb::UltraCircuitBuilder(); + auto builder = UltraCircuitBuilder(); std::vector in_field{ witness_pt(&builder, fr(convert_bytes(in))), diff --git a/barretenberg/cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa.hpp b/barretenberg/cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa.hpp index ca4a212a8662..1c2649ed1b38 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa.hpp @@ -4,42 +4,43 @@ #include "../../primitives/circuit_builders/circuit_builders_fwd.hpp" #include "../../primitives/uint/uint.hpp" #include "barretenberg/crypto/ecdsa/ecdsa.hpp" -namespace bb::stdlib::ecdsa { +namespace bb::stdlib { -template struct signature { +template struct ecdsa_signature { stdlib::byte_array r; stdlib::byte_array s; stdlib::uint8 v; }; template -bool_t verify_signature(const stdlib::byte_array& message, - const G1& public_key, - const signature& sig); +bool_t ecdsa_verify_signature(const stdlib::byte_array& message, + const G1& public_key, + const ecdsa_signature& sig); template -bool_t verify_signature_noassert(const stdlib::byte_array& message, - const G1& public_key, - const signature& sig); +bool_t ecdsa_verify_signature_noassert(const stdlib::byte_array& message, + const G1& public_key, + const ecdsa_signature& sig); template -bool_t verify_signature_prehashed_message_noassert(const stdlib::byte_array& hashed_message, - const G1& public_key, - const signature& sig); +bool_t ecdsa_verify_signature_prehashed_message_noassert(const stdlib::byte_array& hashed_message, + const G1& public_key, + const ecdsa_signature& sig); -template static signature from_witness(Builder* ctx, const crypto::ecdsa::signature& input) +template +static ecdsa_signature ecdsa_from_witness(Builder* ctx, const crypto::ecdsa_signature& input) { std::vector r_vec(std::begin(input.r), std::end(input.r)); std::vector s_vec(std::begin(input.s), std::end(input.s)); stdlib::byte_array r(ctx, r_vec); stdlib::byte_array s(ctx, s_vec); stdlib::uint8 v(ctx, input.v); - signature out; + ecdsa_signature out; out.r = r; out.s = s; out.v = v; return out; } -} // namespace bb::stdlib::ecdsa +} // namespace bb::stdlib #include "./ecdsa_impl.hpp" \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa.test.cpp index ca55a8af5638..69aedf7e4351 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa.test.cpp @@ -8,9 +8,8 @@ using namespace bb; -namespace test_stdlib_ecdsa { -using Builder = bb::UltraCircuitBuilder; -using curve = stdlib::secp256k1; +using Builder = UltraCircuitBuilder; +using curve_ = stdlib::secp256k1; using curveR1 = stdlib::secp256r1; TEST(stdlib_ecdsa, verify_signature) @@ -20,31 +19,31 @@ TEST(stdlib_ecdsa, verify_signature) // whaaablaghaaglerijgeriij std::string message_string = "Instructions unclear, ask again later."; - crypto::ecdsa::key_pair account; - account.private_key = curve::fr::random_element(); - account.public_key = curve::g1::one * account.private_key; + crypto::ecdsa_key_pair account; + account.private_key = curve_::fr::random_element(); + account.public_key = curve_::g1::one * account.private_key; - crypto::ecdsa::signature signature = - crypto::ecdsa::construct_signature(message_string, account); + crypto::ecdsa_signature signature = + crypto::ecdsa_construct_signature(message_string, account); - bool first_result = crypto::ecdsa::verify_signature( + bool first_result = crypto::ecdsa_verify_signature( message_string, account.public_key, signature); EXPECT_EQ(first_result, true); - curve::g1_bigfr_ct public_key = curve::g1_bigfr_ct::from_witness(&builder, account.public_key); + curve_::g1_bigfr_ct public_key = curve_::g1_bigfr_ct::from_witness(&builder, account.public_key); std::vector rr(signature.r.begin(), signature.r.end()); std::vector ss(signature.s.begin(), signature.s.end()); uint8_t vv = signature.v; - stdlib::ecdsa::signature sig{ curve::byte_array_ct(&builder, rr), - curve::byte_array_ct(&builder, ss), - stdlib::uint8(&builder, vv) }; + stdlib::ecdsa_signature sig{ curve_::byte_array_ct(&builder, rr), + curve_::byte_array_ct(&builder, ss), + stdlib::uint8(&builder, vv) }; - curve::byte_array_ct message(&builder, message_string); + curve_::byte_array_ct message(&builder, message_string); - curve::bool_ct signature_result = - stdlib::ecdsa::verify_signature( + curve_::bool_ct signature_result = + stdlib::ecdsa_verify_signature( message, public_key, sig); EXPECT_EQ(signature_result.get_value(), true); @@ -61,15 +60,14 @@ TEST(stdlib_ecdsa, verify_r1_signature) std::string message_string = "Instructions unclear, ask again later."; - crypto::ecdsa::key_pair account; + crypto::ecdsa_key_pair account; account.private_key = curveR1::fr::random_element(); account.public_key = curveR1::g1::one * account.private_key; - crypto::ecdsa::signature signature = - crypto::ecdsa::construct_signature(message_string, - account); + crypto::ecdsa_signature signature = + crypto::ecdsa_construct_signature(message_string, account); - bool first_result = crypto::ecdsa::verify_signature( + bool first_result = crypto::ecdsa_verify_signature( message_string, account.public_key, signature); EXPECT_EQ(first_result, true); @@ -79,14 +77,14 @@ TEST(stdlib_ecdsa, verify_r1_signature) std::vector ss(signature.s.begin(), signature.s.end()); uint8_t vv = signature.v; - stdlib::ecdsa::signature sig{ curveR1::byte_array_ct(&builder, rr), - curveR1::byte_array_ct(&builder, ss), - stdlib::uint8(&builder, vv) }; + stdlib::ecdsa_signature sig{ curveR1::byte_array_ct(&builder, rr), + curveR1::byte_array_ct(&builder, ss), + stdlib::uint8(&builder, vv) }; curveR1::byte_array_ct message(&builder, message_string); curveR1::bool_ct signature_result = - stdlib::ecdsa::verify_signature( + stdlib::ecdsa_verify_signature( message, public_key, sig); EXPECT_EQ(signature_result.get_value(), true); @@ -97,40 +95,40 @@ TEST(stdlib_ecdsa, verify_r1_signature) EXPECT_EQ(proof_result, true); } -TEST(stdlib_ecdsa, verify_signature_noassert_succeed) +TEST(stdlib_ecdsa, ecdsa_verify_signature_noassert_succeed) { Builder builder = Builder(); // whaaablaghaaglerijgeriij std::string message_string = "Instructions unclear, ask again later."; - crypto::ecdsa::key_pair account; - account.private_key = curve::fr::random_element(); - account.public_key = curve::g1::one * account.private_key; + crypto::ecdsa_key_pair account; + account.private_key = curve_::fr::random_element(); + account.public_key = curve_::g1::one * account.private_key; - crypto::ecdsa::signature signature = - crypto::ecdsa::construct_signature(message_string, account); + crypto::ecdsa_signature signature = + crypto::ecdsa_construct_signature(message_string, account); - bool first_result = crypto::ecdsa::verify_signature( + bool first_result = crypto::ecdsa_verify_signature( message_string, account.public_key, signature); EXPECT_EQ(first_result, true); - curve::g1_bigfr_ct public_key = curve::g1_bigfr_ct::from_witness(&builder, account.public_key); + curve_::g1_bigfr_ct public_key = curve_::g1_bigfr_ct::from_witness(&builder, account.public_key); std::vector rr(signature.r.begin(), signature.r.end()); std::vector ss(signature.s.begin(), signature.s.end()); uint8_t vv = signature.v; - stdlib::ecdsa::signature sig{ - curve::byte_array_ct(&builder, rr), - curve::byte_array_ct(&builder, ss), + stdlib::ecdsa_signature sig{ + curve_::byte_array_ct(&builder, rr), + curve_::byte_array_ct(&builder, ss), stdlib::uint8(&builder, vv), }; - curve::byte_array_ct message(&builder, message_string); + curve_::byte_array_ct message(&builder, message_string); - curve::bool_ct signature_result = - stdlib::ecdsa::verify_signature_noassert( + curve_::bool_ct signature_result = + stdlib::ecdsa_verify_signature_noassert( message, public_key, sig); EXPECT_EQ(signature_result.get_value(), true); @@ -141,38 +139,40 @@ TEST(stdlib_ecdsa, verify_signature_noassert_succeed) EXPECT_EQ(proof_result, true); } -TEST(stdlib_ecdsa, verify_signature_noassert_fail) +TEST(stdlib_ecdsa, ecdsa_verify_signature_noassert_fail) { Builder builder = Builder(); // whaaablaghaaglerijgeriij std::string message_string = "Instructions unclear, ask again later."; - crypto::ecdsa::key_pair account; - account.private_key = curve::fr::random_element(); - account.public_key = curve::g1::one * account.private_key; + crypto::ecdsa_key_pair account; + account.private_key = curve_::fr::random_element(); + account.public_key = curve_::g1::one * account.private_key; - crypto::ecdsa::signature signature = - crypto::ecdsa::construct_signature(message_string, account); + crypto::ecdsa_signature signature = + crypto::ecdsa_construct_signature(message_string, account); // tamper w. signature to make fail signature.r[0] += 1; - bool first_result = crypto::ecdsa::verify_signature( + bool first_result = crypto::ecdsa_verify_signature( message_string, account.public_key, signature); EXPECT_EQ(first_result, false); - curve::g1_bigfr_ct public_key = curve::g1_bigfr_ct::from_witness(&builder, account.public_key); + curve_::g1_bigfr_ct public_key = curve_::g1_bigfr_ct::from_witness(&builder, account.public_key); std::vector rr(signature.r.begin(), signature.r.end()); std::vector ss(signature.s.begin(), signature.s.end()); - stdlib::ecdsa::signature sig{ curve::byte_array_ct(&builder, rr), curve::byte_array_ct(&builder, ss), 27 }; + stdlib::ecdsa_signature sig{ curve_::byte_array_ct(&builder, rr), + curve_::byte_array_ct(&builder, ss), + 27 }; - curve::byte_array_ct message(&builder, message_string); + curve_::byte_array_ct message(&builder, message_string); - curve::bool_ct signature_result = - stdlib::ecdsa::verify_signature_noassert( + curve_::bool_ct signature_result = + stdlib::ecdsa_verify_signature_noassert( message, public_key, sig); EXPECT_EQ(signature_result.get_value(), false); @@ -182,4 +182,3 @@ TEST(stdlib_ecdsa, verify_signature_noassert_fail) bool proof_result = builder.check_circuit(); EXPECT_EQ(proof_result, true); } -} // namespace test_stdlib_ecdsa diff --git a/barretenberg/cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa_impl.hpp b/barretenberg/cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa_impl.hpp index 5f7403fb2c1b..fa67089fd4ee 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/encryption/ecdsa/ecdsa_impl.hpp @@ -4,7 +4,7 @@ #include "barretenberg/stdlib/hash/sha256/sha256.hpp" #include "barretenberg/stdlib/primitives//bit_array/bit_array.hpp" -namespace bb::stdlib::ecdsa { +namespace bb::stdlib { /** * @brief Verify ECDSA signature. Produces unsatisfiable constraints if signature fails @@ -20,9 +20,9 @@ namespace bb::stdlib::ecdsa { * @return bool_t */ template -bool_t verify_signature(const stdlib::byte_array& message, - const G1& public_key, - const signature& sig) +bool_t ecdsa_verify_signature(const stdlib::byte_array& message, + const G1& public_key, + const ecdsa_signature& sig) { Builder* ctx = message.get_context() ? message.get_context() : public_key.x.context; @@ -130,9 +130,9 @@ bool_t verify_signature(const stdlib::byte_array& message, * @return bool_t */ template -bool_t verify_signature_prehashed_message_noassert(const stdlib::byte_array& hashed_message, - const G1& public_key, - const signature& sig) +bool_t ecdsa_verify_signature_prehashed_message_noassert(const stdlib::byte_array& hashed_message, + const G1& public_key, + const ecdsa_signature& sig) { Builder* ctx = hashed_message.get_context() ? hashed_message.get_context() : public_key.x.context; @@ -210,14 +210,15 @@ bool_t verify_signature_prehashed_message_noassert(const stdlib::byte_a * @return bool_t */ template -bool_t verify_signature_noassert(const stdlib::byte_array& message, - const G1& public_key, - const signature& sig) +bool_t ecdsa_verify_signature_noassert(const stdlib::byte_array& message, + const G1& public_key, + const ecdsa_signature& sig) { stdlib::byte_array hashed_message = static_cast>(stdlib::sha256(message)); - return verify_signature_prehashed_message_noassert(hashed_message, public_key, sig); + return ecdsa_verify_signature_prehashed_message_noassert( + hashed_message, public_key, sig); } -} // namespace bb::stdlib::ecdsa \ No newline at end of file +} // namespace bb::stdlib \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/encryption/schnorr/schnorr.cpp b/barretenberg/cpp/src/barretenberg/stdlib/encryption/schnorr/schnorr.cpp index 2f73d0646c39..8c4c8e011c45 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/encryption/schnorr/schnorr.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/encryption/schnorr/schnorr.cpp @@ -7,13 +7,14 @@ #include "barretenberg/stdlib/primitives/group/cycle_group.hpp" #include -namespace bb::stdlib::schnorr { +namespace bb::stdlib { /** * @brief Instantiate a witness containing the signature (s, e) as a quadruple of * field_t elements (s_lo, s_hi, e_lo, e_hi). */ -template signature_bits convert_signature(C* context, const crypto::schnorr::signature& signature) +template +schnorr_signature_bits schnorr_convert_signature(C* context, const crypto::schnorr_signature& signature) { using cycle_scalar = typename cycle_group::cycle_scalar; @@ -23,8 +24,8 @@ template signature_bits convert_signature(C* context, const cryp const uint8_t* e_ptr = &signature.e[0]; numeric::read(s_ptr, s_bigint); numeric::read(e_ptr, e_bigint); - signature_bits sig{ .s = cycle_scalar::from_witness_bitstring(context, s_bigint, 256), - .e = cycle_scalar::from_witness_bitstring(context, e_bigint, 256) }; + schnorr_signature_bits sig{ .s = cycle_scalar::from_witness_bitstring(context, s_bigint, 256), + .e = cycle_scalar::from_witness_bitstring(context, e_bigint, 256) }; return sig; } @@ -37,9 +38,9 @@ template signature_bits convert_signature(C* context, const cryp * (~1,169k for fixed/variable_base_mul, ~4k for blake2s) for a string of length = 34. */ template -std::array, 2> verify_signature_internal(const byte_array& message, - const cycle_group& pub_key, - const signature_bits& sig) +std::array, 2> schnorr_verify_signature_internal(const byte_array& message, + const cycle_group& pub_key, + const schnorr_signature_bits& sig) { cycle_group g1(grumpkin::g1::one); // compute g1 * sig.s + key * sig,e @@ -66,9 +67,11 @@ std::array, 2> verify_signature_internal(const byte_array& message * e' == e is true. */ template -void verify_signature(const byte_array& message, const cycle_group& pub_key, const signature_bits& sig) +void schnorr_verify_signature(const byte_array& message, + const cycle_group& pub_key, + const schnorr_signature_bits& sig) { - auto [output_lo, output_hi] = verify_signature_internal(message, pub_key, sig); + auto [output_lo, output_hi] = schnorr_verify_signature_internal(message, pub_key, sig); output_lo.assert_equal(sig.e.lo, "verify signature failed"); output_hi.assert_equal(sig.e.hi, "verify signature failed"); } @@ -79,37 +82,42 @@ void verify_signature(const byte_array& message, const cycle_group& pub_ke * and return the boolean witness e' == e. */ template -bool_t signature_verification_result(const byte_array& message, - const cycle_group& pub_key, - const signature_bits& sig) +bool_t schnorr_signature_verification_result(const byte_array& message, + const cycle_group& pub_key, + const schnorr_signature_bits& sig) { - auto [output_lo, output_hi] = verify_signature_internal(message, pub_key, sig); + auto [output_lo, output_hi] = schnorr_verify_signature_internal(message, pub_key, sig); bool_t valid = (output_lo == sig.e.lo) && (output_hi == sig.e.hi); return valid; } #define VERIFY_SIGNATURE_INTERNAL(circuit_type) \ - template std::array, 2> verify_signature_internal( \ - const byte_array&, const cycle_group&, const signature_bits&) + template std::array, 2> schnorr_verify_signature_internal( \ + const byte_array&, \ + const cycle_group&, \ + const schnorr_signature_bits&) VERIFY_SIGNATURE_INTERNAL(bb::StandardCircuitBuilder); VERIFY_SIGNATURE_INTERNAL(bb::UltraCircuitBuilder); VERIFY_SIGNATURE_INTERNAL(bb::GoblinUltraCircuitBuilder); #define VERIFY_SIGNATURE(circuit_type) \ - template void verify_signature( \ - const byte_array&, const cycle_group&, const signature_bits&) + template void schnorr_verify_signature(const byte_array&, \ + const cycle_group&, \ + const schnorr_signature_bits&) VERIFY_SIGNATURE(bb::StandardCircuitBuilder); VERIFY_SIGNATURE(bb::UltraCircuitBuilder); VERIFY_SIGNATURE(bb::GoblinUltraCircuitBuilder); #define SIGNATURE_VERIFICATION_RESULT(circuit_type) \ - template bool_t signature_verification_result( \ - const byte_array&, const cycle_group&, const signature_bits&) + template bool_t schnorr_signature_verification_result( \ + const byte_array&, \ + const cycle_group&, \ + const schnorr_signature_bits&) SIGNATURE_VERIFICATION_RESULT(bb::StandardCircuitBuilder); SIGNATURE_VERIFICATION_RESULT(bb::UltraCircuitBuilder); SIGNATURE_VERIFICATION_RESULT(bb::GoblinUltraCircuitBuilder); #define CONVERT_SIGNATURE(circuit_type) \ - template signature_bits convert_signature(circuit_type*, \ - const crypto::schnorr::signature&) + template schnorr_signature_bits schnorr_convert_signature( \ + circuit_type*, const crypto::schnorr_signature&) CONVERT_SIGNATURE(bb::StandardCircuitBuilder); CONVERT_SIGNATURE(bb::UltraCircuitBuilder); CONVERT_SIGNATURE(bb::GoblinUltraCircuitBuilder); -} // namespace bb::stdlib::schnorr +} // namespace bb::stdlib diff --git a/barretenberg/cpp/src/barretenberg/stdlib/encryption/schnorr/schnorr.hpp b/barretenberg/cpp/src/barretenberg/stdlib/encryption/schnorr/schnorr.hpp index 26f2ef0784b5..b9ea2e632a5d 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/encryption/schnorr/schnorr.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/encryption/schnorr/schnorr.hpp @@ -6,26 +6,29 @@ #include "../../primitives/witness/witness.hpp" #include "barretenberg/crypto/schnorr/schnorr.hpp" -namespace bb::stdlib::schnorr { +namespace bb::stdlib { -template struct signature_bits { +template struct schnorr_signature_bits { typename cycle_group::cycle_scalar s; typename cycle_group::cycle_scalar e; }; -template signature_bits convert_signature(C* context, const crypto::schnorr::signature& sig); +template +schnorr_signature_bits schnorr_convert_signature(C* context, const crypto::schnorr_signature& sig); template -std::array, 2> verify_signature_internal(const byte_array& message, - const cycle_group& pub_key, - const signature_bits& sig); +std::array, 2> schnorr_verify_signature_internal(const byte_array& message, + const cycle_group& pub_key, + const schnorr_signature_bits& sig); template -void verify_signature(const byte_array& message, const cycle_group& pub_key, const signature_bits& sig); +void schnorr_verify_signature(const byte_array& message, + const cycle_group& pub_key, + const schnorr_signature_bits& sig); template -bool_t signature_verification_result(const byte_array& message, - const cycle_group& pub_key, - const signature_bits& sig); +bool_t schnorr_signature_verification_result(const byte_array& message, + const cycle_group& pub_key, + const schnorr_signature_bits& sig); -} // namespace bb::stdlib::schnorr +} // namespace bb::stdlib diff --git a/barretenberg/cpp/src/barretenberg/stdlib/encryption/schnorr/schnorr.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/encryption/schnorr/schnorr.test.cpp index 0ae462195d5b..6c5bfe9573f9 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/encryption/schnorr/schnorr.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/encryption/schnorr/schnorr.test.cpp @@ -5,24 +5,21 @@ #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" #include "schnorr.hpp" -namespace bb::test_stdlib_schnorr { - using namespace bb; using namespace bb::stdlib; -using namespace bb::stdlib::schnorr; -using Builder = bb::UltraCircuitBuilder; +using Builder = UltraCircuitBuilder; using bool_ct = bool_t; using byte_array_ct = byte_array; using field_ct = field_t; using witness_ct = witness_t; /** - * @test Test circuit verifying a Schnorr signature generated by \see{crypto::schnorr::verify_signature}. + * @test Test circuit verifying a Schnorr signature generated by \see{crypto::schnorr_verify_signature}. * We only test: messages signed and verified using Grumpkin and the BLAKE2s hash function. We test strings of lengths * 0, 1, ..., 33. */ -TEST(stdlib_schnorr, verify_signature) +TEST(stdlib_schnorr, schnorr_verify_signature) { std::string longer_string = "This is a test string of length 34"; @@ -31,24 +28,24 @@ TEST(stdlib_schnorr, verify_signature) Builder builder = Builder(); auto message_string = longer_string.substr(0, i); - crypto::schnorr::key_pair account; + crypto::schnorr_key_pair account; account.private_key = grumpkin::fr::random_element(); account.public_key = grumpkin::g1::one * account.private_key; - crypto::schnorr::signature signature = - crypto::schnorr::construct_signature( - message_string, account); + crypto::schnorr_signature signature = + crypto::schnorr_construct_signature(message_string, + account); - bool first_result = crypto::schnorr::verify_signature( + bool first_result = crypto::schnorr_verify_signature( message_string, account.public_key, signature); EXPECT_EQ(first_result, true); cycle_group pub_key{ witness_ct(&builder, account.public_key.x), witness_ct(&builder, account.public_key.y), false }; - signature_bits sig = convert_signature(&builder, signature); + schnorr_signature_bits sig = schnorr_convert_signature(&builder, signature); byte_array_ct message(&builder, message_string); - verify_signature(message, pub_key, sig); + schnorr_verify_signature(message, pub_key, sig); info("num gates = ", builder.get_num_gates()); bool result = builder.check_circuit(); @@ -66,22 +63,22 @@ TEST(stdlib_schnorr, verify_signature_failure) std::string message_string = "This is a test string of length 34"; // create key pair 1 - crypto::schnorr::key_pair account1; + crypto::schnorr_key_pair account1; account1.private_key = grumpkin::fr::random_element(); account1.public_key = grumpkin::g1::one * account1.private_key; // create key pair 2 - crypto::schnorr::key_pair account2; + crypto::schnorr_key_pair account2; account2.private_key = grumpkin::fr::random_element(); account2.public_key = grumpkin::g1::one * account2.private_key; // sign the message with account 1 private key - crypto::schnorr::signature signature = - crypto::schnorr::construct_signature(message_string, - account1); + crypto::schnorr_signature signature = + crypto::schnorr_construct_signature(message_string, + account1); // check native verification with account 2 public key fails - bool native_result = crypto::schnorr::verify_signature( + bool native_result = crypto::schnorr_verify_signature( message_string, account2.public_key, signature); EXPECT_EQ(native_result, false); @@ -89,9 +86,9 @@ TEST(stdlib_schnorr, verify_signature_failure) cycle_group pub_key2_ct{ witness_ct(&builder, account2.public_key.x), witness_ct(&builder, account2.public_key.y), false }; - signature_bits sig = convert_signature(&builder, signature); + schnorr_signature_bits sig = schnorr_convert_signature(&builder, signature); byte_array_ct message(&builder, message_string); - verify_signature(message, pub_key2_ct, sig); + schnorr_verify_signature(message, pub_key2_ct, sig); info("num gates = ", builder.get_num_gates()); @@ -100,33 +97,33 @@ TEST(stdlib_schnorr, verify_signature_failure) } /** - * @test Like stdlib_schnorr.verify_signature, but we use the function signature_verification that produces a + * @test Like stdlib_schnorr.schnorr_verify_signature, but we use the function signature_verification that produces a * boolean witness and does not require the prover to provide a valid signature. */ -TEST(stdlib_schnorr, signature_verification_result) +TEST(stdlib_schnorr, schnorr_signature_verification_result) { std::string longer_string = "This is a test string of length 34"; Builder builder = Builder(); - crypto::schnorr::key_pair account; + crypto::schnorr_key_pair account; account.private_key = grumpkin::fr::random_element(); account.public_key = grumpkin::g1::one * account.private_key; - crypto::schnorr::signature signature = - crypto::schnorr::construct_signature(longer_string, - account); + crypto::schnorr_signature signature = + crypto::schnorr_construct_signature(longer_string, + account); - bool first_result = crypto::schnorr::verify_signature( + bool first_result = crypto::schnorr_verify_signature( longer_string, account.public_key, signature); EXPECT_EQ(first_result, true); cycle_group pub_key{ witness_ct(&builder, account.public_key.x), witness_ct(&builder, account.public_key.y), false }; - signature_bits sig = convert_signature(&builder, signature); + schnorr_signature_bits sig = schnorr_convert_signature(&builder, signature); byte_array_ct message(&builder, longer_string); - bool_ct signature_result = signature_verification_result(message, pub_key, sig); + bool_ct signature_result = schnorr_signature_verification_result(message, pub_key, sig); EXPECT_EQ(signature_result.witness_bool, true); info("num gates = ", builder.get_num_gates()); @@ -145,22 +142,22 @@ TEST(stdlib_schnorr, signature_verification_result_failure) std::string message_string = "This is a test string of length 34"; // create key pair 1 - crypto::schnorr::key_pair account1; + crypto::schnorr_key_pair account1; account1.private_key = grumpkin::fr::random_element(); account1.public_key = grumpkin::g1::one * account1.private_key; // create key pair 2 - crypto::schnorr::key_pair account2; + crypto::schnorr_key_pair account2; account2.private_key = grumpkin::fr::random_element(); account2.public_key = grumpkin::g1::one * account2.private_key; // sign the message with account 1 private key - crypto::schnorr::signature signature = - crypto::schnorr::construct_signature(message_string, - account1); + crypto::schnorr_signature signature = + crypto::schnorr_construct_signature(message_string, + account1); // check native verification with account 2 public key fails - bool native_result = crypto::schnorr::verify_signature( + bool native_result = crypto::schnorr_verify_signature( message_string, account2.public_key, signature); EXPECT_EQ(native_result, false); @@ -168,9 +165,9 @@ TEST(stdlib_schnorr, signature_verification_result_failure) cycle_group pub_key2_ct{ witness_ct(&builder, account2.public_key.x), witness_ct(&builder, account2.public_key.y), false }; - signature_bits sig = convert_signature(&builder, signature); + schnorr_signature_bits sig = schnorr_convert_signature(&builder, signature); byte_array_ct message(&builder, message_string); - bool_ct signature_result = signature_verification_result(message, pub_key2_ct, sig); + bool_ct signature_result = schnorr_signature_verification_result(message, pub_key2_ct, sig); EXPECT_EQ(signature_result.witness_bool, false); info("num gates = ", builder.get_num_gates()); @@ -178,5 +175,3 @@ TEST(stdlib_schnorr, signature_verification_result_failure) bool verification_result = builder.check_circuit(); EXPECT_EQ(verification_result, true); } - -} // namespace bb::test_stdlib_schnorr diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/blake2s/blake2s.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/blake2s/blake2s.test.cpp index bf8be6de42fc..f5a8b37f24dc 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/blake2s/blake2s.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/blake2s/blake2s.test.cpp @@ -7,7 +7,7 @@ using namespace bb; using namespace bb::stdlib; -using Builder = bb::UltraCircuitBuilder; +using Builder = UltraCircuitBuilder; using field_ct = field_t; using witness_ct = witness_t; @@ -24,7 +24,7 @@ using public_witness_t = public_witness_t; // byte_array_ct input_arr(&builder, input_v); // byte_array_ct output = blake2s(input_arr); -// std::vector expected = blake2::blake2s(input_v); +// std::vector expected = crypto::blake2s(input_v); // EXPECT_EQ(output.get_value(), expected); @@ -43,7 +43,7 @@ TEST(stdlib_blake2s, test_single_block_plookup) byte_array_plookup input_arr(&builder, input_v); byte_array_plookup output = blake2s(input_arr); - auto expected = blake2::blake2s(input_v); + auto expected = crypto::blake2s(input_v); EXPECT_EQ(output.get_value(), std::vector(expected.begin(), expected.end())); @@ -62,7 +62,7 @@ TEST(stdlib_blake2s, test_single_block_plookup) // byte_array_ct input_arr(&builder, input_v); // byte_array_ct output = blake2s(input_arr); -// std::vector expected = blake2::blake2s(input_v); +// std::vector expected = crypto::blake2s(input_v); // EXPECT_EQ(output.get_value(), expected); @@ -81,7 +81,7 @@ TEST(stdlib_blake2s, test_double_block_plookup) byte_array_plookup input_arr(&builder, input_v); byte_array_plookup output = blake2s(input_arr); - auto expected = blake2::blake2s(input_v); + auto expected = crypto::blake2s(input_v); EXPECT_EQ(output.get_value(), std::vector(expected.begin(), expected.end())); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/blake2s/blake_util.hpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/blake2s/blake_util.hpp index 418f601e1466..25a65a5abbcf 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/blake2s/blake_util.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/blake2s/blake_util.hpp @@ -6,7 +6,7 @@ namespace bb::stdlib::blake_util { -using namespace plookup; +using namespace bb::plookup; // constants enum blake_constant { BLAKE3_STATE_SIZE = 16 }; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/blake3s/blake3s.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/blake3s/blake3s.test.cpp index 69c5b7a79040..9e054605e3a0 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/blake3s/blake3s.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/blake3s/blake3s.test.cpp @@ -10,8 +10,8 @@ using byte_array = stdlib::byte_array; using public_witness_t = stdlib::public_witness_t; using byte_array_plookup = stdlib::byte_array; using public_witness_t_plookup = stdlib::public_witness_t; -using StandardBuilder = bb::StandardCircuitBuilder; -using UltraBuilder = bb::UltraCircuitBuilder; +using StandardBuilder = StandardCircuitBuilder; +using UltraBuilder = UltraCircuitBuilder; TEST(stdlib_blake3s, test_single_block) { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/keccak/keccak.cpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/keccak/keccak.cpp index 3f10f28b9c39..2392853e3355 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/keccak/keccak.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/keccak/keccak.cpp @@ -5,7 +5,7 @@ #include "barretenberg/stdlib/primitives/uint/uint.hpp" namespace bb::stdlib { -using namespace plookup; +using namespace bb::plookup; /** * @brief Normalize a base-11 limb and left-rotate by keccak::ROTATIONS[lane_index] bits. diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/keccak/keccak.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/keccak/keccak.test.cpp index 3c414a26856d..49409098b2fc 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/keccak/keccak.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/keccak/keccak.test.cpp @@ -6,7 +6,7 @@ using namespace bb; -typedef bb::UltraCircuitBuilder Builder; +typedef UltraCircuitBuilder Builder; typedef stdlib::byte_array byte_array; typedef stdlib::public_witness_t public_witness_t; typedef stdlib::field_t field_ct; @@ -14,7 +14,7 @@ typedef stdlib::witness_t witness_ct; typedef stdlib::uint32 uint32_ct; namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } TEST(stdlib_keccak, keccak_format_input_table) @@ -67,7 +67,7 @@ TEST(stdlib_keccak, keccak_rho_output_table) { Builder builder = Builder(); - bb::constexpr_for<0, 25, 1>([&] { + constexpr_for<0, 25, 1>([&] { uint256_t extended_native = 0; uint256_t binary_native = 0; for (size_t j = 0; j < 64; ++j) { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.test.cpp index e81aeae6bf56..71787e0a8de4 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/pedersen/pedersen.test.cpp @@ -5,10 +5,9 @@ #include "barretenberg/stdlib/primitives/curves/bn254.hpp" #include "pedersen.hpp" -namespace test_StdlibPedersen { using namespace bb; namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } template class StdlibPedersen : public testing::Test { @@ -155,41 +154,41 @@ template class StdlibPedersen : public testing::Test { Builder builder; for (size_t i = 0; i < 7; ++i) { - std::vector inputs; + std::vector inputs; inputs.push_back(bb::fr::random_element()); inputs.push_back(bb::fr::random_element()); inputs.push_back(bb::fr::random_element()); inputs.push_back(bb::fr::random_element()); if (i == 1) { - inputs[0] = bb::fr(0); + inputs[0] = fr(0); } if (i == 2) { - inputs[1] = bb::fr(0); - inputs[2] = bb::fr(0); + inputs[1] = fr(0); + inputs[2] = fr(0); } if (i == 3) { - inputs[3] = bb::fr(0); + inputs[3] = fr(0); } if (i == 4) { - inputs[0] = bb::fr(0); - inputs[3] = bb::fr(0); + inputs[0] = fr(0); + inputs[3] = fr(0); } if (i == 5) { - inputs[0] = bb::fr(0); - inputs[1] = bb::fr(0); - inputs[2] = bb::fr(0); - inputs[3] = bb::fr(0); + inputs[0] = fr(0); + inputs[1] = fr(0); + inputs[2] = fr(0); + inputs[3] = fr(0); } if (i == 6) { - inputs[1] = bb::fr(1); + inputs[1] = fr(1); } std::vector witnesses; for (auto input : inputs) { witnesses.push_back(witness_ct(&builder, input)); } - bb::fr expected = crypto::pedersen_hash::hash(inputs); + fr expected = crypto::pedersen_hash::hash(inputs); fr_ct result = pedersen_hash::hash(witnesses); EXPECT_EQ(result.get_value(), expected); @@ -225,7 +224,7 @@ template class StdlibPedersen : public testing::Test { { Builder builder; - std::vector inputs; + std::vector inputs; std::vector> witness_inputs; for (size_t i = 0; i < 8; ++i) { @@ -237,7 +236,7 @@ template class StdlibPedersen : public testing::Test { } } - bb::fr expected = crypto::pedersen_hash::hash(inputs); + fr expected = crypto::pedersen_hash::hash(inputs); auto result = pedersen_hash::hash(witness_inputs); EXPECT_EQ(result.get_value(), expected); @@ -309,5 +308,3 @@ TYPED_TEST(StdlibPedersen, HashConstants) { TestFixture::test_hash_constants(); }; - -} // namespace test_StdlibPedersen diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/poseidon2/poseidon2.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/poseidon2/poseidon2.test.cpp index 428193f5c39b..6d5e4bb1cdf3 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/poseidon2/poseidon2.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/poseidon2/poseidon2.test.cpp @@ -4,10 +4,9 @@ #include "barretenberg/numeric/random/engine.hpp" #include "barretenberg/stdlib/primitives/curves/bn254.hpp" -namespace test_StdlibPoseidon2 { using namespace bb; namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } template class StdlibPoseidon2 : public testing::Test { @@ -128,7 +127,7 @@ template class StdlibPoseidon2 : public testing::Test { { Builder builder; - std::vector inputs; + std::vector inputs; std::vector> witness_inputs; for (size_t i = 0; i < 8; ++i) { @@ -140,7 +139,7 @@ template class StdlibPoseidon2 : public testing::Test { } } - bb::fr expected = native_poseidon2::hash(inputs); + fr expected = native_poseidon2::hash(inputs); auto result = poseidon2::hash(builder, witness_inputs); EXPECT_EQ(result.get_value(), expected); @@ -185,5 +184,3 @@ TYPED_TEST(StdlibPoseidon2, TestHashConstants) { TestFixture::test_hash_constants(); }; - -} // namespace test_StdlibPoseidon2 diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/sha256/sha256.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/sha256/sha256.test.cpp index 618dc52ef93f..9d7e3299b61a 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/sha256/sha256.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/sha256/sha256.test.cpp @@ -9,16 +9,13 @@ #include "barretenberg/numeric/bitop/sparse_form.hpp" #include "barretenberg/numeric/random/engine.hpp" -namespace { -auto& engine = numeric::random::get_debug_engine(); -} - -namespace bb::test_stdlib_sha256 { - using namespace bb; using namespace bb::stdlib; -using Builder = bb::UltraCircuitBuilder; +namespace { +auto& engine = numeric::get_debug_randomness(); +} +using Builder = UltraCircuitBuilder; using byte_array_ct = byte_array; using packed_byte_array_ct = packed_byte_array; @@ -120,18 +117,18 @@ std::array inner_block(std::array& w) // auto builder = UltraPlonkBuilder(); // std::array w_inputs; -// std::array, 64> w_elements; +// std::array, 64> w_elements; // for (size_t i = 0; i < 64; ++i) { // w_inputs[i] = engine.get_random_uint32(); -// w_elements[i] = bb::stdlib::witness_t(&builder, -// bb::fr(w_inputs[i])); +// w_elements[i] = stdlib::witness_t(&builder, +// fr(w_inputs[i])); // } // const auto expected = inner_block(w_inputs); // const std::array, 8> result = -// bb::stdlib::sha256_inner_block(w_elements); +// stdlib::sha256_inner_block(w_elements); // for (size_t i = 0; i < 8; ++i) { // EXPECT_EQ(uint256_t(result[i].get_value()).data[0] & 0xffffffffUL, // uint256_t(expected[i]).data[0] & 0xffffffffUL); @@ -141,22 +138,22 @@ std::array inner_block(std::array& w) // auto prover = composer.create_prover(); // auto verifier = composer.create_verifier(); -// bb::plonk::proof proof = prover.construct_proof(); +// plonk::proof proof = prover.construct_proof(); // bool proof_result = builder.check_circuit(); // EXPECT_EQ(proof_result, true); // } TEST(stdlib_sha256, test_plookup_55_bytes) { - typedef bb::stdlib::field_t field_pt; - typedef bb::stdlib::packed_byte_array packed_byte_array_pt; + typedef stdlib::field_t field_pt; + typedef stdlib::packed_byte_array packed_byte_array_pt; // 55 bytes is the largest number of bytes that can be hashed in a single block, // accounting for the single padding bit, and the 64 size bits required by the SHA-256 standard. - auto builder = bb::UltraCircuitBuilder(); + auto builder = UltraCircuitBuilder(); packed_byte_array_pt input(&builder, "An 8 character password? Snow White and the 7 Dwarves.."); - packed_byte_array_pt output_bits = bb::stdlib::sha256(input); + packed_byte_array_pt output_bits = stdlib::sha256(input); std::vector output = output_bits.to_unverified_byte_slices(4); @@ -181,7 +178,7 @@ TEST(stdlib_sha256, test_55_bytes) auto builder = Builder(); packed_byte_array_ct input(&builder, "An 8 character password? Snow White and the 7 Dwarves.."); - packed_byte_array_ct output_bits = bb::stdlib::sha256(input); + packed_byte_array_ct output_bits = stdlib::sha256(input); std::vector output = output_bits.to_unverified_byte_slices(4); @@ -201,13 +198,13 @@ TEST(stdlib_sha256, test_55_bytes) TEST(stdlib_sha256, test_NIST_vector_one_packed_byte_array) { - typedef bb::stdlib::field_t field_pt; - typedef bb::stdlib::packed_byte_array packed_byte_array_pt; + typedef stdlib::field_t field_pt; + typedef stdlib::packed_byte_array packed_byte_array_pt; - auto builder = bb::UltraCircuitBuilder(); + auto builder = UltraCircuitBuilder(); packed_byte_array_pt input(&builder, "abc"); - packed_byte_array_pt output_bytes = bb::stdlib::sha256(input); + packed_byte_array_pt output_bytes = stdlib::sha256(input); std::vector output = output_bytes.to_unverified_byte_slices(4); EXPECT_EQ(uint256_t(output[0].get_value()).data[0], (uint64_t)0xBA7816BFU); EXPECT_EQ(uint256_t(output[1].get_value()).data[0], (uint64_t)0x8F01CFEAU); @@ -225,14 +222,14 @@ TEST(stdlib_sha256, test_NIST_vector_one_packed_byte_array) TEST(stdlib_sha256, test_NIST_vector_one) { - typedef bb::stdlib::field_t field_pt; - typedef bb::stdlib::packed_byte_array packed_byte_array_pt; + typedef stdlib::field_t field_pt; + typedef stdlib::packed_byte_array packed_byte_array_pt; - auto builder = bb::UltraCircuitBuilder(); + auto builder = UltraCircuitBuilder(); packed_byte_array_pt input(&builder, "abc"); - packed_byte_array_pt output_bits = bb::stdlib::sha256(input); + packed_byte_array_pt output_bits = stdlib::sha256(input); std::vector output = output_bits.to_unverified_byte_slices(4); @@ -256,7 +253,7 @@ TEST(stdlib_sha256, test_NIST_vector_two) byte_array_ct input(&builder, "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"); - byte_array_ct output_bits = bb::stdlib::sha256(input); + byte_array_ct output_bits = stdlib::sha256(input); std::vector output = packed_byte_array_ct(output_bits).to_unverified_byte_slices(4); @@ -281,7 +278,7 @@ TEST(stdlib_sha256, test_NIST_vector_three) // one byte, 0xbd byte_array_ct input(&builder, std::vector{ 0xbd }); - byte_array_ct output_bits = bb::stdlib::sha256(input); + byte_array_ct output_bits = stdlib::sha256(input); std::vector output = packed_byte_array_ct(output_bits).to_unverified_byte_slices(4); @@ -306,7 +303,7 @@ TEST(stdlib_sha256, test_NIST_vector_four) // 4 bytes, 0xc98c8e55 byte_array_ct input(&builder, std::vector{ 0xc9, 0x8c, 0x8e, 0x55 }); - byte_array_ct output_bits = bb::stdlib::sha256(input); + byte_array_ct output_bits = stdlib::sha256(input); std::vector output = packed_byte_array_ct(output_bits).to_unverified_byte_slices(4); @@ -327,10 +324,10 @@ TEST(stdlib_sha256, test_NIST_vector_four) HEAVY_TEST(stdlib_sha256, test_NIST_vector_five) { - typedef bb::stdlib::field_t field_pt; - typedef bb::stdlib::packed_byte_array packed_byte_array_pt; + typedef stdlib::field_t field_pt; + typedef stdlib::packed_byte_array packed_byte_array_pt; - auto builder = bb::UltraCircuitBuilder(); + auto builder = UltraCircuitBuilder(); packed_byte_array_pt input( &builder, @@ -345,7 +342,7 @@ HEAVY_TEST(stdlib_sha256, test_NIST_vector_five) "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" "AAAAAAAAAA"); - packed_byte_array_pt output_bits = bb::stdlib::sha256(input); + packed_byte_array_pt output_bits = stdlib::sha256(input); std::vector output = output_bits.to_unverified_byte_slices(4); @@ -374,7 +371,7 @@ TEST(stdlib_sha256, test_input_len_multiple) auto input_buf = std::vector(inp, 1); byte_array_ct input(&builder, input_buf); - byte_array_ct output_bits = bb::stdlib::sha256(input); + byte_array_ct output_bits = stdlib::sha256(input); auto circuit_output = output_bits.get_value(); @@ -418,7 +415,7 @@ TEST(stdlib_sha256, test_input_str_len_multiple) auto input_buf = std::vector(input_str.begin(), input_str.end()); byte_array_ct input(&builder, input_buf); - byte_array_ct output_bits = bb::stdlib::sha256(input); + byte_array_ct output_bits = stdlib::sha256(input); auto circuit_output = output_bits.get_value(); @@ -427,5 +424,3 @@ TEST(stdlib_sha256, test_input_str_len_multiple) EXPECT_EQ(circuit_output, expected); } } - -} // namespace bb::test_stdlib_sha256 diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/sha256/sha256_plookup.cpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/sha256/sha256_plookup.cpp index cb16d9f89ccc..bffa757acd72 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/sha256/sha256_plookup.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/sha256/sha256_plookup.cpp @@ -11,7 +11,7 @@ using namespace bb; namespace bb::stdlib::sha256_plookup { -using namespace plookup; +using namespace bb::plookup; namespace internal { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/hash.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/hash.test.cpp index 8daf6b0ef385..2e420fb15383 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/hash.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/hash.test.cpp @@ -5,12 +5,10 @@ #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" #include "barretenberg/stdlib/merkle_tree/membership.hpp" -namespace bb::stdlib_merkle_tree_hash_test { - using namespace bb; using namespace bb::stdlib; -using Builder = bb::UltraCircuitBuilder; +using Builder = UltraCircuitBuilder; using field_ct = field_t; using witness_ct = witness_t; @@ -64,4 +62,3 @@ TEST(stdlib_merkle_tree_hash, compute_tree_native) } EXPECT_EQ(tree_vector.back(), mem_tree.root()); } -} // namespace bb::stdlib_merkle_tree_hash_test \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/membership.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/membership.test.cpp index f559cf01085d..1d8d06820e74 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/membership.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/membership.test.cpp @@ -7,17 +7,15 @@ #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" -namespace { -auto& engine = numeric::random::get_debug_engine(); -} - -namespace bb::stdlib_merkle_test { - using namespace bb; using namespace bb::stdlib::merkle_tree; using namespace bb::stdlib; -using Builder = bb::UltraCircuitBuilder; +namespace { +auto& engine = numeric::get_debug_randomness(); +} + +using Builder = UltraCircuitBuilder; using bool_ct = bool_t; using field_ct = field_t; @@ -247,4 +245,3 @@ TEST(stdlib_merkle_tree, test_update_memberships) bool result = builder.check_circuit(); EXPECT_EQ(result, true); } -} // namespace bb::stdlib_merkle_test \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/merkle_tree.bench.cpp b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/merkle_tree.bench.cpp index 94268b49bb17..49871e881e6f 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/merkle_tree.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/merkle_tree.bench.cpp @@ -8,7 +8,7 @@ using namespace benchmark; using namespace bb::stdlib::merkle_tree; namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = bb::numeric::get_debug_randomness(); } constexpr size_t DEPTH = 256; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/merkle_tree.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/merkle_tree.test.cpp index ec80f169126f..55bd530c2161 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/merkle_tree.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/merkle_tree.test.cpp @@ -5,18 +5,16 @@ #include "memory_store.hpp" #include "memory_tree.hpp" -namespace bb::test_stdlib_merkle_tree { - using namespace bb::stdlib; using namespace bb::stdlib::merkle_tree; -using Builder = bb::UltraCircuitBuilder; +using Builder = UltraCircuitBuilder; using field_ct = field_t; using witness_ct = witness_t; namespace { -auto& engine = numeric::random::get_debug_engine(); -auto& random_engine = numeric::random::get_engine(); +auto& engine = numeric::get_debug_randomness(); +auto& random_engine = numeric::get_randomness(); } // namespace static std::vector VALUES = []() { @@ -184,4 +182,3 @@ TEST(stdlib_merkle_tree, test_get_sibling_path_layers) EXPECT_NE(before[2], after[2]); } } -} // namespace bb::test_stdlib_merkle_tree \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/nullifier_tree/nullifier_tree.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/nullifier_tree/nullifier_tree.test.cpp index de20b85ddbd4..99a1eeeffdeb 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/nullifier_tree/nullifier_tree.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/merkle_tree/nullifier_tree/nullifier_tree.test.cpp @@ -9,8 +9,8 @@ using namespace bb; using namespace bb::stdlib::merkle_tree; namespace { -auto& engine = numeric::random::get_debug_engine(); -auto& random_engine = numeric::random::get_engine(); +auto& engine = numeric::get_debug_randomness(); +auto& random_engine = numeric::get_randomness(); } // namespace static std::vector VALUES = []() { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield.test.cpp index e47278837ec2..cc03446d73f2 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield.test.cpp @@ -18,7 +18,6 @@ #include #include -namespace test_stdlib_bigfield { using namespace bb; /* A note regarding Plookup: @@ -30,7 +29,7 @@ using namespace bb; */ namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } template class stdlib_bigfield : public testing::Test { @@ -827,18 +826,18 @@ template class stdlib_bigfield : public testing::Test { static void test_conditional_select_regression() { auto builder = Builder(); - bb::fq a(0); - bb::fq b(1); + fq a(0); + fq b(1); fq_ct a_ct(&builder, a); fq_ct b_ct(&builder, b); fq_ct selected = a_ct.conditional_select(b_ct, typename bn254::bool_ct(&builder, true)); - EXPECT_EQ(bb::fq((selected.get_value() % uint512_t(bb::fq::modulus)).lo), b); + EXPECT_EQ(fq((selected.get_value() % uint512_t(bb::fq::modulus)).lo), b); } static void test_division_context() { auto builder = Builder(); - bb::fq a(1); + fq a(1); fq_ct a_ct(&builder, a); fq_ct ret = fq_ct::div_check_denominator_nonzero({}, a_ct); EXPECT_NE(ret.get_context(), nullptr); @@ -943,15 +942,15 @@ TYPED_TEST(stdlib_bigfield, division_context) // fq_ct::NUM_LIMB_BITS * 2))), // witness_ct( // &builder, -// bb::fr(uint256_t(inputs[0]).slice(fq_ct::NUM_LIMB_BITS * 2, +// fr(uint256_t(inputs[0]).slice(fq_ct::NUM_LIMB_BITS * 2, // fq_ct::NUM_LIMB_BITS * 4)))); // fq_ct b1(&builder, uint256_t(inputs[1])); // fq_ct b2(&builder, uint256_t(inputs[2])); // fq_ct c = a / (b1 - b2); // // uint256_t modulus{ bb::Bn254FqParams::modulus_0, -// // bb::Bn254FqParams::modulus_1, -// // bb::Bn254FqParams::modulus_2, -// // bb::Bn254FqParams::modulus_3 }; +// // Bn254FqParams::modulus_1, +// // Bn254FqParams::modulus_2, +// // Bn254FqParams::modulus_3 }; // fq expected = (inputs[0] / (inputs[1] - inputs[2])); // std::cerr << "denominator = " << inputs[1] - inputs[2] << std::endl; @@ -978,20 +977,20 @@ TYPED_TEST(stdlib_bigfield, division_context) // // PLOOKUP TESTS // TEST(stdlib_bigfield_plookup, test_mul) // { -// plonk::UltraPlonkBuilder builder = bb::plonk::UltraPlonkBuilder(); +// plonk::UltraPlonkBuilder builder = plonk::UltraPlonkBuilder(); // size_t num_repetitions = 1; // for (size_t i = 0; i < num_repetitions; ++i) { // fq inputs[3]{ fq::random_element(), fq::random_element(), fq::random_element() }; // fq_ct a( // witness_ct(&builder, bb::fr(uint256_t(inputs[0]).slice(0, // fq_ct::NUM_LIMB_BITS * 2))), witness_ct(&builder, -// bb::fr( +// fr( // uint256_t(inputs[0]).slice(fq_ct::NUM_LIMB_BITS * 2, fq_ct::NUM_LIMB_BITS * // 4)))); // fq_ct b( // witness_ct(&builder, bb::fr(uint256_t(inputs[1]).slice(0, // fq_ct::NUM_LIMB_BITS * 2))), witness_ct(&builder, -// bb::fr( +// fr( // uint256_t(inputs[1]).slice(fq_ct::NUM_LIMB_BITS * 2, fq_ct::NUM_LIMB_BITS * // 4)))); // std::cerr << "starting mul" << std::endl; @@ -1025,14 +1024,14 @@ TYPED_TEST(stdlib_bigfield, division_context) // TEST(stdlib_bigfield_plookup, test_sqr) // { -// plonk::UltraPlonkBuilder builder = bb::plonk::UltraPlonkBuilder(); +// plonk::UltraPlonkBuilder builder = plonk::UltraPlonkBuilder(); // size_t num_repetitions = 10; // for (size_t i = 0; i < num_repetitions; ++i) { // fq inputs[3]{ fq::random_element(), fq::random_element(), fq::random_element() }; // fq_ct a( // witness_ct(&builder, bb::fr(uint256_t(inputs[0]).slice(0, // fq_ct::NUM_LIMB_BITS * 2))), witness_ct(&builder, -// bb::fr( +// fr( // uint256_t(inputs[0]).slice(fq_ct::NUM_LIMB_BITS * 2, fq_ct::NUM_LIMB_BITS * // 4)))); // uint64_t before = builder.get_num_gates(); @@ -1062,4 +1061,3 @@ TYPED_TEST(stdlib_bigfield, division_context) // bool result = verifier.verify_proof(proof); // EXPECT_EQ(result, true); // } -} // namespace test_stdlib_bigfield diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup.test.cpp index 6561525428f8..1dad1d6a38cc 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup.test.cpp @@ -9,9 +9,8 @@ #include "barretenberg/stdlib/primitives/curves/secp256k1.hpp" #include "barretenberg/stdlib/primitives/curves/secp256r1.hpp" -namespace test_stdlib_biggroup { namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } using namespace bb; @@ -907,7 +906,7 @@ HEAVY_TYPED_TEST(stdlib_biggroup, multiple_montgomery_ladder) HEAVY_TYPED_TEST(stdlib_biggroup, compute_naf) { // ULTRATODO: make this work for secp curves - if constexpr (TypeParam::Curve::type == bb::CurveType::BN254) { + if constexpr (TypeParam::Curve::type == CurveType::BN254) { size_t num_repetitions = 1; for (size_t i = 0; i < num_repetitions; i++) { TestFixture::test_compute_naf(); @@ -980,7 +979,7 @@ HEAVY_TYPED_TEST(stdlib_biggroup, wnaf_batch_4) /* The following tests are specific to BN254 and don't work when Fr is a bigfield */ HEAVY_TYPED_TEST(stdlib_biggroup, bn254_endo_batch_mul) { - if constexpr (TypeParam::Curve::type == bb::CurveType::BN254 && !TypeParam::use_bigfield) { + if constexpr (TypeParam::Curve::type == CurveType::BN254 && !TypeParam::use_bigfield) { if constexpr (HasGoblinBuilder) { GTEST_SKIP() << "https://github.com/AztecProtocol/barretenberg/issues/707"; } else { @@ -992,7 +991,7 @@ HEAVY_TYPED_TEST(stdlib_biggroup, bn254_endo_batch_mul) } HEAVY_TYPED_TEST(stdlib_biggroup, mixed_mul_bn254_endo) { - if constexpr (TypeParam::Curve::type == bb::CurveType::BN254 && !TypeParam::use_bigfield) { + if constexpr (TypeParam::Curve::type == CurveType::BN254 && !TypeParam::use_bigfield) { if constexpr (HasGoblinBuilder) { GTEST_SKIP() << "https://github.com/AztecProtocol/barretenberg/issues/707"; } else { @@ -1006,7 +1005,7 @@ HEAVY_TYPED_TEST(stdlib_biggroup, mixed_mul_bn254_endo) /* The following tests are specific to SECP256k1 */ HEAVY_TYPED_TEST(stdlib_biggroup, wnaf_secp256k1) { - if constexpr (TypeParam::Curve::type == bb::CurveType::SECP256K1) { + if constexpr (TypeParam::Curve::type == CurveType::SECP256K1) { TestFixture::test_wnaf_secp256k1(); } else { GTEST_SKIP(); @@ -1014,7 +1013,7 @@ HEAVY_TYPED_TEST(stdlib_biggroup, wnaf_secp256k1) } HEAVY_TYPED_TEST(stdlib_biggroup, wnaf_8bit_secp256k1) { - if constexpr (TypeParam::Curve::type == bb::CurveType::SECP256K1) { + if constexpr (TypeParam::Curve::type == CurveType::SECP256K1) { TestFixture::test_wnaf_8bit_secp256k1(); } else { GTEST_SKIP(); @@ -1022,10 +1021,9 @@ HEAVY_TYPED_TEST(stdlib_biggroup, wnaf_8bit_secp256k1) } HEAVY_TYPED_TEST(stdlib_biggroup, ecdsa_mul_secp256k1) { - if constexpr (TypeParam::Curve::type == bb::CurveType::SECP256K1) { + if constexpr (TypeParam::Curve::type == CurveType::SECP256K1) { TestFixture::test_ecdsa_mul_secp256k1(); } else { GTEST_SKIP(); } } -} // namespace test_stdlib_biggroup diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_goblin.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_goblin.test.cpp index 2d6a147ea9db..1753d04de84f 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_goblin.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/biggroup/biggroup_goblin.test.cpp @@ -9,9 +9,8 @@ #include "barretenberg/numeric/random/engine.hpp" #include -namespace test_stdlib_biggroup_goblin { namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } using namespace bb; @@ -85,4 +84,3 @@ HEAVY_TYPED_TEST(stdlib_biggroup_goblin, batch_mul) { TestFixture::test_goblin_style_batch_mul(); } -} // namespace test_stdlib_biggroup_goblin diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bit_array/bit_array.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bit_array/bit_array.test.cpp index 8db4db895f2e..7f002085da0c 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bit_array/bit_array.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bit_array/bit_array.test.cpp @@ -17,12 +17,10 @@ using bit_array_ct = stdlib::bit_array; \ using bool_ct = stdlib::bool_t; -namespace test_stdlib_bit_array { - using namespace bb; namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } template class BitArrayTest : public ::testing::Test {}; @@ -129,4 +127,3 @@ TYPED_TEST(BitArrayTest, test_uint32_vector_constructor) static_cast(test_bit_array_2).get_value(); } -} // namespace test_stdlib_bit_array diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bool/bool.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bool/bool.test.cpp index e3d4dfc7159b..d9f87cd59ab4 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bool/bool.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bool/bool.test.cpp @@ -8,11 +8,10 @@ using witness_ct = stdlib::witness_t; \ using bool_ct = stdlib::bool_t; -namespace test_stdlib_bool { using namespace bb; namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } template class BoolTest : public ::testing::Test {}; @@ -528,4 +527,3 @@ TYPED_TEST(BoolTest, Normalize) bool result = builder.check_circuit(); EXPECT_EQ(result, true); } -} // namespace test_stdlib_bool \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/byte_array/byte_array.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/byte_array/byte_array.test.cpp index 3f1ec92fb3ac..0985b61aad51 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/byte_array/byte_array.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/byte_array/byte_array.test.cpp @@ -7,7 +7,6 @@ #pragma GCC diagnostic ignored "-Wunused-local-typedefs" -namespace test_stdlib_byte_array { using namespace bb; using namespace bb::stdlib; @@ -138,5 +137,3 @@ TYPED_TEST(ByteArrayTest, set_bit) bool proof_result = builder.check_circuit(); EXPECT_EQ(proof_result, true); } - -} // namespace test_stdlib_byte_array diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/circuit_builders/circuit_builders_fwd.hpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/circuit_builders/circuit_builders_fwd.hpp index b1427d772764..ca1e082d04df 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/circuit_builders/circuit_builders_fwd.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/circuit_builders/circuit_builders_fwd.hpp @@ -9,12 +9,10 @@ construction in stdlib and contains macros for explicit instantiation. #pragma once #include -namespace bb::honk { -namespace flavor { +namespace bb::honk::flavor { class Standard; class Ultra; -} // namespace flavor -} // namespace bb::honk +} // namespace bb::honk::flavor namespace bb { class Bn254FrParams; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/curves/bn254.hpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/curves/bn254.hpp index 594ac29d75de..d437cee50441 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/curves/bn254.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/curves/bn254.hpp @@ -17,6 +17,8 @@ template struct bn254 { using ScalarFieldNative = curve::BN254::ScalarField; using BaseFieldNative = curve::BN254::BaseField; using GroupNative = curve::BN254::Group; + using ElementNative = GroupNative::element; + using AffineElementNative = GroupNative::affine_element; // Stdlib types corresponding to those defined in the native description of the curve. // Note: its useful to have these type names match the native analog exactly so that components that digest a Curve diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/curves/secp256k1.hpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/curves/secp256k1.hpp index c771f3e1f7f5..9ab05338b66f 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/curves/secp256k1.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/curves/secp256k1.hpp @@ -11,21 +11,21 @@ namespace bb::stdlib { template struct secp256k1 { static constexpr bb::CurveType type = bb::CurveType::SECP256K1; - typedef ::secp256k1::fq fq; - typedef ::secp256k1::fr fr; - typedef ::secp256k1::g1 g1; + using fq = ::secp256k1::fq; + using fr = ::secp256k1::fr; + using g1 = ::secp256k1::g1; - typedef CircuitType Builder; - typedef witness_t witness_ct; - typedef public_witness_t public_witness_ct; - typedef field_t fr_ct; - typedef byte_array byte_array_ct; - typedef bool_t bool_ct; - typedef stdlib::uint32 uint32_ct; + using Builder = CircuitType; + using witness_ct = witness_t; + using public_witness_ct = public_witness_t; + using fr_ct = field_t; + using byte_array_ct = byte_array; + using bool_ct = bool_t; + using uint32_ct = stdlib::uint32; - typedef bigfield fq_ct; - typedef bigfield bigfr_ct; - typedef element g1_ct; - typedef element g1_bigfr_ct; + using fq_ct = bigfield; + using bigfr_ct = bigfield; + using g1_ct = element; + using g1_bigfr_ct = element; }; } // namespace bb::stdlib diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/array.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/array.test.cpp index bb4602e33b6c..70b7e8fee188 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/array.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/array.test.cpp @@ -6,16 +6,14 @@ #include #include -namespace test_stdlib_array { +using namespace bb; namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } template void ignore_unused(T&) {} // use to ignore unused variables in lambdas -using namespace bb; - template class stdlib_array : public testing::Test { typedef stdlib::bool_t bool_ct; typedef stdlib::field_t field_ct; @@ -695,4 +693,3 @@ TYPED_TEST(stdlib_array, test_pata_nonzero_after_zero_target_fails_2) { TestFixture::test_pata_nonzero_after_zero_target_fails_2(); } -} // namespace test_stdlib_array \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field.test.cpp index 444364e4b3fb..6977453e34a1 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/field.test.cpp @@ -10,10 +10,8 @@ using namespace bb; -namespace test_stdlib_field { - namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } template void ignore_unused(T&) {} // use to ignore unused variables in lambdas @@ -193,12 +191,12 @@ template class stdlib_field : public testing::Test { Builder builder = Builder(); field_ct a = witness_ct(&builder, bb::fr::random_element()); - a *= bb::fr::random_element(); - a += bb::fr::random_element(); + a *= fr::random_element(); + a += fr::random_element(); field_ct b = witness_ct(&builder, bb::fr::random_element()); - b *= bb::fr::random_element(); - b += bb::fr::random_element(); + b *= fr::random_element(); + b += fr::random_element(); // numerator constant field_ct out = field_ct(&builder, b.get_value()) / a; @@ -618,11 +616,11 @@ template class stdlib_field : public testing::Test { constexpr uint256_t modulus_minus_one = fr::modulus - 1; const fr p_lo = modulus_minus_one.slice(0, 130); - std::vector test_elements = { bb::fr::random_element(), - 0, - -1, - bb::fr(static_cast(engine.get_random_uint8())), - bb::fr((static_cast(1) << 130) + 1 + p_lo) }; + std::vector test_elements = { bb::fr::random_element(), + 0, + -1, + fr(static_cast(engine.get_random_uint8())), + fr((static_cast(1) << 130) + 1 + p_lo) }; for (auto a_expected : test_elements) { field_ct a = witness_ct(&builder, a_expected); @@ -713,13 +711,13 @@ template class stdlib_field : public testing::Test { { Builder builder = Builder(); - bb::fr base_val(engine.get_random_uint256()); + fr base_val(engine.get_random_uint256()); uint32_t exponent_val = engine.get_random_uint32(); field_ct base = witness_ct(&builder, base_val); field_ct exponent = witness_ct(&builder, exponent_val); field_ct result = base.pow(exponent); - bb::fr expected = base_val.pow(exponent_val); + fr expected = base_val.pow(exponent_val); EXPECT_EQ(result.get_value(), expected); @@ -732,7 +730,7 @@ template class stdlib_field : public testing::Test { { Builder builder = Builder(); - bb::fr base_val(engine.get_random_uint256()); + fr base_val(engine.get_random_uint256()); uint32_t exponent_val = 0; field_ct base = witness_ct(&builder, base_val); @@ -750,7 +748,7 @@ template class stdlib_field : public testing::Test { { Builder builder = Builder(); - bb::fr base_val(engine.get_random_uint256()); + fr base_val(engine.get_random_uint256()); uint32_t exponent_val = 1; field_ct base = witness_ct(&builder, base_val); @@ -770,13 +768,13 @@ template class stdlib_field : public testing::Test { const size_t num_gates_start = builder.num_gates; - bb::fr base_val(engine.get_random_uint256()); + fr base_val(engine.get_random_uint256()); uint32_t exponent_val = engine.get_random_uint32(); field_ct base(&builder, base_val); field_ct exponent(&builder, exponent_val); field_ct result = base.pow(exponent); - bb::fr expected = base_val.pow(exponent_val); + fr expected = base_val.pow(exponent_val); EXPECT_EQ(result.get_value(), expected); @@ -788,13 +786,13 @@ template class stdlib_field : public testing::Test { { Builder builder = Builder(); - bb::fr base_val(engine.get_random_uint256()); + fr base_val(engine.get_random_uint256()); uint32_t exponent_val = engine.get_random_uint32(); field_ct base(&builder, base_val); field_ct exponent = witness_ct(&builder, exponent_val); field_ct result = base.pow(exponent); - bb::fr expected = base_val.pow(exponent_val); + fr expected = base_val.pow(exponent_val); EXPECT_EQ(result.get_value(), expected); @@ -807,13 +805,13 @@ template class stdlib_field : public testing::Test { { Builder builder = Builder(); - bb::fr base_val(engine.get_random_uint256()); + fr base_val(engine.get_random_uint256()); uint32_t exponent_val = engine.get_random_uint32(); field_ct base = witness_ct(&builder, base_val); field_ct exponent(&builder, exponent_val); field_ct result = base.pow(exponent); - bb::fr expected = base_val.pow(exponent_val); + fr expected = base_val.pow(exponent_val); EXPECT_EQ(result.get_value(), expected); info("num gates = ", builder.get_num_gates()); @@ -826,14 +824,14 @@ template class stdlib_field : public testing::Test { { Builder builder = Builder(); - bb::fr base_val(engine.get_random_uint256()); + fr base_val(engine.get_random_uint256()); uint64_t exponent_val = engine.get_random_uint32(); exponent_val += (uint64_t(1) << 32); field_ct base = witness_ct(&builder, base_val); field_ct exponent = witness_ct(&builder, exponent_val); field_ct result = base.pow(exponent); - bb::fr expected = base_val.pow(exponent_val); + fr expected = base_val.pow(exponent_val); EXPECT_NE(result.get_value(), expected); EXPECT_EQ(builder.failed(), true); @@ -844,7 +842,7 @@ template class stdlib_field : public testing::Test { { Builder builder = Builder(); - bb::fr value(engine.get_random_uint256()); + fr value(engine.get_random_uint256()); field_ct value_ct = witness_ct(&builder, value); field_ct first_copy = witness_ct(&builder, value_ct.get_value()); @@ -1035,5 +1033,3 @@ TYPED_TEST(stdlib_field, test_ranged_less_than) { TestFixture::test_ranged_less_than(); } - -} // namespace test_stdlib_field diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/group/cycle_group.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/group/cycle_group.test.cpp index c321120d4c5a..9a4fcd32c854 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/group/cycle_group.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/group/cycle_group.test.cpp @@ -17,11 +17,10 @@ using bool_ct = stdlib::bool_t; \ using witness_ct = stdlib::witness_t; -namespace stdlib_cycle_group_tests { using namespace bb; namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-local-typedefs" @@ -567,5 +566,3 @@ TYPED_TEST(CycleGroupTest, TestMul) EXPECT_EQ(proof_result, true); } #pragma GCC diagnostic pop - -} // namespace stdlib_cycle_group_tests diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/logic/logic.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/logic/logic.test.cpp index a8d88e0f9be4..d0ac7d4f1b2f 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/logic/logic.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/logic/logic.test.cpp @@ -15,17 +15,14 @@ using field_ct = stdlib::field_t; \ using bool_ct = stdlib::bool_t; \ using public_witness_ct = stdlib::public_witness_t; - -namespace test_stdlib_logic { +using namespace bb; namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } template void ignore_unused(T&) {} // use to ignore unused variables in lambdas -using namespace bb; - template class LogicTest : public testing::Test {}; using CircuitTypes = ::testing::Types; @@ -147,5 +144,3 @@ TYPED_TEST(LogicTest, DifferentWitnessSameResult) EXPECT_EQ(result, false); } } - -} // namespace test_stdlib_logic \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/dynamic_array.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/dynamic_array.test.cpp index 07525e2cd174..ff419207d4f4 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/dynamic_array.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/dynamic_array.test.cpp @@ -7,15 +7,14 @@ #include "../bool/bool.hpp" #include "../circuit_builders/circuit_builders.hpp" -namespace test_stdlib_dynamic_array { using namespace bb; namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } // Defining ultra-specific types for local testing. -using Builder = bb::UltraCircuitBuilder; +using Builder = UltraCircuitBuilder; using bool_ct = stdlib::bool_t; using field_ct = stdlib::field_t; using witness_ct = stdlib::witness_t; @@ -63,5 +62,3 @@ TEST(DynamicArray, DynamicArrayReadWriteConsistency) bool verified = builder.check_circuit(); EXPECT_EQ(verified, true); } - -} // namespace test_stdlib_dynamic_array \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/ram_table.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/ram_table.test.cpp index 0f471c3a4ca7..4c58de3300b1 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/ram_table.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/ram_table.test.cpp @@ -4,17 +4,15 @@ #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" #include "ram_table.hpp" -namespace test_stdlib_ram_table { - using namespace bb; // Defining ultra-specific types for local testing. -using Builder = bb::UltraCircuitBuilder; +using Builder = UltraCircuitBuilder; using field_ct = stdlib::field_t; using witness_ct = stdlib::witness_t; using ram_table_ct = stdlib::ram_table; namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } TEST(ram_table, ram_table_init_read_consistency) @@ -30,7 +28,7 @@ TEST(ram_table, ram_table_init_read_consistency) ram_table_ct table(table_values); field_ct result(0); - bb::fr expected(0); + fr expected(0); for (size_t i = 0; i < 10; ++i) { field_ct index(witness_ct(&builder, (uint64_t)i)); @@ -56,7 +54,7 @@ TEST(ram_table, ram_table_read_write_consistency) Builder builder; const size_t table_size = 10; - std::vector table_values(table_size); + std::vector table_values(table_size); ram_table_ct table(&builder, table_size); @@ -64,12 +62,12 @@ TEST(ram_table, ram_table_read_write_consistency) table.write(i, 0); } field_ct result(0); - bb::fr expected(0); + fr expected(0); const auto update = [&]() { for (size_t i = 0; i < table_size / 2; ++i) { - table_values[2 * i] = bb::fr::random_element(); - table_values[2 * i + 1] = bb::fr::random_element(); + table_values[2 * i] = fr::random_element(); + table_values[2 * i + 1] = fr::random_element(); // init with both constant and variable values table.write(2 * i, table_values[2 * i]); @@ -100,4 +98,3 @@ TEST(ram_table, ram_table_read_write_consistency) bool verified = builder.check_circuit(); EXPECT_EQ(verified, true); } -} // namespace test_stdlib_ram_table \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/rom_table.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/rom_table.test.cpp index 9fdd7ffe021c..dbbb9b099375 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/rom_table.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/memory/rom_table.test.cpp @@ -5,17 +5,16 @@ #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" #include "rom_table.hpp" -namespace test_stdlib_rom_array { using namespace bb; // Defining ultra-specific types for local testing. -using Builder = bb::UltraCircuitBuilder; +using Builder = UltraCircuitBuilder; using field_ct = stdlib::field_t; using witness_ct = stdlib::witness_t; using rom_table_ct = stdlib::rom_table; namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } TEST(rom_table, rom_table_read_write_consistency) @@ -31,7 +30,7 @@ TEST(rom_table, rom_table_read_write_consistency) rom_table_ct table(table_values); field_ct result(0); - bb::fr expected(0); + fr expected(0); for (size_t i = 0; i < 10; ++i) { field_ct index(witness_ct(&builder, (uint64_t)i)); @@ -62,5 +61,3 @@ TEST(rom_table, rom_table_read_write_consistency) bool verified = builder.check_circuit(); EXPECT_EQ(verified, true); } - -} // namespace test_stdlib_rom_array diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.test.cpp index 2eca3f8ff12b..81552258c9b8 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/packed_byte_array/packed_byte_array.test.cpp @@ -7,11 +7,10 @@ #pragma GCC diagnostic ignored "-Wunused-local-typedefs" -namespace test_stdlib_packed_byte_array { using namespace bb; namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } #define STDLIB_TYPE_ALIASES \ using Builder = TypeParam; \ @@ -194,5 +193,3 @@ TYPED_TEST(PackedByteArrayTest, TestAppendUint32) EXPECT_TRUE(builder.check_circuit()); } - -} // namespace test_stdlib_packed_byte_array diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.test.cpp index 2620e827c473..00d2b6846eed 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/plookup/plookup.test.cpp @@ -9,17 +9,16 @@ #include "barretenberg/stdlib/primitives/uint/uint.hpp" #include -namespace test_stdlib_plookups { using namespace bb; -using namespace plookup; +using namespace bb::plookup; // Defining ultra-specific types for local testing. -using Builder = bb::UltraCircuitBuilder; +using Builder = UltraCircuitBuilder; using field_ct = stdlib::field_t; using witness_ct = stdlib::witness_t; -using plookup_read = bb::stdlib::plookup_read; +using plookup_read = stdlib::plookup_read; namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } // TODO FIX FIX @@ -27,15 +26,15 @@ auto& engine = numeric::random::get_debug_engine(); // { // Builder builder = Builder(); -// bb::fr input_value = fr::random_element(); +// fr input_value = fr::random_element(); // field_ct input_hi = witness_ct(&builder, uint256_t(input_value).slice(126, 256)); // field_ct input_lo = witness_ct(&builder, uint256_t(input_value).slice(0, 126)); // const auto lookup_hi = plookup_read::get_lookup_accumulators(MultiTableId::PEDERSEN_LEFT_HI, input_hi); // const auto lookup_lo = plookup_read::get_lookup_accumulators(MultiTableId::PEDERSEN_LEFT_LO, input_lo); -// std::vector expected_x; -// std::vector expected_y; +// std::vector expected_x; +// std::vector expected_y; // const size_t num_lookups_hi = // (128 + crypto::pedersen_hash::lookup::BITS_PER_TABLE) / crypto::pedersen_hash::lookup::BITS_PER_TABLE; @@ -45,7 +44,7 @@ auto& engine = numeric::random::get_debug_engine(); // EXPECT_EQ(num_lookups_lo, lookup_lo[ColumnIdx::C1].size()); // const size_t num_lookups = num_lookups_hi + num_lookups_lo; -// std::vector expected_scalars; +// std::vector expected_scalars; // expected_x.resize(num_lookups); // expected_y.resize(num_lookups); // expected_scalars.resize(num_lookups); @@ -104,15 +103,15 @@ auto& engine = numeric::random::get_debug_engine(); // { // Builder builder = Builder(); -// bb::fr input_value = fr::random_element(); +// fr input_value = fr::random_element(); // field_ct input_hi = witness_ct(&builder, uint256_t(input_value).slice(126, 256)); // field_ct input_lo = witness_ct(&builder, uint256_t(input_value).slice(0, 126)); // const auto lookup_hi = plookup_read::get_lookup_accumulators(MultiTableId::PEDERSEN_RIGHT_HI, input_hi); // const auto lookup_lo = plookup_read::get_lookup_accumulators(MultiTableId::PEDERSEN_RIGHT_LO, input_lo); -// std::vector expected_x; -// std::vector expected_y; +// std::vector expected_x; +// std::vector expected_y; // const size_t num_lookups_hi = // (128 + crypto::pedersen_hash::lookup::BITS_PER_TABLE) / crypto::pedersen_hash::lookup::BITS_PER_TABLE; @@ -122,7 +121,7 @@ auto& engine = numeric::random::get_debug_engine(); // EXPECT_EQ(num_lookups_lo, lookup_lo[ColumnIdx::C1].size()); // const size_t num_lookups = num_lookups_hi + num_lookups_lo; -// std::vector expected_scalars; +// std::vector expected_scalars; // expected_x.resize(num_lookups); // expected_y.resize(num_lookups); // expected_scalars.resize(num_lookups); @@ -238,9 +237,9 @@ TEST(stdlib_plookup, blake2s_xor_rotate_16) const auto left_slices = numeric::slice_input(left_value, 1 << 6, num_lookups); const auto right_slices = numeric::slice_input(right_value, 1 << 6, num_lookups); - std::vector out_expected(num_lookups); - std::vector left_expected(num_lookups); - std::vector right_expected(num_lookups); + std::vector out_expected(num_lookups); + std::vector left_expected(num_lookups); + std::vector right_expected(num_lookups); for (size_t i = 0; i < left_slices.size(); ++i) { if (i == 2) { @@ -261,7 +260,7 @@ TEST(stdlib_plookup, blake2s_xor_rotate_16) * out_coefficients must be (a5/a4, a4/a3, a3/a2, a2/a1, a1/a0). Note that these are stored in reverse orde * for simplicity. */ - std::vector out_coefficients{ (1 << 6), (bb::fr(1) / bb::fr(1 << 22)), (1 << 2), (1 << 6), (1 << 6) }; + std::vector out_coefficients{ (1 << 6), (bb::fr(1) / bb::fr(1 << 22)), (1 << 2), (1 << 6), (1 << 6) }; for (size_t i = num_lookups - 2; i < num_lookups; --i) { out_expected[i] += out_expected[i + 1] * out_coefficients[i]; @@ -280,10 +279,10 @@ TEST(stdlib_plookup, blake2s_xor_rotate_16) * while defining the table we had set the coefficient of s0 to 1, so to correct that, we need to multiply by a * constant. */ - auto mul_constant = bb::fr(1 << 16); - bb::fr lookup_output = lookup[ColumnIdx::C3][0].get_value() * mul_constant; + auto mul_constant = fr(1 << 16); + fr lookup_output = lookup[ColumnIdx::C3][0].get_value() * mul_constant; uint32_t xor_rotate_output = numeric::rotate32(uint32_t(left_value) ^ uint32_t(right_value), 16); - EXPECT_EQ(bb::fr(uint256_t(xor_rotate_output)), lookup_output); + EXPECT_EQ(fr(uint256_t(xor_rotate_output)), lookup_output); bool result = builder.check_circuit(); @@ -307,9 +306,9 @@ TEST(stdlib_plookup, blake2s_xor_rotate_8) const auto left_slices = numeric::slice_input(left_value, 1 << 6, num_lookups); const auto right_slices = numeric::slice_input(right_value, 1 << 6, num_lookups); - std::vector out_expected(num_lookups); - std::vector left_expected(num_lookups); - std::vector right_expected(num_lookups); + std::vector out_expected(num_lookups); + std::vector left_expected(num_lookups); + std::vector right_expected(num_lookups); for (size_t i = 0; i < left_slices.size(); ++i) { if (i == 1) { @@ -324,8 +323,8 @@ TEST(stdlib_plookup, blake2s_xor_rotate_8) right_expected[i] = right_slices[i]; } - auto mul_constant = bb::fr(1 << 24); - std::vector out_coefficients{ (bb::fr(1) / mul_constant), (1 << 4), (1 << 6), (1 << 6), (1 << 6) }; + auto mul_constant = fr(1 << 24); + std::vector out_coefficients{ (bb::fr(1) / mul_constant), (1 << 4), (1 << 6), (1 << 6), (1 << 6) }; for (size_t i = num_lookups - 2; i < num_lookups; --i) { out_expected[i] += out_expected[i + 1] * out_coefficients[i]; @@ -339,9 +338,9 @@ TEST(stdlib_plookup, blake2s_xor_rotate_8) EXPECT_EQ(lookup[ColumnIdx::C3][i].get_value(), out_expected[i]); } - bb::fr lookup_output = lookup[ColumnIdx::C3][0].get_value() * mul_constant; + fr lookup_output = lookup[ColumnIdx::C3][0].get_value() * mul_constant; uint32_t xor_rotate_output = numeric::rotate32(uint32_t(left_value) ^ uint32_t(right_value), 8); - EXPECT_EQ(bb::fr(uint256_t(xor_rotate_output)), lookup_output); + EXPECT_EQ(fr(uint256_t(xor_rotate_output)), lookup_output); bool result = builder.check_circuit(); @@ -365,9 +364,9 @@ TEST(stdlib_plookup, blake2s_xor_rotate_7) const auto left_slices = numeric::slice_input(left_value, 1 << 6, num_lookups); const auto right_slices = numeric::slice_input(right_value, 1 << 6, num_lookups); - std::vector out_expected(num_lookups); - std::vector left_expected(num_lookups); - std::vector right_expected(num_lookups); + std::vector out_expected(num_lookups); + std::vector left_expected(num_lookups); + std::vector right_expected(num_lookups); for (size_t i = 0; i < left_slices.size(); ++i) { if (i == 1) { @@ -382,8 +381,8 @@ TEST(stdlib_plookup, blake2s_xor_rotate_7) right_expected[i] = right_slices[i]; } - auto mul_constant = bb::fr(1 << 25); - std::vector out_coefficients{ (bb::fr(1) / mul_constant), (1 << 5), (1 << 6), (1 << 6), (1 << 6) }; + auto mul_constant = fr(1 << 25); + std::vector out_coefficients{ (bb::fr(1) / mul_constant), (1 << 5), (1 << 6), (1 << 6), (1 << 6) }; for (size_t i = num_lookups - 2; i < num_lookups; --i) { out_expected[i] += out_expected[i + 1] * out_coefficients[i]; @@ -397,9 +396,9 @@ TEST(stdlib_plookup, blake2s_xor_rotate_7) EXPECT_EQ(lookup[ColumnIdx::C3][i].get_value(), out_expected[i]); } - bb::fr lookup_output = lookup[ColumnIdx::C3][0].get_value() * mul_constant; + fr lookup_output = lookup[ColumnIdx::C3][0].get_value() * mul_constant; uint32_t xor_rotate_output = numeric::rotate32(uint32_t(left_value) ^ uint32_t(right_value), 7); - EXPECT_EQ(bb::fr(uint256_t(xor_rotate_output)), lookup_output); + EXPECT_EQ(fr(uint256_t(xor_rotate_output)), lookup_output); bool result = builder.check_circuit(); @@ -442,9 +441,9 @@ TEST(stdlib_plookup, blake2s_xor) // t5 = a5 // // output = (t0 - 2^12 t2) * 2^{32 - 12} + t2 - bb::fr lookup_output = lookup[ColumnIdx::C3][2].get_value(); - bb::fr t2_term = bb::fr(1 << 12) * lookup[ColumnIdx::C3][2].get_value(); - lookup_output += bb::fr(1 << 20) * (lookup[ColumnIdx::C3][0].get_value() - t2_term); + fr lookup_output = lookup[ColumnIdx::C3][2].get_value(); + fr t2_term = fr(1 << 12) * lookup[ColumnIdx::C3][2].get_value(); + lookup_output += fr(1 << 20) * (lookup[ColumnIdx::C3][0].get_value() - t2_term); for (size_t i = num_lookups - 2; i < num_lookups; --i) { out_expected[i] += out_expected[i + 1] * (1 << 6); @@ -456,7 +455,7 @@ TEST(stdlib_plookup, blake2s_xor) // The following checks if the xor output rotated by 12 can be computed correctly from basic blake2s_xor. // auto xor_rotate_output = numeric::rotate32(uint32_t(left_value) ^ uint32_t(right_value), 12); - EXPECT_EQ(bb::fr(uint256_t(xor_rotate_output)), lookup_output); + EXPECT_EQ(fr(uint256_t(xor_rotate_output)), lookup_output); for (size_t i = 0; i < num_lookups; ++i) { EXPECT_EQ(lookup[ColumnIdx::C1][i].get_value(), bb::fr(left_expected[i])); @@ -520,7 +519,7 @@ TEST(stdlib_plookup, secp256k1_generator) uint64_t wnaf_entries[18] = { 0 }; bool skew = false; - bb::wnaf::fixed_wnaf<129, 1, 8>(&input_value.data[0], &wnaf_entries[0], skew, 0); + wnaf::fixed_wnaf<129, 1, 8>(&input_value.data[0], &wnaf_entries[0], skew, 0); std::vector naf_values; for (size_t i = 0; i < 17; ++i) { @@ -605,5 +604,3 @@ TEST(stdlib_plookup, secp256k1_generator) bool proof_result = builder.check_circuit(); EXPECT_EQ(proof_result, true); } - -} // namespace test_stdlib_plookups diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint.test.cpp index 7afc1b71f1b3..93c167cbde62 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/safe_uint/safe_uint.test.cpp @@ -7,6 +7,8 @@ #include #include +using namespace bb; + #pragma GCC diagnostic ignored "-Wunused-local-typedefs" #define STDLIB_TYPE_ALIASES \ @@ -19,10 +21,9 @@ using public_witness_ct = stdlib::public_witness_t; namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } -namespace test_stdlib_safe_uint { using namespace bb; template void ignore_unused(T&) {} // use to ignore unused variables in lambdas @@ -706,4 +707,3 @@ TYPED_TEST(SafeUintTest, TestByteArrayConversion) arr.write(static_cast(safe)); EXPECT_EQ(arr.get_string(), expected); } -} // namespace test_stdlib_safe_uint diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/plookup/logic.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/plookup/logic.cpp index bd42fd7b40b9..e9e2960b7756 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/plookup/logic.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/plookup/logic.cpp @@ -5,7 +5,7 @@ using namespace bb; namespace bb::stdlib { -using namespace plookup; +using namespace bb::plookup; template uint_plookup uint_plookup::operator&(const uint_plookup& other) const diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/uint.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/uint.test.cpp index a075df2e662b..73a4ac6c6dda 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/uint.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/uint/uint.test.cpp @@ -3,11 +3,10 @@ #include #include -using namespace bb; using namespace bb; namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } // NOTE: We only test width 32, but widths 8, 16, 32 and 64 can all be tested. @@ -16,7 +15,7 @@ auto& engine = numeric::random::get_debug_engine(); // test_xor_special, test_xor_more_constants, test_and_constants, test_and_special, test_or_special, // test_ror_special, test_hash_rounds, test_and, test_xor, test_or. // They fail with 'C++ exception with description"Last key slice greater than 64" thrown in the test body."' -namespace test_stdlib_uint { + typedef uint32_t uint_native; size_t uint_native_width = 8 * sizeof(uint_native); uint_native uint_native_max = static_cast((static_cast(1) << uint_native_width) - 1); @@ -1915,10 +1914,10 @@ TYPED_TEST(stdlib_uint, test_at) // There was one plookup-specific test in the ./plookup/uint_plookup.test.cpp TEST(stdlib_uint32, test_accumulators_plookup_uint32) { - using uint32_ct = bb::stdlib::uint32; - using witness_ct = bb::stdlib::witness_t; + using uint32_ct = stdlib::uint32; + using witness_ct = stdlib::witness_t; - bb::UltraCircuitBuilder builder; + UltraCircuitBuilder builder; uint32_t a_val = engine.get_random_uint32(); uint32_t b_val = engine.get_random_uint32(); @@ -1940,4 +1939,3 @@ TEST(stdlib_uint32, test_accumulators_plookup_uint32) bool proof_result = builder.check_circuit(); EXPECT_EQ(proof_result, true); } -} // namespace test_stdlib_uint diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.test.cpp index 4d8386ada5cf..307e388e368a 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/transcript/transcript.test.cpp @@ -13,7 +13,7 @@ namespace bb::stdlib::recursion::honk { using Builder = UltraCircuitBuilder; using UltraFlavor = ::bb::honk::flavor::Ultra; using UltraRecursiveFlavor = ::bb::honk::flavor::UltraRecursive_; -using FF = bb::fr; +using FF = fr; using BaseTranscript = ::bb::honk::BaseTranscript; /** @@ -124,8 +124,8 @@ TEST(RecursiveHonkTranscript, InterfacesMatch) */ TEST(RecursiveHonkTranscript, ReturnValuesMatch) { - using FF = bb::fr; - using Commitment = bb::g1::affine_element; + using FF = fr; + using Commitment = g1::affine_element; using field_ct = field_t; using fq_ct = bigfield; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp new file mode 100644 index 000000000000..6578f48cc992 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.cpp @@ -0,0 +1,96 @@ +#include "barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.hpp" +#include "barretenberg/commitment_schemes/zeromorph/zeromorph.hpp" +#include "barretenberg/numeric/bitop/get_msb.hpp" +#include "barretenberg/sumcheck/instance/verifier_instance.hpp" +#include "barretenberg/transcript/transcript.hpp" + +namespace bb::stdlib::recursion::honk { + +template +DeciderRecursiveVerifier_::DeciderRecursiveVerifier_(Builder* builder) + : builder(builder) +{} + +/** + * @brief This function verifies an Ultra Honk proof for a given Flavor, produced for a relaxed instance (ϕ, \vec{β*}, + * e*). + * + */ +template +std::array DeciderRecursiveVerifier_::verify_proof( + const bb::plonk::proof& proof) +{ + using Sumcheck = ::bb::honk::sumcheck::SumcheckVerifier; + using Curve = typename Flavor::Curve; + using ZeroMorph = ::bb::honk::pcs::zeromorph::ZeroMorphVerifier_; + using VerifierCommitments = typename Flavor::VerifierCommitments; + using Transcript = typename Flavor::Transcript; + using Instance = typename ::bb::honk::VerifierInstance_; + + static constexpr size_t NUM_SUBRELATIONS = Flavor::NUM_SUBRELATIONS; + transcript = std::make_shared(builder, proof.proof_data); + auto inst = std::make_unique(); + + const auto instance_size = transcript->template receive_from_prover("instance_size"); + const auto public_input_size = transcript->template receive_from_prover("public_input_size"); + const auto log_instance_size = static_cast(numeric::get_msb(uint32_t(instance_size.get_value()))); + + for (size_t i = 0; i < uint32_t(public_input_size.get_value()); ++i) { + auto public_input_i = transcript->template receive_from_prover("public_input_" + std::to_string(i)); + inst->public_inputs.emplace_back(public_input_i); + } + + auto eta = transcript->template receive_from_prover("eta"); + auto beta = transcript->template receive_from_prover("beta"); + auto gamma = transcript->template receive_from_prover("gamma"); + auto public_input_delta = transcript->template receive_from_prover("public_input_delta"); + auto lookup_grand_product_delta = transcript->template receive_from_prover("lookup_grand_product_delta"); + inst->relation_parameters = + RelationParameters{ eta, beta, gamma, public_input_delta, lookup_grand_product_delta }; + + for (size_t idx = 0; idx < NUM_SUBRELATIONS - 1; idx++) { + inst->alphas[idx] = transcript->template receive_from_prover("alpha" + std::to_string(idx)); + } + + inst->target_sum = transcript->template receive_from_prover("target_sum"); + + inst->gate_challenges = std::vector(log_instance_size); + for (size_t idx = 0; idx < log_instance_size; idx++) { + inst->gate_challenges[idx] = + transcript->template receive_from_prover("gate_challenge_" + std::to_string(idx)); + } + auto comm_view = inst->witness_commitments.get_all(); + auto witness_labels = inst->commitment_labels.get_witness(); + for (size_t idx = 0; idx < witness_labels.size(); idx++) { + comm_view[idx] = transcript->template receive_from_prover(witness_labels[idx]); + } + + inst->verification_key = std::make_shared(inst->instance_size, inst->public_input_size); + auto vk_view = inst->verification_key->get_all(); + auto vk_labels = inst->commitment_labels.get_precomputed(); + for (size_t idx = 0; idx < vk_labels.size(); idx++) { + vk_view[idx] = transcript->template receive_from_prover(vk_labels[idx]); + } + + VerifierCommitments commitments{ inst->verification_key, inst->witness_commitments }; + + auto sumcheck = Sumcheck(log_instance_size, transcript, inst->target_sum); + + auto [multivariate_challenge, claimed_evaluations, sumcheck_verified] = + sumcheck.verify(inst->relation_parameters, inst->alphas, inst->gate_challenges); + + // Execute ZeroMorph rounds. See https://hackmd.io/dlf9xEwhTQyE3hiGbq4FsA?view for a complete description of the + // unrolled protocol. + auto pairing_points = ZeroMorph::verify(commitments.get_unshifted(), + commitments.get_to_be_shifted(), + claimed_evaluations.get_unshifted(), + claimed_evaluations.get_shifted(), + multivariate_challenge, + transcript); + + return pairing_points; +} + +template class DeciderRecursiveVerifier_>; +template class DeciderRecursiveVerifier_>; +} // namespace bb::stdlib::recursion::honk diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.hpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.hpp new file mode 100644 index 000000000000..18e6b75fa0bc --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.hpp @@ -0,0 +1,30 @@ +#pragma once +#include "barretenberg/flavor/goblin_ultra_recursive.hpp" +#include "barretenberg/flavor/ultra_recursive.hpp" +#include "barretenberg/plonk/proof_system/types/proof.hpp" +#include "barretenberg/stdlib/recursion/honk/transcript/transcript.hpp" +#include "barretenberg/sumcheck/sumcheck.hpp" + +namespace bb::stdlib::recursion::honk { +template class DeciderRecursiveVerifier_ { + using FF = typename Flavor::FF; + using Commitment = typename Flavor::Commitment; + using GroupElement = typename Flavor::GroupElement; + using VerificationKey = typename Flavor::VerificationKey; + using VerifierCommitmentKey = typename Flavor::VerifierCommitmentKey; + using Builder = typename Flavor::CircuitBuilder; + using RelationSeparator = typename Flavor::RelationSeparator; + using PairingPoints = std::array; + + public: + explicit DeciderRecursiveVerifier_(Builder* builder); + + PairingPoints verify_proof(const bb::plonk::proof& proof); + + std::map commitments; + std::shared_ptr pcs_verification_key; + Builder* builder; + std::shared_ptr> transcript; +}; + +} // namespace bb::stdlib::recursion::honk \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp new file mode 100644 index 000000000000..68c366de5b94 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.cpp @@ -0,0 +1,320 @@ +#include "protogalaxy_recursive_verifier.hpp" +#include "barretenberg/polynomials/polynomial.hpp" +#include "barretenberg/proof_system/library/grand_product_delta.hpp" +namespace bb::stdlib::recursion::honk { + +template +void ProtoGalaxyRecursiveVerifier_::receive_accumulator(const std::shared_ptr& inst, + const std::string& domain_separator) +{ + // Get circuit parameters + const auto instance_size = transcript->template receive_from_prover(domain_separator + "_instance_size"); + const auto public_input_size = + transcript->template receive_from_prover(domain_separator + "_public_input_size"); + inst->instance_size = uint32_t(instance_size.get_value()); + inst->log_instance_size = uint32_t(numeric::get_msb(inst->instance_size)); + inst->public_input_size = uint32_t(public_input_size.get_value()); + + // Get folded public inputs + for (size_t i = 0; i < inst->public_input_size; ++i) { + auto public_input_i = + transcript->template receive_from_prover(domain_separator + "_public_input_" + std::to_string(i)); + inst->public_inputs.emplace_back(public_input_i); + } + + // Get folded relation parameters + auto eta = transcript->template receive_from_prover(domain_separator + "_eta"); + auto beta = transcript->template receive_from_prover(domain_separator + "_beta"); + auto gamma = transcript->template receive_from_prover(domain_separator + "_gamma"); + auto public_input_delta = transcript->template receive_from_prover(domain_separator + "_public_input_delta"); + auto lookup_grand_product_delta = + transcript->template receive_from_prover(domain_separator + "_lookup_grand_product_delta"); + inst->relation_parameters = + RelationParameters{ eta, beta, gamma, public_input_delta, lookup_grand_product_delta }; + + // Get the folded relation separator challenges \vec{α} + for (size_t idx = 0; idx < NUM_SUBRELATIONS - 1; idx++) { + inst->alphas[idx] = + transcript->template receive_from_prover(domain_separator + "_alpha_" + std::to_string(idx)); + } + + inst->target_sum = transcript->template receive_from_prover(domain_separator + "_target_sum"); + + // Get the folded gate challenges, \vec{β} in the paper + inst->gate_challenges = std::vector(inst->log_instance_size); + for (size_t idx = 0; idx < inst->log_instance_size; idx++) { + inst->gate_challenges[idx] = + transcript->template receive_from_prover(domain_separator + "_gate_challenge_" + std::to_string(idx)); + } + + // Get the folded commitments to all witness polynomials + auto comm_view = inst->witness_commitments.get_all(); + auto witness_labels = inst->commitment_labels.get_witness(); + for (size_t idx = 0; idx < witness_labels.size(); idx++) { + comm_view[idx] = + transcript->template receive_from_prover(domain_separator + "_" + witness_labels[idx]); + } + + // Get the folded commitments to selector polynomials + inst->verification_key = std::make_shared(inst->instance_size, inst->public_input_size); + auto vk_view = inst->verification_key->get_all(); + auto vk_labels = inst->commitment_labels.get_precomputed(); + for (size_t idx = 0; idx < vk_labels.size(); idx++) { + vk_view[idx] = transcript->template receive_from_prover(domain_separator + "_" + vk_labels[idx]); + } +} + +template +void ProtoGalaxyRecursiveVerifier_::receive_and_finalise_instance( + const std::shared_ptr& inst, const std::string& domain_separator) +{ + // Get circuit parameters and the public inputs + const auto instance_size = transcript->template receive_from_prover(domain_separator + "_instance_size"); + const auto public_input_size = + transcript->template receive_from_prover(domain_separator + "_public_input_size"); + inst->instance_size = uint32_t(instance_size.get_value()); + inst->log_instance_size = static_cast(numeric::get_msb(inst->instance_size)); + inst->public_input_size = uint32_t(public_input_size.get_value()); + + for (size_t i = 0; i < inst->public_input_size; ++i) { + auto public_input_i = + transcript->template receive_from_prover(domain_separator + "_public_input_" + std::to_string(i)); + inst->public_inputs.emplace_back(public_input_i); + } + + const auto pub_inputs_offset = + transcript->template receive_from_prover(domain_separator + "_pub_inputs_offset"); + + inst->pub_inputs_offset = uint32_t(pub_inputs_offset.get_value()); + + // Get commitments to first three wire polynomials + auto labels = inst->commitment_labels; + auto& witness_commitments = inst->witness_commitments; + witness_commitments.w_l = transcript->template receive_from_prover(domain_separator + "_" + labels.w_l); + witness_commitments.w_r = transcript->template receive_from_prover(domain_separator + "_" + labels.w_r); + witness_commitments.w_o = transcript->template receive_from_prover(domain_separator + "_" + labels.w_o); + + // Get challenge for sorted list batching and wire four memory records commitment + auto eta = transcript->get_challenge(domain_separator + "_eta"); + witness_commitments.sorted_accum = + transcript->template receive_from_prover(domain_separator + "_" + labels.sorted_accum); + witness_commitments.w_4 = transcript->template receive_from_prover(domain_separator + "_" + labels.w_4); + + // Get permutation challenges and commitment to permutation and lookup grand products + auto [beta, gamma] = transcript->get_challenges(domain_separator + "_beta", domain_separator + "_gamma"); + witness_commitments.z_perm = + transcript->template receive_from_prover(domain_separator + "_" + labels.z_perm); + witness_commitments.z_lookup = + transcript->template receive_from_prover(domain_separator + "_" + labels.z_lookup); + + // Compute correction terms for grand products + const FF public_input_delta = bb::honk::compute_public_input_delta( + inst->public_inputs, beta, gamma, inst->instance_size, inst->pub_inputs_offset); + const FF lookup_grand_product_delta = + bb::honk::compute_lookup_grand_product_delta(beta, gamma, inst->instance_size); + inst->relation_parameters = + RelationParameters{ eta, beta, gamma, public_input_delta, lookup_grand_product_delta }; + + // Get the relation separation challenges + for (size_t idx = 0; idx < NUM_SUBRELATIONS - 1; idx++) { + inst->alphas[idx] = transcript->get_challenge(domain_separator + "_alpha_" + std::to_string(idx)); + } + + // Get the commitments to the selector polynomials for the given instance + inst->verification_key = std::make_shared(inst->instance_size, inst->public_input_size); + auto vk_view = inst->verification_key->get_all(); + auto vk_labels = labels.get_precomputed(); + for (size_t idx = 0; idx < vk_labels.size(); idx++) { + vk_view[idx] = transcript->template receive_from_prover(domain_separator + "_" + vk_labels[idx]); + } +} + +// TODO(https://github.com/AztecProtocol/barretenberg/issues/795): The rounds prior to actual verifying are common +// between decider and folding verifier and could be somehow shared so we do not duplicate code so much. +template void ProtoGalaxyRecursiveVerifier_::prepare_for_folding() +{ + auto index = 0; + auto inst = instances[0]; + auto domain_separator = std::to_string(index); + const auto is_accumulator = transcript->template receive_from_prover(domain_separator + "is_accumulator"); + inst->is_accumulator = static_cast(is_accumulator.get_value()); + if (inst->is_accumulator) { + receive_accumulator(inst, domain_separator); + } else { + // This is the first round of folding and we need to generate some gate challenges. + // TODO(https://github.com/AztecProtocol/barretenberg/issues/740): implement option 2 to make this more + // efficient by avoiding the computation of the perturbator + receive_and_finalise_instance(inst, domain_separator); + inst->target_sum = 0; + auto beta = transcript->get_challenge(domain_separator + "_initial_gate_challenge"); + std::vector gate_challenges(inst->log_instance_size); + gate_challenges[0] = beta; + for (size_t i = 1; i < inst->log_instance_size; i++) { + gate_challenges[i] = gate_challenges[i - 1].sqr(); + } + inst->gate_challenges = gate_challenges; + } + index++; + + for (auto it = instances.begin() + 1; it != instances.end(); it++, index++) { + auto inst = *it; + auto domain_separator = std::to_string(index); + receive_and_finalise_instance(inst, domain_separator); + } +} + +template +void ProtoGalaxyRecursiveVerifier_::verify_folding_proof(std::vector proof) +{ + using Transcript = typename Flavor::Transcript; + using ElementNative = typename Flavor::Curve::ElementNative; + using AffineElementNative = typename Flavor::Curve::AffineElementNative; + using ScalarNative = typename Flavor::Curve::ScalarFieldNative; + + transcript = std::make_shared(builder, proof); + prepare_for_folding(); + + auto delta = transcript->get_challenge("delta"); + auto accumulator = get_accumulator(); + auto deltas = compute_round_challenge_pows(accumulator->log_instance_size, delta); + + std::vector perturbator_coeffs(accumulator->log_instance_size + 1); + for (size_t idx = 0; idx <= accumulator->log_instance_size; idx++) { + perturbator_coeffs[idx] = transcript->template receive_from_prover("perturbator_" + std::to_string(idx)); + } + + // TODO(https://github.com/AztecProtocol/barretenberg/issues/833): As currently the stdlib transcript is not + // creating proper constraints linked to Fiat-Shamir we add an additonal gate to ensure assert_equal is correct. + // This comparison to 0 can be removed here and below once we have merged the transcript. + auto zero = FF::from_witness(builder, ScalarNative(0)); + zero.assert_equal(accumulator->target_sum - perturbator_coeffs[0], "F(0) != e"); + + FF perturbator_challenge = transcript->get_challenge("perturbator_challenge"); + + auto perturbator_at_challenge = evaluate_perturbator(perturbator_coeffs, perturbator_challenge); + // The degree of K(X) is dk - k - 1 = k(d - 1) - 1. Hence we need k(d - 1) evaluations to represent it. + std::array combiner_quotient_evals; + for (size_t idx = 0; idx < VerifierInstances::BATCHED_EXTENDED_LENGTH - VerifierInstances::NUM; idx++) { + combiner_quotient_evals[idx] = transcript->template receive_from_prover( + "combiner_quotient_" + std::to_string(idx + VerifierInstances::NUM)); + } + Univariate combiner_quotient( + combiner_quotient_evals); + FF combiner_challenge = transcript->get_challenge("combiner_quotient_challenge"); + auto combiner_quotient_at_challenge = combiner_quotient.evaluate(combiner_challenge); // fine recursive i think + + auto vanishing_polynomial_at_challenge = combiner_challenge * (combiner_challenge - FF(1)); + auto lagranges = std::vector{ FF(1) - combiner_challenge, combiner_challenge }; + + // Compute next folding parameters and verify against the ones received from the prover + auto expected_next_target_sum = + perturbator_at_challenge * lagranges[0] + vanishing_polynomial_at_challenge * combiner_quotient_at_challenge; + auto next_target_sum = transcript->template receive_from_prover("next_target_sum"); + zero.assert_equal(expected_next_target_sum - next_target_sum, "next target sum mismatch"); + + auto expected_betas_star = update_gate_challenges(perturbator_challenge, accumulator->gate_challenges, deltas); + for (size_t idx = 0; idx < accumulator->log_instance_size; idx++) { + auto beta_star = transcript->template receive_from_prover("next_gate_challenge_" + std::to_string(idx)); + zero.assert_equal(beta_star - expected_betas_star[idx], + " next gate challenge mismatch at: " + std::to_string(idx)); + } + + // Compute ϕ and verify against the data received from the prover + WitnessCommitments acc_witness_commitments; + auto witness_labels = commitment_labels.get_witness(); + size_t comm_idx = 0; + auto random_generator = Commitment::from_witness(builder, AffineElementNative(ElementNative::random_element())); + for (auto& expected_comm : acc_witness_commitments.get_all()) { + expected_comm = random_generator; + size_t inst = 0; + for (auto& instance : instances) { + expected_comm = expected_comm + instance->witness_commitments.get_all()[comm_idx] * lagranges[inst]; + inst++; + } + auto comm = transcript->template receive_from_prover("next_" + witness_labels[comm_idx]); + auto res = expected_comm - comm; + random_generator.x.assert_equal(res.x); + random_generator.y.assert_equal(res.y); + comm_idx++; + } + + std::vector folded_public_inputs(instances[0]->public_inputs.size(), 0); + size_t public_input_idx = 0; + for (auto& expected_public_input : folded_public_inputs) { + size_t inst = 0; + for (auto& instance : instances) { + expected_public_input += instance->public_inputs[public_input_idx] * lagranges[inst]; + inst++; + } + auto next_public_input = + transcript->template receive_from_prover("next_public_input" + std::to_string(public_input_idx)); + zero.assert_equal(expected_public_input - next_public_input, + "folded public input mismatch at: " + std::to_string(public_input_idx)); + public_input_idx++; + } + + for (size_t alpha_idx = 0; alpha_idx < NUM_SUBRELATIONS - 1; alpha_idx++) { + FF expected_alpha(0); + size_t instance_idx = 0; + for (auto& instance : instances) { + expected_alpha += instance->alphas[alpha_idx] * lagranges[instance_idx]; + instance_idx++; + } + auto next_alpha = transcript->template receive_from_prover("next_alpha_" + std::to_string(alpha_idx)); + zero.assert_equal(expected_alpha - next_alpha, + "folded relation separator mismatch at: " + std::to_string(alpha_idx)); + } + + auto expected_parameters = bb::RelationParameters{}; + for (size_t inst_idx = 0; inst_idx < VerifierInstances::NUM; inst_idx++) { + auto instance = instances[inst_idx]; + expected_parameters.eta += instance->relation_parameters.eta * lagranges[inst_idx]; + expected_parameters.beta += instance->relation_parameters.beta * lagranges[inst_idx]; + expected_parameters.gamma += instance->relation_parameters.gamma * lagranges[inst_idx]; + expected_parameters.public_input_delta += + instance->relation_parameters.public_input_delta * lagranges[inst_idx]; + expected_parameters.lookup_grand_product_delta += + instance->relation_parameters.lookup_grand_product_delta * lagranges[inst_idx]; + } + + auto next_eta = transcript->template receive_from_prover("next_eta"); + zero.assert_equal(expected_parameters.eta - next_eta, "relation parameter eta mismatch"); + + auto next_beta = transcript->template receive_from_prover("next_beta"); + zero.assert_equal(expected_parameters.beta - next_beta, "relation parameter beta mismatch"); + + auto next_gamma = transcript->template receive_from_prover("next_gamma"); + zero.assert_equal(expected_parameters.gamma - next_gamma, "relation parameter gamma mismatch"); + + auto next_public_input_delta = transcript->template receive_from_prover("next_public_input_delta"); + zero.assert_equal(expected_parameters.public_input_delta - next_public_input_delta, + "relation parameter public input delta mismatch"); + + auto next_lookup_grand_product_delta = + transcript->template receive_from_prover("next_lookup_grand_product_delta"); + zero.assert_equal(expected_parameters.lookup_grand_product_delta - next_lookup_grand_product_delta, + "relation parameter lookup grand product delta mismatch"); + + auto acc_vk = std::make_shared(instances[0]->instance_size, instances[0]->public_input_size); + auto vk_labels = commitment_labels.get_precomputed(); + size_t vk_idx = 0; + for (auto& expected_vk : acc_vk->get_all()) { + size_t inst = 0; + expected_vk = random_generator; + for (auto& instance : instances) { + expected_vk = expected_vk + instance->verification_key->get_all()[vk_idx] * lagranges[inst]; + inst++; + } + auto vk = transcript->template receive_from_prover("next_" + vk_labels[vk_idx]); + auto res = expected_vk - vk; + random_generator.x.assert_equal(res.x); + random_generator.y.assert_equal(res.y); + vk_idx++; + } +} + +template class ProtoGalaxyRecursiveVerifier_< + bb::honk::VerifierInstances_, 2>>; +template class ProtoGalaxyRecursiveVerifier_< + bb::honk::VerifierInstances_, 2>>; +} // namespace bb::stdlib::recursion::honk \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.hpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.hpp new file mode 100644 index 000000000000..64b757195428 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.hpp @@ -0,0 +1,118 @@ +#pragma once +#include "barretenberg/flavor/flavor.hpp" +#include "barretenberg/flavor/goblin_ultra_recursive.hpp" +#include "barretenberg/flavor/ultra_recursive.hpp" +#include "barretenberg/plonk/proof_system/types/proof.hpp" +#include "barretenberg/protogalaxy/folding_result.hpp" +#include "barretenberg/stdlib/recursion/honk/transcript/transcript.hpp" +#include "barretenberg/sumcheck/instance/instances.hpp" + +namespace bb::stdlib::recursion::honk { +template class ProtoGalaxyRecursiveVerifier_ { + public: + using Flavor = typename VerifierInstances::Flavor; + using FF = typename Flavor::FF; + using Commitment = typename Flavor::Commitment; + using GroupElement = typename Flavor::GroupElement; + using Instance = typename VerifierInstances::Instance; + using VerificationKey = typename Flavor::VerificationKey; + using WitnessCommitments = typename Flavor::WitnessCommitments; + using CommitmentLabels = typename Flavor::CommitmentLabels; + using Builder = typename Flavor::CircuitBuilder; + using RelationSeparator = typename Flavor::RelationSeparator; + using PairingPoints = std::array; + + static constexpr size_t NUM_SUBRELATIONS = Flavor::NUM_SUBRELATIONS; + + VerifierInstances instances; + + CommitmentLabels commitment_labels; + + Builder* builder; + std::shared_ptr> transcript; + + explicit ProtoGalaxyRecursiveVerifier_(Builder* builder) + : instances(VerifierInstances()) + , builder(builder){}; + /** + * @brief Given a new round challenge δ for each iteration of the full ProtoGalaxy protocol, compute the vector + * [δ, δ^2,..., δ^t] where t = logn and n is the size of the instance. + */ + static std::vector compute_round_challenge_pows(size_t log_instance_size, FF round_challenge) + { + std::vector pows(log_instance_size); + pows[0] = round_challenge; + for (size_t i = 1; i < log_instance_size; i++) { + pows[i] = pows[i - 1].sqr(); + } + return pows; + } + + static std::vector update_gate_challenges(const FF perturbator_challenge, + const std::vector& gate_challenges, + const std::vector& round_challenges) + { + auto log_instance_size = gate_challenges.size(); + std::vector next_gate_challenges(log_instance_size); + + for (size_t idx = 0; idx < log_instance_size; idx++) { + next_gate_challenges[idx] = gate_challenges[idx] + perturbator_challenge * round_challenges[idx]; + } + return next_gate_challenges; + } + + std::shared_ptr get_accumulator() { return instances[0]; } + + /** + * @brief Instatiate the instances and the transcript. + * + * @param fold_data The data transmitted via the transcript by the prover. + */ + void prepare_for_folding(); + + /** + * @brief Instantiate the accumulator (i.e. the relaxed instance) from the transcript. + * + */ + void receive_accumulator(const std::shared_ptr&, const std::string&); + + /** + * @brief Process the public data ϕ for the Instances to be folded. + * + */ + void receive_and_finalise_instance(const std::shared_ptr&, const std::string&); + + /** + * @brief Run the folding protocol on the verifier side to establish whether the public data ϕ of the new + * accumulator, received from the prover is the same as that produced by the verifier. + * + * @details In the recursive setting this function doesn't return anything because the equality checks performed by + * the recursive verifier, ensuring the folded ϕ*, e* and β* on the verifier side correspond to what has been sent + * by the prover, are expressed as constraints. + + */ + void verify_folding_proof(std::vector proof); + + /** + * @brief Evaluates the perturbator at a given scalar, in a sequential manner for the recursive setting. + * + * @details This method is equivalent to the one in the Polynomial class for evaluating a polynomial, represented by + * coefficients in monomial basis, at a given point. The Polynomial class is used in the native verifier for + * constructing and computing the perturbator. We implement this separate functionality here in the recursive + * folding verifier to avoid instantiating the entire Polynomial class on stdlib::bn254. Furthermore, the evaluation + * needs to be done sequentially as we don't support a parallel_for in circuits. + * + */ + static FF evaluate_perturbator(std::vector coeffs, FF point) + { + FF point_acc = FF(1); + FF result = FF(0); + for (size_t i = 0; i < coeffs.size(); i++) { + result += coeffs[i] * point_acc; + point_acc *= point; + } + return result; + }; +}; + +} // namespace bb::stdlib::recursion::honk \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.test.cpp new file mode 100644 index 000000000000..61dee74084fa --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.test.cpp @@ -0,0 +1,350 @@ +#include "barretenberg/stdlib/recursion/honk/verifier/protogalaxy_recursive_verifier.hpp" +#include "barretenberg/common/test.hpp" +#include "barretenberg/flavor/ultra_recursive.hpp" +#include "barretenberg/stdlib/hash/blake3s/blake3s.hpp" +#include "barretenberg/stdlib/hash/pedersen/pedersen.hpp" +#include "barretenberg/stdlib/primitives/curves/bn254.hpp" +#include "barretenberg/stdlib/recursion/honk/verifier/decider_recursive_verifier.hpp" +#include "barretenberg/ultra_honk/ultra_composer.hpp" + +namespace bb::stdlib::recursion::honk { +class ProtogalaxyRecursiveTest : public testing::Test { + public: + // Define types relevant for testing + using UltraFlavor = ::bb::honk::flavor::Ultra; + using GoblinUltraFlavor = ::bb::honk::flavor::GoblinUltra; + using UltraComposer = ::bb::honk::UltraComposer_; + using GoblinUltraComposer = ::bb::honk::UltraComposer_; + + using InnerFlavor = UltraFlavor; + using InnerComposer = UltraComposer; + using Instance = ::bb::honk::ProverInstance_; + using InnerBuilder = typename InnerComposer::CircuitBuilder; + using InnerCurve = bn254; + using Commitment = InnerFlavor::Commitment; + using FF = InnerFlavor::FF; + + // Types for recursive verifier circuit + // cannot do on Goblin + using OuterBuilder = GoblinUltraCircuitBuilder; + using RecursiveFlavor = ::bb::honk::flavor::UltraRecursive_; + using RecursiveVerifierInstances = ::bb::honk::VerifierInstances_; + using FoldingRecursiveVerifier = ProtoGalaxyRecursiveVerifier_; + using DeciderRecursiveVerifier = DeciderRecursiveVerifier_; + using DeciderVerifier = ::bb::honk::DeciderVerifier_; + using NativeVerifierInstances = ::bb::honk::VerifierInstances_; + using NativeFoldingVerifier = bb::honk::ProtoGalaxyVerifier_; + + // Helper for getting composer for prover/verifier of recursive (outer) circuit + template static auto get_outer_composer() + { + if constexpr (IsGoblinBuilder) { + return GoblinUltraComposer(); + } else { + return UltraComposer(); + } + } + + /** + * @brief Create a non-trivial arbitrary inner circuit, the proof of which will be recursively verified + * + * @param builder + * @param public_inputs + * @param log_num_gates + * + * TODO(https://github.com/AztecProtocol/barretenberg/issues/744): make testing utility with functionality shared + * amongst test files + */ + static void create_inner_circuit(InnerBuilder& builder, size_t log_num_gates = 10) + { + using fr_ct = InnerCurve::ScalarField; + using fq_ct = InnerCurve::BaseField; + using public_witness_ct = InnerCurve::public_witness_ct; + using witness_ct = InnerCurve::witness_ct; + using byte_array_ct = InnerCurve::byte_array_ct; + using fr = typename InnerCurve::ScalarFieldNative; + + // Create 2^log_n many add gates based on input log num gates + const size_t num_gates = 1 << log_num_gates; + for (size_t i = 0; i < num_gates; ++i) { + fr a = fr::random_element(); + uint32_t a_idx = builder.add_variable(a); + + fr b = fr::random_element(); + fr c = fr::random_element(); + fr d = a + b + c; + uint32_t b_idx = builder.add_variable(b); + uint32_t c_idx = builder.add_variable(c); + uint32_t d_idx = builder.add_variable(d); + + builder.create_big_add_gate({ a_idx, b_idx, c_idx, d_idx, fr(1), fr(1), fr(1), fr(-1), fr(0) }); + } + + // Define some additional non-trivial but arbitrary circuit logic + fr_ct a(public_witness_ct(&builder, fr::random_element())); + fr_ct b(public_witness_ct(&builder, fr::random_element())); + fr_ct c(public_witness_ct(&builder, fr::random_element())); + + for (size_t i = 0; i < 32; ++i) { + a = (a * b) + b + a; + a = a.madd(b, c); + } + pedersen_hash::hash({ a, b }); + byte_array_ct to_hash(&builder, "nonsense test data"); + blake3s(to_hash); + + fr bigfield_data = fr::random_element(); + fr bigfield_data_a{ bigfield_data.data[0], bigfield_data.data[1], 0, 0 }; + fr bigfield_data_b{ bigfield_data.data[2], bigfield_data.data[3], 0, 0 }; + + fq_ct big_a(fr_ct(witness_ct(&builder, bigfield_data_a.to_montgomery_form())), fr_ct(witness_ct(&builder, 0))); + fq_ct big_b(fr_ct(witness_ct(&builder, bigfield_data_b.to_montgomery_form())), fr_ct(witness_ct(&builder, 0))); + + big_a* big_b; + }; + + public: + static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } + + static std::shared_ptr fold_and_verify(const std::vector>& instances, + InnerComposer& inner_composer) + { + // Generate a folding proof + auto inner_folding_prover = inner_composer.create_folding_prover(instances); + auto inner_folding_proof = inner_folding_prover.fold_instances(); + + // Create a recursive folding verifier circuit for the folding proof of the two instances + OuterBuilder outer_folding_circuit; + FoldingRecursiveVerifier verifier{ &outer_folding_circuit }; + verifier.verify_folding_proof(inner_folding_proof.folding_data); + info("Recursive Verifier with Ultra instances: num gates = ", outer_folding_circuit.num_gates); + + // Perform native folding verification and ensure it returns the same result (either true or false) as calling + // check_circuit on the recursive folding verifier + auto native_folding_verifier = inner_composer.create_folding_verifier(); + auto native_folding_result = native_folding_verifier.verify_folding_proof(inner_folding_proof.folding_data); + EXPECT_EQ(native_folding_result, outer_folding_circuit.check_circuit()); + + // Ensure that the underlying native and recursive folding verification algorithms agree by ensuring + // the manifests produced by each agree. + auto recursive_folding_manifest = verifier.transcript->get_manifest(); + auto native_folding_manifest = native_folding_verifier.transcript->get_manifest(); + + for (size_t i = 0; i < recursive_folding_manifest.size(); ++i) { + EXPECT_EQ(recursive_folding_manifest[i], native_folding_manifest[i]); + } + + // Check for a failure flag in the recursive verifier circuit + EXPECT_EQ(outer_folding_circuit.failed(), false) << outer_folding_circuit.err(); + + return inner_folding_proof.accumulator; + } +}; +/** + * @brief Create inner circuit and call check_circuit on it + * + */ +TEST_F(ProtogalaxyRecursiveTest, InnerCircuit) +{ + InnerBuilder builder; + + create_inner_circuit(builder); + + bool result = builder.check_circuit(); + EXPECT_EQ(result, true); +} + +/** + * @brief Ensure that evaluating the perturbator in the recursive folding verifier returns the same result as + * evaluating in Polynomial class. + * + */ +TEST_F(ProtogalaxyRecursiveTest, NewEvaluate) +{ + OuterBuilder builder; + using fr_ct = bn254::ScalarField; + using fr = bn254::ScalarFieldNative; + + std::vector coeffs; + std::vector coeffs_ct; + for (size_t idx = 0; idx < 8; idx++) { + auto el = fr::random_element(); + coeffs.emplace_back(el); + coeffs_ct.emplace_back(fr_ct(&builder, el)); + } + Polynomial poly(coeffs); + fr point = fr::random_element(); + fr_ct point_ct(fr_ct(&builder, point)); + auto res1 = poly.evaluate(point); + + auto res2 = FoldingRecursiveVerifier::evaluate_perturbator(coeffs_ct, point_ct); + EXPECT_EQ(res1, res2.get_value()); +} + +/** + * @brief Tests a simple recursive fold that is valid works as expected. + * + */ +TEST_F(ProtogalaxyRecursiveTest, RecursiveFoldingTest) +{ + // Create two arbitrary circuits for the first round of folding + InnerBuilder builder1; + + create_inner_circuit(builder1); + InnerBuilder builder2; + builder2.add_public_variable(FF(1)); + create_inner_circuit(builder2); + + InnerComposer inner_composer = InnerComposer(); + auto instance1 = inner_composer.create_instance(builder1); + auto instance2 = inner_composer.create_instance(builder2); + auto instances = std::vector>{ instance1, instance2 }; + + fold_and_verify(instances, inner_composer); +} + +/** + * @brief Recursively verify two rounds of folding valid circuits and then recursive verify the final decider proof, + * make sure the verifer circuits pass check_circuit(). Ensure that the algorithm of the recursive and native verifiers + * are identical by checking the manifests + + */ +TEST_F(ProtogalaxyRecursiveTest, FullProtogalaxyRecursiveTest) +{ + + // Create two arbitrary circuits for the first round of folding + InnerBuilder builder1; + + create_inner_circuit(builder1); + InnerBuilder builder2; + builder2.add_public_variable(FF(1)); + create_inner_circuit(builder2); + + InnerComposer inner_composer = InnerComposer(); + auto instance1 = inner_composer.create_instance(builder1); + auto instance2 = inner_composer.create_instance(builder2); + auto instances = std::vector>{ instance1, instance2 }; + + auto accumulator = fold_and_verify(instances, inner_composer); + + // Create another circuit to do a second round of folding + InnerBuilder builder3; + create_inner_circuit(builder3); + auto instance3 = inner_composer.create_instance(builder3); + instances = std::vector>{ accumulator, instance3 }; + + accumulator = fold_and_verify(instances, inner_composer); + + // Create a decider proof for the relaxed instance obtained through folding + auto inner_decider_prover = inner_composer.create_decider_prover(accumulator); + auto inner_decider_proof = inner_decider_prover.construct_proof(); + + // Create a decider verifier circuit for recursively verifying the decider proof + OuterBuilder outer_decider_circuit; + DeciderRecursiveVerifier decider_verifier{ &outer_decider_circuit }; + auto pairing_points = decider_verifier.verify_proof(inner_decider_proof); + info("Decider Recursive Verifier: num gates = ", outer_decider_circuit.num_gates); + // Check for a failure flag in the recursive verifier circuit + EXPECT_EQ(outer_decider_circuit.failed(), false) << outer_decider_circuit.err(); + + // Perform native verification then perform the pairing on the outputs of the recursive + // decider verifier and check that the result agrees. + DeciderVerifier native_decider_verifier = inner_composer.create_decider_verifier(accumulator); + auto native_result = native_decider_verifier.verify_proof(inner_decider_proof); + auto recursive_result = native_decider_verifier.pcs_verification_key->pairing_check(pairing_points[0].get_value(), + pairing_points[1].get_value()); + EXPECT_EQ(native_result, recursive_result); + + // Ensure that the underlying native and recursive decider verification algorithms agree by ensuring + // the manifests produced are the same. + auto recursive_decider_manifest = decider_verifier.transcript->get_manifest(); + auto native_decider_manifest = native_decider_verifier.transcript->get_manifest(); + for (size_t i = 0; i < recursive_decider_manifest.size(); ++i) { + EXPECT_EQ(recursive_decider_manifest[i], native_decider_manifest[i]); + } + + // Construct and verify a proof of the recursive decider verifier circuit + { + auto composer = get_outer_composer(); + auto instance = composer.create_instance(outer_decider_circuit); + auto prover = composer.create_prover(instance); + auto verifier = composer.create_verifier(instance); + auto proof = prover.construct_proof(); + bool verified = verifier.verify_proof(proof); + + ASSERT(verified); + } +} + +TEST_F(ProtogalaxyRecursiveTest, TamperedDeciderProof) +{ + // Create two arbitrary circuits for the first round of folding + InnerBuilder builder1; + + create_inner_circuit(builder1); + InnerBuilder builder2; + builder2.add_public_variable(FF(1)); + create_inner_circuit(builder2); + + InnerComposer inner_composer = InnerComposer(); + auto instance1 = inner_composer.create_instance(builder1); + auto instance2 = inner_composer.create_instance(builder2); + auto instances = std::vector>{ instance1, instance2 }; + + auto accumulator = fold_and_verify(instances, inner_composer); + + // Tamper with the accumulator by changing the target sum + accumulator->target_sum = FF::random_element(); + + // Create a decider proof for the relaxed instance obtained through folding + auto inner_decider_prover = inner_composer.create_decider_prover(accumulator); + auto inner_decider_proof = inner_decider_prover.construct_proof(); + + // Create a decider verifier circuit for recursively verifying the decider proof + OuterBuilder outer_decider_circuit; + DeciderRecursiveVerifier decider_verifier{ &outer_decider_circuit }; + decider_verifier.verify_proof(inner_decider_proof); + info("Decider Recursive Verifier: num gates = ", outer_decider_circuit.num_gates); + + // We expect the decider circuit check to fail due to the bad proof + EXPECT_FALSE(outer_decider_circuit.check_circuit()); +} + +TEST_F(ProtogalaxyRecursiveTest, TamperedAccumulator) +{ + // Create two arbitrary circuits for the first round of folding + InnerBuilder builder1; + + create_inner_circuit(builder1); + InnerBuilder builder2; + builder2.add_public_variable(FF(1)); + create_inner_circuit(builder2); + + InnerComposer inner_composer = InnerComposer(); + auto instance1 = inner_composer.create_instance(builder1); + auto instance2 = inner_composer.create_instance(builder2); + auto instances = std::vector>{ instance1, instance2 }; + + auto accumulator = fold_and_verify(instances, inner_composer); + + // Create another circuit to do a second round of folding + InnerBuilder builder3; + create_inner_circuit(builder3); + auto instance3 = inner_composer.create_instance(builder3); + + // Tamper with the accumulator + instances = std::vector>{ accumulator, instance3 }; + accumulator->prover_polynomials.w_l[1] = FF::random_element(); + + // Generate a folding proof + auto inner_folding_prover = inner_composer.create_folding_prover(instances); + auto inner_folding_proof = inner_folding_prover.fold_instances(); + + // Create a recursive folding verifier circuit for the folding proof of the two instances + OuterBuilder outer_folding_circuit; + FoldingRecursiveVerifier verifier{ &outer_folding_circuit }; + verifier.verify_folding_proof(inner_folding_proof.folding_data); + EXPECT_EQ(outer_folding_circuit.check_circuit(), false); +} + +} // namespace bb::stdlib::recursion::honk \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.hpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.hpp index f26b44d11167..5712966f0016 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/honk/verifier/ultra_recursive_verifier.hpp @@ -20,11 +20,6 @@ template class UltraRecursiveVerifier_ { explicit UltraRecursiveVerifier_(Builder* builder, const std::shared_ptr& native_verifier_key); - UltraRecursiveVerifier_(UltraRecursiveVerifier_&& other) = delete; - UltraRecursiveVerifier_(const UltraRecursiveVerifier_& other) = delete; - UltraRecursiveVerifier_& operator=(const UltraRecursiveVerifier_& other) = delete; - UltraRecursiveVerifier_& operator=(UltraRecursiveVerifier_&& other) = delete; - ~UltraRecursiveVerifier_() = default; // TODO(luke): Eventually this will return something like aggregation_state but I'm simplifying for now until we // determine the exact interface. Simply returns the two pairing points. diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/transcript/transcript.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/transcript/transcript.test.cpp index 6d370e4cbd57..7f6b856a253d 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/transcript/transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/transcript/transcript.test.cpp @@ -56,9 +56,9 @@ transcript::Manifest create_manifest(const size_t num_public_inputs) } // namespace struct TestData { - std::vector g1_elements; - std::vector fr_elements; - std::vector public_input_elements; + std::vector g1_elements; + std::vector fr_elements; + std::vector public_input_elements; size_t num_public_inputs; }; @@ -69,8 +69,8 @@ TestData get_test_data() data.g1_elements.push_back(bb::g1::affine_element(bb::g1::element::random_element())); data.fr_elements.push_back(bb::fr::random_element()); } - data.fr_elements[2] = bb::fr(0); - data.fr_elements[3] = bb::fr(0); + data.fr_elements[2] = fr(0); + data.fr_elements[3] = fr(0); data.num_public_inputs = 13; for (size_t i = 0; i < data.num_public_inputs; ++i) { data.public_input_elements.push_back(bb::fr::random_element()); @@ -191,8 +191,7 @@ TEST(stdlib_transcript, validate_transcript) const auto check_challenge = [&normal_transcript, &recursive_transcript](const std::string& challenge_name, const size_t challenge_idx = 0) { field_t result = recursive_transcript.get_challenge_field_element(challenge_name, challenge_idx); - bb::fr expected = - bb::fr::serialize_from_buffer(&normal_transcript.get_challenge(challenge_name, challenge_idx)[0]); + fr expected = fr::serialize_from_buffer(&normal_transcript.get_challenge(challenge_name, challenge_idx)[0]); EXPECT_EQ(result.get_value(), expected); }; @@ -209,21 +208,21 @@ TEST(stdlib_transcript, validate_transcript) const auto check_field_element = [&normal_transcript, &recursive_transcript](const std::string& element_name) { field_t result = recursive_transcript.get_field_element(element_name); - bb::fr expected = bb::fr::serialize_from_buffer(&normal_transcript.get_element(element_name)[0]); + fr expected = fr::serialize_from_buffer(&normal_transcript.get_element(element_name)[0]); EXPECT_EQ(result.get_value(), expected); }; const auto check_group_element = [&normal_transcript, &recursive_transcript](const std::string& element_name) { group_t recursive_value = recursive_transcript.get_circuit_group_element(element_name); - bb::g1::affine_element expected = - bb::g1::affine_element::serialize_from_buffer(&normal_transcript.get_element(element_name)[0]); - bb::g1::affine_element result{ recursive_value.x.get_value().lo, recursive_value.y.get_value().lo }; + g1::affine_element expected = + g1::affine_element::serialize_from_buffer(&normal_transcript.get_element(element_name)[0]); + g1::affine_element result{ recursive_value.x.get_value().lo, recursive_value.y.get_value().lo }; EXPECT_EQ(result, expected); }; const auto check_public_inputs = [&normal_transcript, &recursive_transcript]() { std::vector result = recursive_transcript.get_field_element_vector("public_inputs"); - std::vector expected = many_from_buffer(normal_transcript.get_element("public_inputs")); + std::vector expected = many_from_buffer(normal_transcript.get_element("public_inputs")); EXPECT_EQ(result.size(), expected.size()); for (size_t i = 0; i < result.size(); ++i) { EXPECT_EQ(result[i].get_value(), expected[i]); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/verification_key/verification_key.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/verification_key/verification_key.test.cpp index a6e60ec4e740..b579681391c1 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/verification_key/verification_key.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/verification_key/verification_key.test.cpp @@ -7,7 +7,7 @@ #include "barretenberg/srs/factories/file_crs_factory.hpp" namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } // namespace using namespace bb::plonk; @@ -20,8 +20,8 @@ using namespace bb::plonk; */ template class VerificationKeyFixture : public testing::Test { public: - using Curve = bb::stdlib::bn254; - using RecursVk = bb::stdlib::recursion::verification_key; + using Curve = stdlib::bn254; + using RecursVk = stdlib::recursion::verification_key; static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } diff --git a/barretenberg/cpp/src/barretenberg/stdlib/recursion/verifier/verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/recursion/verifier/verifier.test.cpp index 97a2933c32d1..b3d9cadc6ce1 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/recursion/verifier/verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/recursion/verifier/verifier.test.cpp @@ -16,7 +16,7 @@ namespace bb::stdlib { template class stdlib_verifier : public testing::Test { - using InnerComposer = bb::plonk::UltraComposer; + using InnerComposer = plonk::UltraComposer; using InnerBuilder = typename InnerComposer::CircuitBuilder; using OuterBuilder = typename OuterComposer::CircuitBuilder; @@ -36,7 +36,7 @@ template class stdlib_verifier : public testing::Test { using inner_scalar_field = typename inner_curve::ScalarFieldNative; using outer_scalar_field = typename outer_curve::BaseFieldNative; - using pairing_target_field = bb::fq12; + using pairing_target_field = fq12; // These constexpr definitions are to allow for the following: An Ultra Pedersen hash evaluates to a // different value from the Standard version of the Pedersen hash. Therefore, the fiat-shamir @@ -212,7 +212,7 @@ template class stdlib_verifier : public testing::Test { plonk::proof proof_to_recursively_verify_b = prover.construct_proof(); - auto output = bb::stdlib::recursion::verify_proof( + auto output = stdlib::recursion::verify_proof( &outer_circuit, verification_key_b, recursive_manifest, proof_to_recursively_verify_b, previous_output); verification_key_b->hash(); @@ -265,8 +265,8 @@ template class stdlib_verifier : public testing::Test { transcript::Manifest recursive_manifest = InnerComposer::create_manifest(prover_a.key->num_public_inputs); - bb::stdlib::recursion::aggregation_state output = - bb::stdlib::recursion::verify_proof( + stdlib::recursion::aggregation_state output = + stdlib::recursion::verify_proof( &outer_circuit, verification_key, recursive_manifest, recursive_proof); return { output, verification_key }; @@ -320,7 +320,7 @@ template class stdlib_verifier : public testing::Test { { x1, y1 }, }; - pairing_target_field result = bb::pairing::reduced_ate_pairing_batch_precomputed(P_affine, lines, 2); + pairing_target_field result = pairing::reduced_ate_pairing_batch_precomputed(P_affine, lines, 2); return (result == pairing_target_field::one()); } @@ -332,13 +332,13 @@ template class stdlib_verifier : public testing::Test { static void check_pairing(const circuit_outputs& circuit_output) { - auto g2_lines = bb::srs::get_crs_factory()->get_verifier_crs()->get_precomputed_g2_lines(); + auto g2_lines = srs::get_crs_factory()->get_verifier_crs()->get_precomputed_g2_lines(); g1::affine_element P[2]; P[0].x = outer_scalar_field(circuit_output.aggregation_state.P0.x.get_value().lo); P[0].y = outer_scalar_field(circuit_output.aggregation_state.P0.y.get_value().lo); P[1].x = outer_scalar_field(circuit_output.aggregation_state.P1.x.get_value().lo); P[1].y = outer_scalar_field(circuit_output.aggregation_state.P1.y.get_value().lo); - pairing_target_field inner_proof_result = bb::pairing::reduced_ate_pairing_batch_precomputed(P, g2_lines, 2); + pairing_target_field inner_proof_result = pairing::reduced_ate_pairing_batch_precomputed(P, g2_lines, 2); EXPECT_EQ(inner_proof_result, pairing_target_field::one()); } @@ -347,7 +347,7 @@ template class stdlib_verifier : public testing::Test { info("number of gates in recursive verification circuit = ", outer_circuit.get_num_gates()); bool result = outer_circuit.check_circuit(); EXPECT_EQ(result, expected_result); - auto g2_lines = bb::srs::get_crs_factory()->get_verifier_crs()->get_precomputed_g2_lines(); + auto g2_lines = srs::get_crs_factory()->get_verifier_crs()->get_precomputed_g2_lines(); EXPECT_EQ(check_recursive_proof_public_inputs(outer_circuit, g2_lines), true); } diff --git a/barretenberg/cpp/src/barretenberg/stdlib/types/ultra.hpp b/barretenberg/cpp/src/barretenberg/stdlib/types/ultra.hpp index 555d3f2975eb..96bf0d2b2033 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/types/ultra.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/types/ultra.hpp @@ -57,9 +57,7 @@ using namespace stdlib::merkle_tree; using hash_path = stdlib::merkle_tree::hash_path; } // namespace merkle_tree -namespace schnorr { -using signature_bits = stdlib::schnorr::signature_bits; -} // namespace schnorr +using schnorr_signature_bits = stdlib::schnorr_signature_bits; // Ultra-composer specific types using rom_table_ct = stdlib::rom_table; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/utility/utility.hpp b/barretenberg/cpp/src/barretenberg/stdlib/utility/utility.hpp index bec32c7a78c1..1759f5fc4121 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/utility/utility.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/utility/utility.hpp @@ -117,6 +117,10 @@ template class StdlibTypesUtility { using type = uint32_t; }; + template struct NativeType { + using type = bool; + }; + template struct NativeType { using type = FF; }; diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.test.cpp b/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.test.cpp index 9de85a376045..86c51e5ed1c3 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.test.cpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/instance/prover_instance.test.cpp @@ -5,9 +5,8 @@ #include "barretenberg/proof_system/library/grand_product_library.hpp" #include "barretenberg/srs/factories/file_crs_factory.hpp" #include - +using namespace bb; using namespace bb::honk; -namespace instance_tests { template class InstanceTests : public testing::Test { using FF = typename Flavor::FF; @@ -89,5 +88,3 @@ TYPED_TEST(InstanceTests, SortedListAccumulator) { TestFixture::test_sorted_list_accumulator_construction(); } - -} // namespace instance_tests \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/partial_evaluation.test.cpp b/barretenberg/cpp/src/barretenberg/sumcheck/partial_evaluation.test.cpp index c0df47b4861e..83c5084988a0 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/partial_evaluation.test.cpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/partial_evaluation.test.cpp @@ -4,7 +4,6 @@ #include using namespace bb::honk::sumcheck; -namespace test_sumcheck_polynomials { template class PartialEvaluationTests : public testing::Test {}; @@ -317,5 +316,3 @@ TYPED_TEST(PartialEvaluationTests, ThreeRoundsGenericMultiplePolys) EXPECT_EQ((polynomial_get_all[i])[0], expected_val[i]); } } - -} // namespace test_sumcheck_polynomials diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.test.cpp b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.test.cpp index 7d385c5947e2..81a58a3f1692 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.test.cpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.test.cpp @@ -11,18 +11,16 @@ #include "barretenberg/ultra_honk/ultra_composer.hpp" #include - +using namespace bb; using namespace bb::honk; using namespace bb::honk::sumcheck; -using Flavor = bb::honk::flavor::Ultra; +using Flavor = honk::flavor::Ultra; using FF = typename Flavor::FF; using ProverPolynomials = typename Flavor::ProverPolynomials; using RelationSeparator = Flavor::RelationSeparator; const size_t NUM_POLYNOMIALS = Flavor::NUM_ALL_ENTITIES; -namespace test_sumcheck_round { - -bb::Polynomial random_poly(size_t size) +Polynomial random_poly(size_t size) { auto poly = bb::Polynomial(size); for (auto& coeff : poly) { @@ -53,7 +51,7 @@ TEST_F(SumcheckTests, PolynomialNormalization) // Randomly construct the prover polynomials that are input to Sumcheck. // Note: ProverPolynomials are defined as spans so the polynomials they point to need to exist in memory. - std::array, NUM_POLYNOMIALS> random_polynomials; + std::array, NUM_POLYNOMIALS> random_polynomials; for (auto& poly : random_polynomials) { poly = random_poly(multivariate_n); } @@ -116,7 +114,7 @@ TEST_F(SumcheckTests, PolynomialNormalization) // full polynomials at challenge u via the evaluate_mle() function std::vector u_challenge = { u_0, u_1, u_2 }; for (auto [full_poly, claimed_eval] : zip_view(full_polynomials.get_all(), output.claimed_evaluations.get_all())) { - bb::Polynomial poly(full_poly); + Polynomial poly(full_poly); auto v_expected = poly.evaluate_mle(u_challenge); EXPECT_EQ(v_expected, claimed_eval); } @@ -129,7 +127,7 @@ TEST_F(SumcheckTests, Prover) // Randomly construct the prover polynomials that are input to Sumcheck. // Note: ProverPolynomials are defined as spans so the polynomials they point to need to exist in memory. - std::array, NUM_POLYNOMIALS> random_polynomials; + std::array, NUM_POLYNOMIALS> random_polynomials; for (auto& poly : random_polynomials) { poly = random_poly(multivariate_n); } @@ -176,9 +174,9 @@ TEST_F(SumcheckTests, ProverAndVerifierSimple) // Construct prover polynomials where each is the zero polynomial. // Note: ProverPolynomials are defined as spans so the polynomials they point to need to exist in memory. - std::array, NUM_POLYNOMIALS> zero_polynomials; + std::array, NUM_POLYNOMIALS> zero_polynomials; for (auto& poly : zero_polynomials) { - poly = bb::Polynomial(multivariate_n); + poly = Polynomial(multivariate_n); } auto full_polynomials = construct_ultra_full_polynomials(zero_polynomials); @@ -213,7 +211,7 @@ TEST_F(SumcheckTests, ProverAndVerifierSimple) full_polynomials.q_arith = q_arith; // Set aribitrary random relation parameters - bb::RelationParameters relation_parameters{ + RelationParameters relation_parameters{ .beta = FF::random_element(), .gamma = FF::random_element(), .public_input_delta = FF::one(), @@ -255,5 +253,3 @@ TEST_F(SumcheckTests, ProverAndVerifierSimple) run_test(/* expect_verified=*/true); run_test(/* expect_verified=*/false); } - -} // namespace test_sumcheck_round diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.test.cpp b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.test.cpp index bb33dc4ef7f6..5091717988e7 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.test.cpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck_round.test.cpp @@ -3,7 +3,7 @@ #include "barretenberg/relations/utils.hpp" #include - +using namespace bb; using namespace bb::honk; using namespace bb::honk::sumcheck; @@ -12,9 +12,7 @@ using bb::Univariate; using Flavor = flavor::Ultra; using FF = typename Flavor::FF; -using Utils = bb::RelationUtils; - -namespace test_sumcheck_round { +using Utils = RelationUtils; /** * @brief Test SumcheckRound functions for operations on tuples (and tuples of tuples) of Univariates @@ -22,7 +20,7 @@ namespace test_sumcheck_round { */ TEST(SumcheckRound, SumcheckTupleOfTuplesOfUnivariates) { - using Flavor = bb::honk::flavor::Ultra; + using Flavor = honk::flavor::Ultra; using FF = typename Flavor::FF; using RelationSeparator = typename Flavor::RelationSeparator; @@ -43,7 +41,7 @@ TEST(SumcheckRound, SumcheckTupleOfTuplesOfUnivariates) Utils::scale_univariates(tuple_of_tuples, challenge, running_challenge); // Use extend_and_batch_univariates to extend to MAX_LENGTH then accumulate - bb::PowPolynomial pow_polynomial({ 1 }); + PowPolynomial pow_polynomial({ 1 }); auto result = Univariate(); SumcheckProverRound::extend_and_batch_univariates(tuple_of_tuples, result, pow_polynomial); @@ -73,8 +71,8 @@ TEST(SumcheckRound, SumcheckTupleOfTuplesOfUnivariates) */ TEST(SumcheckRound, TuplesOfEvaluationArrays) { - using Flavor = bb::honk::flavor::Ultra; - using Utils = bb::RelationUtils; + using Flavor = honk::flavor::Ultra; + using Utils = RelationUtils; using FF = typename Flavor::FF; using RelationSeparator = typename Flavor::RelationSeparator; @@ -113,7 +111,7 @@ TEST(SumcheckRound, TuplesOfEvaluationArrays) */ TEST(SumcheckRound, AddTuplesOfTuplesOfUnivariates) { - using Flavor = bb::honk::flavor::Ultra; + using Flavor = honk::flavor::Ultra; using FF = typename Flavor::FF; // Define some arbitrary univariates @@ -141,5 +139,3 @@ TEST(SumcheckRound, AddTuplesOfTuplesOfUnivariates) EXPECT_EQ(std::get<0>(std::get<1>(tuple_of_tuples_1)), expected_sum_2); EXPECT_EQ(std::get<1>(std::get<1>(tuple_of_tuples_1)), expected_sum_3); } - -} // namespace test_sumcheck_round diff --git a/barretenberg/cpp/src/barretenberg/transcript/transcript.test.cpp b/barretenberg/cpp/src/barretenberg/transcript/transcript.test.cpp index b62cc960a2a4..f9698f1a6c8c 100644 --- a/barretenberg/cpp/src/barretenberg/transcript/transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/transcript/transcript.test.cpp @@ -1,12 +1,12 @@ #include "barretenberg/transcript/transcript.hpp" #include -namespace bb::honk_transcript_tests { +using namespace bb; -using FF = bb::fr; -using Fr = bb::fr; -using Fq = bb::fq; -using Transcript = bb::honk::BaseTranscript; +using FF = fr; +using Fr = fr; +using Fq = fq; +using Transcript = honk::BaseTranscript; /** * @brief Test sending, receiving, and exporting proofs @@ -47,5 +47,3 @@ TEST(BaseTranscript, TwoProversTwoFields) EXPECT_STATE(verifier_transcript, 0, 64, 64); EXPECT_EQ(received_b, elt_b); } - -} // namespace bb::honk_transcript_tests diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.test.cpp b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.test.cpp index f6bcffd50bd5..7221bab8ff53 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/goblin_translator_composer.test.cpp @@ -7,16 +7,14 @@ #include "barretenberg/translator_vm/goblin_translator_prover.hpp" #include - +using namespace bb; using namespace bb::honk; using CircuitBuilder = flavor::GoblinTranslator::CircuitBuilder; using Transcript = flavor::GoblinTranslator::Transcript; -using OpQueue = bb::ECCOpQueue; - -namespace test_goblin_translator_composer { +using OpQueue = ECCOpQueue; namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } std::vector add_variables(auto& circuit_constructor, std::vector variables) @@ -48,9 +46,9 @@ class GoblinTranslatorComposerTests : public ::testing::Test { */ TEST_F(GoblinTranslatorComposerTests, Basic) { - using G1 = bb::g1::affine_element; - using Fr = bb::fr; - using Fq = bb::fq; + using G1 = g1::affine_element; + using Fr = fr; + using Fq = fq; auto P1 = G1::random_element(); auto P2 = G1::random_element(); @@ -81,5 +79,3 @@ TEST_F(GoblinTranslatorComposerTests, Basic) bool verified = verifier.verify_proof(proof); EXPECT_TRUE(verified); } - -} // namespace test_goblin_translator_composer diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp index 654834bd1516..6dcc73e1f7f3 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/databus_composer.test.cpp @@ -9,13 +9,11 @@ #include "barretenberg/proof_system/instance_inspector.hpp" #include "barretenberg/ultra_honk/ultra_composer.hpp" #include "barretenberg/ultra_honk/ultra_prover.hpp" - +using namespace bb; using namespace bb::honk; -namespace test_ultra_honk_composer { - namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } class DataBusComposerTests : public ::testing::Test { @@ -54,7 +52,7 @@ TEST_F(DataBusComposerTests, CallDataRead) // Add mock data to op queue to simulate interaction with a previous circuit op_queue->populate_with_mock_initital_data(); - auto builder = bb::GoblinUltraCircuitBuilder{ op_queue }; + auto builder = GoblinUltraCircuitBuilder{ op_queue }; // Create a general test circuit generate_test_circuit(builder); @@ -95,5 +93,3 @@ TEST_F(DataBusComposerTests, CallDataRead) bool verified = verifier.verify_proof(proof); EXPECT_TRUE(verified); } - -} // namespace test_ultra_honk_composer diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp index 96512d75f106..ff5d21488c3f 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_composer.test.cpp @@ -7,13 +7,11 @@ #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" #include "barretenberg/ultra_honk/ultra_composer.hpp" #include "barretenberg/ultra_honk/ultra_prover.hpp" - +using namespace bb; using namespace bb::honk; -namespace test_ultra_honk_composer { - namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } class GoblinUltraHonkComposerTests : public ::testing::Test { @@ -99,7 +97,7 @@ TEST_F(GoblinUltraHonkComposerTests, SingleCircuit) // Add mock data to op queue to simulate interaction with a previous circuit op_queue->populate_with_mock_initital_data(); - auto builder = bb::GoblinUltraCircuitBuilder{ op_queue }; + auto builder = GoblinUltraCircuitBuilder{ op_queue }; generate_test_circuit(builder); @@ -130,7 +128,7 @@ TEST_F(GoblinUltraHonkComposerTests, MultipleCircuitsMergeOnly) // Construct multiple test circuits that share an ECC op queue. Generate and verify a proof for each. size_t NUM_CIRCUITS = 3; for (size_t i = 0; i < NUM_CIRCUITS; ++i) { - auto builder = bb::GoblinUltraCircuitBuilder{ op_queue }; + auto builder = GoblinUltraCircuitBuilder{ op_queue }; generate_test_circuit(builder); @@ -158,7 +156,7 @@ TEST_F(GoblinUltraHonkComposerTests, MultipleCircuitsHonkOnly) // Construct multiple test circuits that share an ECC op queue. Generate and verify a proof for each. size_t NUM_CIRCUITS = 3; for (size_t i = 0; i < NUM_CIRCUITS; ++i) { - auto builder = bb::GoblinUltraCircuitBuilder{ op_queue }; + auto builder = GoblinUltraCircuitBuilder{ op_queue }; generate_test_circuit(builder); @@ -186,7 +184,7 @@ TEST_F(GoblinUltraHonkComposerTests, MultipleCircuitsHonkAndMerge) // Construct multiple test circuits that share an ECC op queue. Generate and verify a proof for each. size_t NUM_CIRCUITS = 3; for (size_t i = 0; i < NUM_CIRCUITS; ++i) { - auto builder = bb::GoblinUltraCircuitBuilder{ op_queue }; + auto builder = GoblinUltraCircuitBuilder{ op_queue }; generate_test_circuit(builder); @@ -212,5 +210,3 @@ TEST_F(GoblinUltraHonkComposerTests, MultipleCircuitsHonkAndMerge) EXPECT_EQ(result, expected); } } - -} // namespace test_ultra_honk_composer diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp index 3eceba80cf37..0865eff99bb2 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/goblin_ultra_transcript.test.cpp @@ -6,13 +6,14 @@ #include "barretenberg/ultra_honk/ultra_composer.hpp" #include +using namespace bb; using namespace bb::honk; class GoblinUltraTranscriptTests : public ::testing::Test { public: static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } - using Flavor = bb::honk::flavor::GoblinUltra; + using Flavor = honk::flavor::GoblinUltra; using FF = Flavor::FF; /** diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp index 87ece52bb3fc..1f41c5325abf 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/protogalaxy.test.cpp @@ -2,7 +2,7 @@ #include "barretenberg/protogalaxy/protogalaxy_prover.hpp" #include "barretenberg/ultra_honk/ultra_composer.hpp" #include - +using namespace bb; using namespace bb::honk; using Flavor = flavor::Ultra; @@ -14,22 +14,18 @@ using FF = Flavor::FF; using Affine = Flavor::Commitment; using Projective = Flavor::GroupElement; using Builder = Flavor::CircuitBuilder; -using Polynomial = typename Flavor::Polynomial; using ProverPolynomials = Flavor::ProverPolynomials; -using RelationParameters = bb::RelationParameters; using WitnessCommitments = typename Flavor::WitnessCommitments; using CommitmentKey = Flavor::CommitmentKey; -using PowPolynomial = bb::PowPolynomial; const size_t NUM_POLYNOMIALS = Flavor::NUM_ALL_ENTITIES; -namespace bb::protogalaxy_tests { namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } // TODO(https://github.com/AztecProtocol/barretenberg/issues/744): make testing utility with functionality shared // amongst test files in the proof system -bb::Polynomial get_random_polynomial(size_t size) +Polynomial get_random_polynomial(size_t size) { auto poly = bb::Polynomial(size); for (auto& coeff : poly) { @@ -51,7 +47,7 @@ std::shared_ptr fold_and_verify(const std::vector& accumulator, } void decide_and_verify(std::shared_ptr& accumulator, UltraComposer& composer, bool expected_result) { - auto decider_prover = composer.create_decider_prover(accumulator, composer.commitment_key); + auto decider_prover = composer.create_decider_prover(accumulator); auto decider_verifier = composer.create_decider_verifier(accumulator); auto decision = decider_prover.construct_proof(); auto verified = decider_verifier.verify_proof(decision); @@ -144,12 +140,12 @@ TEST_F(ProtoGalaxyTests, PerturbatorPolynomial) const size_t log_instance_size(3); const size_t instance_size(1 << log_instance_size); - std::array, NUM_POLYNOMIALS> random_polynomials; + std::array, NUM_POLYNOMIALS> random_polynomials; for (auto& poly : random_polynomials) { poly = get_random_polynomial(instance_size); } auto full_polynomials = construct_ultra_full_polynomials(random_polynomials); - auto relation_parameters = bb::RelationParameters::get_random(); + auto relation_parameters = RelationParameters::get_random(); RelationSeparator alphas; for (auto& alpha : alphas) { alpha = FF::random_element(); @@ -163,7 +159,7 @@ TEST_F(ProtoGalaxyTests, PerturbatorPolynomial) } // Construct pow(\vec{betas}) as in the paper - auto pow_beta = PowPolynomial(betas); + auto pow_beta = bb::PowPolynomial(betas); pow_beta.compute_values(); // Compute the corresponding target sum and create a dummy accumulator @@ -189,12 +185,12 @@ TEST_F(ProtoGalaxyTests, PerturbatorPolynomial) TEST_F(ProtoGalaxyTests, CombinerQuotient) { auto compressed_perturbator = FF(2); // F(\alpha) in the paper - auto combiner = bb::Univariate(std::array{ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32 }); + auto combiner = Univariate(std::array{ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32 }); auto combiner_quotient = ProtoGalaxyProver::compute_combiner_quotient(compressed_perturbator, combiner); // K(i) = (G(i) - ( L_0(i) * F(\alpha)) / Z(i), i = {2,.., 13} for ProverInstances::NUM = 2 // K(i) = (G(i) - (1 - i) * F(\alpha)) / i * (i - 1) - auto expected_evals = bb::Univariate(std::array{ + auto expected_evals = Univariate(std::array{ (FF(22) - (FF(1) - FF(2)) * compressed_perturbator) / (FF(2) * FF(2 - 1)), (FF(23) - (FF(1) - FF(3)) * compressed_perturbator) / (FF(3) * FF(3 - 1)), (FF(24) - (FF(1) - FF(4)) * compressed_perturbator) / (FF(4) * FF(4 - 1)), @@ -346,6 +342,4 @@ TEST_F(ProtoGalaxyTests, TamperedAccumulatorPolynomial) auto second_accumulator = fold_and_verify(instances, composer, false); decide_and_verify(second_accumulator, composer, false); -} - -} // namespace bb::protogalaxy_tests \ No newline at end of file +} \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp index 7b86527e5883..bbecb252bf66 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/relation_correctness.test.cpp @@ -11,11 +11,9 @@ #include "barretenberg/relations/ultra_arithmetic_relation.hpp" #include "barretenberg/ultra_honk/ultra_composer.hpp" #include - +using namespace bb; using namespace bb::honk; -namespace test_honk_relations { - void ensure_non_zero(auto& polynomial) { bool has_non_zero_coefficient = false; @@ -131,12 +129,14 @@ template void create_some_lookup_gates(auto& circuit_builder) uint256_t(pedersen_input_value) .slice(plookup::fixed_base::table::BITS_PER_LO_SCALAR, plookup::fixed_base::table::BITS_PER_LO_SCALAR + plookup::fixed_base::table::BITS_PER_HI_SCALAR); - const auto input_lo = uint256_t(pedersen_input_value).slice(0, plookup::fixed_base::table::BITS_PER_LO_SCALAR); + const auto input_lo = uint256_t(pedersen_input_value).slice(0, bb::plookup::fixed_base::table::BITS_PER_LO_SCALAR); const auto input_hi_index = circuit_builder.add_variable(input_hi); const auto input_lo_index = circuit_builder.add_variable(input_lo); - const auto sequence_data_hi = plookup::get_lookup_accumulators(plookup::MultiTableId::FIXED_BASE_LEFT_HI, input_hi); - const auto sequence_data_lo = plookup::get_lookup_accumulators(plookup::MultiTableId::FIXED_BASE_LEFT_LO, input_lo); + const auto sequence_data_hi = + plookup::get_lookup_accumulators(bb::plookup::MultiTableId::FIXED_BASE_LEFT_HI, input_hi); + const auto sequence_data_lo = + plookup::get_lookup_accumulators(bb::plookup::MultiTableId::FIXED_BASE_LEFT_LO, input_lo); circuit_builder.create_gates_from_plookup_accumulators( plookup::MultiTableId::FIXED_BASE_LEFT_HI, sequence_data_hi, input_hi_index); @@ -226,7 +226,7 @@ template void create_some_ecc_op_queue_gates(auto& circuit_bui { using G1 = typename Flavor::Curve::Group; using FF = typename Flavor::FF; - static_assert(bb::IsGoblinFlavor); + static_assert(IsGoblinFlavor); const size_t num_ecc_operations = 10; // arbitrary for (size_t i = 0; i < num_ecc_operations; ++i) { auto point = G1::affine_one * FF::random_element(); @@ -258,7 +258,7 @@ TEST_F(RelationCorrectnessTests, UltraRelationCorrectness) // Create a composer and then add an assortment of gates designed to ensure that the constraint(s) represented // by each relation are non-trivially exercised. - auto builder = bb::UltraCircuitBuilder(); + auto builder = UltraCircuitBuilder(); // Create an assortment of representative gates create_some_add_gates(builder); @@ -310,7 +310,7 @@ TEST_F(RelationCorrectnessTests, GoblinUltraRelationCorrectness) // Create a composer and then add an assortment of gates designed to ensure that the constraint(s) represented // by each relation are non-trivially exercised. - auto builder = bb::GoblinUltraCircuitBuilder(); + auto builder = GoblinUltraCircuitBuilder(); // Create an assortment of representative gates create_some_add_gates(builder); @@ -378,14 +378,14 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorPermutationRelationCorrectness) using ProverPolynomials = typename Flavor::ProverPolynomials; using Polynomial = bb::Polynomial; using namespace bb::honk::permutation_library; - auto& engine = numeric::random::get_debug_engine(); + auto& engine = numeric::get_debug_randomness(); auto circuit_size = Flavor::MINI_CIRCUIT_SIZE * Flavor::CONCATENATION_INDEX; // We only need gamma, because permutationr elation only uses gamma FF gamma = FF::random_element(); // Fill relation parameters - bb::RelationParameters params; + RelationParameters params; params.gamma = gamma; // Create storage for polynomials @@ -495,14 +495,14 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorGenPermSortRelationCorrectness) using FF = typename Flavor::FF; using ProverPolynomials = typename Flavor::ProverPolynomials; using Polynomial = bb::Polynomial; - auto& engine = numeric::random::get_debug_engine(); + auto& engine = numeric::get_debug_randomness(); const auto circuit_size = Flavor::FULL_CIRCUIT_SIZE; const auto sort_step = Flavor::SORT_STEP; const auto max_value = (1 << Flavor::MICRO_LIMB_BITS) - 1; // No relation parameters are used in this relation - bb::RelationParameters params; + RelationParameters params; ProverPolynomials prover_polynomials; // Allocate polynomials @@ -577,13 +577,13 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorExtraRelationsCorrectness) using ProverPolynomialIds = typename Flavor::ProverPolynomialIds; using Polynomial = bb::Polynomial; - auto& engine = numeric::random::get_debug_engine(); + auto& engine = numeric::get_debug_randomness(); auto circuit_size = Flavor::FULL_CIRCUIT_SIZE; auto mini_circuit_size = Flavor::MINI_CIRCUIT_SIZE; // We only use accumulated_result from relation parameters in this relation - bb::RelationParameters params; + RelationParameters params; params.accumulated_result = { FF::random_element(), FF::random_element(), FF::random_element(), FF::random_element() }; @@ -679,12 +679,12 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorDecompositionRelationCorrectnes using ProverPolynomials = typename Flavor::ProverPolynomials; using ProverPolynomialIds = typename Flavor::ProverPolynomialIds; using Polynomial = bb::Polynomial; - auto& engine = numeric::random::get_debug_engine(); + auto& engine = numeric::get_debug_randomness(); auto circuit_size = Flavor::FULL_CIRCUIT_SIZE; // Decomposition relation doesn't use any relation parameters - bb::RelationParameters params; + RelationParameters params; // Create storage for polynomials ProverPolynomials prover_polynomials; @@ -1058,7 +1058,7 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorNonNativeRelationCorrectness) constexpr auto circuit_size = Flavor::FULL_CIRCUIT_SIZE; constexpr auto mini_circuit_size = Flavor::MINI_CIRCUIT_SIZE; - auto& engine = numeric::random::get_debug_engine(); + auto& engine = numeric::get_debug_randomness(); auto op_queue = std::make_shared(); @@ -1083,10 +1083,10 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorNonNativeRelationCorrectness) const auto evaluation_input_x = BF::random_element(&engine); // Generating all the values is pretty tedious, so just use CircuitBuilder - auto circuit_builder = bb::GoblinTranslatorCircuitBuilder(batching_challenge_v, evaluation_input_x, op_queue); + auto circuit_builder = GoblinTranslatorCircuitBuilder(batching_challenge_v, evaluation_input_x, op_queue); // The non-native field relation uses limbs of evaluation_input_x and powers of batching_challenge_v as inputs - bb::RelationParameters params; + RelationParameters params; auto v_power = BF::one(); for (size_t i = 0; i < 4 /*Number of powers of v that we need {1,2,3,4}*/; i++) { v_power *= batching_challenge_v; @@ -1180,5 +1180,3 @@ TEST_F(RelationCorrectnessTests, GoblinTranslatorNonNativeRelationCorrectness) // Check that Non-Native Field relation is satisfied across each row of the prover polynomials check_relation>(circuit_size, prover_polynomials, params); } - -} // namespace test_honk_relations diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp index ab2cb1141cb2..fe0fede946c9 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/sumcheck.test.cpp @@ -14,14 +14,13 @@ #include +using namespace bb; using namespace bb::honk; using namespace bb::honk::sumcheck; -using Flavor = bb::honk::flavor::Ultra; +using Flavor = honk::flavor::Ultra; using FF = typename Flavor::FF; -namespace test_sumcheck_round { - class SumcheckTestsRealCircuit : public ::testing::Test { protected: static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } @@ -39,7 +38,7 @@ TEST_F(SumcheckTestsRealCircuit, Ultra) using RelationSeparator = typename Flavor::RelationSeparator; // Create a composer and a dummy circuit with a few gates - auto builder = bb::UltraCircuitBuilder(); + auto builder = UltraCircuitBuilder(); FF a = FF::one(); // Add some basic add gates, with a public input for good measure @@ -69,12 +68,14 @@ TEST_F(SumcheckTestsRealCircuit, Ultra) uint256_t(pedersen_input_value) .slice(plookup::fixed_base::table::BITS_PER_LO_SCALAR, plookup::fixed_base::table::BITS_PER_LO_SCALAR + plookup::fixed_base::table::BITS_PER_HI_SCALAR); - const FF input_lo = uint256_t(pedersen_input_value).slice(0, plookup::fixed_base::table::BITS_PER_LO_SCALAR); + const FF input_lo = uint256_t(pedersen_input_value).slice(0, bb::plookup::fixed_base::table::BITS_PER_LO_SCALAR); const auto input_hi_index = builder.add_variable(input_hi); const auto input_lo_index = builder.add_variable(input_lo); - const auto sequence_data_hi = plookup::get_lookup_accumulators(plookup::MultiTableId::FIXED_BASE_LEFT_HI, input_hi); - const auto sequence_data_lo = plookup::get_lookup_accumulators(plookup::MultiTableId::FIXED_BASE_LEFT_LO, input_lo); + const auto sequence_data_hi = + plookup::get_lookup_accumulators(bb::plookup::MultiTableId::FIXED_BASE_LEFT_HI, input_hi); + const auto sequence_data_lo = + plookup::get_lookup_accumulators(bb::plookup::MultiTableId::FIXED_BASE_LEFT_LO, input_lo); builder.create_gates_from_plookup_accumulators( plookup::MultiTableId::FIXED_BASE_LEFT_HI, sequence_data_hi, input_hi_index); @@ -200,5 +201,3 @@ TEST_F(SumcheckTestsRealCircuit, Ultra) ASSERT_TRUE(verified); } - -} // namespace test_sumcheck_round diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp index b81d6a421785..5d2a6a71ea26 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.hpp @@ -110,8 +110,7 @@ template class UltraComposer_ { */ MergeVerifier_ create_merge_verifier() { return MergeVerifier_(); } - ProtoGalaxyProver_ create_folding_prover(const std::vector>& instances, - const std::shared_ptr& commitment_key) + ProtoGalaxyProver_ create_folding_prover(const std::vector>& instances) { ProtoGalaxyProver_ output_state(instances, commitment_key); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp index 3ab5595dcddb..09a1bdb72f3b 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_composer.test.cpp @@ -16,12 +16,11 @@ #include #include +using namespace bb; using namespace bb::honk; -namespace test_ultra_honk_composer { - namespace { -auto& engine = numeric::random::get_debug_engine(); +auto& engine = numeric::get_debug_randomness(); } std::vector add_variables(auto& circuit_builder, std::vector variables) @@ -53,9 +52,6 @@ void ensure_non_zero(auto& polynomial) } class UltraHonkComposerTests : public ::testing::Test { - public: - using fr = bb::fr; - protected: static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } }; @@ -69,7 +65,7 @@ class UltraHonkComposerTests : public ::testing::Test { */ TEST_F(UltraHonkComposerTests, ANonZeroPolynomialIsAGoodPolynomial) { - auto circuit_builder = bb::UltraCircuitBuilder(); + auto circuit_builder = UltraCircuitBuilder(); auto composer = UltraComposer(); auto instance = composer.create_instance(circuit_builder); @@ -96,7 +92,7 @@ TEST_F(UltraHonkComposerTests, ANonZeroPolynomialIsAGoodPolynomial) */ TEST_F(UltraHonkComposerTests, PublicInputs) { - auto builder = bb::UltraCircuitBuilder(); + auto builder = UltraCircuitBuilder(); size_t num_gates = 10; // Add some arbitrary arithmetic gates that utilize public inputs @@ -120,7 +116,7 @@ TEST_F(UltraHonkComposerTests, PublicInputs) TEST_F(UltraHonkComposerTests, XorConstraint) { - auto circuit_builder = bb::UltraCircuitBuilder(); + auto circuit_builder = UltraCircuitBuilder(); uint32_t left_value = engine.get_random_uint32(); uint32_t right_value = engine.get_random_uint32(); @@ -148,9 +144,9 @@ TEST_F(UltraHonkComposerTests, XorConstraint) TEST_F(UltraHonkComposerTests, create_gates_from_plookup_accumulators) { - auto circuit_builder = bb::UltraCircuitBuilder(); + auto circuit_builder = UltraCircuitBuilder(); - bb::fr input_value = fr::random_element(); + fr input_value = fr::random_element(); const fr input_lo = static_cast(input_value).slice(0, plookup::fixed_base::table::BITS_PER_LO_SCALAR); const auto input_lo_index = circuit_builder.add_variable(input_lo); @@ -215,7 +211,7 @@ TEST_F(UltraHonkComposerTests, create_gates_from_plookup_accumulators) TEST_F(UltraHonkComposerTests, test_no_lookup_proof) { - auto circuit_builder = bb::UltraCircuitBuilder(); + auto circuit_builder = UltraCircuitBuilder(); for (size_t i = 0; i < 16; ++i) { for (size_t j = 0; j < 16; ++j) { @@ -240,7 +236,7 @@ TEST_F(UltraHonkComposerTests, test_elliptic_gate) { typedef grumpkin::g1::affine_element affine_element; typedef grumpkin::g1::element element; - auto circuit_builder = bb::UltraCircuitBuilder(); + auto circuit_builder = UltraCircuitBuilder(); affine_element p1 = affine_element::random_element(); affine_element p2 = affine_element::random_element(); @@ -272,7 +268,7 @@ TEST_F(UltraHonkComposerTests, test_elliptic_gate) TEST_F(UltraHonkComposerTests, non_trivial_tag_permutation) { - auto circuit_builder = bb::UltraCircuitBuilder(); + auto circuit_builder = UltraCircuitBuilder(); fr a = fr::random_element(); fr b = -a; @@ -300,7 +296,7 @@ TEST_F(UltraHonkComposerTests, non_trivial_tag_permutation) TEST_F(UltraHonkComposerTests, non_trivial_tag_permutation_and_cycles) { - auto circuit_builder = bb::UltraCircuitBuilder(); + auto circuit_builder = UltraCircuitBuilder(); fr a = fr::random_element(); fr c = -a; @@ -339,7 +335,7 @@ TEST_F(UltraHonkComposerTests, non_trivial_tag_permutation_and_cycles) TEST_F(UltraHonkComposerTests, bad_tag_permutation) { { - auto circuit_builder = bb::UltraCircuitBuilder(); + auto circuit_builder = UltraCircuitBuilder(); fr a = fr::random_element(); fr b = -a; @@ -364,7 +360,7 @@ TEST_F(UltraHonkComposerTests, bad_tag_permutation) } // Same as above but without tag creation to check reason of failure is really tag mismatch { - auto circuit_builder = bb::UltraCircuitBuilder(); + auto circuit_builder = UltraCircuitBuilder(); fr a = fr::random_element(); fr b = -a; @@ -384,7 +380,7 @@ TEST_F(UltraHonkComposerTests, bad_tag_permutation) TEST_F(UltraHonkComposerTests, sort_widget) { - auto circuit_builder = bb::UltraCircuitBuilder(); + auto circuit_builder = UltraCircuitBuilder(); fr a = fr::one(); fr b = fr(2); fr c = fr(3); @@ -412,7 +408,7 @@ TEST_F(UltraHonkComposerTests, sort_with_edges_gate) fr h = fr(8); { - auto circuit_builder = bb::UltraCircuitBuilder(); + auto circuit_builder = UltraCircuitBuilder(); auto a_idx = circuit_builder.add_variable(a); auto b_idx = circuit_builder.add_variable(b); auto c_idx = circuit_builder.add_variable(c); @@ -429,7 +425,7 @@ TEST_F(UltraHonkComposerTests, sort_with_edges_gate) } { - auto circuit_builder = bb::UltraCircuitBuilder(); + auto circuit_builder = UltraCircuitBuilder(); auto a_idx = circuit_builder.add_variable(a); auto b_idx = circuit_builder.add_variable(b); auto c_idx = circuit_builder.add_variable(c); @@ -445,7 +441,7 @@ TEST_F(UltraHonkComposerTests, sort_with_edges_gate) prove_and_verify(circuit_builder, composer, /*expected_result=*/false); } { - auto circuit_builder = bb::UltraCircuitBuilder(); + auto circuit_builder = UltraCircuitBuilder(); auto a_idx = circuit_builder.add_variable(a); auto b_idx = circuit_builder.add_variable(b); auto c_idx = circuit_builder.add_variable(c); @@ -461,7 +457,7 @@ TEST_F(UltraHonkComposerTests, sort_with_edges_gate) prove_and_verify(circuit_builder, composer, /*expected_result=*/false); } { - auto circuit_builder = bb::UltraCircuitBuilder(); + auto circuit_builder = UltraCircuitBuilder(); auto a_idx = circuit_builder.add_variable(a); auto c_idx = circuit_builder.add_variable(c); auto d_idx = circuit_builder.add_variable(d); @@ -477,7 +473,7 @@ TEST_F(UltraHonkComposerTests, sort_with_edges_gate) prove_and_verify(circuit_builder, composer, /*expected_result=*/false); } { - auto circuit_builder = bb::UltraCircuitBuilder(); + auto circuit_builder = UltraCircuitBuilder(); auto idx = add_variables(circuit_builder, { 1, 2, 5, 6, 7, 10, 11, 13, 16, 17, 20, 22, 22, 25, 26, 29, 29, 32, 32, 33, 35, 38, 39, 39, 42, 42, 43, 45 }); circuit_builder.create_sort_constraint_with_edges(idx, 1, 45); @@ -486,7 +482,7 @@ TEST_F(UltraHonkComposerTests, sort_with_edges_gate) prove_and_verify(circuit_builder, composer, /*expected_result=*/true); } { - auto circuit_builder = bb::UltraCircuitBuilder(); + auto circuit_builder = UltraCircuitBuilder(); auto idx = add_variables(circuit_builder, { 1, 2, 5, 6, 7, 10, 11, 13, 16, 17, 20, 22, 22, 25, 26, 29, 29, 32, 32, 33, 35, 38, 39, 39, 42, 42, 43, 45 }); circuit_builder.create_sort_constraint_with_edges(idx, 1, 29); @@ -499,7 +495,7 @@ TEST_F(UltraHonkComposerTests, sort_with_edges_gate) TEST_F(UltraHonkComposerTests, range_constraint) { { - auto circuit_builder = bb::UltraCircuitBuilder(); + auto circuit_builder = UltraCircuitBuilder(); auto indices = add_variables(circuit_builder, { 1, 2, 3, 4, 5, 6, 7, 8 }); for (size_t i = 0; i < indices.size(); i++) { circuit_builder.create_new_range_constraint(indices[i], 8); @@ -511,7 +507,7 @@ TEST_F(UltraHonkComposerTests, range_constraint) prove_and_verify(circuit_builder, composer, /*expected_result=*/true); } { - auto circuit_builder = bb::UltraCircuitBuilder(); + auto circuit_builder = UltraCircuitBuilder(); auto indices = add_variables(circuit_builder, { 3 }); for (size_t i = 0; i < indices.size(); i++) { circuit_builder.create_new_range_constraint(indices[i], 3); @@ -523,7 +519,7 @@ TEST_F(UltraHonkComposerTests, range_constraint) prove_and_verify(circuit_builder, composer, /*expected_result=*/true); } { - auto circuit_builder = bb::UltraCircuitBuilder(); + auto circuit_builder = UltraCircuitBuilder(); auto indices = add_variables(circuit_builder, { 1, 2, 3, 4, 5, 6, 8, 25 }); for (size_t i = 0; i < indices.size(); i++) { circuit_builder.create_new_range_constraint(indices[i], 8); @@ -534,7 +530,7 @@ TEST_F(UltraHonkComposerTests, range_constraint) prove_and_verify(circuit_builder, composer, /*expected_result=*/false); } { - auto circuit_builder = bb::UltraCircuitBuilder(); + auto circuit_builder = UltraCircuitBuilder(); auto indices = add_variables(circuit_builder, { 1, 2, 3, 4, 5, 6, 10, 8, 15, 11, 32, 21, 42, 79, 16, 10, 3, 26, 19, 51 }); for (size_t i = 0; i < indices.size(); i++) { @@ -546,7 +542,7 @@ TEST_F(UltraHonkComposerTests, range_constraint) prove_and_verify(circuit_builder, composer, /*expected_result=*/true); } { - auto circuit_builder = bb::UltraCircuitBuilder(); + auto circuit_builder = UltraCircuitBuilder(); auto indices = add_variables(circuit_builder, { 1, 2, 3, 80, 5, 6, 29, 8, 15, 11, 32, 21, 42, 79, 16, 10, 3, 26, 13, 14 }); for (size_t i = 0; i < indices.size(); i++) { @@ -558,7 +554,7 @@ TEST_F(UltraHonkComposerTests, range_constraint) prove_and_verify(circuit_builder, composer, /*expected_result=*/false); } { - auto circuit_builder = bb::UltraCircuitBuilder(); + auto circuit_builder = UltraCircuitBuilder(); auto indices = add_variables(circuit_builder, { 1, 0, 3, 80, 5, 6, 29, 8, 15, 11, 32, 21, 42, 79, 16, 10, 3, 26, 13, 14 }); for (size_t i = 0; i < indices.size(); i++) { @@ -573,7 +569,7 @@ TEST_F(UltraHonkComposerTests, range_constraint) TEST_F(UltraHonkComposerTests, range_with_gates) { - auto circuit_builder = bb::UltraCircuitBuilder(); + auto circuit_builder = UltraCircuitBuilder(); auto idx = add_variables(circuit_builder, { 1, 2, 3, 4, 5, 6, 7, 8 }); for (size_t i = 0; i < idx.size(); i++) { circuit_builder.create_new_range_constraint(idx[i], 8); @@ -592,7 +588,7 @@ TEST_F(UltraHonkComposerTests, range_with_gates) TEST_F(UltraHonkComposerTests, range_with_gates_where_range_is_not_a_power_of_two) { - auto circuit_builder = bb::UltraCircuitBuilder(); + auto circuit_builder = UltraCircuitBuilder(); auto idx = add_variables(circuit_builder, { 1, 2, 3, 4, 5, 6, 7, 8 }); for (size_t i = 0; i < idx.size(); i++) { circuit_builder.create_new_range_constraint(idx[i], 12); @@ -613,7 +609,7 @@ TEST_F(UltraHonkComposerTests, sort_widget_complex) { { - auto circuit_builder = bb::UltraCircuitBuilder(); + auto circuit_builder = UltraCircuitBuilder(); std::vector a = { 1, 3, 4, 7, 7, 8, 11, 14, 15, 15, 18, 19, 21, 21, 24, 25, 26, 27, 30, 32 }; std::vector ind; for (size_t i = 0; i < a.size(); i++) @@ -625,7 +621,7 @@ TEST_F(UltraHonkComposerTests, sort_widget_complex) } { - auto circuit_builder = bb::UltraCircuitBuilder(); + auto circuit_builder = UltraCircuitBuilder(); std::vector a = { 1, 3, 4, 7, 7, 8, 16, 14, 15, 15, 18, 19, 21, 21, 24, 25, 26, 27, 30, 32 }; std::vector ind; for (size_t i = 0; i < a.size(); i++) @@ -639,7 +635,7 @@ TEST_F(UltraHonkComposerTests, sort_widget_complex) TEST_F(UltraHonkComposerTests, sort_widget_neg) { - auto circuit_builder = bb::UltraCircuitBuilder(); + auto circuit_builder = UltraCircuitBuilder(); fr a = fr::one(); fr b = fr(2); fr c = fr(3); @@ -657,7 +653,7 @@ TEST_F(UltraHonkComposerTests, sort_widget_neg) TEST_F(UltraHonkComposerTests, composed_range_constraint) { - auto circuit_builder = bb::UltraCircuitBuilder(); + auto circuit_builder = UltraCircuitBuilder(); auto c = fr::random_element(); auto d = uint256_t(c).slice(0, 133); auto e = fr(d); @@ -671,8 +667,8 @@ TEST_F(UltraHonkComposerTests, composed_range_constraint) TEST_F(UltraHonkComposerTests, non_native_field_multiplication) { - using fq = bb::fq; - auto circuit_builder = bb::UltraCircuitBuilder(); + using fq = fq; + auto circuit_builder = UltraCircuitBuilder(); fq a = fq::random_element(); fq b = fq::random_element(); @@ -716,7 +712,7 @@ TEST_F(UltraHonkComposerTests, non_native_field_multiplication) const auto q_indices = get_limb_witness_indices(split_into_limbs(uint256_t(q))); const auto r_indices = get_limb_witness_indices(split_into_limbs(uint256_t(r))); - bb::non_native_field_witnesses inputs{ + non_native_field_witnesses inputs{ a_indices, b_indices, q_indices, r_indices, modulus_limbs, fr(uint256_t(modulus)), }; const auto [lo_1_idx, hi_1_idx] = circuit_builder.evaluate_non_native_field_multiplication(inputs); @@ -728,7 +724,7 @@ TEST_F(UltraHonkComposerTests, non_native_field_multiplication) TEST_F(UltraHonkComposerTests, rom) { - auto circuit_builder = bb::UltraCircuitBuilder(); + auto circuit_builder = UltraCircuitBuilder(); uint32_t rom_values[8]{ circuit_builder.add_variable(fr::random_element()), circuit_builder.add_variable(fr::random_element()), @@ -770,7 +766,7 @@ TEST_F(UltraHonkComposerTests, rom) TEST_F(UltraHonkComposerTests, ram) { - auto circuit_builder = bb::UltraCircuitBuilder(); + auto circuit_builder = UltraCircuitBuilder(); uint32_t ram_values[8]{ circuit_builder.add_variable(fr::random_element()), circuit_builder.add_variable(fr::random_element()), @@ -834,7 +830,7 @@ TEST_F(UltraHonkComposerTests, ram) TEST_F(UltraHonkComposerTests, range_checks_on_duplicates) { - auto circuit_builder = bb::UltraCircuitBuilder(); + auto circuit_builder = UltraCircuitBuilder(); uint32_t a = circuit_builder.add_variable(100); uint32_t b = circuit_builder.add_variable(100); @@ -874,7 +870,7 @@ TEST_F(UltraHonkComposerTests, range_checks_on_duplicates) // before range constraints are applied to it. TEST_F(UltraHonkComposerTests, range_constraint_small_variable) { - auto circuit_builder = bb::UltraCircuitBuilder(); + auto circuit_builder = UltraCircuitBuilder(); uint16_t mask = (1 << 8) - 1; int a = engine.get_random_uint16() & mask; @@ -890,6 +886,4 @@ TEST_F(UltraHonkComposerTests, range_constraint_small_variable) auto composer = UltraComposer(); prove_and_verify(circuit_builder, composer, /*expected_result=*/true); -} - -} // namespace test_ultra_honk_composer \ No newline at end of file +} \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp index 2c5c6ccb1dce..9fe521be717d 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp @@ -6,13 +6,14 @@ #include "barretenberg/ultra_honk/ultra_composer.hpp" #include +using namespace bb; using namespace bb::honk; class UltraTranscriptTests : public ::testing::Test { public: static void SetUpTestSuite() { bb::srs::init_crs_factory("../srs_db/ignition"); } - using Flavor = bb::honk::flavor::Ultra; + using Flavor = honk::flavor::Ultra; using FF = Flavor::FF; /** diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_alu_trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_alu_trace.cpp new file mode 100644 index 000000000000..7da44d916bd4 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_alu_trace.cpp @@ -0,0 +1,347 @@ +#include "AvmMini_alu_trace.hpp" + +namespace avm_trace { + +/** + * @brief Constructor of Alu trace builder of AVM. Only serves to set the capacity of the + * underlying trace. + */ +AvmMiniAluTraceBuilder::AvmMiniAluTraceBuilder() +{ + alu_trace.reserve(AVM_TRACE_SIZE); +} + +/** + * @brief Resetting the internal state so that a new Alu trace can be rebuilt using the same object. + * + */ +void AvmMiniAluTraceBuilder::reset() +{ + alu_trace.clear(); +} + +/** + * @brief Prepare the Alu trace to be incorporated into the main trace. + * + * @return The Alu trace (which is moved). + */ +std::vector AvmMiniAluTraceBuilder::finalize() +{ + return std::move(alu_trace); +} + +/** + * @brief Build Alu trace and compute the result of an addition of type defined by in_tag. + * Besides the addition calculation, for the types u8, u16, u32, u64, and u128, we + * have to store the result of the addition modulo 2^128 decomposed into 8-bit and + * 16-bit registers, i.e., + * a+b mod. 2^128 = alu_u8_r0 + alu_u8_r1 * 2^8 + alu_u16_r0 * 2^16 ... + alu_u16_r6 * 2^112 + * + * @param a Left operand of the addition + * @param b Right operand of the addition + * @param in_tag Instruction tag defining the number of bits on which the addition applies. + * It is assumed that the caller never uses the type u0. + * @param clk Clock referring to the operation in the main trace. + * + * @return FF The result of the addition casted in a finite field element + */ +FF AvmMiniAluTraceBuilder::add(FF const& a, FF const& b, AvmMemoryTag in_tag, uint32_t const clk) +{ + FF c{}; + bool carry = false; + uint8_t alu_u8_r0{}; + uint8_t alu_u8_r1{}; + std::array alu_u16_reg{}; + + uint128_t a_u128{ a }; + uint128_t b_u128{ b }; + uint128_t c_u128 = a_u128 + b_u128; + + switch (in_tag) { + case AvmMemoryTag::FF: + c = a + b; + break; + case AvmMemoryTag::U8: + c = FF{ static_cast(c_u128) }; + break; + case AvmMemoryTag::U16: + c = FF{ static_cast(c_u128) }; + break; + case AvmMemoryTag::U32: + c = FF{ static_cast(c_u128) }; + break; + case AvmMemoryTag::U64: + c = FF{ static_cast(c_u128) }; + break; + case AvmMemoryTag::U128: + c = FF{ uint256_t::from_uint128(c_u128) }; + break; + case AvmMemoryTag::U0: // Unsupported as instruction tag + return FF{ 0 }; + } + + if (in_tag != AvmMemoryTag::FF) { + // a_u128 + b_u128 >= 2^128 <==> c_u128 < a_u128 + if (c_u128 < a_u128) { + carry = true; + } + + uint128_t c_trunc_128 = c_u128; + alu_u8_r0 = static_cast(c_trunc_128); + c_trunc_128 >>= 8; + alu_u8_r1 = static_cast(c_trunc_128); + c_trunc_128 >>= 8; + + for (size_t i = 0; i < 7; i++) { + alu_u16_reg.at(i) = static_cast(c_trunc_128); + c_trunc_128 >>= 16; + } + } + + alu_trace.push_back(AvmMiniAluTraceBuilder::AluTraceEntry{ + .alu_clk = clk, + .alu_op_add = true, + .alu_ff_tag = in_tag == AvmMemoryTag::FF, + .alu_u8_tag = in_tag == AvmMemoryTag::U8, + .alu_u16_tag = in_tag == AvmMemoryTag::U16, + .alu_u32_tag = in_tag == AvmMemoryTag::U32, + .alu_u64_tag = in_tag == AvmMemoryTag::U64, + .alu_u128_tag = in_tag == AvmMemoryTag::U128, + .alu_ia = a, + .alu_ib = b, + .alu_ic = c, + .alu_cf = carry, + .alu_u8_r0 = alu_u8_r0, + .alu_u8_r1 = alu_u8_r1, + .alu_u16_reg = alu_u16_reg, + }); + + return c; +} + +/** + * @brief Build Alu trace and compute the result of a subtraction of type defined by in_tag. + * Besides the subtraction calculation, for the types u8, u16, u32, u64, and u128, we + * have to store the result of the subtraction modulo 2^128 decomposed into 8-bit and + * 16-bit registers, i.e., + * a-b mod. 2^128 = alu_u8_r0 + alu_u8_r1 * 2^8 + alu_u16_r0 * 2^16 ... + alu_u16_r6 * 2^112 + * + * @param a Left operand of the subtraction + * @param b Right operand of the subtraction + * @param in_tag Instruction tag defining the number of bits on which the subtracttion applies. + * It is assumed that the caller never uses the type u0. + * @param clk Clock referring to the operation in the main trace. + * + * @return FF The result of the subtraction casted in a finite field element + */ +FF AvmMiniAluTraceBuilder::sub(FF const& a, FF const& b, AvmMemoryTag in_tag, uint32_t const clk) +{ + FF c{}; + bool carry = false; + uint8_t alu_u8_r0{}; + uint8_t alu_u8_r1{}; + std::array alu_u16_reg{}; + uint128_t a_u128{ a }; + uint128_t b_u128{ b }; + uint128_t c_u128 = a_u128 - b_u128; + + switch (in_tag) { + case AvmMemoryTag::FF: + c = a - b; + break; + case AvmMemoryTag::U8: + c = FF{ static_cast(c_u128) }; + break; + case AvmMemoryTag::U16: + c = FF{ static_cast(c_u128) }; + break; + case AvmMemoryTag::U32: + c = FF{ static_cast(c_u128) }; + break; + case AvmMemoryTag::U64: + c = FF{ static_cast(c_u128) }; + break; + case AvmMemoryTag::U128: + c = FF{ uint256_t::from_uint128(c_u128) }; + break; + case AvmMemoryTag::U0: // Unsupported as instruction tag + return FF{ 0 }; + } + + if (in_tag != AvmMemoryTag::FF) { + // Underflow when a_u128 < b_u128 + if (a_u128 < b_u128) { + carry = true; + } + + uint128_t c_trunc_128 = c_u128; + alu_u8_r0 = static_cast(c_trunc_128); + c_trunc_128 >>= 8; + alu_u8_r1 = static_cast(c_trunc_128); + c_trunc_128 >>= 8; + + for (size_t i = 0; i < 7; i++) { + alu_u16_reg.at(i) = static_cast(c_trunc_128); + c_trunc_128 >>= 16; + } + } + + alu_trace.push_back(AvmMiniAluTraceBuilder::AluTraceEntry{ + .alu_clk = clk, + .alu_op_sub = true, + .alu_ff_tag = in_tag == AvmMemoryTag::FF, + .alu_u8_tag = in_tag == AvmMemoryTag::U8, + .alu_u16_tag = in_tag == AvmMemoryTag::U16, + .alu_u32_tag = in_tag == AvmMemoryTag::U32, + .alu_u64_tag = in_tag == AvmMemoryTag::U64, + .alu_u128_tag = in_tag == AvmMemoryTag::U128, + .alu_ia = a, + .alu_ib = b, + .alu_ic = c, + .alu_cf = carry, + .alu_u8_r0 = alu_u8_r0, + .alu_u8_r1 = alu_u8_r1, + .alu_u16_reg = alu_u16_reg, + }); + + return c; +} + +/** + * @brief Build Alu trace and compute the result of an multiplication of type defined by in_tag. + * + * @param a Left operand of the multiplication + * @param b Right operand of the multiplication + * @param in_tag Instruction tag defining the number of bits on which the multiplication applies. + * It is assumed that the caller never uses the type u0. + * @param clk Clock referring to the operation in the main trace. + * + * @return FF The result of the multiplication casted in a finite field element + */ +FF AvmMiniAluTraceBuilder::mul(FF const& a, FF const& b, AvmMemoryTag in_tag, uint32_t const clk) +{ + FF c{}; + bool carry = false; + uint8_t alu_u8_r0{}; + uint8_t alu_u8_r1{}; + + std::array alu_u16_reg{}; + + uint128_t a_u128{ a }; + uint128_t b_u128{ b }; + uint128_t c_u128 = a_u128 * b_u128; // Multiplication over the integers (not mod. 2^64) + + switch (in_tag) { + case AvmMemoryTag::FF: + c = a * b; + break; + case AvmMemoryTag::U8: + c = FF{ static_cast(c_u128) }; + break; + case AvmMemoryTag::U16: + c = FF{ static_cast(c_u128) }; + break; + case AvmMemoryTag::U32: + c = FF{ static_cast(c_u128) }; + break; + case AvmMemoryTag::U64: + c = FF{ static_cast(c_u128) }; + break; + case AvmMemoryTag::U128: { + uint256_t a_u256{ a }; + uint256_t b_u256{ b }; + uint256_t c_u256 = a_u256 * b_u256; // Multiplication over the integers (not mod. 2^128) + + uint128_t a_u128{ a_u256 }; + uint128_t b_u128{ b_u256 }; + + uint128_t c_u128 = a_u128 * b_u128; + + // Decompose a_u128 and b_u128 over 8 16-bit registers. + std::array alu_u16_reg_a{}; + std::array alu_u16_reg_b{}; + uint128_t a_trunc_128 = a_u128; + uint128_t b_trunc_128 = b_u128; + + for (size_t i = 0; i < 8; i++) { + alu_u16_reg_a.at(i) = static_cast(a_trunc_128); + alu_u16_reg_b.at(i) = static_cast(b_trunc_128); + a_trunc_128 >>= 16; + b_trunc_128 >>= 16; + } + + // Represent a, b with 64-bit limbs: a = a_l + 2^64 * a_h, b = b_l + 2^64 * b_h, + // c_high := 2^128 * a_h * b_h + uint256_t c_high = ((a_u256 >> 64) * (b_u256 >> 64)) << 128; + + // From PIL relation in alu_chip.pil, we need to determine the bit CF and 64-bit value R' in + // a * b_l + a_l * b_h * 2^64 = (CF * 2^64 + R') * 2^128 + c + // LHS is c_u256 - c_high + + // CF bit + carry = ((c_u256 - c_high) >> 192) > 0; + // R' value + uint64_t alu_u64_r0 = static_cast(((c_u256 - c_high) >> 128) & uint256_t(UINT64_MAX)); + + c = FF{ uint256_t::from_uint128(c_u128) }; + + alu_trace.push_back(AvmMiniAluTraceBuilder::AluTraceEntry{ + .alu_clk = clk, + .alu_op_mul = true, + .alu_u128_tag = in_tag == AvmMemoryTag::U128, + .alu_ia = a, + .alu_ib = b, + .alu_ic = c, + .alu_cf = carry, + .alu_u16_reg = alu_u16_reg_a, + .alu_u64_r0 = alu_u64_r0, + }); + + alu_trace.push_back(AvmMiniAluTraceBuilder::AluTraceEntry{ + .alu_u16_reg = alu_u16_reg_b, + }); + + return c; + } + case AvmMemoryTag::U0: // Unsupported as instruction tag + return FF{ 0 }; + } + + // Following code executed for: u8, u16, u32, u64 (u128 returned handled specifically) + if (in_tag != AvmMemoryTag::FF) { + // Decomposition of c_u128 into 8-bit and 16-bit registers as follows: + // alu_u8_r0 + alu_u8_r1 * 2^8 + alu_u16_r0 * 2^16 ... + alu_u16_r6 * 2^112 + uint128_t c_trunc_128 = c_u128; + alu_u8_r0 = static_cast(c_trunc_128); + c_trunc_128 >>= 8; + alu_u8_r1 = static_cast(c_trunc_128); + c_trunc_128 >>= 8; + + for (size_t i = 0; i < 7; i++) { + alu_u16_reg.at(i) = static_cast(c_trunc_128); + c_trunc_128 >>= 16; + } + } + + // Following code executed for: ff, u8, u16, u32, u64 (u128 returned handled specifically) + alu_trace.push_back(AvmMiniAluTraceBuilder::AluTraceEntry{ + .alu_clk = clk, + .alu_op_mul = true, + .alu_ff_tag = in_tag == AvmMemoryTag::FF, + .alu_u8_tag = in_tag == AvmMemoryTag::U8, + .alu_u16_tag = in_tag == AvmMemoryTag::U16, + .alu_u32_tag = in_tag == AvmMemoryTag::U32, + .alu_u64_tag = in_tag == AvmMemoryTag::U64, + .alu_ia = a, + .alu_ib = b, + .alu_ic = c, + .alu_cf = carry, + .alu_u8_r0 = alu_u8_r0, + .alu_u8_r1 = alu_u8_r1, + .alu_u16_reg = alu_u16_reg, + }); + + return c; +} + +} // namespace avm_trace diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_alu_trace.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_alu_trace.hpp new file mode 100644 index 000000000000..cda0263cb8da --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_alu_trace.hpp @@ -0,0 +1,49 @@ +#pragma once + +#include "AvmMini_common.hpp" + +namespace avm_trace { + +class AvmMiniAluTraceBuilder { + + public: + struct AluTraceEntry { + uint32_t alu_clk{}; + + bool alu_op_add = false; + bool alu_op_sub = false; + bool alu_op_mul = false; + + bool alu_ff_tag = false; + bool alu_u8_tag = false; + bool alu_u16_tag = false; + bool alu_u32_tag = false; + bool alu_u64_tag = false; + bool alu_u128_tag = false; + + FF alu_ia{}; + FF alu_ib{}; + FF alu_ic{}; + + bool alu_cf = false; + + uint8_t alu_u8_r0{}; + uint8_t alu_u8_r1{}; + + std::array alu_u16_reg{}; + + uint64_t alu_u64_r0{}; + }; + + AvmMiniAluTraceBuilder(); + void reset(); + std::vector finalize(); + + FF add(FF const& a, FF const& b, AvmMemoryTag in_tag, uint32_t clk); + FF sub(FF const& a, FF const& b, AvmMemoryTag in_tag, uint32_t clk); + FF mul(FF const& a, FF const& b, AvmMemoryTag in_tag, uint32_t clk); + + private: + std::vector alu_trace; +}; +} // namespace avm_trace \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_common.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_common.hpp index 8588b632b87c..10b3c3473304 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_common.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_common.hpp @@ -11,7 +11,7 @@ namespace avm_trace { // Number of rows static const size_t AVM_TRACE_SIZE = 256; -enum class IntermRegister : uint32_t { ia = 0, ib = 1, ic = 2 }; -enum class AvmMemoryTag : uint32_t { u0 = 0, u8 = 1, u16 = 2, u32 = 3, u64 = 4, u128 = 5, ff = 6 }; +enum class IntermRegister : uint32_t { IA = 0, IB = 1, IC = 2 }; +enum class AvmMemoryTag : uint32_t { U0 = 0, U8 = 1, U16 = 2, U32 = 3, U64 = 4, U128 = 5, FF = 6 }; } // namespace avm_trace \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_helper.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_helper.cpp index 207485ac63d6..9e1fd096c895 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_helper.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_helper.cpp @@ -39,6 +39,12 @@ void log_avmMini_trace(std::vector const& trace, size_t beg, size_t end) info("internal_return: ", trace.at(i).avmMini_sel_internal_return); info("internal_return_ptr:", trace.at(i).avmMini_internal_return_ptr); + info("=======ALU TRACE====================================================================="); + info("alu_clk ", trace.at(i).aluChip_alu_clk); + info("alu_ia ", trace.at(i).aluChip_alu_ia); + info("alu_ib ", trace.at(i).aluChip_alu_ib); + info("alu_ic ", trace.at(i).aluChip_alu_ic); + info("=======MAIN TRACE===================================================================="); info("ia: ", trace.at(i).avmMini_ia); info("ib: ", trace.at(i).avmMini_ib); diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_mem_trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_mem_trace.cpp index f55d7e9d8b6f..557244116b15 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_mem_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_mem_trace.cpp @@ -21,38 +21,6 @@ void AvmMiniMemTraceBuilder::reset() memory.fill(FF(0)); } -/** - * @brief A comparator on MemoryTraceEntry to be used by sorting algorithm. We sort first by - * ascending address (m_addr), then by clock (m_clk) and finally sub-clock (m_sub_clk). - * - * @param left The left hand side memory trace entry - * @param right The right hand side memory trace entry - * - * @return A boolean indicating whether left member is smaller than right member. - */ -bool AvmMiniMemTraceBuilder::compare_mem_entries(const MemoryTraceEntry& left, const MemoryTraceEntry& right) -{ - if (left.m_addr < right.m_addr) { - return true; - } - - if (left.m_addr > right.m_addr) { - return false; - } - - if (left.m_clk < right.m_clk) { - return true; - } - - if (left.m_clk > right.m_clk) { - return false; - } - - // No safeguard in case they are equal. The caller should ensure this property. - // Otherwise, relation will not be satisfied. - return left.m_sub_clk < right.m_sub_clk; -} - /** * @brief Prepare the memory trace to be incorporated into the main trace. * @@ -61,7 +29,7 @@ bool AvmMiniMemTraceBuilder::compare_mem_entries(const MemoryTraceEntry& left, c std::vector AvmMiniMemTraceBuilder::finalize() { // Sort memTrace - std::sort(mem_trace.begin(), mem_trace.end(), compare_mem_entries); + std::sort(mem_trace.begin(), mem_trace.end()); return std::move(mem_trace); } @@ -144,19 +112,19 @@ bool AvmMiniMemTraceBuilder::load_in_mem_trace( { uint32_t sub_clk = 0; switch (interm_reg) { - case IntermRegister::ia: + case IntermRegister::IA: sub_clk = SUB_CLK_LOAD_A; break; - case IntermRegister::ib: + case IntermRegister::IB: sub_clk = SUB_CLK_LOAD_B; break; - case IntermRegister::ic: + case IntermRegister::IC: sub_clk = SUB_CLK_LOAD_C; break; } auto m_tag = memory_tag.at(addr); - if (m_tag == AvmMemoryTag::u0 || m_tag == m_in_tag) { + if (m_tag == AvmMemoryTag::U0 || m_tag == m_in_tag) { insert_in_mem_trace(clk, sub_clk, addr, val, m_in_tag, false); return true; } @@ -181,13 +149,13 @@ void AvmMiniMemTraceBuilder::store_in_mem_trace( { uint32_t sub_clk = 0; switch (interm_reg) { - case IntermRegister::ia: + case IntermRegister::IA: sub_clk = SUB_CLK_STORE_A; break; - case IntermRegister::ib: + case IntermRegister::IB: sub_clk = SUB_CLK_STORE_B; break; - case IntermRegister::ic: + case IntermRegister::IC: sub_clk = SUB_CLK_STORE_C; break; } diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_mem_trace.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_mem_trace.hpp index 6a06dcee1fb1..0cf1bcaca48a 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_mem_trace.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_mem_trace.hpp @@ -16,21 +16,48 @@ class AvmMiniMemTraceBuilder { static const uint32_t SUB_CLK_STORE_C = 5; struct MemoryTraceEntry { - uint32_t m_clk; - uint32_t m_sub_clk; - uint32_t m_addr; + uint32_t m_clk{}; + uint32_t m_sub_clk{}; + uint32_t m_addr{}; FF m_val{}; - AvmMemoryTag m_tag; - AvmMemoryTag m_in_tag; + AvmMemoryTag m_tag{}; + AvmMemoryTag m_in_tag{}; bool m_rw = false; bool m_tag_err = false; FF m_one_min_inv{}; + + /** + * @brief A comparator on MemoryTraceEntry to be used by sorting algorithm. We sort first by + * ascending address (m_addr), then by clock (m_clk) and finally sub-clock (m_sub_clk). + */ + bool operator<(const MemoryTraceEntry& other) const + { + if (m_addr < other.m_addr) { + return true; + } + + if (m_addr > other.m_addr) { + return false; + } + + if (m_clk < other.m_clk) { + return true; + } + + if (m_clk > other.m_clk) { + return false; + } + + // No safeguard in case they are equal. The caller should ensure this property. + // Otherwise, relation will not be satisfied. + return m_sub_clk < other.m_sub_clk; + } }; // Structure to return value and tag matching boolean after a memory read. struct MemRead { - bool tag_match; - FF val; + bool tag_match = false; + FF val{}; }; AvmMiniMemTraceBuilder(); @@ -49,8 +76,6 @@ class AvmMiniMemTraceBuilder { std::array memory_tag{}; // The tag of the corresponding memory // entry (aligned with the memory array). - static bool compare_mem_entries(const MemoryTraceEntry& left, const MemoryTraceEntry& right); - void insert_in_mem_trace( uint32_t m_clk, uint32_t m_sub_clk, uint32_t m_addr, FF const& m_val, AvmMemoryTag m_in_tag, bool m_rw); void load_mismatch_tag_in_mem_trace(uint32_t m_clk, diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_trace.cpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_trace.cpp index c38a615560fa..771a1590ea1f 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_trace.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_trace.cpp @@ -29,9 +29,10 @@ void AvmMiniTraceBuilder::reset() { main_trace.clear(); mem_trace_builder.reset(); + alu_trace_builder.reset(); } -/** TODO: Implement for non finite field types +/** * @brief Addition with direct memory access. * * @param a_offset An index in memory pointing to the first operand of the addition. @@ -44,17 +45,17 @@ void AvmMiniTraceBuilder::add(uint32_t a_offset, uint32_t b_offset, uint32_t dst auto clk = static_cast(main_trace.size()); // Reading from memory and loading into ia resp. ib. - auto read_a = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::ia, a_offset, in_tag); - auto read_b = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::ib, b_offset, in_tag); + auto read_a = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::IA, a_offset, in_tag); + auto read_b = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::IB, b_offset, in_tag); bool tag_match = read_a.tag_match && read_b.tag_match; // a + b = c - FF a = read_a.val; - FF b = read_b.val; - FF c = a + b; + FF a = tag_match ? read_a.val : FF(0); + FF b = tag_match ? read_b.val : FF(0); + FF c = alu_trace_builder.add(a, b, in_tag, clk); // Write into memory value c from intermediate register ic. - mem_trace_builder.write_into_memory(clk, IntermRegister::ic, dst_offset, c, in_tag); + mem_trace_builder.write_into_memory(clk, IntermRegister::IC, dst_offset, c, in_tag); main_trace.push_back(Row{ .avmMini_clk = clk, @@ -63,9 +64,9 @@ void AvmMiniTraceBuilder::add(uint32_t a_offset, uint32_t b_offset, uint32_t dst .avmMini_sel_op_add = FF(1), .avmMini_in_tag = FF(static_cast(in_tag)), .avmMini_tag_err = FF(static_cast(!tag_match)), - .avmMini_ia = tag_match ? a : FF(0), - .avmMini_ib = tag_match ? b : FF(0), - .avmMini_ic = tag_match ? c : FF(0), + .avmMini_ia = a, + .avmMini_ib = b, + .avmMini_ic = c, .avmMini_mem_op_a = FF(1), .avmMini_mem_op_b = FF(1), .avmMini_mem_op_c = FF(1), @@ -76,7 +77,7 @@ void AvmMiniTraceBuilder::add(uint32_t a_offset, uint32_t b_offset, uint32_t dst }); }; -/** TODO: Implement for non finite field types +/** * @brief Subtraction with direct memory access. * * @param a_offset An index in memory pointing to the first operand of the subtraction. @@ -89,17 +90,17 @@ void AvmMiniTraceBuilder::sub(uint32_t a_offset, uint32_t b_offset, uint32_t dst auto clk = static_cast(main_trace.size()); // Reading from memory and loading into ia resp. ib. - auto read_a = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::ia, a_offset, in_tag); - auto read_b = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::ib, b_offset, in_tag); + auto read_a = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::IA, a_offset, in_tag); + auto read_b = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::IB, b_offset, in_tag); bool tag_match = read_a.tag_match && read_b.tag_match; // a - b = c - FF a = read_a.val; - FF b = read_b.val; - FF c = a - b; + FF a = tag_match ? read_a.val : FF(0); + FF b = tag_match ? read_b.val : FF(0); + FF c = alu_trace_builder.sub(a, b, in_tag, clk); // Write into memory value c from intermediate register ic. - mem_trace_builder.write_into_memory(clk, IntermRegister::ic, dst_offset, c, in_tag); + mem_trace_builder.write_into_memory(clk, IntermRegister::IC, dst_offset, c, in_tag); main_trace.push_back(Row{ .avmMini_clk = clk, @@ -108,9 +109,9 @@ void AvmMiniTraceBuilder::sub(uint32_t a_offset, uint32_t b_offset, uint32_t dst .avmMini_sel_op_sub = FF(1), .avmMini_in_tag = FF(static_cast(in_tag)), .avmMini_tag_err = FF(static_cast(!tag_match)), - .avmMini_ia = tag_match ? a : FF(0), - .avmMini_ib = tag_match ? b : FF(0), - .avmMini_ic = tag_match ? c : FF(0), + .avmMini_ia = a, + .avmMini_ib = b, + .avmMini_ic = c, .avmMini_mem_op_a = FF(1), .avmMini_mem_op_b = FF(1), .avmMini_mem_op_c = FF(1), @@ -121,7 +122,7 @@ void AvmMiniTraceBuilder::sub(uint32_t a_offset, uint32_t b_offset, uint32_t dst }); }; -/** TODO: Implement for non finite field types +/** * @brief Multiplication with direct memory access. * * @param a_offset An index in memory pointing to the first operand of the multiplication. @@ -134,17 +135,17 @@ void AvmMiniTraceBuilder::mul(uint32_t a_offset, uint32_t b_offset, uint32_t dst auto clk = static_cast(main_trace.size()); // Reading from memory and loading into ia resp. ib. - auto read_a = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::ia, a_offset, in_tag); - auto read_b = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::ib, b_offset, in_tag); + auto read_a = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::IA, a_offset, in_tag); + auto read_b = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::IB, b_offset, in_tag); bool tag_match = read_a.tag_match && read_b.tag_match; // a * b = c - FF a = read_a.val; - FF b = read_b.val; - FF c = a * b; + FF a = tag_match ? read_a.val : FF(0); + FF b = tag_match ? read_b.val : FF(0); + FF c = alu_trace_builder.mul(a, b, in_tag, clk); // Write into memory value c from intermediate register ic. - mem_trace_builder.write_into_memory(clk, IntermRegister::ic, dst_offset, c, in_tag); + mem_trace_builder.write_into_memory(clk, IntermRegister::IC, dst_offset, c, in_tag); main_trace.push_back(Row{ .avmMini_clk = clk, @@ -153,9 +154,9 @@ void AvmMiniTraceBuilder::mul(uint32_t a_offset, uint32_t b_offset, uint32_t dst .avmMini_sel_op_mul = FF(1), .avmMini_in_tag = FF(static_cast(in_tag)), .avmMini_tag_err = FF(static_cast(!tag_match)), - .avmMini_ia = tag_match ? a : FF(0), - .avmMini_ib = tag_match ? b : FF(0), - .avmMini_ic = tag_match ? c : FF(0), + .avmMini_ia = a, + .avmMini_ib = b, + .avmMini_ic = c, .avmMini_mem_op_a = FF(1), .avmMini_mem_op_b = FF(1), .avmMini_mem_op_c = FF(1), @@ -179,8 +180,8 @@ void AvmMiniTraceBuilder::div(uint32_t a_offset, uint32_t b_offset, uint32_t dst auto clk = static_cast(main_trace.size()); // Reading from memory and loading into ia resp. ib. - auto read_a = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::ia, a_offset, in_tag); - auto read_b = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::ib, b_offset, in_tag); + auto read_a = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::IA, a_offset, in_tag); + auto read_b = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::IB, b_offset, in_tag); bool tag_match = read_a.tag_match && read_b.tag_match; // a * b^(-1) = c @@ -202,7 +203,7 @@ void AvmMiniTraceBuilder::div(uint32_t a_offset, uint32_t b_offset, uint32_t dst } // Write into memory value c from intermediate register ic. - mem_trace_builder.write_into_memory(clk, IntermRegister::ic, dst_offset, c, in_tag); + mem_trace_builder.write_into_memory(clk, IntermRegister::IC, dst_offset, c, in_tag); main_trace.push_back(Row{ .avmMini_clk = clk, @@ -226,6 +227,38 @@ void AvmMiniTraceBuilder::div(uint32_t a_offset, uint32_t b_offset, uint32_t dst }); } +// TODO: Finish SET opcode implementation. This is a partial implementation +// facilitating testing of arithmetic operations over non finite field types. +// We add an entry in the memory trace and a simplified one in the main trace +// without operation selector. +// TODO: PIL relations for the SET opcode need to be implemented. +// No check is performed that val pertains to type defined by in_tag. +/** + * @brief Set a constant from bytecode with direct memory access. + * + * @param val The constant to be written upcasted to u128 + * @param dst_offset Memory destination offset where val is written to + * @param in_tag The instruction memory tag + */ +void AvmMiniTraceBuilder::set(uint128_t val, uint32_t dst_offset, AvmMemoryTag in_tag) +{ + auto clk = static_cast(main_trace.size()); + auto val_ff = FF{ uint256_t::from_uint128(val) }; + + mem_trace_builder.write_into_memory(clk, IntermRegister::IC, dst_offset, val_ff, in_tag); + + main_trace.push_back(Row{ + .avmMini_clk = clk, + .avmMini_pc = FF(pc++), + .avmMini_internal_return_ptr = FF(internal_return_ptr), + .avmMini_in_tag = FF(static_cast(in_tag)), + .avmMini_ic = val_ff, + .avmMini_mem_op_c = FF(1), + .avmMini_rwc = FF(1), + .avmMini_mem_idx_c = FF(dst_offset), + }); +} + /** * @brief CALLDATACOPY opcode with direct memory access, i.e., * M[dst_offset:dst_offset+copy_size] = calldata[cd_offset:cd_offset+copy_size] @@ -237,6 +270,9 @@ void AvmMiniTraceBuilder::div(uint32_t a_offset, uint32_t b_offset, uint32_t dst * TODO: Implement the indirect memory version (maybe not required) * TODO: taking care of intermediate register values consistency and propagating their * values to the next row when not overwritten. + * TODO: error handling if dst_offset + copy_size > 2^32 which would lead to + * out-of-bound memory write. Similarly, if cd_offset + copy_size is larger + * than call_data_mem.size() * * @param cd_offset The starting index of the region in calldata to be copied. * @param copy_size The number of finite field elements to be copied into memory. @@ -274,7 +310,7 @@ void AvmMiniTraceBuilder::call_data_copy(uint32_t cd_offset, uint32_t rwa = 1; // Storing from Ia - mem_trace_builder.write_into_memory(clk, IntermRegister::ia, mem_idx_a, ia, AvmMemoryTag::ff); + mem_trace_builder.write_into_memory(clk, IntermRegister::IA, mem_idx_a, ia, AvmMemoryTag::FF); if (copy_size - pos > 1) { ib = call_data_mem.at(cd_offset + pos + 1); @@ -283,7 +319,7 @@ void AvmMiniTraceBuilder::call_data_copy(uint32_t cd_offset, rwb = 1; // Storing from Ib - mem_trace_builder.write_into_memory(clk, IntermRegister::ib, mem_idx_b, ib, AvmMemoryTag::ff); + mem_trace_builder.write_into_memory(clk, IntermRegister::IB, mem_idx_b, ib, AvmMemoryTag::FF); } if (copy_size - pos > 2) { @@ -293,14 +329,14 @@ void AvmMiniTraceBuilder::call_data_copy(uint32_t cd_offset, rwc = 1; // Storing from Ic - mem_trace_builder.write_into_memory(clk, IntermRegister::ic, mem_idx_c, ic, AvmMemoryTag::ff); + mem_trace_builder.write_into_memory(clk, IntermRegister::IC, mem_idx_c, ic, AvmMemoryTag::FF); } main_trace.push_back(Row{ .avmMini_clk = clk, .avmMini_pc = FF(pc++), .avmMini_internal_return_ptr = FF(internal_return_ptr), - .avmMini_in_tag = FF(static_cast(AvmMemoryTag::ff)), + .avmMini_in_tag = FF(static_cast(AvmMemoryTag::FF)), .avmMini_ia = ia, .avmMini_ib = ib, .avmMini_ic = ic, @@ -330,12 +366,13 @@ void AvmMiniTraceBuilder::call_data_copy(uint32_t cd_offset, * intermediate registers and then values are copied to the returned vector. * TODO: Implement the indirect memory version (maybe not required) * TODO: taking care of flagging this row as the last one? Special STOP flag? + * TODO: error handling if ret_offset + ret_size > 2^32 which would lead to + * out-of-bound memory read. * * @param ret_offset The starting index of the memory region to be returned. * @param ret_size The number of elements to be returned. * @return The returned memory region as a std::vector. */ - std::vector AvmMiniTraceBuilder::return_op(uint32_t ret_offset, uint32_t ret_size) { // We parallelize loading memory operations in chunk of 3, i.e., 1 per intermediate register. @@ -361,7 +398,7 @@ std::vector AvmMiniTraceBuilder::return_op(uint32_t ret_offset, uint32_t ret uint32_t mem_idx_a = ret_offset + pos; // Reading and loading to Ia - auto read_a = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::ia, mem_idx_a, AvmMemoryTag::ff); + auto read_a = mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::IA, mem_idx_a, AvmMemoryTag::FF); FF ia = read_a.val; returnMem.push_back(ia); @@ -371,7 +408,7 @@ std::vector AvmMiniTraceBuilder::return_op(uint32_t ret_offset, uint32_t ret // Reading and loading to Ib auto read_b = - mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::ib, mem_idx_b, AvmMemoryTag::ff); + mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::IB, mem_idx_b, AvmMemoryTag::FF); FF ib = read_b.val; returnMem.push_back(ib); } @@ -382,7 +419,7 @@ std::vector AvmMiniTraceBuilder::return_op(uint32_t ret_offset, uint32_t ret // Reading and loading to Ic auto read_c = - mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::ic, mem_idx_c, AvmMemoryTag::ff); + mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::IC, mem_idx_c, AvmMemoryTag::FF); FF ic = read_c.val; returnMem.push_back(ic); } @@ -392,7 +429,7 @@ std::vector AvmMiniTraceBuilder::return_op(uint32_t ret_offset, uint32_t ret .avmMini_pc = FF(pc), .avmMini_internal_return_ptr = FF(internal_return_ptr), .avmMini_sel_halt = FF(1), - .avmMini_in_tag = FF(static_cast(AvmMemoryTag::ff)), + .avmMini_in_tag = FF(static_cast(AvmMemoryTag::FF)), .avmMini_ia = ia, .avmMini_ib = ib, .avmMini_ic = ic, @@ -417,7 +454,7 @@ std::vector AvmMiniTraceBuilder::return_op(uint32_t ret_offset, uint32_t ret * @brief HALT opcode * This opcode effectively stops program execution, and is used in the relation that * ensures the program counter increments on each opcode. - * i.e.ythe program counter should freeze and the halt flag is set to 1. + * i.e. the program counter should freeze and the halt flag is set to 1. */ void AvmMiniTraceBuilder::halt() { @@ -477,7 +514,7 @@ void AvmMiniTraceBuilder::internal_call(uint32_t jmp_dest) internal_call_stack.push(stored_pc); // Add the return location to the memory trace - mem_trace_builder.write_into_memory(clk, IntermRegister::ib, internal_return_ptr, FF(stored_pc), AvmMemoryTag::ff); + mem_trace_builder.write_into_memory(clk, IntermRegister::IB, internal_return_ptr, FF(stored_pc), AvmMemoryTag::FF); main_trace.push_back(Row{ .avmMini_clk = clk, @@ -513,7 +550,7 @@ void AvmMiniTraceBuilder::internal_return() // Internal return pointer is decremented // We want to load the value pointed by the internal pointer auto read_a = - mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::ia, internal_return_ptr - 1, AvmMemoryTag::ff); + mem_trace_builder.read_and_load_from_memory(clk, IntermRegister::IA, internal_return_ptr - 1, AvmMemoryTag::FF); main_trace.push_back(Row{ .avmMini_clk = clk, @@ -544,14 +581,17 @@ void AvmMiniTraceBuilder::internal_return() std::vector AvmMiniTraceBuilder::finalize() { auto mem_trace = mem_trace_builder.finalize(); + auto alu_trace = alu_trace_builder.finalize(); size_t mem_trace_size = mem_trace.size(); size_t main_trace_size = main_trace.size(); + size_t alu_trace_size = alu_trace.size(); // TODO: We will have to handle this through error handling and not an assertion // Smaller than N because we have to add an extra initial row to support shifted // elements assert(mem_trace_size < AVM_TRACE_SIZE); assert(main_trace_size < AVM_TRACE_SIZE); + assert(alu_trace_size < AVM_TRACE_SIZE); // Fill the rest with zeros. size_t zero_rows_num = AVM_TRACE_SIZE - main_trace_size - 1; @@ -561,6 +601,7 @@ std::vector AvmMiniTraceBuilder::finalize() main_trace.at(main_trace_size - 1).avmMini_last = FF(1); + // Memory trace inclusion for (size_t i = 0; i < mem_trace_size; i++) { auto const& src = mem_trace.at(i); auto& dest = main_trace.at(i); @@ -584,6 +625,45 @@ std::vector AvmMiniTraceBuilder::finalize() } } + // Alu trace inclusion + for (size_t i = 0; i < alu_trace_size; i++) { + auto const& src = alu_trace.at(i); + auto& dest = main_trace.at(i); + + dest.aluChip_alu_clk = FF(static_cast(src.alu_clk)); + + dest.aluChip_alu_op_add = FF(static_cast(src.alu_op_add)); + dest.aluChip_alu_op_sub = FF(static_cast(src.alu_op_sub)); + dest.aluChip_alu_op_mul = FF(static_cast(src.alu_op_mul)); + + dest.aluChip_alu_ff_tag = FF(static_cast(src.alu_ff_tag)); + dest.aluChip_alu_u8_tag = FF(static_cast(src.alu_u8_tag)); + dest.aluChip_alu_u16_tag = FF(static_cast(src.alu_u16_tag)); + dest.aluChip_alu_u32_tag = FF(static_cast(src.alu_u32_tag)); + dest.aluChip_alu_u64_tag = FF(static_cast(src.alu_u64_tag)); + dest.aluChip_alu_u128_tag = FF(static_cast(src.alu_u128_tag)); + + dest.aluChip_alu_ia = src.alu_ia; + dest.aluChip_alu_ib = src.alu_ib; + dest.aluChip_alu_ic = src.alu_ic; + + dest.aluChip_alu_cf = FF(static_cast(src.alu_cf)); + + dest.aluChip_alu_u8_r0 = FF(src.alu_u8_r0); + dest.aluChip_alu_u8_r1 = FF(src.alu_u8_r1); + + dest.aluChip_alu_u16_r0 = FF(src.alu_u16_reg.at(0)); + dest.aluChip_alu_u16_r1 = FF(src.alu_u16_reg.at(1)); + dest.aluChip_alu_u16_r2 = FF(src.alu_u16_reg.at(2)); + dest.aluChip_alu_u16_r3 = FF(src.alu_u16_reg.at(3)); + dest.aluChip_alu_u16_r4 = FF(src.alu_u16_reg.at(4)); + dest.aluChip_alu_u16_r5 = FF(src.alu_u16_reg.at(5)); + dest.aluChip_alu_u16_r6 = FF(src.alu_u16_reg.at(6)); + dest.aluChip_alu_u16_r7 = FF(src.alu_u16_reg.at(7)); + + dest.aluChip_alu_u64_r0 = FF(src.alu_u64_r0); + } + // Adding extra row for the shifted values at the top of the execution trace. Row first_row = Row{ .avmMini_first = FF(1), .memTrace_m_lastAccess = FF(1) }; main_trace.insert(main_trace.begin(), first_row); diff --git a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_trace.hpp b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_trace.hpp index ef8e51b65bf3..af09f2e4d142 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_trace.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm_trace/AvmMini_trace.hpp @@ -2,6 +2,7 @@ #include +#include "AvmMini_alu_trace.hpp" #include "AvmMini_common.hpp" #include "AvmMini_mem_trace.hpp" #include "barretenberg/common/throw_or_abort.hpp" @@ -36,6 +37,9 @@ class AvmMiniTraceBuilder { // Division with direct memory access. void div(uint32_t a_offset, uint32_t b_offset, uint32_t dst_offset, AvmMemoryTag in_tag); + // Set a constant from bytecode with direct memory access. + void set(uint128_t val, uint32_t dst_offset, AvmMemoryTag in_tag); + // Jump to a given program counter. void jump(uint32_t jmp_dest); @@ -63,6 +67,7 @@ class AvmMiniTraceBuilder { private: std::vector main_trace; AvmMiniMemTraceBuilder mem_trace_builder; + AvmMiniAluTraceBuilder alu_trace_builder; uint32_t pc = 0; uint32_t internal_return_ptr = CALLSTACK_OFFSET; diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.cpp index aec530be7578..552582558c44 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_prover.cpp @@ -72,8 +72,10 @@ void AvmMiniProver::execute_relation_check_rounds() using Sumcheck = sumcheck::SumcheckProver; auto sumcheck = Sumcheck(key->circuit_size, transcript); + FF alpha = transcript->get_challenge("Sumcheck:alpha"); std::vector gate_challenges(numeric::get_msb(key->circuit_size)); + for (size_t idx = 0; idx < gate_challenges.size(); idx++) { gate_challenges[idx] = transcript->get_challenge("Sumcheck:gate_challenge_" + std::to_string(idx)); } diff --git a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp index 2da2112a9b38..09beb8a866e3 100644 --- a/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/generated/AvmMini_verifier.cpp @@ -72,6 +72,54 @@ bool AvmMiniVerifier::verify_proof(const plonk::proof& proof) transcript->template receive_from_prover(commitment_labels.memTrace_m_tag_err); commitments.memTrace_m_one_min_inv = transcript->template receive_from_prover(commitment_labels.memTrace_m_one_min_inv); + commitments.aluChip_alu_clk = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_clk); + commitments.aluChip_alu_ia = transcript->template receive_from_prover(commitment_labels.aluChip_alu_ia); + commitments.aluChip_alu_ib = transcript->template receive_from_prover(commitment_labels.aluChip_alu_ib); + commitments.aluChip_alu_ic = transcript->template receive_from_prover(commitment_labels.aluChip_alu_ic); + commitments.aluChip_alu_op_add = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_op_add); + commitments.aluChip_alu_op_sub = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_op_sub); + commitments.aluChip_alu_op_mul = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_op_mul); + commitments.aluChip_alu_op_div = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_op_div); + commitments.aluChip_alu_ff_tag = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_ff_tag); + commitments.aluChip_alu_u8_tag = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u8_tag); + commitments.aluChip_alu_u16_tag = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_tag); + commitments.aluChip_alu_u32_tag = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u32_tag); + commitments.aluChip_alu_u64_tag = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u64_tag); + commitments.aluChip_alu_u128_tag = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u128_tag); + commitments.aluChip_alu_u8_r0 = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u8_r0); + commitments.aluChip_alu_u8_r1 = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u8_r1); + commitments.aluChip_alu_u16_r0 = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r0); + commitments.aluChip_alu_u16_r1 = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r1); + commitments.aluChip_alu_u16_r2 = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r2); + commitments.aluChip_alu_u16_r3 = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r3); + commitments.aluChip_alu_u16_r4 = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r4); + commitments.aluChip_alu_u16_r5 = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r5); + commitments.aluChip_alu_u16_r6 = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r6); + commitments.aluChip_alu_u16_r7 = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u16_r7); + commitments.aluChip_alu_u64_r0 = + transcript->template receive_from_prover(commitment_labels.aluChip_alu_u64_r0); + commitments.aluChip_alu_cf = transcript->template receive_from_prover(commitment_labels.aluChip_alu_cf); commitments.avmMini_pc = transcript->template receive_from_prover(commitment_labels.avmMini_pc); commitments.avmMini_internal_return_ptr = transcript->template receive_from_prover(commitment_labels.avmMini_internal_return_ptr); @@ -119,11 +167,14 @@ bool AvmMiniVerifier::verify_proof(const plonk::proof& proof) // Execute Sumcheck Verifier const size_t log_circuit_size = numeric::get_msb(circuit_size); auto sumcheck = SumcheckVerifier(log_circuit_size, transcript); + FF alpha = transcript->get_challenge("Sumcheck:alpha"); + auto gate_challenges = std::vector(log_circuit_size); for (size_t idx = 0; idx < log_circuit_size; idx++) { gate_challenges[idx] = transcript->get_challenge("Sumcheck:gate_challenge_" + std::to_string(idx)); } + auto [multivariate_challenge, claimed_evaluations, sumcheck_verified] = sumcheck.verify(relation_parameters, alpha, gate_challenges); diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_arithmetic.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_arithmetic.test.cpp index 46ed56f37f36..15f4e0a37eee 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_arithmetic.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_arithmetic.test.cpp @@ -1,18 +1,190 @@ -#include "barretenberg/vm/avm_trace/AvmMini_helper.hpp" -#include "barretenberg/vm/generated/AvmMini_composer.hpp" -#include "barretenberg/vm/generated/AvmMini_prover.hpp" -#include "barretenberg/vm/generated/AvmMini_verifier.hpp" -#include "helpers.test.hpp" - -#include -#include -#include -#include -#include - -namespace tests_avm { -using namespace avm_trace; +#include "AvmMini_common.test.hpp" + +#include "barretenberg/numeric/uint128/uint128.hpp" + +using namespace numeric; +using namespace tests_avm; +namespace { + +void common_validate_arithmetic_op(Row const& main_row, + Row const& alu_row, + FF const& a, + FF const& b, + FF const& c, + FF const& addr_a, + FF const& addr_b, + FF const& addr_c, + avm_trace::AvmMemoryTag const tag) +{ + // Check that the correct result is stored at the expected memory location. + EXPECT_EQ(main_row.avmMini_ic, c); + EXPECT_EQ(main_row.avmMini_mem_idx_c, addr_c); + EXPECT_EQ(main_row.avmMini_mem_op_c, FF(1)); + EXPECT_EQ(main_row.avmMini_rwc, FF(1)); + + // Check that ia and ib registers are correctly set with memory load operations. + EXPECT_EQ(main_row.avmMini_ia, a); + EXPECT_EQ(main_row.avmMini_mem_idx_a, addr_a); + EXPECT_EQ(main_row.avmMini_mem_op_a, FF(1)); + EXPECT_EQ(main_row.avmMini_rwa, FF(0)); + EXPECT_EQ(main_row.avmMini_ib, b); + EXPECT_EQ(main_row.avmMini_mem_idx_b, addr_b); + EXPECT_EQ(main_row.avmMini_mem_op_b, FF(1)); + EXPECT_EQ(main_row.avmMini_rwb, FF(0)); + + // Check the instruction tag + EXPECT_EQ(main_row.avmMini_in_tag, FF(static_cast(tag))); + + // Check that intermediate rgiesters are correctly copied in Alu trace + EXPECT_EQ(alu_row.aluChip_alu_ia, a); + EXPECT_EQ(alu_row.aluChip_alu_ib, b); + EXPECT_EQ(alu_row.aluChip_alu_ic, c); +} + +Row common_validate_add(std::vector const& trace, + FF const& a, + FF const& b, + FF const& c, + FF const& addr_a, + FF const& addr_b, + FF const& addr_c, + avm_trace::AvmMemoryTag const tag) +{ + // Find the first row enabling the addition selector + auto row = std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avmMini_sel_op_add == FF(1); }); + + // Find the corresponding Alu trace row + auto clk = row->avmMini_clk; + auto alu_row = std::ranges::find_if(trace.begin(), trace.end(), [clk](Row r) { return r.aluChip_alu_clk == clk; }); + + // Check that both rows were found + EXPECT_TRUE(row != trace.end()); + EXPECT_TRUE(alu_row != trace.end()); + + common_validate_arithmetic_op(*row, *alu_row, a, b, c, addr_a, addr_b, addr_c, tag); + + // Check that addition selector is set. + EXPECT_EQ(row->avmMini_sel_op_add, FF(1)); + EXPECT_EQ(alu_row->aluChip_alu_op_add, FF(1)); + + return *alu_row; +} + +Row common_validate_sub(std::vector const& trace, + FF const& a, + FF const& b, + FF const& c, + FF const& addr_a, + FF const& addr_b, + FF const& addr_c, + avm_trace::AvmMemoryTag const tag) +{ + // Find the first row enabling the subtraction selector + auto row = std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avmMini_sel_op_sub == FF(1); }); + + // Find the corresponding Alu trace row + auto clk = row->avmMini_clk; + auto alu_row = std::ranges::find_if(trace.begin(), trace.end(), [clk](Row r) { return r.aluChip_alu_clk == clk; }); + + // Check that both rows were found + EXPECT_TRUE(row != trace.end()); + EXPECT_TRUE(alu_row != trace.end()); + + common_validate_arithmetic_op(*row, *alu_row, a, b, c, addr_a, addr_b, addr_c, tag); + + // Check that subtraction selector is set. + EXPECT_EQ(row->avmMini_sel_op_sub, FF(1)); + EXPECT_EQ(alu_row->aluChip_alu_op_sub, FF(1)); + + return *alu_row; +} + +size_t common_validate_mul(std::vector const& trace, + FF const& a, + FF const& b, + FF const& c, + FF const& addr_a, + FF const& addr_b, + FF const& addr_c, + avm_trace::AvmMemoryTag const tag) +{ + // Find the first row enabling the multiplication selector + auto row = std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avmMini_sel_op_mul == FF(1); }); + + // Find the corresponding Alu trace row + auto clk = row->avmMini_clk; + auto alu_row = std::ranges::find_if(trace.begin(), trace.end(), [clk](Row r) { return r.aluChip_alu_clk == clk; }); + + // Check that both rows were found + EXPECT_TRUE(row != trace.end()); + EXPECT_TRUE(alu_row != trace.end()); + + common_validate_arithmetic_op(*row, *alu_row, a, b, c, addr_a, addr_b, addr_c, tag); + + // Check that multiplication selector is set. + EXPECT_EQ(row->avmMini_sel_op_mul, FF(1)); + EXPECT_EQ(alu_row->aluChip_alu_op_mul, FF(1)); + + return static_cast(alu_row - trace.begin()); +} + +// This function generates a mutated trace of an addition where a and b are the passed inputs. +// a and b are stored in memory indices 0 and 1. c_mutated is the wrong result of the addition +// and the memory and alu trace are created consistently with the wrong value c_mutated. +std::vector gen_mutated_trace_add(FF const& a, FF const& b, FF const& c_mutated, avm_trace::AvmMemoryTag tag) +{ + auto trace_builder = avm_trace::AvmMiniTraceBuilder(); + trace_builder.set(uint128_t{ a }, 0, tag); + trace_builder.set(uint128_t{ b }, 1, tag); + trace_builder.add(0, 1, 2, tag); + trace_builder.halt(); + auto trace = trace_builder.finalize(); + + auto select_row = [](Row r) { return r.avmMini_sel_op_add == FF(1); }; + mutate_ic_in_trace(trace, select_row, c_mutated, true); + + return trace; +} + +// This function generates a mutated trace of a subtraction where a and b are the passed inputs. +// a and b are stored in memory indices 0 and 1. c_mutated is the wrong result of the subtraction +// and the memory and alu trace are created consistently with the wrong value c_mutated. +std::vector gen_mutated_trace_sub(FF const& a, FF const& b, FF const& c_mutated, avm_trace::AvmMemoryTag tag) +{ + auto trace_builder = avm_trace::AvmMiniTraceBuilder(); + trace_builder.set(uint128_t{ a }, 0, tag); + trace_builder.set(uint128_t{ b }, 1, tag); + trace_builder.sub(0, 1, 2, tag); + trace_builder.halt(); + auto trace = trace_builder.finalize(); + + auto select_row = [](Row r) { return r.avmMini_sel_op_sub == FF(1); }; + mutate_ic_in_trace(trace, select_row, c_mutated, true); + + return trace; +} + +// This function generates a mutated trace of a multiplication where a and b are the passed inputs. +// a and b are stored in memory indices 0 and 1. c_mutated is the wrong result of the multiplication +// and the memory and alu trace are created consistently with the wrong value c_mutated. +std::vector gen_mutated_trace_mul(FF const& a, FF const& b, FF const& c_mutated, avm_trace::AvmMemoryTag tag) +{ + auto trace_builder = avm_trace::AvmMiniTraceBuilder(); + trace_builder.set(uint128_t{ a }, 0, tag); + trace_builder.set(uint128_t{ b }, 1, tag); + trace_builder.mul(0, 1, 2, tag); + trace_builder.halt(); + auto trace = trace_builder.finalize(); + + auto select_row = [](Row r) { return r.avmMini_sel_op_mul == FF(1); }; + mutate_ic_in_trace(trace, select_row, c_mutated, true); + + return trace; +} + +} // anonymous namespace +using namespace avm_trace; class AvmMiniArithmeticTests : public ::testing::Test { public: AvmMiniTraceBuilder trace_builder; @@ -21,16 +193,28 @@ class AvmMiniArithmeticTests : public ::testing::Test { // TODO(640): The Standard Honk on Grumpkin test suite fails unless the SRS is initialised for every test. void SetUp() override { - bb::srs::init_crs_factory("../srs_db/ignition"); + srs::init_crs_factory("../srs_db/ignition"); trace_builder = AvmMiniTraceBuilder(); // Clean instance for every run. }; }; -class AvmMiniArithmeticNegativeTests : public AvmMiniArithmeticTests {}; +class AvmMiniArithmeticTestsFF : public AvmMiniArithmeticTests {}; +class AvmMiniArithmeticTestsU8 : public AvmMiniArithmeticTests {}; +class AvmMiniArithmeticTestsU16 : public AvmMiniArithmeticTests {}; +class AvmMiniArithmeticTestsU32 : public AvmMiniArithmeticTests {}; +class AvmMiniArithmeticTestsU64 : public AvmMiniArithmeticTests {}; +class AvmMiniArithmeticTestsU128 : public AvmMiniArithmeticTests {}; + +class AvmMiniArithmeticNegativeTestsFF : public AvmMiniArithmeticTests {}; +class AvmMiniArithmeticNegativeTestsU8 : public AvmMiniArithmeticTests {}; +class AvmMiniArithmeticNegativeTestsU16 : public AvmMiniArithmeticTests {}; +class AvmMiniArithmeticNegativeTestsU32 : public AvmMiniArithmeticTests {}; +class AvmMiniArithmeticNegativeTestsU64 : public AvmMiniArithmeticTests {}; +class AvmMiniArithmeticNegativeTestsU128 : public AvmMiniArithmeticTests {}; /****************************************************************************** * - * POSITIVE TESTS - Finite Field Type + * POSITIVE TESTS * ****************************************************************************** * The positive tests aim at testing that a genuinely generated execution trace @@ -52,106 +236,96 @@ class AvmMiniArithmeticNegativeTests : public AvmMiniArithmeticTests {}; * will still correctly work along the development of the AVM. ******************************************************************************/ +/****************************************************************************** + * Positive Tests - FF + ******************************************************************************/ + // Test on basic addition over finite field type. -TEST_F(AvmMiniArithmeticTests, additionFF) +TEST_F(AvmMiniArithmeticTestsFF, addition) { // trace_builder trace_builder.call_data_copy(0, 3, 0, std::vector{ 37, 4, 11 }); // Memory layout: [37,4,11,0,0,0,....] - trace_builder.add(0, 1, 4, AvmMemoryTag::ff); // [37,4,11,0,41,0,....] + trace_builder.add(0, 1, 4, AvmMemoryTag::FF); // [37,4,11,0,41,0,....] trace_builder.return_op(0, 5); auto trace = trace_builder.finalize(); - // Find the first row enabling the addition selector - auto row = std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avmMini_sel_op_add == FF(1); }); + auto alu_row = common_validate_add(trace, FF(37), FF(4), FF(41), FF(0), FF(1), FF(4), AvmMemoryTag::FF); - // Check that the correct result is stored at the expected memory location. - EXPECT_TRUE(row != trace.end()); - EXPECT_EQ(row->avmMini_ic, FF(41)); - EXPECT_EQ(row->avmMini_mem_idx_c, FF(4)); - EXPECT_EQ(row->avmMini_mem_op_c, FF(1)); - EXPECT_EQ(row->avmMini_rwc, FF(1)); + EXPECT_EQ(alu_row.aluChip_alu_ff_tag, FF(1)); + EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0)); validate_trace_proof(std::move(trace)); } // Test on basic subtraction over finite field type. -TEST_F(AvmMiniArithmeticTests, subtractionFF) +TEST_F(AvmMiniArithmeticTestsFF, subtraction) { trace_builder.call_data_copy(0, 3, 0, std::vector{ 8, 4, 17 }); // Memory layout: [8,4,17,0,0,0,....] - trace_builder.sub(2, 0, 1, AvmMemoryTag::ff); // [8,9,17,0,0,0....] + trace_builder.sub(2, 0, 1, AvmMemoryTag::FF); // [8,9,17,0,0,0....] trace_builder.return_op(0, 3); auto trace = trace_builder.finalize(); - // Find the first row enabling the subtraction selector - auto row = std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avmMini_sel_op_sub == FF(1); }); + auto alu_row = common_validate_sub(trace, FF(17), FF(8), FF(9), FF(2), FF(0), FF(1), AvmMemoryTag::FF); - // Check that the correct result is stored at the expected memory location. - EXPECT_TRUE(row != trace.end()); - EXPECT_EQ(row->avmMini_ic, FF(9)); - EXPECT_EQ(row->avmMini_mem_idx_c, FF(1)); - EXPECT_EQ(row->avmMini_mem_op_c, FF(1)); - EXPECT_EQ(row->avmMini_rwc, FF(1)); + EXPECT_EQ(alu_row.aluChip_alu_ff_tag, FF(1)); + EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0)); validate_trace_proof(std::move(trace)); } // Test on basic multiplication over finite field type. -TEST_F(AvmMiniArithmeticTests, multiplicationFF) +TEST_F(AvmMiniArithmeticTestsFF, multiplication) { trace_builder.call_data_copy(0, 3, 0, std::vector{ 5, 0, 20 }); // Memory layout: [5,0,20,0,0,0,....] - trace_builder.mul(2, 0, 1, AvmMemoryTag::ff); // [5,100,20,0,0,0....] + trace_builder.mul(2, 0, 1, AvmMemoryTag::FF); // [5,100,20,0,0,0....] trace_builder.return_op(0, 3); auto trace = trace_builder.finalize(); - // Find the first row enabling the multiplication selector - auto row = std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avmMini_sel_op_mul == FF(1); }); + auto alu_row_index = common_validate_mul(trace, FF(20), FF(5), FF(100), FF(2), FF(0), FF(1), AvmMemoryTag::FF); + auto alu_row = trace.at(alu_row_index); - // Check that the correct result is stored at the expected memory location. - EXPECT_TRUE(row != trace.end()); - EXPECT_EQ(row->avmMini_ic, FF(100)); - EXPECT_EQ(row->avmMini_mem_idx_c, FF(1)); - EXPECT_EQ(row->avmMini_mem_op_c, FF(1)); - EXPECT_EQ(row->avmMini_rwc, FF(1)); + EXPECT_EQ(alu_row.aluChip_alu_ff_tag, FF(1)); + EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0)); validate_trace_proof(std::move(trace)); } // Test on multiplication by zero over finite field type. -TEST_F(AvmMiniArithmeticTests, multiplicationByZeroFF) +TEST_F(AvmMiniArithmeticTestsFF, multiplicationByZero) { trace_builder.call_data_copy(0, 1, 0, std::vector{ 127 }); // Memory layout: [127,0,0,0,0,0,....] - trace_builder.mul(0, 1, 2, AvmMemoryTag::ff); // [127,0,0,0,0,0....] + trace_builder.mul(0, 1, 2, AvmMemoryTag::FF); // [127,0,0,0,0,0....] trace_builder.return_op(0, 3); auto trace = trace_builder.finalize(); - // Find the first row enabling the multiplication selector - auto row = std::ranges::find_if(trace.begin(), trace.end(), [](Row r) { return r.avmMini_sel_op_mul == FF(1); }); + auto alu_row_index = common_validate_mul(trace, FF(127), FF(0), FF(0), FF(0), FF(1), FF(2), AvmMemoryTag::FF); + auto alu_row = trace.at(alu_row_index); - // Check that the correct result is stored at the expected memory location. - EXPECT_TRUE(row != trace.end()); - EXPECT_EQ(row->avmMini_ic, FF(0)); - EXPECT_EQ(row->avmMini_mem_idx_c, FF(2)); - EXPECT_EQ(row->avmMini_mem_op_c, FF(1)); - EXPECT_EQ(row->avmMini_rwc, FF(1)); + EXPECT_EQ(alu_row.aluChip_alu_ff_tag, FF(1)); + EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0)); validate_trace_proof(std::move(trace)); } // Test on basic division over finite field type. -TEST_F(AvmMiniArithmeticTests, divisionFF) +TEST_F(AvmMiniArithmeticTestsFF, division) { trace_builder.call_data_copy(0, 2, 0, std::vector{ 15, 315 }); // Memory layout: [15,315,0,0,0,0,....] - trace_builder.div(1, 0, 2, AvmMemoryTag::ff); // [15,315,21,0,0,0....] + trace_builder.div(1, 0, 2, AvmMemoryTag::FF); // [15,315,21,0,0,0....] trace_builder.return_op(0, 3); auto trace = trace_builder.finalize(); @@ -169,12 +343,12 @@ TEST_F(AvmMiniArithmeticTests, divisionFF) } // Test on division with zero numerator over finite field type. -TEST_F(AvmMiniArithmeticTests, divisionNumeratorZeroFF) +TEST_F(AvmMiniArithmeticTestsFF, divisionNumeratorZero) { trace_builder.call_data_copy(0, 1, 0, std::vector{ 15 }); // Memory layout: [15,0,0,0,0,0,....] - trace_builder.div(1, 0, 0, AvmMemoryTag::ff); // [0,0,0,0,0,0....] + trace_builder.div(1, 0, 0, AvmMemoryTag::FF); // [0,0,0,0,0,0....] trace_builder.return_op(0, 3); auto trace = trace_builder.finalize(); @@ -193,12 +367,12 @@ TEST_F(AvmMiniArithmeticTests, divisionNumeratorZeroFF) // Test on division by zero over finite field type. // We check that the operator error flag is raised. -TEST_F(AvmMiniArithmeticTests, divisionByZeroErrorFF) +TEST_F(AvmMiniArithmeticTestsFF, divisionByZeroError) { trace_builder.call_data_copy(0, 1, 0, std::vector{ 15 }); // Memory layout: [15,0,0,0,0,0,....] - trace_builder.div(0, 1, 2, AvmMemoryTag::ff); // [15,0,0,0,0,0....] + trace_builder.div(0, 1, 2, AvmMemoryTag::FF); // [15,0,0,0,0,0....] trace_builder.halt(); auto trace = trace_builder.finalize(); @@ -218,10 +392,10 @@ TEST_F(AvmMiniArithmeticTests, divisionByZeroErrorFF) // Test on division of zero by zero over finite field type. // We check that the operator error flag is raised. -TEST_F(AvmMiniArithmeticTests, divisionZeroByZeroErrorFF) +TEST_F(AvmMiniArithmeticTestsFF, divisionZeroByZeroError) { // Memory layout: [0,0,0,0,0,0,....] - trace_builder.div(0, 1, 2, AvmMemoryTag::ff); // [0,0,0,0,0,0....] + trace_builder.div(0, 1, 2, AvmMemoryTag::FF); // [0,0,0,0,0,0....] trace_builder.halt(); auto trace = trace_builder.finalize(); @@ -243,27 +417,937 @@ TEST_F(AvmMiniArithmeticTests, divisionZeroByZeroErrorFF) // and finishing with a division by zero. The chosen combination is arbitrary. // We only test that the proof can be correctly generated and verified. // No check on the evaluation is performed here. -TEST_F(AvmMiniArithmeticTests, arithmeticFFWithError) +TEST_F(AvmMiniArithmeticTestsFF, mixedOperationsWithError) { trace_builder.call_data_copy(0, 3, 2, std::vector{ 45, 23, 12 }); // Memory layout: [0,0,45,23,12,0,0,0,....] - trace_builder.add(2, 3, 4, AvmMemoryTag::ff); // [0,0,45,23,68,0,0,0,....] - trace_builder.add(4, 5, 5, AvmMemoryTag::ff); // [0,0,45,23,68,68,0,0,....] - trace_builder.add(5, 5, 5, AvmMemoryTag::ff); // [0,0,45,23,68,136,0,0,....] - trace_builder.add(5, 6, 7, AvmMemoryTag::ff); // [0,0,45,23,68,136,0,136,0....] - trace_builder.sub(7, 6, 8, AvmMemoryTag::ff); // [0,0,45,23,68,136,0,136,136,0....] - trace_builder.mul(8, 8, 8, AvmMemoryTag::ff); // [0,0,45,23,68,136,0,136,136^2,0....] - trace_builder.div(3, 5, 1, AvmMemoryTag::ff); // [0,23*136^(-1),45,23,68,136,0,136,136^2,0....] - trace_builder.div(1, 1, 9, AvmMemoryTag::ff); // [0,23*136^(-1),45,23,68,136,0,136,136^2,1,0....] + trace_builder.add(2, 3, 4, AvmMemoryTag::FF); // [0,0,45,23,68,0,0,0,....] + trace_builder.add(4, 5, 5, AvmMemoryTag::FF); // [0,0,45,23,68,68,0,0,....] + trace_builder.add(5, 5, 5, AvmMemoryTag::FF); // [0,0,45,23,68,136,0,0,....] + trace_builder.add(5, 6, 7, AvmMemoryTag::FF); // [0,0,45,23,68,136,0,136,0....] + trace_builder.sub(7, 6, 8, AvmMemoryTag::FF); // [0,0,45,23,68,136,0,136,136,0....] + trace_builder.mul(8, 8, 8, AvmMemoryTag::FF); // [0,0,45,23,68,136,0,136,136^2,0....] + trace_builder.div(3, 5, 1, AvmMemoryTag::FF); // [0,23*136^(-1),45,23,68,136,0,136,136^2,0....] + trace_builder.div(1, 1, 9, AvmMemoryTag::FF); // [0,23*136^(-1),45,23,68,136,0,136,136^2,1,0....] trace_builder.div( - 9, 0, 4, AvmMemoryTag::ff); // [0,23*136^(-1),45,23,1/0,136,0,136,136^2,1,0....] Error: division by 0 + 9, 0, 4, AvmMemoryTag::FF); // [0,23*136^(-1),45,23,1/0,136,0,136,136^2,1,0....] Error: division by 0 trace_builder.halt(); auto trace = trace_builder.finalize(); validate_trace_proof(std::move(trace)); } +/****************************************************************************** + * Positive Tests - U8 + ******************************************************************************/ + +// Test on basic addition over u8 type. +TEST_F(AvmMiniArithmeticTestsU8, addition) +{ + // trace_builder + trace_builder.set(62, 0, AvmMemoryTag::U8); + trace_builder.set(29, 1, AvmMemoryTag::U8); + + // Memory layout: [62,29,0,0,0,....] + trace_builder.add(0, 1, 2, AvmMemoryTag::U8); // [62,29,91,0,0,....] + trace_builder.return_op(2, 1); + auto trace = trace_builder.finalize(); + + auto alu_row = common_validate_add(trace, FF(62), FF(29), FF(91), FF(0), FF(1), FF(2), AvmMemoryTag::U8); + + EXPECT_EQ(alu_row.aluChip_alu_u8_tag, FF(1)); + EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(91)); + validate_trace_proof(std::move(trace)); +} + +// Test on basic addition over u8 type with carry. +TEST_F(AvmMiniArithmeticTestsU8, additionCarry) +{ + // trace_builder + trace_builder.set(159, 0, AvmMemoryTag::U8); + trace_builder.set(100, 1, AvmMemoryTag::U8); + + // Memory layout: [159,100,0,0,0,....] + trace_builder.add(0, 1, 2, AvmMemoryTag::U8); // [159,100,3,0,0,....] + trace_builder.return_op(2, 1); + auto trace = trace_builder.finalize(); + + auto alu_row = common_validate_add(trace, FF(159), FF(100), FF(3), FF(0), FF(1), FF(2), AvmMemoryTag::U8); + + EXPECT_EQ(alu_row.aluChip_alu_u8_tag, FF(1)); + EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(3)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(1)); + + validate_trace_proof(std::move(trace)); +} + +// Test on basic subtraction over u8 type. +TEST_F(AvmMiniArithmeticTestsU8, subtraction) +{ + // trace_builder + trace_builder.set(162, 0, AvmMemoryTag::U8); + trace_builder.set(29, 1, AvmMemoryTag::U8); + + // Memory layout: [162,29,0,0,0,....] + trace_builder.sub(0, 1, 2, AvmMemoryTag::U8); // [162,29,133,0,0,....] + trace_builder.return_op(2, 1); + auto trace = trace_builder.finalize(); + + auto alu_row = common_validate_sub(trace, FF(162), FF(29), FF(133), FF(0), FF(1), FF(2), AvmMemoryTag::U8); + + EXPECT_EQ(alu_row.aluChip_alu_u8_tag, FF(1)); + EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(133)); + + validate_trace_proof(std::move(trace)); +} + +// Test on subtraction over u8 type with carry. +// For a subtraction a - b = c, there is a carry flag iff a < b (equivalent to a < c) +TEST_F(AvmMiniArithmeticTestsU8, subtractionCarry) +{ + // trace_builder + trace_builder.set(5, 0, AvmMemoryTag::U8); + trace_builder.set(29, 1, AvmMemoryTag::U8); + + // Memory layout: [5,29,0,0,0,....] + trace_builder.sub(0, 1, 2, AvmMemoryTag::U8); // [5,29,232,0,0,....] + trace_builder.return_op(2, 1); + auto trace = trace_builder.finalize(); + + auto alu_row = common_validate_sub(trace, FF(5), FF(29), FF(232), FF(0), FF(1), FF(2), AvmMemoryTag::U8); + + EXPECT_EQ(alu_row.aluChip_alu_u8_tag, FF(1)); + EXPECT_EQ(alu_row.aluChip_alu_cf, FF(1)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(232)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(UINT8_MAX)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(UINT16_MAX)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r1, FF(UINT16_MAX)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r2, FF(UINT16_MAX)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r3, FF(UINT16_MAX)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r4, FF(UINT16_MAX)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r5, FF(UINT16_MAX)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r6, FF(UINT16_MAX)); + + validate_trace_proof(std::move(trace)); +} + +// Test on basic multiplication over u8 type. +TEST_F(AvmMiniArithmeticTestsU8, multiplication) +{ + // trace_builder + trace_builder.set(13, 0, AvmMemoryTag::U8); + trace_builder.set(15, 1, AvmMemoryTag::U8); + + trace_builder.mul(0, 1, 2, AvmMemoryTag::U8); + trace_builder.return_op(2, 1); + auto trace = trace_builder.finalize(); + + auto alu_row_index = common_validate_mul(trace, FF(13), FF(15), FF(195), FF(0), FF(1), FF(2), AvmMemoryTag::U8); + auto alu_row = trace.at(alu_row_index); + + EXPECT_EQ(alu_row.aluChip_alu_u8_tag, FF(1)); + + // Decomposition of integer multiplication in 8-bit registers + EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(195)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0)); + + validate_trace_proof(std::move(trace)); +} + +// Test on multiplication over u8 type with overflow. +TEST_F(AvmMiniArithmeticTestsU8, multiplicationOverflow) +{ + // trace_builder + trace_builder.set(200, 0, AvmMemoryTag::U8); + trace_builder.set(170, 1, AvmMemoryTag::U8); + + trace_builder.mul(0, 1, 2, AvmMemoryTag::U8); + trace_builder.return_op(2, 1); + auto trace = trace_builder.finalize(); + + auto alu_row_index = common_validate_mul(trace, FF(200), FF(170), FF(208), FF(0), FF(1), FF(2), AvmMemoryTag::U8); + auto alu_row = trace.at(alu_row_index); + + EXPECT_EQ(alu_row.aluChip_alu_u8_tag, FF(1)); + + // Decomposition of integer multiplication in 8-bit registers + // 34'000 = 208 + 132 * 256 + EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(208)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(132)); + + validate_trace_proof(std::move(trace)); +} + +/****************************************************************************** + * Positive Tests - U16 + ******************************************************************************/ + +// Test on basic addition over u16 type. +TEST_F(AvmMiniArithmeticTestsU16, addition) +{ + // trace_builder + trace_builder.set(1775, 119, AvmMemoryTag::U16); + trace_builder.set(33005, 546, AvmMemoryTag::U16); + + trace_builder.add(546, 119, 5, AvmMemoryTag::U16); + trace_builder.return_op(5, 1); + auto trace = trace_builder.finalize(); + + auto alu_row = + common_validate_add(trace, FF(33005), FF(1775), FF(34780), FF(546), FF(119), FF(5), AvmMemoryTag::U16); + + EXPECT_EQ(alu_row.aluChip_alu_u16_tag, FF(1)); + EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0xDC)); // 34780 = 0x87DC + EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0x87)); + + validate_trace_proof(std::move(trace)); +} + +// Test on basic addition over u16 type with carry. +TEST_F(AvmMiniArithmeticTestsU16, additionCarry) +{ + // trace_builder + trace_builder.set(UINT16_MAX - 982, 0, AvmMemoryTag::U16); + trace_builder.set(1000, 1, AvmMemoryTag::U16); + + trace_builder.add(1, 0, 0, AvmMemoryTag::U16); + trace_builder.return_op(0, 1); + auto trace = trace_builder.finalize(); + + auto alu_row = + common_validate_add(trace, FF(1000), FF(UINT16_MAX - 982), FF(17), FF(1), FF(0), FF(0), AvmMemoryTag::U16); + + EXPECT_EQ(alu_row.aluChip_alu_u16_tag, FF(1)); + EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(17)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0)); + + validate_trace_proof(std::move(trace)); +} + +// Test on basic subtraction over u16 type. +TEST_F(AvmMiniArithmeticTestsU16, subtraction) +{ + // trace_builder + trace_builder.set(1775, 119, AvmMemoryTag::U16); + trace_builder.set(33005, 546, AvmMemoryTag::U16); + + trace_builder.sub(546, 119, 5, AvmMemoryTag::U16); + trace_builder.return_op(5, 1); + auto trace = trace_builder.finalize(); + + auto alu_row = + common_validate_sub(trace, FF(33005), FF(1775), FF(31230), FF(546), FF(119), FF(5), AvmMemoryTag::U16); + + EXPECT_EQ(alu_row.aluChip_alu_u16_tag, FF(1)); + EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0xFE)); // 31230 in Hex: 79FE + EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0x79)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(0)); + + validate_trace_proof(std::move(trace)); +} + +// Test on basic subtraction over u16 type with carry. +// For a subtraction a - b = c, there is a carry flag iff a < b (equivalent to a < c) +TEST_F(AvmMiniArithmeticTestsU16, subtractionCarry) +{ + // trace_builder + trace_builder.set(UINT16_MAX - 982, 0, AvmMemoryTag::U16); + trace_builder.set(1000, 1, AvmMemoryTag::U16); + + trace_builder.sub(1, 0, 0, AvmMemoryTag::U16); + trace_builder.return_op(0, 1); + auto trace = trace_builder.finalize(); + + auto alu_row = + common_validate_sub(trace, FF(1000), FF(UINT16_MAX - 982), FF(1983), FF(1), FF(0), FF(0), AvmMemoryTag::U16); + + EXPECT_EQ(alu_row.aluChip_alu_u16_tag, FF(1)); + EXPECT_EQ(alu_row.aluChip_alu_cf, FF(1)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0xBF)); // 1983 = 0x7BF + EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(7)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(UINT16_MAX)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r1, FF(UINT16_MAX)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r2, FF(UINT16_MAX)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r3, FF(UINT16_MAX)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r4, FF(UINT16_MAX)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r5, FF(UINT16_MAX)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r6, FF(UINT16_MAX)); + + validate_trace_proof(std::move(trace)); +} + +// Test on basic multiplication over u16 type. +TEST_F(AvmMiniArithmeticTestsU16, multiplication) +{ + // trace_builder + trace_builder.set(200, 0, AvmMemoryTag::U16); + trace_builder.set(245, 1, AvmMemoryTag::U16); + + trace_builder.mul(0, 1, 2, AvmMemoryTag::U16); + trace_builder.return_op(2, 1); + auto trace = trace_builder.finalize(); + + auto alu_row_index = + common_validate_mul(trace, FF(200), FF(245), FF(49000), FF(0), FF(1), FF(2), AvmMemoryTag::U16); + auto alu_row = trace.at(alu_row_index); + + EXPECT_EQ(alu_row.aluChip_alu_u16_tag, FF(1)); + + // Decomposition of integer multiplication in 8-bit and 16-bit registers + EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0x68)); // 49000 = 0xBF68 + EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0xBF)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(0)); + + validate_trace_proof(std::move(trace)); +} + +// Test on multiplication over u16 type with overflow. +TEST_F(AvmMiniArithmeticTestsU16, multiplicationOverflow) +{ + // trace_builder + trace_builder.set(512, 0, AvmMemoryTag::U16); + trace_builder.set(1024, 1, AvmMemoryTag::U16); + + trace_builder.mul(0, 1, 2, AvmMemoryTag::U16); + trace_builder.return_op(2, 1); + auto trace = trace_builder.finalize(); + + auto alu_row_index = common_validate_mul(trace, FF(512), FF(1024), FF(0), FF(0), FF(1), FF(2), AvmMemoryTag::U16); + auto alu_row = trace.at(alu_row_index); + + EXPECT_EQ(alu_row.aluChip_alu_u16_tag, FF(1)); + + // Decomposition of integer multiplication in 8-bit and 16-bit registers + // 512 * 1024 = 0 + 8 * 2^16 + EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(8)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r1, FF(0)); + + validate_trace_proof(std::move(trace)); +} + +/****************************************************************************** + * Positive Tests - U32 + ******************************************************************************/ + +// Test on basic addition over u32 type. +TEST_F(AvmMiniArithmeticTestsU32, addition) +{ + // trace_builder + trace_builder.set(1000000000, 8, AvmMemoryTag::U32); + trace_builder.set(1234567891, 9, AvmMemoryTag::U32); + + trace_builder.add(8, 9, 0, AvmMemoryTag::U32); + trace_builder.return_op(0, 1); + auto trace = trace_builder.finalize(); + + auto alu_row = common_validate_add( + trace, FF(1000000000), FF(1234567891), FF(2234567891LLU), FF(8), FF(9), FF(0), AvmMemoryTag::U32); + + EXPECT_EQ(alu_row.aluChip_alu_u32_tag, FF(1)); + EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(2234567891LLU & UINT8_MAX)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF((2234567891LLU >> 8) & UINT8_MAX)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(2234567891LLU >> 16)); + + validate_trace_proof(std::move(trace)); +} + +// Test on basic addition over u32 type with carry. +TEST_F(AvmMiniArithmeticTestsU32, additionCarry) +{ + // trace_builder + trace_builder.set(UINT32_MAX - 1293, 8, AvmMemoryTag::U32); + trace_builder.set(2293, 9, AvmMemoryTag::U32); + + trace_builder.add(8, 9, 0, AvmMemoryTag::U32); + trace_builder.return_op(0, 1); + auto trace = trace_builder.finalize(); + + auto alu_row = + common_validate_add(trace, FF(UINT32_MAX - 1293), FF(2293), FF(999), FF(8), FF(9), FF(0), AvmMemoryTag::U32); + + EXPECT_EQ(alu_row.aluChip_alu_u32_tag, FF(1)); + EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(231)); // 999 = 3 * 256 + 231 + EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(3)); + + validate_trace_proof(std::move(trace)); +} + +// Test on basic subtraction over u32 type. +TEST_F(AvmMiniArithmeticTestsU32, subtraction) +{ + // trace_builder + trace_builder.set(1345678991, 8, AvmMemoryTag::U32); + trace_builder.set(1234567891, 9, AvmMemoryTag::U32); + + trace_builder.sub(8, 9, 0, AvmMemoryTag::U32); + trace_builder.return_op(0, 1); + auto trace = trace_builder.finalize(); + + auto alu_row = common_validate_sub( + trace, FF(1345678991), FF(1234567891), FF(111111100), FF(8), FF(9), FF(0), AvmMemoryTag::U32); + + EXPECT_EQ(alu_row.aluChip_alu_u32_tag, FF(1)); + EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); + + // 111111100 = 0x69F6BBC + EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0xBC)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0x6B)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(0x69F)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r1, FF(0)); + + validate_trace_proof(std::move(trace)); +} + +// Test on basic subtraction over u32 type with carry. +// For a subtraction a - b = c, there is a carry flag iff a < b (equivalent to a < c) +TEST_F(AvmMiniArithmeticTestsU32, subtractionCarry) +{ + // trace_builder + trace_builder.set(UINT32_MAX - 99, 8, AvmMemoryTag::U32); + trace_builder.set(3210987654, 9, AvmMemoryTag::U32); + + trace_builder.sub(9, 8, 0, AvmMemoryTag::U32); + trace_builder.return_op(0, 1); + auto trace = trace_builder.finalize(); + + auto alu_row = common_validate_sub( + trace, FF(3210987654LLU), FF(UINT32_MAX - 99), FF(3210987754LLU), FF(9), FF(8), FF(0), AvmMemoryTag::U32); + + EXPECT_EQ(alu_row.aluChip_alu_u32_tag, FF(1)); + EXPECT_EQ(alu_row.aluChip_alu_cf, FF(1)); + + // 3210987754 = 0xBF63C8EA + EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0xEA)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0xC8)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(0xBF63)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r1, FF(UINT16_MAX)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r2, FF(UINT16_MAX)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r3, FF(UINT16_MAX)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r4, FF(UINT16_MAX)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r5, FF(UINT16_MAX)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r6, FF(UINT16_MAX)); + + validate_trace_proof(std::move(trace)); +} + +// Test on basic multiplication over u32 type. +TEST_F(AvmMiniArithmeticTestsU32, multiplication) +{ + // trace_builder + trace_builder.set(11111, 0, AvmMemoryTag::U32); + trace_builder.set(11111, 1, AvmMemoryTag::U32); + + trace_builder.mul(0, 1, 2, AvmMemoryTag::U32); + trace_builder.return_op(2, 1); + auto trace = trace_builder.finalize(); + + auto alu_row_index = + common_validate_mul(trace, FF(11111), FF(11111), FF(123454321), FF(0), FF(1), FF(2), AvmMemoryTag::U32); + auto alu_row = trace.at(alu_row_index); + + EXPECT_EQ(alu_row.aluChip_alu_u32_tag, FF(1)); + + // Decomposition of integer multiplication in 8-bit and 16-bit registers + // 123454321 = 0x75BC371 + EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0x71)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0xC3)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(0x75B)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r1, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r2, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r3, FF(0)); + + validate_trace_proof(std::move(trace)); +} + +// Test on multiplication over u32 type with overflow. +TEST_F(AvmMiniArithmeticTestsU32, multiplicationOverflow) +{ + // trace_builder + trace_builder.set(11 << 25, 0, AvmMemoryTag::U32); + trace_builder.set(13 << 22, 1, AvmMemoryTag::U32); + + trace_builder.mul(0, 1, 2, AvmMemoryTag::U32); + trace_builder.return_op(2, 1); + auto trace = trace_builder.finalize(); + + auto alu_row_index = + common_validate_mul(trace, FF(11 << 25), FF(13 << 22), FF(0), FF(0), FF(1), FF(2), AvmMemoryTag::U32); + auto alu_row = trace.at(alu_row_index); + + EXPECT_EQ(alu_row.aluChip_alu_u32_tag, FF(1)); + + // Decomposition of integer multiplication in 8-bit and 16-bit registers + // 143 * 2^47 = 0 + 0 * 2^16 + 2^15 * 2^32 + 71 * 2^48 + EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r1, FF(32768)); // 2^15 + EXPECT_EQ(alu_row.aluChip_alu_u16_r2, FF(71)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r3, FF(0)); + + validate_trace_proof(std::move(trace)); +} + +/****************************************************************************** + * Positive Tests - U64 + ******************************************************************************/ + +// Test on basic addition over u64 type. +TEST_F(AvmMiniArithmeticTestsU64, addition) +{ + uint64_t const a = 7813981340746672LLU; + uint64_t const b = 2379061066771309LLU; + uint64_t const c = 10193042407517981LLU; + + // trace_builder + trace_builder.set(a, 8, AvmMemoryTag::U64); + trace_builder.set(b, 9, AvmMemoryTag::U64); + + trace_builder.add(8, 9, 9, AvmMemoryTag::U64); + trace_builder.return_op(9, 1); + auto trace = trace_builder.finalize(); + + auto alu_row = common_validate_add(trace, FF(a), FF(b), FF(c), FF(8), FF(9), FF(9), AvmMemoryTag::U64); + + EXPECT_EQ(alu_row.aluChip_alu_u64_tag, FF(1)); + EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); + + // c in HEX: 2436849FE16F1D + EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0x1D)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0x6F)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(0x9FE1)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r1, FF(0x3684)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r2, FF(0x24)); + + validate_trace_proof(std::move(trace)); +} + +// Test on basic addition over u64 type with carry. +TEST_F(AvmMiniArithmeticTestsU64, additionCarry) +{ + uint64_t const a = UINT64_MAX - 77LLU; + uint64_t const b = UINT64_MAX - 123LLU; + uint64_t const c = UINT64_MAX - 201LLU; + + // trace_builder + trace_builder.set(a, 0, AvmMemoryTag::U64); + trace_builder.set(b, 1, AvmMemoryTag::U64); + + trace_builder.add(0, 1, 0, AvmMemoryTag::U64); + trace_builder.return_op(0, 1); + auto trace = trace_builder.finalize(); + + auto alu_row = common_validate_add(trace, FF(a), FF(b), FF(c), FF(0), FF(1), FF(0), AvmMemoryTag::U64); + + EXPECT_EQ(alu_row.aluChip_alu_u64_tag, FF(1)); + EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(UINT8_MAX - 201)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(UINT8_MAX)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(UINT16_MAX)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r1, FF(UINT16_MAX)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r2, FF(UINT16_MAX)); + + validate_trace_proof(std::move(trace)); +} + +// Test on basic subtraction over u64 type. +TEST_F(AvmMiniArithmeticTestsU64, subtraction) +{ + uint64_t const a = 9876543210123456789LLU; + uint64_t const b = 9866543210123456789LLU; + uint64_t const c = 10000000000000000LLU; + + // trace_builder + trace_builder.set(a, 8, AvmMemoryTag::U64); + trace_builder.set(b, 9, AvmMemoryTag::U64); + + trace_builder.sub(8, 9, 9, AvmMemoryTag::U64); + trace_builder.return_op(9, 1); + auto trace = trace_builder.finalize(); + + auto alu_row = common_validate_sub(trace, FF(a), FF(b), FF(c), FF(8), FF(9), FF(9), AvmMemoryTag::U64); + + EXPECT_EQ(alu_row.aluChip_alu_u64_tag, FF(1)); + EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); + + // 10000000000000000 = 0x2386F26FC10000 + EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(0X6FC1)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r1, FF(0X86F2)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r2, FF(0X23)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r3, FF(0)); + + validate_trace_proof(std::move(trace)); +} + +// Test on basic subtraction over u64 type with carry. +// For a subtraction a - b = c, there is a carry flag iff a < b (equivalent to a < c) +TEST_F(AvmMiniArithmeticTestsU64, subtractionCarry) +{ + uint64_t const a = UINT64_MAX - 77LLU; + uint64_t const b = UINT64_MAX - 2LLU; + uint64_t const c = UINT64_MAX - 74; + + // trace_builder + trace_builder.set(a, 0, AvmMemoryTag::U64); + trace_builder.set(b, 1, AvmMemoryTag::U64); + + trace_builder.sub(0, 1, 0, AvmMemoryTag::U64); + trace_builder.return_op(0, 1); + auto trace = trace_builder.finalize(); + + auto alu_row = common_validate_sub(trace, FF(a), FF(b), FF(c), FF(0), FF(1), FF(0), AvmMemoryTag::U64); + + EXPECT_EQ(alu_row.aluChip_alu_u64_tag, FF(1)); + EXPECT_EQ(alu_row.aluChip_alu_cf, FF(1)); + + EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(UINT8_MAX - 74)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(UINT8_MAX)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(UINT16_MAX)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r1, FF(UINT16_MAX)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r2, FF(UINT16_MAX)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r3, FF(UINT16_MAX)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r4, FF(UINT16_MAX)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r5, FF(UINT16_MAX)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r6, FF(UINT16_MAX)); + validate_trace_proof(std::move(trace)); +} + +// Test on basic multiplication over u64 type. +TEST_F(AvmMiniArithmeticTestsU64, multiplication) +{ + // trace_builder + trace_builder.set(999888777, 0, AvmMemoryTag::U64); + trace_builder.set(555444333, 1, AvmMemoryTag::U64); + + trace_builder.mul(0, 1, 2, AvmMemoryTag::U64); + trace_builder.return_op(2, 1); + auto trace = trace_builder.finalize(); + + auto alu_row_index = common_validate_mul( + trace, FF(999888777), FF(555444333), FF(555382554814950741LLU), FF(0), FF(1), FF(2), AvmMemoryTag::U64); + auto alu_row = trace.at(alu_row_index); + + EXPECT_EQ(alu_row.aluChip_alu_u64_tag, FF(1)); + + // Decomposition of integer multiplication in 8-bit and 16-bit registers + // 555,382,554,814,950,741 = 0x 7B5 1D7D B631 AD55 + EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0x55)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0xAD)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(0xB631)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r1, FF(0x1D7D)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r2, FF(0x7B5)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r3, FF(0)); + + validate_trace_proof(std::move(trace)); +} + +// Test on multiplication over u64 type with overflow. +TEST_F(AvmMiniArithmeticTestsU64, multiplicationOverflow) +{ + uint64_t const a = UINT64_MAX; + uint64_t const b = UINT64_MAX; + // (2^64 - 1)^2 = 2^128 - 2^65 + 1 (mod. 2^64) = 1 + + // trace_builder + trace_builder.set(a, 0, AvmMemoryTag::U64); + trace_builder.set(b, 1, AvmMemoryTag::U64); + + trace_builder.mul(0, 1, 2, AvmMemoryTag::U64); + trace_builder.return_op(2, 1); + auto trace = trace_builder.finalize(); + + auto alu_row_index = common_validate_mul(trace, FF(a), FF(b), FF(1), FF(0), FF(1), FF(2), AvmMemoryTag::U64); + auto alu_row = trace.at(alu_row_index); + + EXPECT_EQ(alu_row.aluChip_alu_u64_tag, FF(1)); + + // Decomposition of integer multiplication in 8-bit and 16-bit registers + // 2^128 - 2^65 + 1 + EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(1)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r1, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r2, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r3, FF(UINT16_MAX - 1)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r4, FF(UINT16_MAX)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r5, FF(UINT16_MAX)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r6, FF(UINT16_MAX)); + + validate_trace_proof(std::move(trace)); +} + +/****************************************************************************** + * Positive Tests - U128 + ******************************************************************************/ + +// Test on basic addition over u128 type. +TEST_F(AvmMiniArithmeticTestsU128, addition) +{ + uint128_t const a = (uint128_t{ 0x5555222233334444LLU } << 64) + uint128_t{ 0x88889999AAAABBBBLLU }; + uint128_t const b = (uint128_t{ 0x3333222233331111LLU } << 64) + uint128_t{ 0x5555111155553333LLU }; + uint128_t const c = (uint128_t{ 0x8888444466665555LLU } << 64) + uint128_t{ 0xDDDDAAAAFFFFEEEELLU }; + + // trace_builder + trace_builder.set(a, 8, AvmMemoryTag::U128); + trace_builder.set(b, 9, AvmMemoryTag::U128); + + trace_builder.add(8, 9, 9, AvmMemoryTag::U128); + trace_builder.return_op(9, 1); + auto trace = trace_builder.finalize(); + + auto alu_row = common_validate_add(trace, + FF(uint256_t::from_uint128(a)), + FF(uint256_t::from_uint128(b)), + FF(uint256_t::from_uint128(c)), + FF(8), + FF(9), + FF(9), + AvmMemoryTag::U128); + + EXPECT_EQ(alu_row.aluChip_alu_u128_tag, FF(1)); + EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0xEE)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0xEE)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(0xFFFF)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r1, FF(0xAAAA)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r2, FF(0xDDDD)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r3, FF(0x5555)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r4, FF(0x6666)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r5, FF(0x4444)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r6, FF(0x8888)); + + validate_trace_proof(std::move(trace)); +} + +// Test on basic addition over u128 type with carry. +TEST_F(AvmMiniArithmeticTestsU128, additionCarry) +{ + uint128_t const a = (uint128_t{ UINT64_MAX } << 64) + uint128_t{ UINT64_MAX } - uint128_t{ 72948899 }; + uint128_t const b = (uint128_t{ UINT64_MAX } << 64) + uint128_t{ UINT64_MAX } - uint128_t{ 36177344 }; + uint128_t const c = + (uint128_t{ UINT64_MAX } << 64) + uint128_t{ UINT64_MAX } - uint128_t{ 36177345 } - uint128_t{ 72948899 }; + + // trace_builder + trace_builder.set(a, 8, AvmMemoryTag::U128); + trace_builder.set(b, 9, AvmMemoryTag::U128); + + trace_builder.add(8, 9, 9, AvmMemoryTag::U128); + trace_builder.return_op(9, 1); + auto trace = trace_builder.finalize(); + + auto alu_row = common_validate_add(trace, + FF(uint256_t::from_uint128(a)), + FF(uint256_t::from_uint128(b)), + FF(uint256_t::from_uint128(c)), + FF(8), + FF(9), + FF(9), + AvmMemoryTag::U128); + + EXPECT_EQ(alu_row.aluChip_alu_u128_tag, FF(1)); + EXPECT_EQ(alu_row.aluChip_alu_cf, FF(1)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0x9B)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0xDD)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(0xF97E)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r1, FF(0xFFFF)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r2, FF(0xFFFF)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r3, FF(0xFFFF)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r4, FF(0xFFFF)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r5, FF(0xFFFF)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r6, FF(0xFFFF)); + + validate_trace_proof(std::move(trace)); +} + +// Test on basic subtraction over u128 type. +TEST_F(AvmMiniArithmeticTestsU128, subtraction) +{ + uint128_t const a = (uint128_t{ UINT64_MAX } << 64) + uint128_t{ UINT64_MAX } - uint128_t{ 36177344 }; + uint128_t const b = (uint128_t{ UINT64_MAX } << 64) + uint128_t{ UINT64_MAX } - uint128_t{ 72948899 }; + uint128_t const c = 36771555; // 72948899 - 36177344 + + // trace_builder + trace_builder.set(a, 8, AvmMemoryTag::U128); + trace_builder.set(b, 9, AvmMemoryTag::U128); + + trace_builder.sub(8, 9, 9, AvmMemoryTag::U128); + trace_builder.return_op(9, 1); + auto trace = trace_builder.finalize(); + + auto alu_row = common_validate_sub(trace, + FF(uint256_t::from_uint128(a)), + FF(uint256_t::from_uint128(b)), + FF(uint256_t::from_uint128(c)), + FF(8), + FF(9), + FF(9), + AvmMemoryTag::U128); + + EXPECT_EQ(alu_row.aluChip_alu_u128_tag, FF(1)); + EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); + + // 36771555 = 23116E3 + EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0xE3)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0x16)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(0x231)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r1, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r2, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r3, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r4, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r5, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r6, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r7, FF(0)); + + validate_trace_proof(std::move(trace)); +} + +// Test on basic subtraction over u128 type with carry. +TEST_F(AvmMiniArithmeticTestsU128, subtractionCarry) +{ + uint128_t const a = (uint128_t{ 0x5555222233334444LLU } << 64) + uint128_t{ 0x88889999AAAABBBBLLU }; + uint128_t const b = (uint128_t{ 0x3333222233331111LLU } << 64) + uint128_t{ 0x5555111155553333LLU }; + uint128_t const c = (uint128_t{ 0x2222000000003333LLU } << 64) + uint128_t{ 0x3333888855558888LLU }; + + // trace_builder + trace_builder.set(a, 8, AvmMemoryTag::U128); + trace_builder.set(b, 9, AvmMemoryTag::U128); + + trace_builder.sub(8, 9, 9, AvmMemoryTag::U128); + trace_builder.return_op(9, 1); + auto trace = trace_builder.finalize(); + + auto alu_row = common_validate_sub(trace, + FF(uint256_t::from_uint128(a)), + FF(uint256_t::from_uint128(b)), + FF(uint256_t::from_uint128(c)), + FF(8), + FF(9), + FF(9), + AvmMemoryTag::U128); + + EXPECT_EQ(alu_row.aluChip_alu_u128_tag, FF(1)); + EXPECT_EQ(alu_row.aluChip_alu_cf, FF(0)); + + EXPECT_EQ(alu_row.aluChip_alu_u8_r0, FF(0x88)); + EXPECT_EQ(alu_row.aluChip_alu_u8_r1, FF(0x88)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r0, FF(0x5555)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r1, FF(0x8888)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r2, FF(0x3333)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r3, FF(0x3333)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r4, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r5, FF(0)); + EXPECT_EQ(alu_row.aluChip_alu_u16_r6, FF(0x2222)); + + validate_trace_proof(std::move(trace)); +} + +// Test on basic multiplication over u128 type. +TEST_F(AvmMiniArithmeticTestsU128, multiplication) +{ + // trace_builder + trace_builder.set(0x38D64BF685FFBLLU, 0, AvmMemoryTag::U128); + trace_builder.set(0x1F92C762C98DFLLU, 1, AvmMemoryTag::U128); + // Integer multiplication output in HEX: 70289AEB0A7DDA0BAE60CA3A5 + FF c{ uint256_t{ 0xA7DDA0BAE60CA3A5, 0x70289AEB0, 0, 0 } }; + + trace_builder.mul(0, 1, 2, AvmMemoryTag::U128); + trace_builder.return_op(2, 1); + auto trace = trace_builder.finalize(); + + auto alu_row_index = common_validate_mul( + trace, FF(0x38D64BF685FFBLLU), FF(555444333222111LLU), c, FF(0), FF(1), FF(2), AvmMemoryTag::U128); + auto alu_row_first = trace.at(alu_row_index); + + EXPECT_EQ(alu_row_first.aluChip_alu_u128_tag, FF(1)); + + // Decomposition of the first operand in 16-bit registers + EXPECT_EQ(alu_row_first.aluChip_alu_u16_r0, FF(0x5FFB)); + EXPECT_EQ(alu_row_first.aluChip_alu_u16_r1, FF(0xBF68)); + EXPECT_EQ(alu_row_first.aluChip_alu_u16_r2, FF(0x8D64)); + EXPECT_EQ(alu_row_first.aluChip_alu_u16_r3, FF(0x3)); + + // Decomposition of the second operand in 16-bit registers + auto alu_row_second = trace.at(alu_row_index + 1); + EXPECT_EQ(alu_row_second.aluChip_alu_u16_r0, FF(0x98DF)); + EXPECT_EQ(alu_row_second.aluChip_alu_u16_r1, FF(0x762C)); + EXPECT_EQ(alu_row_second.aluChip_alu_u16_r2, FF(0xF92C)); + EXPECT_EQ(alu_row_second.aluChip_alu_u16_r3, FF(0x1)); + validate_trace_proof(std::move(trace)); +} + +// Test on multiplication over u128 type with overflow. +TEST_F(AvmMiniArithmeticTestsU128, multiplicationOverflow) +{ + // (2^128 - 2) * (2^128 - 4) = 2^256 - 2^130 - 2^129 + 2^3 + // The above modulo 2^128 = 8 + uint128_t const a = (uint128_t{ UINT64_MAX } << 64) + uint128_t{ UINT64_MAX - 1 }; + uint128_t const b = (uint128_t{ UINT64_MAX } << 64) + uint128_t{ UINT64_MAX - 3 }; + + // trace_builder + trace_builder.set(a, 0, AvmMemoryTag::U128); + trace_builder.set(b, 1, AvmMemoryTag::U128); + + trace_builder.mul(0, 1, 2, AvmMemoryTag::U128); + trace_builder.return_op(2, 1); + auto trace = trace_builder.finalize(); + + auto alu_row_index = common_validate_mul(trace, + FF{ uint256_t::from_uint128(a) }, + FF{ uint256_t::from_uint128(b) }, + FF{ 8 }, + FF(0), + FF(1), + FF(2), + AvmMemoryTag::U128); + auto alu_row_first = trace.at(alu_row_index); + + EXPECT_EQ(alu_row_first.aluChip_alu_u128_tag, FF(1)); + + // Decomposition of the first operand in 16-bit registers + EXPECT_EQ(alu_row_first.aluChip_alu_u16_r0, FF(0xFFFE)); + EXPECT_EQ(alu_row_first.aluChip_alu_u16_r1, FF(UINT16_MAX)); + EXPECT_EQ(alu_row_first.aluChip_alu_u16_r2, FF(UINT16_MAX)); + EXPECT_EQ(alu_row_first.aluChip_alu_u16_r3, FF(UINT16_MAX)); + EXPECT_EQ(alu_row_first.aluChip_alu_u16_r4, FF(UINT16_MAX)); + EXPECT_EQ(alu_row_first.aluChip_alu_u16_r5, FF(UINT16_MAX)); + EXPECT_EQ(alu_row_first.aluChip_alu_u16_r6, FF(UINT16_MAX)); + EXPECT_EQ(alu_row_first.aluChip_alu_u16_r7, FF(UINT16_MAX)); + + // Decomposition of the second operand in 16-bit registers + auto alu_row_second = trace.at(alu_row_index + 1); + EXPECT_EQ(alu_row_second.aluChip_alu_u16_r0, FF(0xFFFC)); + EXPECT_EQ(alu_row_second.aluChip_alu_u16_r1, FF(UINT16_MAX)); + EXPECT_EQ(alu_row_second.aluChip_alu_u16_r2, FF(UINT16_MAX)); + EXPECT_EQ(alu_row_second.aluChip_alu_u16_r3, FF(UINT16_MAX)); + EXPECT_EQ(alu_row_second.aluChip_alu_u16_r4, FF(UINT16_MAX)); + EXPECT_EQ(alu_row_second.aluChip_alu_u16_r5, FF(UINT16_MAX)); + EXPECT_EQ(alu_row_second.aluChip_alu_u16_r6, FF(UINT16_MAX)); + EXPECT_EQ(alu_row_second.aluChip_alu_u16_r7, FF(UINT16_MAX)); + + // Other registers involved in the relevant relations + // PIL relation (alu_chip.pil): a * b_l + a_l * b_h * 2^64 = (CF * 2^64 + R') * 2^128 + c + // (2^128 - 2) * (2^64 - 4) + (2^64 - 2) * (2^64 - 1) * 2^64 = + // 2 * 2^192 + (- 4 - 2 - 1) * 2^128 + (-2 + 2) * 2^64 + 8 = (2^65 - 7) * 2^128 + 8 + // Therefore, CF = 1 and R' = 2^64 - 7 + EXPECT_EQ(alu_row_first.aluChip_alu_u64_r0, FF{ UINT64_MAX - 6 }); // 2^64 - 7 + EXPECT_EQ(alu_row_first.aluChip_alu_cf, FF(1)); + + validate_trace_proof(std::move(trace)); +} + /****************************************************************************** * * NEGATIVE TESTS - Finite Field Type @@ -277,7 +1361,7 @@ TEST_F(AvmMiniArithmeticTests, arithmeticFFWithError) * and division by having dedicated unit test for each of them. * A typical pattern is to wrongly mutate the result of the operation. The memory trace * is consistently adapted so that the negative test is applying to the relation - * if the arithmetic operation and not the layout of the memory trace. + * of the arithmetic operation and not the layout of the memory trace. * * Finding the row pertaining to the arithmetic operation is done through * a scan of all rows and stopping at the first one with the corresponding @@ -285,58 +1369,39 @@ TEST_F(AvmMiniArithmeticTests, arithmeticFFWithError) * will still correctly work along the development of the AVM. ******************************************************************************/ +/****************************************************************************** + * Negative Tests - FF + ******************************************************************************/ + // Test on basic incorrect addition over finite field type. -TEST_F(AvmMiniArithmeticNegativeTests, additionFF) +TEST_F(AvmMiniArithmeticNegativeTestsFF, addition) { - trace_builder.call_data_copy(0, 3, 0, std::vector{ 37, 4, 11 }); - - // Memory layout: [37,4,11,0,0,0,....] - trace_builder.add(0, 1, 4, AvmMemoryTag::ff); // [37,4,11,0,41,0,....] - auto trace = trace_builder.finalize(); - - auto select_row = [](Row r) { return r.avmMini_sel_op_add == FF(1); }; - mutate_ic_in_trace(trace, std::move(select_row), FF(40)); - - EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "SUBOP_ADDITION_FF"); + auto trace = gen_mutated_trace_add(FF(37), FF(4), FF(40), AvmMemoryTag::FF); + EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_ADD_SUB_1"); } // Test on basic incorrect subtraction over finite field type. -TEST_F(AvmMiniArithmeticNegativeTests, subtractionFF) +TEST_F(AvmMiniArithmeticNegativeTestsFF, subtraction) { - trace_builder.call_data_copy(0, 3, 0, std::vector{ 8, 4, 17 }); - - // Memory layout: [8,4,17,0,0,0,....] - trace_builder.sub(2, 0, 1, AvmMemoryTag::ff); // [8,9,17,0,0,0....] - auto trace = trace_builder.finalize(); - - auto select_row = [](Row r) { return r.avmMini_sel_op_sub == FF(1); }; - mutate_ic_in_trace(trace, std::move(select_row), FF(-9)); - - EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "SUBOP_SUBTRACTION_FF"); + auto trace = gen_mutated_trace_sub(FF(17), FF(8), FF(-9), AvmMemoryTag::FF); + EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_ADD_SUB_1"); } // Test on basic incorrect multiplication over finite field type. -TEST_F(AvmMiniArithmeticNegativeTests, multiplicationFF) +TEST_F(AvmMiniArithmeticNegativeTestsFF, multiplication) { - trace_builder.call_data_copy(0, 3, 0, std::vector{ 5, 0, 20 }); - - // Memory layout: [5,0,20,0,0,0,....] - trace_builder.mul(2, 0, 1, AvmMemoryTag::ff); // [5,100,20,0,0,0....] - auto trace = trace_builder.finalize(); - - auto select_row = [](Row r) { return r.avmMini_sel_op_mul == FF(1); }; - mutate_ic_in_trace(trace, std::move(select_row), FF(1000)); - - EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "SUBOP_MULTIPLICATION_FF"); + auto trace = gen_mutated_trace_mul(FF(9), FF(100), FF(9000000), AvmMemoryTag::FF); + EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_MULTIPLICATION_FF"); } // Test on basic incorrect division over finite field type. -TEST_F(AvmMiniArithmeticNegativeTests, divisionFF) +TEST_F(AvmMiniArithmeticNegativeTestsFF, divisionFF) { trace_builder.call_data_copy(0, 2, 0, std::vector{ 15, 315 }); // Memory layout: [15,315,0,0,0,0,....] - trace_builder.div(1, 0, 2, AvmMemoryTag::ff); // [15,315,21,0,0,0....] + trace_builder.div(1, 0, 2, AvmMemoryTag::FF); // [15,315,21,0,0,0....] + trace_builder.halt(); auto trace = trace_builder.finalize(); auto select_row = [](Row r) { return r.avmMini_sel_op_div == FF(1); }; @@ -347,12 +1412,13 @@ TEST_F(AvmMiniArithmeticNegativeTests, divisionFF) // Test where division is not by zero but an operation error is wrongly raised // in the trace. -TEST_F(AvmMiniArithmeticNegativeTests, divisionNoZeroButErrorFF) +TEST_F(AvmMiniArithmeticNegativeTestsFF, divisionNoZeroButError) { trace_builder.call_data_copy(0, 2, 0, std::vector{ 15, 315 }); // Memory layout: [15,315,0,0,0,0,....] - trace_builder.div(1, 0, 2, AvmMemoryTag::ff); // [15,315,21,0,0,0....] + trace_builder.div(1, 0, 2, AvmMemoryTag::FF); // [15,315,21,0,0,0....] + trace_builder.halt(); auto trace = trace_builder.finalize(); // Find the first row enabling the division selector @@ -372,12 +1438,12 @@ TEST_F(AvmMiniArithmeticNegativeTests, divisionNoZeroButErrorFF) } // Test with division by zero occurs and no error is raised (remove error flag) -TEST_F(AvmMiniArithmeticNegativeTests, divisionByZeroNoErrorFF) +TEST_F(AvmMiniArithmeticNegativeTestsFF, divisionByZeroNoError) { trace_builder.call_data_copy(0, 1, 0, std::vector{ 15 }); // Memory layout: [15,0,0,0,0,0,....] - trace_builder.div(0, 1, 2, AvmMemoryTag::ff); // [15,0,0,0,0,0....] + trace_builder.div(0, 1, 2, AvmMemoryTag::FF); // [15,0,0,0,0,0....] trace_builder.halt(); auto trace = trace_builder.finalize(); @@ -391,10 +1457,11 @@ TEST_F(AvmMiniArithmeticNegativeTests, divisionByZeroNoErrorFF) } // Test with division of zero by zero occurs and no error is raised (remove error flag) -TEST_F(AvmMiniArithmeticNegativeTests, divisionZeroByZeroNoErrorFF) +TEST_F(AvmMiniArithmeticNegativeTestsFF, divisionZeroByZeroNoError) { // Memory layout: [0,0,0,0,0,0,....] - trace_builder.div(0, 1, 2, AvmMemoryTag::ff); // [0,0,0,0,0,0....] + trace_builder.div(0, 1, 2, AvmMemoryTag::FF); // [0,0,0,0,0,0....] + trace_builder.halt(); auto trace = trace_builder.finalize(); // Find the first row enabling the division selector @@ -408,13 +1475,14 @@ TEST_F(AvmMiniArithmeticNegativeTests, divisionZeroByZeroNoErrorFF) // Test that error flag cannot be raised for a non-relevant operation such as // the addition, subtraction, multiplication. -TEST_F(AvmMiniArithmeticNegativeTests, operationWithErrorFlagFF) +TEST_F(AvmMiniArithmeticNegativeTestsFF, operationWithErrorFlag) { trace_builder.call_data_copy(0, 3, 0, std::vector{ 37, 4, 11 }); // Memory layout: [37,4,11,0,0,0,....] - trace_builder.add(0, 1, 4, AvmMemoryTag::ff); // [37,4,11,0,41,0,....] + trace_builder.add(0, 1, 4, AvmMemoryTag::FF); // [37,4,11,0,41,0,....] trace_builder.return_op(0, 5); + trace_builder.halt(); auto trace = trace_builder.finalize(); // Find the first row enabling the addition selector @@ -430,7 +1498,7 @@ TEST_F(AvmMiniArithmeticNegativeTests, operationWithErrorFlagFF) trace_builder.call_data_copy(0, 3, 0, std::vector{ 8, 4, 17 }); // Memory layout: [8,4,17,0,0,0,....] - trace_builder.sub(2, 0, 1, AvmMemoryTag::ff); // [8,9,17,0,0,0....] + trace_builder.sub(2, 0, 1, AvmMemoryTag::FF); // [8,9,17,0,0,0....] trace_builder.return_op(0, 3); trace = trace_builder.finalize(); @@ -447,7 +1515,7 @@ TEST_F(AvmMiniArithmeticNegativeTests, operationWithErrorFlagFF) trace_builder.call_data_copy(0, 3, 0, std::vector{ 5, 0, 20 }); // Memory layout: [5,0,20,0,0,0,....] - trace_builder.mul(2, 0, 1, AvmMemoryTag::ff); // [5,100,20,0,0,0....] + trace_builder.mul(2, 0, 1, AvmMemoryTag::FF); // [5,100,20,0,0,0....] trace_builder.return_op(0, 3); trace = trace_builder.finalize(); @@ -460,4 +1528,151 @@ TEST_F(AvmMiniArithmeticNegativeTests, operationWithErrorFlagFF) EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "SUBOP_ERROR_RELEVANT_OP"); } -} // namespace tests_avm \ No newline at end of file +/****************************************************************************** + * Negative Tests - U8 + ******************************************************************************/ + +// Test on basic incorrect addition over U8. +TEST_F(AvmMiniArithmeticNegativeTestsU8, addition) +{ + auto trace = gen_mutated_trace_add(FF(234), FF(22), FF(1), AvmMemoryTag::U8); + EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_ADD_SUB_2"); +} + +// Test on basic incorrect subtraction over U8. +TEST_F(AvmMiniArithmeticNegativeTestsU8, subtraction) +{ + auto trace = gen_mutated_trace_sub(FF(100), FF(104), FF(253), AvmMemoryTag::U8); + EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_ADD_SUB_2"); +} + +// Test on basic incorrect multiplication over U8. +TEST_F(AvmMiniArithmeticNegativeTestsU8, multiplication) +{ + auto trace = gen_mutated_trace_mul(FF(9), FF(100), FF(55), AvmMemoryTag::U8); + EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_MUL_COMMON_2"); +} + +/****************************************************************************** + * Negative Tests - U16 + ******************************************************************************/ + +// Test on basic incorrect addition over U16. +TEST_F(AvmMiniArithmeticNegativeTestsU16, addition) +{ + auto trace = gen_mutated_trace_add(FF(8234), FF(7428), FF(653), AvmMemoryTag::U16); + EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_ADD_SUB_2"); +} + +// Test on basic incorrect subtraction over U16. +TEST_F(AvmMiniArithmeticNegativeTestsU16, subtraction) +{ + auto trace = gen_mutated_trace_sub(FF(100), FF(932), FF(25373), AvmMemoryTag::U16); + EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_ADD_SUB_2"); +} + +// Test on basic incorrect multiplication over U16. +TEST_F(AvmMiniArithmeticNegativeTestsU16, multiplication) +{ + auto trace = gen_mutated_trace_mul(FF(8096), FF(1024), FF(1), AvmMemoryTag::U16); + EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_MUL_COMMON_2"); +} + +/****************************************************************************** + * Negative Tests - U32 + ******************************************************************************/ + +// Test on basic incorrect addition over U32. +TEST_F(AvmMiniArithmeticNegativeTestsU32, addition) +{ + auto trace = gen_mutated_trace_add(FF(1972382341), FF(1111133221), FF(1222222222), AvmMemoryTag::U32); + EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_ADD_SUB_2"); +} + +// Test on basic incorrect subtraction over U32. +TEST_F(AvmMiniArithmeticNegativeTestsU32, subtraction) +{ + auto trace = gen_mutated_trace_sub(FF(3999888777LLU), FF(UINT32_MAX), FF(2537332433LLU), AvmMemoryTag::U32); + EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_ADD_SUB_2"); +} + +// Test on basic incorrect multiplication over U32. +TEST_F(AvmMiniArithmeticNegativeTestsU32, multiplication) +{ + auto trace = gen_mutated_trace_mul(FF(UINT32_MAX), FF(UINT32_MAX), FF(0), AvmMemoryTag::U32); + EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_MUL_COMMON_2"); +} + +/****************************************************************************** + * Negative Tests - U64 + ******************************************************************************/ + +// Test on basic incorrect addition over U64. +TEST_F(AvmMiniArithmeticNegativeTestsU64, addition) +{ + auto trace = gen_mutated_trace_add( + FF(3324236423198282341LLU), FF(999999991111133221LLU), FF(1222222222236LLU), AvmMemoryTag::U64); + EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_ADD_SUB_2"); +} + +// Test on basic incorrect subtraction over U64. +TEST_F(AvmMiniArithmeticNegativeTestsU64, subtraction) +{ + auto trace = + gen_mutated_trace_sub(FF(399988877723434LLU), FF(UINT64_MAX), FF(25373324332342LLU), AvmMemoryTag::U64); + EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_ADD_SUB_2"); +} + +// Test on basic incorrect multiplication over U64. +TEST_F(AvmMiniArithmeticNegativeTestsU64, multiplication) +{ + auto trace = + gen_mutated_trace_mul(FF(399988877723434LLU), FF(9998887772343LLU), FF(9283674827534LLU), AvmMemoryTag::U64); + EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_MUL_COMMON_2"); +} + +/****************************************************************************** + * Negative Tests - U128 + ******************************************************************************/ + +// Test on basic incorrect addition over U128. +TEST_F(AvmMiniArithmeticNegativeTestsU128, addition) +{ + uint128_t const a = (uint128_t{ 0x5555222233334444LLU } << 64) + uint128_t{ 0x88889999AAAABBBBLLU }; + uint128_t const b = (uint128_t{ 0x3333222233331111LLU } << 64) + uint128_t{ 0x5555111155553333LLU }; + uint128_t const c = (uint128_t{ 0x8888444466665555LLU } << 64) + uint128_t{ 0xDDDDAAAAFFFFEEEFLLU }; + + auto trace = gen_mutated_trace_add(FF{ uint256_t::from_uint128(a) }, + FF{ uint256_t::from_uint128(b) }, + FF{ uint256_t::from_uint128(c) }, + AvmMemoryTag::U128); + EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_ADD_SUB_2"); +} + +// Test on basic incorrect subtraction over U128. +TEST_F(AvmMiniArithmeticNegativeTestsU128, subtraction) +{ + uint128_t const a = (uint128_t{ 0x5555222233334444LLU } << 64) + uint128_t{ 0x88889999AAAABBBBLLU }; + uint128_t const b = (uint128_t{ 0x7333222233331111LLU } << 64) + uint128_t{ 0x5555111155553333LLU }; + uint128_t const c = (uint128_t{ 0x8888444466665555LLU } << 64) + uint128_t{ 0xDDDDALLU }; + + auto trace = gen_mutated_trace_sub(FF{ uint256_t::from_uint128(a) }, + FF{ uint256_t::from_uint128(b) }, + FF{ uint256_t::from_uint128(c) }, + AvmMemoryTag::U128); + EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_ADD_SUB_2"); +} + +// Test on basic incorrect multiplication over U128. +TEST_F(AvmMiniArithmeticNegativeTestsU128, multiplication) +{ + uint128_t const a = (uint128_t{ 0x5555222233334444LLU } << 64) + uint128_t{ 0x88889999AAAABBBBLLU }; + uint128_t const b = (uint128_t{ 0x7333222233331111LLU } << 64) + uint128_t{ 0x5555111155553333LLU }; + uint128_t const c = (uint128_t{ 0x8888444466665555LLU } << 64) + uint128_t{ 0xDDDDALLU }; + + auto trace = gen_mutated_trace_mul(FF{ uint256_t::from_uint128(a) }, + FF{ uint256_t::from_uint128(b) }, + FF{ uint256_t::from_uint128(c) }, + AvmMemoryTag::U128); + EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "ALU_MULTIPLICATION_OUT_U128"); +} \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_common.test.hpp b/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_common.test.hpp new file mode 100644 index 000000000000..4d7154552af1 --- /dev/null +++ b/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_common.test.hpp @@ -0,0 +1,13 @@ +#pragma once + +#include "barretenberg/vm/avm_trace/AvmMini_helper.hpp" +#include "barretenberg/vm/generated/AvmMini_composer.hpp" +#include "barretenberg/vm/generated/AvmMini_prover.hpp" +#include "barretenberg/vm/generated/AvmMini_verifier.hpp" +#include "helpers.test.hpp" + +#include +#include +#include +#include +#include \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_control_flow.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_control_flow.test.cpp index eba7e312f211..657ae8e25b1b 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_control_flow.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_control_flow.test.cpp @@ -1,17 +1,7 @@ -#include "barretenberg/vm/avm_trace/AvmMini_helper.hpp" -#include "barretenberg/vm/generated/AvmMini_composer.hpp" -#include "barretenberg/vm/generated/AvmMini_prover.hpp" -#include "barretenberg/vm/generated/AvmMini_verifier.hpp" -#include "helpers.test.hpp" - -#include -#include -#include -#include -#include - -namespace tests_avm { +#include "AvmMini_common.test.hpp" + using namespace avm_trace; +using namespace tests_avm; class AvmMiniControlFlowTests : public ::testing::Test { public: @@ -21,7 +11,7 @@ class AvmMiniControlFlowTests : public ::testing::Test { // TODO(640): The Standard Honk on Grumpkin test suite fails unless the SRS is initialised for every test. void SetUp() override { - bb::srs::init_crs_factory("../srs_db/ignition"); + srs::init_crs_factory("../srs_db/ignition"); trace_builder = AvmMiniTraceBuilder(); // Clean instance for every run. }; }; @@ -295,4 +285,3 @@ TEST_F(AvmMiniControlFlowTests, multipleCallsAndReturns) validate_trace_proof(std::move(trace)); } -} // namespace tests_avm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_memory.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_memory.test.cpp index 79a3b03c96ad..a5ccfd1076a7 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_memory.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/AvmMini_memory.test.cpp @@ -1,18 +1,7 @@ -#include "barretenberg/vm/avm_trace/AvmMini_helper.hpp" -#include "barretenberg/vm/generated/AvmMini_composer.hpp" -#include "barretenberg/vm/generated/AvmMini_prover.hpp" -#include "barretenberg/vm/generated/AvmMini_verifier.hpp" -#include "helpers.test.hpp" - -#include -#include -#include -#include -#include - -namespace tests_avm { -using namespace avm_trace; +#include "AvmMini_common.test.hpp" +using namespace tests_avm; +using namespace avm_trace; class AvmMiniMemoryTests : public ::testing::Test { public: AvmMiniTraceBuilder trace_builder; @@ -21,7 +10,7 @@ class AvmMiniMemoryTests : public ::testing::Test { // TODO(640): The Standard Honk on Grumpkin test suite fails unless the SRS is initialised for every test. void SetUp() override { - bb::srs::init_crs_factory("../srs_db/ignition"); + srs::init_crs_factory("../srs_db/ignition"); trace_builder = AvmMiniTraceBuilder(); // Clean instance for every run. }; }; @@ -45,7 +34,7 @@ TEST_F(AvmMiniMemoryTests, mismatchedTag) { trace_builder.call_data_copy(0, 2, 0, std::vector{ 98, 12 }); - trace_builder.add(0, 1, 4, AvmMemoryTag::u8); + trace_builder.add(0, 1, 4, AvmMemoryTag::U8); trace_builder.halt(); auto trace = trace_builder.finalize(); @@ -69,8 +58,8 @@ TEST_F(AvmMiniMemoryTests, mismatchedTag) EXPECT_TRUE(row != trace.end()); EXPECT_EQ(row->memTrace_m_tag_err, FF(1)); // Error is raised - EXPECT_EQ(row->memTrace_m_in_tag, FF(static_cast(AvmMemoryTag::u8))); - EXPECT_EQ(row->memTrace_m_tag, FF(static_cast(AvmMemoryTag::ff))); + EXPECT_EQ(row->memTrace_m_in_tag, FF(static_cast(AvmMemoryTag::U8))); + EXPECT_EQ(row->memTrace_m_tag, FF(static_cast(AvmMemoryTag::FF))); // Find the memory trace position corresponding to the add sub-operation of register ib. row = std::ranges::find_if(trace.begin(), trace.end(), [clk](Row r) { @@ -80,8 +69,8 @@ TEST_F(AvmMiniMemoryTests, mismatchedTag) EXPECT_TRUE(row != trace.end()); EXPECT_EQ(row->memTrace_m_tag_err, FF(1)); // Error is raised - EXPECT_EQ(row->memTrace_m_in_tag, FF(static_cast(AvmMemoryTag::u8))); - EXPECT_EQ(row->memTrace_m_tag, FF(static_cast(AvmMemoryTag::ff))); + EXPECT_EQ(row->memTrace_m_in_tag, FF(static_cast(AvmMemoryTag::U8))); + EXPECT_EQ(row->memTrace_m_tag, FF(static_cast(AvmMemoryTag::FF))); validate_trace_proof(std::move(trace)); } @@ -93,7 +82,7 @@ TEST_F(AvmMiniMemoryTests, mLastAccessViolation) trace_builder.call_data_copy(0, 2, 0, std::vector{ 4, 9 }); // Memory layout: [4,9,0,0,0,0,....] - trace_builder.sub(1, 0, 2, AvmMemoryTag::u8); // [4,9,5,0,0,0.....] + trace_builder.sub(1, 0, 2, AvmMemoryTag::U8); // [4,9,5,0,0,0.....] trace_builder.halt(); auto trace = trace_builder.finalize(); @@ -123,7 +112,7 @@ TEST_F(AvmMiniMemoryTests, readWriteConsistencyValViolation) trace_builder.call_data_copy(0, 2, 0, std::vector{ 4, 9 }); // Memory layout: [4,9,0,0,0,0,....] - trace_builder.mul(1, 0, 2, AvmMemoryTag::u8); // [4,9,36,0,0,0.....] + trace_builder.mul(1, 0, 2, AvmMemoryTag::U8); // [4,9,36,0,0,0.....] trace_builder.return_op(2, 1); // Return single memory word at position 2 (36) auto trace = trace_builder.finalize(); @@ -153,7 +142,7 @@ TEST_F(AvmMiniMemoryTests, readWriteConsistencyTagViolation) trace_builder.call_data_copy(0, 2, 0, std::vector{ 4, 9 }); // Memory layout: [4,9,0,0,0,0,....] - trace_builder.mul(1, 0, 2, AvmMemoryTag::u8); // [4,9,36,0,0,0.....] + trace_builder.mul(1, 0, 2, AvmMemoryTag::U8); // [4,9,36,0,0,0.....] trace_builder.return_op(2, 1); // Return single memory word at position 2 (36) auto trace = trace_builder.finalize(); @@ -171,7 +160,7 @@ TEST_F(AvmMiniMemoryTests, readWriteConsistencyTagViolation) EXPECT_TRUE(row != trace.end()); - row->memTrace_m_tag = static_cast(AvmMemoryTag::u16); + row->memTrace_m_tag = static_cast(AvmMemoryTag::U16); EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "MEM_READ_WRITE_TAG_CONSISTENCY"); } @@ -193,7 +182,7 @@ TEST_F(AvmMiniMemoryTests, mismatchedTagErrorViolation) { trace_builder.call_data_copy(0, 2, 0, std::vector{ 98, 12 }); - trace_builder.sub(0, 1, 4, AvmMemoryTag::u8); + trace_builder.sub(0, 1, 4, AvmMemoryTag::U8); trace_builder.halt(); auto trace = trace_builder.finalize(); @@ -227,7 +216,7 @@ TEST_F(AvmMiniMemoryTests, consistentTagNoErrorViolation) { trace_builder.call_data_copy(0, 2, 0, std::vector{ 84, 7 }); - trace_builder.div(0, 1, 4, AvmMemoryTag::ff); + trace_builder.div(0, 1, 4, AvmMemoryTag::FF); trace_builder.halt(); auto trace = trace_builder.finalize(); @@ -247,4 +236,3 @@ TEST_F(AvmMiniMemoryTests, consistentTagNoErrorViolation) EXPECT_THROW_WITH_MESSAGE(validate_trace_proof(std::move(trace)), "MEM_IN_TAG_CONSISTENCY_1"); } -} // namespace tests_avm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.cpp b/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.cpp index 8257b93eec89..8377eba5ff87 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.cpp @@ -1,13 +1,8 @@ -#include "helpers.test.hpp" -#include "barretenberg/vm/avm_trace/AvmMini_helper.hpp" -#include "barretenberg/vm/generated/AvmMini_composer.hpp" -#include "barretenberg/vm/generated/AvmMini_prover.hpp" -#include "barretenberg/vm/generated/AvmMini_verifier.hpp" -#include +#include "AvmMini_common.test.hpp" -namespace tests_avm { -using namespace avm_trace; +using namespace bb; +namespace tests_avm { /** * @brief Helper routine proving and verifying a proof based on the supplied trace * @@ -15,12 +10,12 @@ using namespace avm_trace; */ void validate_trace_proof(std::vector&& trace) { - auto circuit_builder = bb::AvmMiniCircuitBuilder(); + auto circuit_builder = AvmMiniCircuitBuilder(); circuit_builder.set_trace(std::move(trace)); EXPECT_TRUE(circuit_builder.check_circuit()); - auto composer = bb::honk::AvmMiniComposer(); + auto composer = honk::AvmMiniComposer(); auto prover = composer.create_prover(circuit_builder); auto proof = prover.construct_proof(); @@ -28,7 +23,7 @@ void validate_trace_proof(std::vector&& trace) bool verified = verifier.verify_proof(proof); if (!verified) { - log_avmMini_trace(circuit_builder.rows, 0, 10); + avm_trace::log_avmMini_trace(circuit_builder.rows, 0, 10); } }; @@ -39,8 +34,9 @@ void validate_trace_proof(std::vector&& trace) * @param trace Execution trace * @param selectRow Lambda serving to select the row in trace * @param newValue The value that will be written in intermediate register Ic at the selected row. + * @param alu A boolean telling whether we mutate the ic value in alu as well. */ -void mutate_ic_in_trace(std::vector& trace, std::function&& selectRow, FF const& newValue) +void mutate_ic_in_trace(std::vector& trace, std::function&& selectRow, FF const& newValue, bool alu) { // Find the first row matching the criteria defined by selectRow auto row = std::ranges::find_if(trace.begin(), trace.end(), selectRow); @@ -51,7 +47,18 @@ void mutate_ic_in_trace(std::vector& trace, std::function&& sele // Mutate the correct result in the main trace row->avmMini_ic = newValue; - // Adapt the memory trace to be consistent with the wrongly computed addition + // Optionally mutate the corresponding ic value in alu + if (alu) { + auto const clk = row->avmMini_clk; + // Find the relevant alu trace entry. + auto alu_row = + std::ranges::find_if(trace.begin(), trace.end(), [clk](Row r) { return r.aluChip_alu_clk == clk; }); + + EXPECT_TRUE(alu_row != trace.end()); + alu_row->aluChip_alu_ic = newValue; + } + + // Adapt the memory trace to be consistent with the wrong result auto const clk = row->avmMini_clk; auto const addr = row->avmMini_mem_idx_c; @@ -63,5 +70,4 @@ void mutate_ic_in_trace(std::vector& trace, std::function&& sele EXPECT_TRUE(mem_row != trace.end()); mem_row->memTrace_m_val = newValue; }; - } // namespace tests_avm \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.hpp b/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.hpp index 145eb171457b..430c1cce45b0 100644 --- a/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.hpp +++ b/barretenberg/cpp/src/barretenberg/vm/tests/helpers.test.hpp @@ -10,10 +10,11 @@ std::string message = e.what(); \ EXPECT_TRUE(message.find(expectedMessage) != std::string::npos); \ } - namespace tests_avm { - void validate_trace_proof(std::vector&& trace); -void mutate_ic_in_trace(std::vector& trace, std::function&& selectRow, FF const& newValue); +void mutate_ic_in_trace(std::vector& trace, + std::function&& selectRow, + FF const& newValue, + bool alu = false); } // namespace tests_avm \ No newline at end of file diff --git a/barretenberg/exports.json b/barretenberg/exports.json index 6a8bd360ccfd..3925ff1fa542 100644 --- a/barretenberg/exports.json +++ b/barretenberg/exports.json @@ -466,6 +466,17 @@ ], "isAsync": false }, + { + "functionName": "acir_new_goblin_acir_composer", + "inArgs": [], + "outArgs": [ + { + "name": "out", + "type": "out_ptr" + } + ], + "isAsync": false + }, { "functionName": "acir_delete_acir_composer", "inArgs": [ @@ -540,7 +551,31 @@ "isAsync": false }, { - "functionName": "acir_create_goblin_proof", + "functionName": "acir_goblin_accumulate", + "inArgs": [ + { + "name": "acir_composer_ptr", + "type": "in_ptr" + }, + { + "name": "constraint_system_buf", + "type": "const uint8_t *" + }, + { + "name": "witness_buf", + "type": "const uint8_t *" + } + ], + "outArgs": [ + { + "name": "out", + "type": "uint8_t **" + } + ], + "isAsync": false + }, + { + "functionName": "acir_goblin_prove", "inArgs": [ { "name": "acir_composer_ptr", @@ -650,7 +685,27 @@ "isAsync": false }, { - "functionName": "acir_verify_goblin_proof", + "functionName": "acir_goblin_verify_accumulator", + "inArgs": [ + { + "name": "acir_composer_ptr", + "type": "in_ptr" + }, + { + "name": "proof_buf", + "type": "const uint8_t *" + } + ], + "outArgs": [ + { + "name": "result", + "type": "bool *" + } + ], + "isAsync": false + }, + { + "functionName": "acir_goblin_verify", "inArgs": [ { "name": "acir_composer_ptr", diff --git a/barretenberg/ts/CHANGELOG.md b/barretenberg/ts/CHANGELOG.md index bb9690faac77..6feb64173df5 100644 --- a/barretenberg/ts/CHANGELOG.md +++ b/barretenberg/ts/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [0.20.0](https://github.com/AztecProtocol/aztec-packages/compare/barretenberg.js-v0.19.0...barretenberg.js-v0.20.0) (2024-01-22) + + +### Features + +* Goblin acir composer ([#4112](https://github.com/AztecProtocol/aztec-packages/issues/4112)) ([5e85b92](https://github.com/AztecProtocol/aztec-packages/commit/5e85b92f48bc31fe55315de9f45c4907e417cb6a)) + ## [0.19.0](https://github.com/AztecProtocol/aztec-packages/compare/barretenberg.js-v0.18.0...barretenberg.js-v0.19.0) (2024-01-17) diff --git a/barretenberg/ts/package.json b/barretenberg/ts/package.json index bca350451b04..59b2a7236b0e 100644 --- a/barretenberg/ts/package.json +++ b/barretenberg/ts/package.json @@ -1,6 +1,6 @@ { "name": "@aztec/bb.js", - "version": "0.19.0", + "version": "0.20.0", "homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/barretenberg/ts", "license": "MIT", "type": "module", diff --git a/barretenberg/ts/src/barretenberg_api/index.ts b/barretenberg/ts/src/barretenberg_api/index.ts index 9ee50ba908b3..d62808515625 100644 --- a/barretenberg/ts/src/barretenberg_api/index.ts +++ b/barretenberg/ts/src/barretenberg_api/index.ts @@ -304,6 +304,18 @@ export class BarretenbergApi { return out[0]; } + async acirNewGoblinAcirComposer(): Promise { + const inArgs = [].map(serializeBufferable); + const outTypes: OutputType[] = [Ptr]; + const result = await this.wasm.callWasmExport( + 'acir_new_goblin_acir_composer', + inArgs, + outTypes.map(t => t.SIZE_IN_BYTES), + ); + const out = result.map((r, i) => outTypes[i].fromBuffer(r)); + return out[0]; + } + async acirDeleteAcirComposer(acirComposerPtr: Ptr): Promise { const inArgs = [acirComposerPtr].map(serializeBufferable); const outTypes: OutputType[] = []; @@ -357,7 +369,23 @@ export class BarretenbergApi { return out[0]; } - async acirCreateGoblinProof( + async acirGoblinAccumulate( + acirComposerPtr: Ptr, + constraintSystemBuf: Uint8Array, + witnessBuf: Uint8Array, + ): Promise { + const inArgs = [acirComposerPtr, constraintSystemBuf, witnessBuf].map(serializeBufferable); + const outTypes: OutputType[] = [BufferDeserializer()]; + const result = await this.wasm.callWasmExport( + 'acir_goblin_accumulate', + inArgs, + outTypes.map(t => t.SIZE_IN_BYTES), + ); + const out = result.map((r, i) => outTypes[i].fromBuffer(r)); + return out[0]; + } + + async acirGoblinProve( acirComposerPtr: Ptr, constraintSystemBuf: Uint8Array, witnessBuf: Uint8Array, @@ -365,7 +393,7 @@ export class BarretenbergApi { const inArgs = [acirComposerPtr, constraintSystemBuf, witnessBuf].map(serializeBufferable); const outTypes: OutputType[] = [BufferDeserializer()]; const result = await this.wasm.callWasmExport( - 'acir_create_goblin_proof', + 'acir_goblin_prove', inArgs, outTypes.map(t => t.SIZE_IN_BYTES), ); @@ -433,11 +461,23 @@ export class BarretenbergApi { return out[0]; } - async acirVerifyGoblinProof(acirComposerPtr: Ptr, proofBuf: Uint8Array): Promise { + async acirGoblinVerifyAccumulator(acirComposerPtr: Ptr, proofBuf: Uint8Array): Promise { + const inArgs = [acirComposerPtr, proofBuf].map(serializeBufferable); + const outTypes: OutputType[] = [BoolDeserializer()]; + const result = await this.wasm.callWasmExport( + 'acir_goblin_verify_accumulator', + inArgs, + outTypes.map(t => t.SIZE_IN_BYTES), + ); + const out = result.map((r, i) => outTypes[i].fromBuffer(r)); + return out[0]; + } + + async acirGoblinVerify(acirComposerPtr: Ptr, proofBuf: Uint8Array): Promise { const inArgs = [acirComposerPtr, proofBuf].map(serializeBufferable); const outTypes: OutputType[] = [BoolDeserializer()]; const result = await this.wasm.callWasmExport( - 'acir_verify_goblin_proof', + 'acir_goblin_verify', inArgs, outTypes.map(t => t.SIZE_IN_BYTES), ); @@ -777,6 +817,18 @@ export class BarretenbergApiSync { return out[0]; } + acirNewGoblinAcirComposer(): Ptr { + const inArgs = [].map(serializeBufferable); + const outTypes: OutputType[] = [Ptr]; + const result = this.wasm.callWasmExport( + 'acir_new_goblin_acir_composer', + inArgs, + outTypes.map(t => t.SIZE_IN_BYTES), + ); + const out = result.map((r, i) => outTypes[i].fromBuffer(r)); + return out[0]; + } + acirDeleteAcirComposer(acirComposerPtr: Ptr): void { const inArgs = [acirComposerPtr].map(serializeBufferable); const outTypes: OutputType[] = []; @@ -830,11 +882,23 @@ export class BarretenbergApiSync { return out[0]; } - acirCreateGoblinProof(acirComposerPtr: Ptr, constraintSystemBuf: Uint8Array, witnessBuf: Uint8Array): Uint8Array { + acirGoblinAccumulate(acirComposerPtr: Ptr, constraintSystemBuf: Uint8Array, witnessBuf: Uint8Array): Uint8Array { + const inArgs = [acirComposerPtr, constraintSystemBuf, witnessBuf].map(serializeBufferable); + const outTypes: OutputType[] = [BufferDeserializer()]; + const result = this.wasm.callWasmExport( + 'acir_goblin_accumulate', + inArgs, + outTypes.map(t => t.SIZE_IN_BYTES), + ); + const out = result.map((r, i) => outTypes[i].fromBuffer(r)); + return out[0]; + } + + acirGoblinProve(acirComposerPtr: Ptr, constraintSystemBuf: Uint8Array, witnessBuf: Uint8Array): Uint8Array { const inArgs = [acirComposerPtr, constraintSystemBuf, witnessBuf].map(serializeBufferable); const outTypes: OutputType[] = [BufferDeserializer()]; const result = this.wasm.callWasmExport( - 'acir_create_goblin_proof', + 'acir_goblin_prove', inArgs, outTypes.map(t => t.SIZE_IN_BYTES), ); @@ -902,11 +966,23 @@ export class BarretenbergApiSync { return out[0]; } - acirVerifyGoblinProof(acirComposerPtr: Ptr, proofBuf: Uint8Array): boolean { + acirGoblinVerifyAccumulator(acirComposerPtr: Ptr, proofBuf: Uint8Array): boolean { + const inArgs = [acirComposerPtr, proofBuf].map(serializeBufferable); + const outTypes: OutputType[] = [BoolDeserializer()]; + const result = this.wasm.callWasmExport( + 'acir_goblin_verify_accumulator', + inArgs, + outTypes.map(t => t.SIZE_IN_BYTES), + ); + const out = result.map((r, i) => outTypes[i].fromBuffer(r)); + return out[0]; + } + + acirGoblinVerify(acirComposerPtr: Ptr, proofBuf: Uint8Array): boolean { const inArgs = [acirComposerPtr, proofBuf].map(serializeBufferable); const outTypes: OutputType[] = [BoolDeserializer()]; const result = this.wasm.callWasmExport( - 'acir_verify_goblin_proof', + 'acir_goblin_verify', inArgs, outTypes.map(t => t.SIZE_IN_BYTES), ); diff --git a/barretenberg/ts/src/main.ts b/barretenberg/ts/src/main.ts index 208c4851a1f9..d06de96431d0 100755 --- a/barretenberg/ts/src/main.ts +++ b/barretenberg/ts/src/main.ts @@ -76,6 +76,7 @@ async function initGoblin(bytecodePath: string, crsPath: string) { const hardcodedGrumpkinSubgroupSizeHack = 262144; const initData = await init(bytecodePath, crsPath, hardcodedGrumpkinSubgroupSizeHack); const { api } = initData; + initData.acirComposer = await api.acirNewGoblinAcirComposer(); // Plus 1 needed! (Move +1 into Crs?) // Need both grumpkin and bn254 SRS's currently @@ -128,6 +129,35 @@ export async function proveAndVerify(bytecodePath: string, witnessPath: string, /* eslint-enable camelcase */ } +export async function accumulateAndVerifyGoblin(bytecodePath: string, witnessPath: string, crsPath: string) { + /* eslint-disable camelcase */ + const acir_test = path.basename(process.cwd()); + + const { api, acirComposer, circuitSize, subgroupSize } = await initGoblin(bytecodePath, crsPath); + try { + debug(`In accumulateAndVerifyGoblin:`); + const bytecode = getBytecode(bytecodePath); + const witness = getWitness(witnessPath); + + writeBenchmark('gate_count', circuitSize, { acir_test, threads }); + writeBenchmark('subgroup_size', subgroupSize, { acir_test, threads }); + + debug(`acirGoblinAccumulate()`); + const proofTimer = new Timer(); + const proof = await api.acirGoblinAccumulate(acirComposer, bytecode, witness); + writeBenchmark('proof_construction_time', proofTimer.ms(), { acir_test, threads }); + + debug(`acirVerifyGoblinProof()`); + const verified = await api.acirGoblinVerifyAccumulator(acirComposer, proof); + debug(`verified: ${verified}`); + console.log({ verified }); + return verified; + } finally { + await api.destroy(); + } + /* eslint-enable camelcase */ +} + export async function proveAndVerifyGoblin(bytecodePath: string, witnessPath: string, crsPath: string) { /* eslint-disable camelcase */ const acir_test = path.basename(process.cwd()); @@ -142,11 +172,11 @@ export async function proveAndVerifyGoblin(bytecodePath: string, witnessPath: st writeBenchmark('subgroup_size', subgroupSize, { acir_test, threads }); const proofTimer = new Timer(); - const proof = await api.acirCreateGoblinProof(acirComposer, bytecode, witness); + const proof = await api.acirGoblinProve(acirComposer, bytecode, witness); writeBenchmark('proof_construction_time', proofTimer.ms(), { acir_test, threads }); debug(`verifying...`); - const verified = await api.acirVerifyGoblinProof(acirComposer, proof); + const verified = await api.acirGoblinVerify(acirComposer, proof); debug(`verified: ${verified}`); console.log({ verified }); return verified; @@ -356,9 +386,20 @@ program process.exit(result ? 0 : 1); }); +program + .command('accumulate_and_verify_goblin') + .description('Generate a GUH proof and verify it. Process exits with success or failure code.') + .option('-b, --bytecode-path ', 'Specify the bytecode path', './target/acir.gz') + .option('-w, --witness-path ', 'Specify the witness path', './target/witness.gz') + .action(async ({ bytecodePath, witnessPath, crsPath }) => { + handleGlobalOptions(); + const result = await accumulateAndVerifyGoblin(bytecodePath, witnessPath, crsPath); + process.exit(result ? 0 : 1); + }); + program .command('prove_and_verify_goblin') - .description('Generate a proof and verify it. Process exits with success or failure code.') + .description('Generate a Goblin proof and verify it. Process exits with success or failure code.') .option('-b, --bytecode-path ', 'Specify the bytecode path', './target/acir.gz') .option('-w, --witness-path ', 'Specify the witness path', './target/witness.gz') .action(async ({ bytecodePath, witnessPath, crsPath }) => { diff --git a/boxes/token/src/contracts/src/types/balance_set.nr b/boxes/token/src/contracts/src/types/balance_set.nr index f81c33db5d48..231320de558d 100644 --- a/boxes/token/src/contracts/src/types/balance_set.nr +++ b/boxes/token/src/contracts/src/types/balance_set.nr @@ -18,12 +18,6 @@ use dep::aztec::note::{ note_interface::NoteInterface, utils::compute_note_hash_for_read_or_nullify, }; -use dep::aztec::oracle::{ - rand::rand, - get_secret_key::get_secret_key, - get_public_key::get_public_key, -}; - use crate::types::token_note::{TokenNote, TOKEN_NOTE_LEN, TokenNoteMethods}; // A set implementing standard manipulation of balances. diff --git a/boxes/token/src/contracts/src/types/token_note.nr b/boxes/token/src/contracts/src/types/token_note.nr index ed22cfc0e98f..f8adf31959db 100644 --- a/boxes/token/src/contracts/src/types/token_note.nr +++ b/boxes/token/src/contracts/src/types/token_note.nr @@ -17,7 +17,7 @@ use dep::aztec::{ }; use dep::aztec::oracle::{ rand::rand, - get_secret_key::get_secret_key, + nullifier_key::get_nullifier_secret_key, get_public_key::get_public_key, }; use dep::safe_math::SafeU120; @@ -72,9 +72,9 @@ impl TokenNote { } // docs:start:nullifier - pub fn compute_nullifier(self) -> Field { + pub fn compute_nullifier(self, context: &mut PrivateContext) -> Field { let note_hash_for_nullify = compute_note_hash_for_read_or_nullify(TokenNoteMethods, self); - let secret = get_secret_key(self.owner); + let secret = context.request_nullifier_secret_key(self.owner); // TODO(#1205) Should use a non-zero generator index. pedersen_hash([ note_hash_for_nullify, @@ -84,6 +84,17 @@ impl TokenNote { } // docs:end:nullifier + pub fn compute_nullifier_without_context(self) -> Field { + let note_hash_for_nullify = compute_note_hash_for_read_or_nullify(TokenNoteMethods, self); + let secret = get_nullifier_secret_key(self.owner); + // TODO(#1205) Should use a non-zero generator index. + pedersen_hash([ + note_hash_for_nullify, + secret.low, + secret.high, + ],0) + } + pub fn set_header(&mut self, header: NoteHeader) { self.header = header; } @@ -116,8 +127,12 @@ fn compute_note_hash(note: TokenNote) -> Field { note.compute_note_hash() } -fn compute_nullifier(note: TokenNote) -> Field { - note.compute_nullifier() +fn compute_nullifier(note: TokenNote, context: &mut PrivateContext) -> Field { + note.compute_nullifier(context) +} + +fn compute_nullifier_without_context(note: TokenNote) -> Field { + note.compute_nullifier_without_context() } fn get_header(note: TokenNote) -> NoteHeader { @@ -138,6 +153,7 @@ global TokenNoteMethods = NoteInterface { serialize, compute_note_hash, compute_nullifier, + compute_nullifier_without_context, get_header, set_header, broadcast, diff --git a/boxes/token/src/contracts/src/types/transparent_note.nr b/boxes/token/src/contracts/src/types/transparent_note.nr index 034b4b3390f7..deb2bcdf6f1b 100644 --- a/boxes/token/src/contracts/src/types/transparent_note.nr +++ b/boxes/token/src/contracts/src/types/transparent_note.nr @@ -70,7 +70,11 @@ impl TransparentNote { ],0) } - pub fn compute_nullifier(self) -> Field { + pub fn compute_nullifier(self, _context: &mut PrivateContext) -> Field { + self.compute_nullifier_without_context() + } + + pub fn compute_nullifier_without_context(self) -> Field { // TODO(#1386): should use `compute_note_hash_for_read_or_nullify` once public functions inject nonce! let siloed_note_hash = compute_siloed_note_hash(TransparentNoteMethods, self); // TODO(#1205) Should use a non-zero generator index. @@ -102,8 +106,12 @@ fn compute_note_hash(note: TransparentNote) -> Field { note.compute_note_hash() } -fn compute_nullifier(note: TransparentNote) -> Field { - note.compute_nullifier() +fn compute_nullifier(note: TransparentNote, context: &mut PrivateContext) -> Field { + note.compute_nullifier(context) +} + +fn compute_nullifier_without_context(note: TransparentNote) -> Field { + note.compute_nullifier_without_context() } fn get_header(note: TransparentNote) -> NoteHeader { @@ -123,6 +131,7 @@ global TransparentNoteMethods = NoteInterface { serialize, compute_note_hash, compute_nullifier, + compute_nullifier_without_context, get_header, set_header, broadcast, diff --git a/circuits/cpp/src/aztec3/utils/types/circuit_types.hpp b/circuits/cpp/src/aztec3/utils/types/circuit_types.hpp index 3f312600c4b9..e9bc1fc610e3 100644 --- a/circuits/cpp/src/aztec3/utils/types/circuit_types.hpp +++ b/circuits/cpp/src/aztec3/utils/types/circuit_types.hpp @@ -94,4 +94,4 @@ template struct CircuitTypes { static byte_array blake2s(const byte_array& input) { return plonk::stdlib::blake2s(input); } }; -} // namespace aztec3::utils::types \ No newline at end of file +} // namespace aztec3::utils::types diff --git a/docs/docs/about_aztec/history/history.mdx b/docs/docs/about_aztec/history/history.mdx deleted file mode 100644 index 17924b86ce69..000000000000 --- a/docs/docs/about_aztec/history/history.mdx +++ /dev/null @@ -1,97 +0,0 @@ ---- -title: History of blockchain privacy ---- - -import Image from "@theme/IdealImage"; - -# A brief history of blockchain privacy - - - ---- - -## Bitcoin - -The original blockchain. - -**Programmability**: - -- None. -- Transfer bitcoin only. - -**Privacy**: - -- None. - ---- - -## Ethereum - -**Programmability**: - -- Turing complete smart contracts. - -**Privacy**: - -- Originally: None. -- Now: - - some specific apps on L1 - - some specific apps, deployed via L2, like zk.money and Aztec Connect. - ---- - -## ZCash - -**Programmability**: - -- None. -- Transfer ZCash only. - -**Privacy**: - -- Transfers of shielded zcash are private. - ---- - -## zk.money - -**Programmability**: - -- Any custom ERC20 token (on Ethereum L1) can be deposited to L2, transferred within L2, and withdrawn from L2. - -**Privacy**: - -- Transfers of the ERC20 tokens within the L2 are private. - ---- - -## Aztec Connect - -**Programmability**: - -- The functionality of zk.money, plus: -- Tokens can be sent from the L2 shielded pool to many L1 DeFi contracts, and the resulting tokens can be re-shielded. This gives anonymity to L1 DeFi users. - -**Privacy**: - -- Transfers of the ERC20 tokens within the L2 are private. -- User DeFi interactions are private. - ---- - -## Aztec - -**Programmability**: - -- Fully programmable private smart contracts: - - Private functions which can edit general private state - - Cheap L2 public functions - - L1 (public) functions. - -**Privacy**: - -- Executing private functions grants: - - Function privacy - - Input privacy - - User privacy -- Executing a private function which calls a public function grants varying degrees of privacy, depending on the application someone deploys. (Similar to how deposits and withdrawals to/from shielded pools can leak privacy). diff --git a/docs/docs/about_aztec/overview.mdx b/docs/docs/about_aztec/overview.mdx index 9bd2afacf191..c2e3d1b97a38 100644 --- a/docs/docs/about_aztec/overview.mdx +++ b/docs/docs/about_aztec/overview.mdx @@ -10,17 +10,15 @@ Aztec is an L2 that brings programmable privacy to Ethereum. A smart contract on Aztec is a collection of functions, written as ZK-SNARK circuits. These circuits can have different modes of execution: -1. Secret Functions -- can read and write private state, read historical public state, consume or send messages to / from Ethereum, and read Ethereum state. They can call other secret functions in the same contract, or other contracts, and can call public functions. +1. Private Functions -- can read and write private state, read historical public state, consume or send messages to / from Ethereum, and read Ethereum state. They can call other private functions in the same contract, or other contracts, and can call public functions. 2. Public Functions -- can read and write public state, write private state, consume or send messages to / from Ethereum and read Ethereum state. They can call other public functions on the same or other contracts. 3. Portal Contracts -- these are contracts on Ethereum that can receive messages from Aztec or send messages to Aztec from Ethereum contracts. Using these different modes of execution, developers can build applications with user privacy, data privacy and code privacy. -User privacy -- transactions may not reveal information about the sender or the recipient. - -Data privacy -- transactions may not reveal information about the payload of the transaction, e.g., the asset or value being transacted. - -Code privacy -- transactions may not reveal the program logic. +- User privacy - transactions may not reveal information about the sender or the recipient. +- Data privacy - transactions may not reveal information about the payload of the transaction, e.g., the asset or value being transacted. +- Code privacy - transactions may not reveal the program logic. Watch Zac, CEO of Aztec, describe our approach to building a privacy preserving smart contract blockchain. diff --git a/docs/docs/concepts/advanced/data_structures/trees.md b/docs/docs/concepts/advanced/data_structures/trees.md index 658782ad010c..d29f9c046697 100644 --- a/docs/docs/concepts/advanced/data_structures/trees.md +++ b/docs/docs/concepts/advanced/data_structures/trees.md @@ -14,7 +14,7 @@ Data includes: - Nullifiers to invalidate old private state ([Nullifier tree](#nullifier-tree)) - Public state ([Public State tree](#public-state-tree)) - Contracts ([Contract tree](#contract-tree)) -- Previous block headers ([Archive tree](#archive-tree)) +- Archive tree for Historical access ([Archive tree](#archive-tree)) - Global Variables ```mermaid @@ -181,9 +181,37 @@ Aztec supports the ability to keep the logic of private functions of a smart con ## Archive Tree -A block includes the root to the Archive Tree (sometimes called the blocks tree). +The archive tree is an append-only Merkle tree that stores hashes of headers of all previous blocks in the chain as its leaves. -The leaves of the tree are hashes of previous block headers. This tree can be used to verify data of any of the trees above at some previous point in time by doing a membership check of the corresponding tree root in the block header and the block header hash in the blocks tree. +As private execution relies on proofs generated by the user, the current block header is not known. We can instead base the proofs on historical state. By including all prior block headers (which include commitments to the state), the historical access tree allows us to easily prove that the historical state that a transaction is using for a proof is valid. + +```mermaid +graph TD; + +PartialStateReference[Partial State
snapshot of note hash tree, nullifier tree, contract tree, public data tree] +StateReference[State Reference
snapshot of L1<>L2 message tree] +GlobalVariables[Global Variables
block number, timestamp, version, chain_id] +Header[Block Header
last snapshot of tree, hash of body] +Logs[Transaction Logs
encrypted & non-encrypted logs] +PublicDataWrite[Public Data Writes
] +ContractData[Contract Data
leaf, address] +TxEffect[Transaction Effects
note hashes, nullifiers, contracts, public writes] +Body[ Body
L1<>L2 messages, transaction effects] +ArchiveTree[Archive Tree
used to validate user-generated proofs and access historical data] + +StateReference --- PartialStateReference +Header --- Body +Header --- StateReference +Header --- GlobalVariables +TxEffect --- ContractData +TxEffect --- PublicDataWrite +TxEffect --- Logs +Body --- TxEffect +HistoricalAccessTree --- Header + +``` + +It can also be used to find information about notes, public state, and contracts that were included in a certain block using [inclusion and non-inclusion proofs](../../../dev_docs/contracts/syntax/historical_access/how_to_prove_history.md). ## Trees of valid Kernel/Rollup circuit Verification Keys diff --git a/docs/docs/concepts/foundation/accounts/keys.md b/docs/docs/concepts/foundation/accounts/keys.md index 21d0f240c818..e5d897d0ffcc 100644 --- a/docs/docs/concepts/foundation/accounts/keys.md +++ b/docs/docs/concepts/foundation/accounts/keys.md @@ -82,7 +82,7 @@ Note that any accounts you own that have been added to the PXE are automatically In addition to deriving encryption keys, the privacy master key is used for deriving nullifier secrets. Whenever a private note is consumed, a nullifier deterministically derived from it is emitted. This mechanisms prevents double-spends, since nullifiers are checked by the protocol to be unique. Now, in order to preserve privacy, a third party should not be able to link a note commitment to its nullifier - this link is enforced by the note implementation. Therefore, calculating the nullifier for a note requires a secret from its owner. -An application in Aztec.nr can request a secret from the current user for computing the nullifier of a note via the `get_secret_key` oracle call: +An application in Aztec.nr can request a secret from the current user for computing the nullifier of a note via the `request_nullifier_secret_key` api: #include_code nullifier /yarn-project/aztec-nr/value-note/src/value_note.nr rust diff --git a/docs/docs/concepts/foundation/main.md b/docs/docs/concepts/foundation/main.md index 5d7e95798829..6c861dfe12d4 100644 --- a/docs/docs/concepts/foundation/main.md +++ b/docs/docs/concepts/foundation/main.md @@ -2,15 +2,31 @@ title: Foundational Concepts --- -As a layer 2 rollup on Ethereum, the Aztec network includes components that look similar to other layer 2 networks, but since it handles private state it also includes many new components. +Aztec Labs is building a layer 2 rollup on Ethereum focused on 3 things: -On this page we will introduce the high level network architecture for Aztec with an emphasis on the concepts that are core to understanding Aztec, including: +- Data privacy +- Confidentiality +- Trustlessness -- [The state model](./state_model/main.md) -- [Accounts](./accounts/main.md) -- [Aztec Smart Contracts](./contracts.md) -- [Transactions](./transactions.md) -- [Communication between network components](./communication/main.md) +## Data privacy + +Data privacy refers to the ability of Aztec smart contract to have private (encrypted) state. Aztec abstracts away many of the complexities associated with managing private state, providing developers with an interface that feels familiar, but is much more powerful. + + + +## Confidentiality + +Confidentiality is the ability of Aztec smart contracts to execute private functions and transactions. Aztec provides a secure, private environment for the execution of sensitive operations, ensuring private information and decrypted data are not accessible to unauthorized applications. + +When a user sends a private transaction on the network, the only information that an external observer can infer is that a transaction was sent. Transaction data, the sender, and the recipient can all be obfuscated. + +Aztec achieved this level of privacy by leveraging a Private eXecution Environment (PXE). This software runs client-side, for example in a browser, and is responsible for managing private keys, encrypting and decrypting data, and executing private functions. The PXE is also responsible for generating proofs of private function execution, which are then sent to the sequencer for inclusion in the rollup. + +## Trustlessness + +Aztec is building a permissionless, censorship resistant, peer-to-peer network. It aims to be credibly neutral, where the same transparent rules apply to everyone, enforced by the protocol. + +Aztec will have a network of sequencers that stake tokens to participate in the network. Sequencers are responsible for aggregating transactions into a block, generating proofs of the state updates (or delegating proof generation to the prover network) and posting it to the rollup contract on Ethereum, along with any required public data for data availability. ## High level network architecture @@ -34,15 +50,8 @@ The sequencer aggregates transactions into a block, generates proofs of the stat ## Further Reading -Here are links to pages with more information about the network components mentioned above: - -- Aztec.js - - [Dapp tutorial](../../dev_docs/tutorials/writing_dapp/main.md) - - [API reference](../../apis/aztec-js) -- Private Execution Environment (PXE) - - [Dapp tutorial](../../dev_docs/tutorials/writing_dapp/pxe_service.md) - - [API reference](../../apis/pxe/index.md) -- [Private Kernel Circuit](../advanced/circuits/kernels/private_kernel.md) -- [Sequencer](./nodes_clients/sequencer.md) -- Prover Network (coming soontm) -- [Rollup Circuit](../advanced/circuits/rollup_circuits/main.md) -- a component of the rollup contract +- [The state model](./state_model/main.md) +- [Accounts](./accounts/main.md) +- [Aztec Smart Contracts](./contracts.md) +- [Transactions](./transactions.md) +- [Communication between network components](./communication/main.md) diff --git a/docs/docs/dev_docs/contracts/syntax/historical_access/history_lib_reference.md b/docs/docs/dev_docs/contracts/syntax/historical_access/history_lib_reference.md new file mode 100644 index 000000000000..b798a129243b --- /dev/null +++ b/docs/docs/dev_docs/contracts/syntax/historical_access/history_lib_reference.md @@ -0,0 +1,119 @@ +--- +title: History Reference +--- + + + +## Note inclusion + +Note inclusion proves that a note existed (its hash was included in a note hash tree) at a specific block number. + +## prove_note_inclusion + +`prove_note_inclusion` takes 4 parameters: + +| Name | Type | Description | +|-----------------|------------------------|-----------------------------------------------------| +| note_interface | NoteInterface | Interface for the note with necessary functionality| +| note_with_header| Note | The note you are proving inclusion for | +| block_number | u32 | Block number for proving note's existence | +| context | PrivateContext | Private context | + +## prove_note_commitment_inclusion + +A **commitment**, also referred to as a **note hash** is a public acknowledgment of the existence of a note without revealing the content of the note. You can learn more about how to compress a note to a note hash [here](../../../../concepts/advanced/data_structures/trees.md#example-note). + +`prove_note_commitment_inclusion` takes 3 parameters: + +| Name | Type | Description | +|-----------------|------------------------|-----------------------------------------------------| +| commitment | Field | Note commitment we are checking inclusion of | +| block_number | u32 | Block number for proving note's existence | +| context| PrivateContext | Private Context | + +## Note validity + +This proves that a note exists and has not been nullified at a specified block. + +### prove_note_validity + +`prove_note_validity` takes 4 parameters: + +| Name | Type | Description | +|-----------------|------------------------|-----------------------------------------------------| +| note_interface | NoteInterface | Interface for the note with necessary functionality| +| note_with_header| Note | The note you are proving inclusion for | +| block_number | u32 | Block number for proving note's existence | +| context | PrivateContext | Private context | + +## Nullifier inclusion + +This proves that a nullifier was included in a certain block (can be used to prove that a note had been nullified). + +### prove_nullifier_inclusion + +`prove_nullifier_inclusion` takes 3 parameters: + +| Name | Type | Description | +|-----------------|------------------------|-----------------------------------------------------| +| nullifier | Field | The nullifier you are proving inclusion for | +| block_number | u32 | Block number for proving note's existence | +| context | PrivateContext | Private context | + +## Nullifier non inclusion + +This proves that a nullifier was not included in a certain block (can be used to prove that a note had not yet been nullified in a given block). + +### prove_nullifier_non_inclusion + +`prove_nullifier_non_inclusion` takes 3 parameters: + +| Name | Type | Description | +|-----------------|------------------------|-----------------------------------------------------| +| nullifier | Field | The nullifier you are proving inclusion for | +| block_number | u32 | Block number for proving note's existence | +| context | PrivateContext | Private context | + + +### note_not_nullified + +Instead of passing the nullifier, you can check that a note has not been nullified by passing the note. + +## Public value inclusion + +This proves that a public value exists at a certain block. + +### prove_public_value_inclusion + +`prove_public_value_inclusion` takes 4 parameters: + +| Name | Type | Description | +|-----------------|------------------------|-----------------------------------------------------| +| value | Field | The public value you are proving inclusion for | +| storage_slot | Field | Storage slot the value exists in | +| block_number | u32 | Block number for proving value's existence | +| context | PrivateContext | Private context | + +## Contract inclusion + +This proves that a contract exists in, ie had been deployed before or in, a certain block. + +### prove_contract_inclusion + +`prove_contract_inclusion` takes 7 parameters: + +| Name | Type | Description | +|---------------------------|-----------------|-------------------------------------------------------| +| deployer_public_key | GrumpkinPoint | Public key of the contract deployer | +| contract_address_salt | Field | Unique identifier for the contract's address | +| function_tree_root | Field | Root of the contract's function tree | +| constructor_hash | Field | Hash of the contract's constructor | +| portal_contract_address | EthAddress | Ethereum address of the associated portal contract | +| block_number | u32 | Block number for proof verification | +| context | PrivateContext | Private context | + +If there is no associated portal contract, you can use a zero Ethereum address: + +```ts +new EthAddress(Buffer.alloc(EthAddress.SIZE_IN_BYTES)); +``` diff --git a/docs/docs/dev_docs/contracts/syntax/historical_access/how_to_prove_history.md b/docs/docs/dev_docs/contracts/syntax/historical_access/how_to_prove_history.md new file mode 100644 index 000000000000..28e3ea04ccf3 --- /dev/null +++ b/docs/docs/dev_docs/contracts/syntax/historical_access/how_to_prove_history.md @@ -0,0 +1,102 @@ +--- +title: How to prove existence of historical notes and nullifiers +--- + +The Aztec Protocol uses an append-only Merkle tree to store hashes of the headers of all previous blocks in the chain as its leaves. This is known as an archive tree. You can learn more about how it works in the [concepts section](../../../../concepts/advanced/data_structures/trees.md#archive-tree). + +# History library + +The history library allows you to prove any of the following at a given block height before the current height: +* [Note inclusion](./history_lib_reference.md#note-inclusion) +* [Nullifier inclusion](./history_lib_reference.md#nullifier-inclusion) +* [Note validity](./history_lib_reference.md#note-validity) +* [Existence of public value](./history_lib_reference.md#public-value-inclusion) +* [Contract inclusion](./history_lib_reference.md#contract-inclusion) + +Using this library, you can check that specific notes or nullifiers were part of Aztec network state at specific blocks. This can be useful for things such as: + +* Verifying a minimum timestamp from a private context +* Checking eligibility based on historical events (e.g. for an airdrop by proving that you owned a note) +* Verifying historic ownership / relinquishing of assets +* Proving existence of a value in public data tree at a given contract slot +* Proving that a contract was deployed in a given block with some parameters + +**In this guide you will learn how to** +* Prove a note was included in a specified block +* Create a nullifier and prove it was not included in a specified block + +For a more extensive reference, go to [the reference page](./history_lib_reference.md). + +## 1. Import the `history` library from `aztec` + +```rust +aztec::{ + #include_code imports yarn-project/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr raw +} +``` + +This imports all functions from the `history` library. You should only import the functions you will use in your contract. + +## 2. Create a note to prove inclusion of + +In general you will likely have the note you want to prove inclusion of. But if you are just experimenting you can create a note with a function like below: + +#include_code create_note yarn-project/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr rust + +## 3. Get the note from the PXE + +Retrieve the note from the user's PXE. + +#include_code get_note_from_pxe yarn-project/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr rust + +In this example, the user's notes are stored in a map called `private_values`. We retrieve this map, then select 1 note from it with the value of `1`. + +## 4. Prove that a note was included in a specified block + +To prove that a note existed in a specified block, call `prove_note_inclusion` as shown in this example: + +#include_code prove_note_inclusion yarn-project/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr rust + +This function takes in 4 arguments: + +1. The note interface (`ValueNoteMethods`) +2. The note (`maybe_note.unwrap_unchecked()`). Here, `unwrap_unchecked()` returns the inner value without asserting `self.is_some()` +3. The block number +4. Private context + +Note: for this to work, you will need to import `ValueNoteMethods` at the beginning of the contract: + +#include_code value_note_imports yarn-project/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr rust + +This will only prove the note existed, not whether or not the note has been nullified. You can prove that a note existed and had not been nullified in a specified block by using `prove_note_validity` which takes the same arguments: + +#include_code prove_note_validity yarn-project/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr rust + +## 5. Create a nullifier to prove inclusion of + +You can easily nullify a note like so: + +#include_code nullify_note yarn-project/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr rust + +This function gets a note from the PXE like we did in [step 3](#3-get-the-note-from-the-pxe) and nullifies it with `remove()`. + +You can then compute this nullifier with `note.compute_nullifier(&mut context)`. + +## 6. Prove that a nullifier was included in a specified block + +Call `prove_nullifier_inclusion` like so: + +#include_code prove_nullifier_inclusion yarn-project/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr rust + +This takes three arguments: +1. The nullifier +2. Block number +3. Private context + +You can also prove that a nullifier was not included in a specified block by using `prove_nullifier_non_inclusion` which takes the same arguments: + +#include_code prove_nullifier_non_inclusion yarn-project/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr rust + +## Prove contract inclusion, public value inclusion, and note commitment inclusion + +To see what else you can do with the `history` library, check out the [reference](./history_lib_reference.md). diff --git a/docs/docs/dev_docs/contracts/syntax/storage/private_state.md b/docs/docs/dev_docs/contracts/syntax/storage/private_state.md index bd50c7696a57..8b38bb0a3657 100644 --- a/docs/docs/dev_docs/contracts/syntax/storage/private_state.md +++ b/docs/docs/dev_docs/contracts/syntax/storage/private_state.md @@ -72,7 +72,11 @@ As part of the initialization of the `Storage` struct, the `Singleton` is create As mentioned, the Singleton is initialized to create the first note and value. -When this function is called, a nullifier of the storage slot is created, preventing this Singleton from being initialized again. If an `owner` is specified, the nullifier will be hashed with the owner's secret key. It's crucial to provide an owner if the Singleton is associated with an account. Initializing it without an owner may inadvertently reveal important information about the owner's intention. +When this function is called, a nullifier of the storage slot is created, preventing this Singleton from being initialized again. + +:::danger Privacy-Leak +Beware that because this nullifier is created only from the storage slot without randomness it is "leaky". This means that if the storage slot depends on the an address then it is possible to link the nullifier to the address. For example, if the singleton is part of a `map` with an `AztecAddress` as the key then the nullifier will be linked to the address. +::: Unlike public states, which have a default initial value of `0` (or many zeros, in the case of a struct, array or map), a private state (of type `Singleton`, `ImmutableSingleton` or `Set`) does not have a default initial value. The `initialize` method (or `insert`, in the case of a `Set`) must be called. @@ -90,7 +94,7 @@ To update the value of a `Singleton`, we can use the `replace` method. The metho An example of this is seen in a example card game, where we create a new note (a `CardNote`) containing some new data, and replace the current note with it: -#include_code state_vars-SingletonReplace /yarn-project/noir-contracts/contracts/docs_example_contract/src/actions.nr rust +#include_code state_vars-SingletonReplace /yarn-project/noir-contracts/contracts/docs_example_contract/src/main.nr rust If two people are trying to modify the Singleton at the same time, only one will succeed as we don't allow duplicate nullifiers! Developers should put in place appropriate access controls to avoid race conditions (unless a race is intended!). @@ -98,7 +102,7 @@ If two people are trying to modify the Singleton at the same time, only one will This function allows us to get the note of a Singleton, essentially reading the value. -#include_code state_vars-SingletonGet /yarn-project/noir-contracts/contracts/docs_example_contract/src/actions.nr rust +#include_code state_vars-SingletonGet /yarn-project/noir-contracts/contracts/docs_example_contract/src/main.nr rust #### Nullifying Note reads @@ -122,7 +126,11 @@ As part of the initialization of the `Storage` struct, the `Singleton` is create ### `initialize` -When this function is invoked, it creates a nullifier for the storage slot, ensuring that the ImmutableSingleton cannot be initialized again. If an owner is specified, the nullifier will be hashed with the owner's secret key. It is crucial to provide an owner if the ImmutableSingleton is linked to an account; initializing it without one may inadvertently disclose sensitive information about the owner's intent. +When this function is invoked, it creates a nullifier for the storage slot, ensuring that the ImmutableSingleton cannot be initialized again. + +:::danger Privacy-Leak +Beware that because this nullifier is created only from the storage slot without randomness it is "leaky". This means that if the storage slot depends on the an address then it is possible to link the nullifier to the address. For example, if the singleton is part of a `map` with an `AztecAddress` as the key then the nullifier will be linked to the address. +::: Set the value of an ImmutableSingleton by calling the `initialize` method: diff --git a/docs/docs/dev_docs/contracts/syntax/storage/public_state.md b/docs/docs/dev_docs/contracts/syntax/storage/public_state.md index f99deee3b4e6..e603cef5e42a 100644 --- a/docs/docs/dev_docs/contracts/syntax/storage/public_state.md +++ b/docs/docs/dev_docs/contracts/syntax/storage/public_state.md @@ -2,9 +2,8 @@ title: Public State --- -To define that a variable is public, it is wrapped in the `PublicState` struct. - The `PublicState` struct is generic over the variable type `T` and its serialized size `T_SERIALIZED_LEN`. + :::info Currently, the length of the types must be specified when declaring the storage struct but the intention is that this will be inferred in the future. ::: diff --git a/docs/docs/dev_docs/getting_started/core-concepts.md b/docs/docs/dev_docs/getting_started/core-concepts.md index cef4b5a6fa69..e4549fb97317 100644 --- a/docs/docs/dev_docs/getting_started/core-concepts.md +++ b/docs/docs/dev_docs/getting_started/core-concepts.md @@ -4,18 +4,19 @@ title: Core Concepts import Image from '@theme/IdealImage'; -This page outlines Aztec concepts that are essential for developers to understand. Reading and understanding these concepts will help you massively when you start to dive deeper into smart contracts. +This page outlines Aztec concepts that are essential for developers to understand. Understanding these concepts will help you as you start to dive deeper into smart contracts. A little bit of time here can save a lot down the road. -# Aztec Overview +## Aztec Overview - + To sum this up: + 1. A user interacts with Aztec through Aztec.js (like web3js or ethersjs) or Aztec CLI 2. Private functions are executed in the PXE, which is client-side -3. They are rolled up and sent to the Public VM +3. They are rolled up and sent to the Public VM (running on an Aztec node) 4. Public functions are executed in the Public VM 5. The Public VM rolls up the private & public transaction rollups 6. These rollups are submitted to Ethereum @@ -24,20 +25,20 @@ To sum this up: The PXE is unaware of the Public VM. And the Public VM is unaware of the PXE. They are completely separate execution environments. This means: -* The PXE and the Public VM cannot directly communicate with each other -* Private transactions in the PXE are executed first, followed by public transactions +- The PXE and the Public VM cannot directly communicate with each other +- Private transactions in the PXE are executed first, followed by public transactions You can call a public function from a private function by using `context.call_public_function`, like this: #include_code call_public_function yarn-project/noir-contracts/contracts/card_game_contract/src/main.nr rust -You cannot call a private function from a public function, but you can use a slow updates tree to read historical public state and stage writes to public state from a private function. +You cannot call a private function from a public function, but you can use a [slow updates tree](../contracts/syntax/slow_updates_tree.md) to read historical public state and stage writes to public state from a private function. ### Data types -Private state works with UTXOs, or what we call notes. To keep things private, everything is stored in an append-only UTXO tree, and a nullifier is created when notes are spent. +Private state works with UTXOs, or what we call notes. To keep things private, everything is stored in an [append-only UTXO tree](../../concepts/advanced/data_structures/trees.md#note-hash-tree), and a nullifier is created when notes are invalidated. -Public state works similarly to other chains like Ethereum, behaving more like a public ledger. +Public state works similarly to other chains like Ethereum, behaving like a public ledger. Working with private state is like creating commitments and nullifiers to state, whereas working with public state is like directly updating state. @@ -45,52 +46,43 @@ We have abstractions for working with private state so you don't have to worry a For example, let's say you're trying to work with an integer. We have a library called `EasyPrivateUint` that acts like an integer but in the background is actually updating notes in private state. For the public side, we instead have something called `SafeU120`. You cannot use EasyPrivateUint in a public environment, and you cannot use SafeU120 in a private environment. -# Storage +## Storage Currently, when writing Aztec.nr smart contracts, you will need to define two things when initiating storage: 1. The storage struct, ie what you are storing and their types 2. A storage `impl` block with `init` function that will be called when you use the storage in a function -The storage struct looks like this: - -#include_code storage_struct yarn-project/noir-contracts/contracts/token_contract/src/main.nr rust - -The storage impl block looks like this: - -#include_code storage_init yarn-project/noir-contracts/contracts/token_contract/src/main.nr rust - The `init` function must declare the storage struct with an instantiation defining how variables are accessed and manipulated. Each variable must be given a storage slot, which can be anything except 0. The impl block is likely to be abstracted away at a later date. Learn more about how to use storage [here](../contracts/syntax/storage/main.md). -# Portals +## Portals Aztec allows you to interact with Ethereum privately - ie no-one knows where the transaction is coming from, just that it is coming from somewhere on Aztec. This is achieved through portals - these are smart contracts written in Solidity that are related to the Ethereum smart contract you want to interact with. -A portal can be associated with multiple Aztec contracts, but an Aztec contract can only be associated with one portal. +A portal can be associated with multiple Aztec contracts, but an Aztec contract can only be associated with one portal. Learn more about how to work with portals [here](../contracts/portals/main.md). -# Account Abstraction +## Accounts -Every account in Aztec is a smart contract. This allows implementing different schemes for transaction signing, nonce management, and fee payments. +Every account in Aztec is a smart contract (account abstraction). This allows implementing different schemes for transaction signing, nonce management, and fee payments. You can write your own account contract to define the rules by which user transactions are authorized and paid for, as well as how user keys are managed. Learn more about account contracts [here](../../concepts/foundation/accounts/main.md). -# Noir Language +## Noir Language Aztec smart contracts are written in a framework on top of Noir, the zero-knowledge domain-specific language developed specifically for Aztec. Its syntax is similar to Rust. Outside of Aztec, Noir is used for writing circuits that can be verified in Solidity. A cursory understanding of Noir is sufficient for writing Aztec contracts. The [Noir docs](https://noir-lang.org) will be a helpful reference when you start writing more advanced contracts. -Now you're ready to dive into coding: +## Next steps -1. [Learn how to interact with a smart contract in Aztec.js](./aztecjs-getting-started.md) -2. [Write your first Aztec smart contract](./aztecnr-getting-started.md) \ No newline at end of file +Continue through the getting started section by reviewing how to write a smart contract contract in [Getting started with Aztec.nr](./aztecnr-getting-started.md). diff --git a/docs/docs/dev_docs/getting_started/main.md b/docs/docs/dev_docs/getting_started/main.md index cfa7fa20c2e9..f2f343b0c2e7 100644 --- a/docs/docs/dev_docs/getting_started/main.md +++ b/docs/docs/dev_docs/getting_started/main.md @@ -2,13 +2,19 @@ title: Getting Started --- -In this section, you will +## Build + +If this is your first time using Aztec, and you want to get started by learning by doing, head to the [Quickstart section](quickstart.md). This section is the entry point to: 1. Set up the Aztec sandbox and deploy a sample first contract with the CLI 2. Deploy and interact with a contract using Aztec.js 3. Write your first smart contract in Aztec.nr -The whole section should take you less than 60 minutes. +## Learn + +If you want to read more about the high level concepts of Aztec before writing some code, head to the [Foundational Concepts section](../../concepts/foundation/main.md). + +## In this section import DocCardList from '@theme/DocCardList'; diff --git a/docs/docs/dev_docs/getting_started/quickstart.md b/docs/docs/dev_docs/getting_started/quickstart.md index b5120e844894..62b56e10afe0 100644 --- a/docs/docs/dev_docs/getting_started/quickstart.md +++ b/docs/docs/dev_docs/getting_started/quickstart.md @@ -4,8 +4,8 @@ title: Quickstart In this guide, you will -1. Set up the Aztec sandbox locally -2. Install the Aztec CLI +1. Set up the Aztec sandbox (local development environment) locally +2. Install the Aztec development kit 3. Use the CLI to deploy an example contract that comes with the sandbox 4. Use the CLI to interact with the contract you just deployed @@ -17,7 +17,7 @@ In this guide, you will ## Install Docker -See this page of the Docker docs for instructions on how to install Docker Desktop for your operating system: [https://docs.docker.com/get-docker/](https://docs.docker.com/get-docker/) +See [this page of the Docker docs](https://docs.docker.com/get-docker/) for instructions on how to install Docker Desktop for your operating system. Once you have Docker installed, make sure it is running by opening the Docker Desktop application. diff --git a/docs/docs/dev_docs/tutorials/token_portal/depositing_to_aztec.md b/docs/docs/dev_docs/tutorials/token_portal/depositing_to_aztec.md index bbb5915ff12d..9452657be1f5 100644 --- a/docs/docs/dev_docs/tutorials/token_portal/depositing_to_aztec.md +++ b/docs/docs/dev_docs/tutorials/token_portal/depositing_to_aztec.md @@ -8,7 +8,20 @@ In this step, we will write our token portal contract on L1. In `l1-contracts/contracts` in your file called `TokenPortal.sol` paste this: -#include_code init /l1-contracts/test/portals/TokenPortal.sol solidity +```solidity +pragma solidity >=0.8.18; + +import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; + +// Messaging +import {IRegistry} from "@aztec/l1-contracts/src/core/interfaces/messagebridge/IRegistry.sol"; +import {IInbox} from "@aztec/l1-contracts/src/core/interfaces/messagebridge/IInbox.sol"; +import {DataStructures} from "@aztec/l1-contracts/src/core/libraries/DataStructures.sol"; +import {Hash} from "@aztec/l1-contracts/src/core/libraries/Hash.sol"; + +#include_code init /l1-contracts/test/portals/TokenPortal.sol raw +``` This imports relevant files including the interfaces used by the Aztec rollup. And initializes the contract with the following parameters: diff --git a/docs/docs/dev_docs/tutorials/token_portal/setup.md b/docs/docs/dev_docs/tutorials/token_portal/setup.md index 2c1e4472f48a..3f738e02fc0f 100644 --- a/docs/docs/dev_docs/tutorials/token_portal/setup.md +++ b/docs/docs/dev_docs/tutorials/token_portal/setup.md @@ -62,7 +62,8 @@ type = "contract" [dependencies] aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/aztec" } -token_portal_content_hash_lib = { git="https://github.com/AztecProtocol/aztec-packages/", tag="aztec-packages-v0.16.9", directory="yarn-project/noir-contracts/contracts/token_portal_content_hash_lib" } +token_portal_content_hash_lib = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/noir-contracts/contracts/token_portal_content_hash_lib" } +protocol_types = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/noir-protocol-circuits/src/crates/types"} ``` We will also be writing some helper functions that should exist elsewhere so we don't overcomplicated our contract. In `src` create two more files - one called `util.nr` and one called `token_interface` - so your dir structure should now look like this: @@ -74,6 +75,7 @@ aztec-contracts ├── src ├── main.nr ├── token_interface.nr + ├── util.nr ``` # Create a JS hardhat project @@ -99,7 +101,7 @@ touch TokenPortal.sol Now add dependencies that are required. These include interfaces to Aztec Inbox, Outbox and Registry smart contracts, OpenZeppelin contracts, and NomicFoundation. ```bash -yarn add @aztec/foundation @aztec/l1-contracts @openzeppelin/contracts && yarn add --dev @nomicfoundation/hardhat-network-helpers @nomicfoundation/hardhat-chai-matchers @nomiclabs/hardhat-ethers @nomiclabs/hardhat-etherscan @types/chai @types/mocha @typechain/ethers-v5 @typechain/hardhat chai hardhat-gas-reporter solidity-coverage ts-node typechain typescript +yarn add @aztec/foundation @aztec/l1-contracts @openzeppelin/contracts && yarn add --dev @nomicfoundation/hardhat-network-helpers @nomicfoundation/hardhat-chai-matchers @nomiclabs/hardhat-ethers @nomiclabs/hardhat-etherscan @types/chai @types/mocha @typechain/ethers-v5 @typechain/hardhat chai@4.0.0 hardhat-gas-reporter solidity-coverage ts-node typechain typescript ``` @@ -129,7 +131,7 @@ Inside the `packages` directory, run ```bash mkdir src && cd src && yarn init -yp -yarn add @aztec/aztec.js @aztec/accounts @aztec/noir-contracts @aztec/circuit-types @aztec/foundation @aztec/l1-artifacts viem "@types/node@^20.8.2" +yarn add typescript @aztec/aztec.js @aztec/accounts @aztec/noir-contracts @aztec/types @aztec/foundation @aztec/l1-artifacts viem@1.21.4 "@types/node@^20.8.2" yarn add -D jest @jest/globals ts-jest ``` @@ -144,7 +146,7 @@ In `package.json`, add: } ``` -Your `package.json` should look something like this: +Your `package.json` should look something like this (do not copy and paste): ```json { @@ -154,18 +156,11 @@ Your `package.json` should look something like this: "license": "MIT", "private": true, "type": "module", - "dependencies": { - "@aztec/aztec.js": "^0.8.7", - "@aztec/foundation": "^0.8.7", - "@aztec/noir-contracts": "^0.8.7", - "@aztec/circuit-types": "^0.8.7", - "@types/node": "^20.8.2", - "ethers": "^5.7" + "dependencies": { + "dep": "version", }, "devDependencies": { - "@jest/globals": "^29.7.0", - "jest": "^29.7.0", - "ts-jest": "^29.1.1" + "dep": "version", }, "scripts": { "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest)" @@ -227,12 +222,6 @@ Then create a jest config file: `jest.config.json` } ``` -You will also need to install some dependencies: - -```bash -yarn add --dev typescript @types/jest ts-jest -``` - Finally, we will create a test file. Run this in the `src` directory.: ```bash @@ -249,6 +238,7 @@ src └── cross_chain_messaging.test.ts ├── jest.config.json ├── package.json +├── tsconfig.json ``` In the next step, we’ll start writing our L1 smart contract with some logic to deposit tokens to Aztec from L1. diff --git a/docs/docs/dev_docs/tutorials/token_portal/typescript_glue_code.md b/docs/docs/dev_docs/tutorials/token_portal/typescript_glue_code.md index 7adc80a0154b..ca4e63c19941 100644 --- a/docs/docs/dev_docs/tutorials/token_portal/typescript_glue_code.md +++ b/docs/docs/dev_docs/tutorials/token_portal/typescript_glue_code.md @@ -4,19 +4,12 @@ title: Deploy & Call Contracts with Typescript In this step we will write a Typescript test to interact with the sandbox and call our contracts! -Go to the `src/test` directory in your `packages` dir and create a new file called `cross_chain_messaging.test.ts`: - -```bash -cd src/test -touch cross_chain_messaging.test.ts -``` - ## Test imports and setup We need some helper files that can keep our code clean. Inside your `src/test` directory: ```bash -mkdir fixtures && cd fixtures +cd fixtures touch utils.ts cd .. && mkdir shared && cd shared touch cross_chain_test_harness.ts @@ -47,8 +40,8 @@ Open `cross_chain_messaging.test.ts` and paste the initial description of the te ```typescript import { expect, jest} from '@jest/globals' -import { AccountWallet, AztecAddress, DebugLogger, EthAddress, Fr, computeAuthWitMessageHash, createDebugLogger, createPXEClient, waitForPXE } from '@aztec/aztec.js'; -import { getInitialTestAccountsWallets } from '@aztec/accounts/testing'; +import { AccountWallet, AztecAddress, DebugLogger, EthAddress, Fr, computeAuthWitMessageHash, createDebugLogger, createPXEClient, waitForSandbox } from '@aztec/aztec.js'; +import { getSandboxAccountsWallets } from '@aztec/accounts/testing'; import { TokenContract } from '@aztec/noir-contracts/Token'; import { TokenBridgeContract } from '@aztec/noir-contracts/TokenBridge'; @@ -80,8 +73,8 @@ describe('e2e_cross_chain_messaging', () => { beforeEach(async () => { logger = createDebugLogger('aztec:e2e_uniswap'); const pxe = createPXEClient(PXE_URL); - await waitForPXE(pxe); - const wallets = await getInitialTestAccountsWallets(pxe); + await waitForSandbox(pxe); + const wallets = await getSandboxAccountsWallets(pxe); const walletClient = createWalletClient({ account: hdAccount, diff --git a/docs/docs/dev_docs/tutorials/token_portal/withdrawing_to_l1.md b/docs/docs/dev_docs/tutorials/token_portal/withdrawing_to_l1.md index fd2a2ea17218..8716421c10b7 100644 --- a/docs/docs/dev_docs/tutorials/token_portal/withdrawing_to_l1.md +++ b/docs/docs/dev_docs/tutorials/token_portal/withdrawing_to_l1.md @@ -42,8 +42,10 @@ For both the public and private flow, we use the same mechanism to determine the After the transaction is completed on L2, the portal must call the outbox to successfully transfer funds to the user on L1. Like with deposits, things can be complex here. For example, what happens if the transaction was done on L2 to burn tokens but can’t be withdrawn to L1? Then the funds are lost forever! How do we prevent this? Paste this in your `TokenPortal.sol`: - -#include_code token_portal_withdraw /l1-contracts/test/portals/TokenPortal.sol solidity +```solidity +#include_code token_portal_withdraw /l1-contracts/test/portals/TokenPortal.sol raw +} +``` Here we reconstruct the L2 to L1 message and check that this message exists on the outbox. If so, we consume it and transfer the funds to the recipient. As part of the reconstruction, the content hash looks similar to what we did in our bridge contract on aztec where we pass the amount and recipient to the the hash. This way a malicious actor can’t change the recipient parameter to the address and withdraw funds to themselves. @@ -53,13 +55,17 @@ We call this pattern _designed caller_ which enables a new paradigm **where we c Before we can compile and use the contract, we need to add two additional functions. -We need a function that let's us read the token value. +We need a function that lets us read the token value. Paste this into `main.nr`: #include_code read_token /yarn-project/noir-contracts/contracts/token_bridge_contract/src/main.nr rust -And the `compute_note_hash_and_nullifier` required on every contract. +And the `compute_note_hash_and_nullifier` required on every contract: + +```rust +#include_code compute_note_hash_and_nullifier_placeholder /yarn-project/noir-contracts/contracts/token_bridge_contract/src/main.nr raw +} +``` -#include_code compute_note_hash_and_nullifier_placeholder /yarn-project/noir-contracts/contracts/token_bridge_contract/src/main.nr rust ## Compile code @@ -75,14 +81,14 @@ npx hardhat compile And compile your Aztec.nr contracts like this: ```bash -cd aztec-contracts/token-bridge +cd aztec-contracts/token_bridge aztec-nargo compile ``` And generate the TypeScript interface for the contract and add it to the test dir: ```bash -aztec-cli codegen target -o ../../../src/test/fixtures --ts +aztec-cli codegen target -o ../../src/test/fixtures --ts ``` This will create a TS interface in our `src/test` folder! diff --git a/docs/docs/dev_docs/tutorials/writing_private_voting_contract.md b/docs/docs/dev_docs/tutorials/writing_private_voting_contract.md index b5e6f0847211..c8ab1e70f641 100644 --- a/docs/docs/dev_docs/tutorials/writing_private_voting_contract.md +++ b/docs/docs/dev_docs/tutorials/writing_private_voting_contract.md @@ -71,7 +71,7 @@ Inside this, paste these imports: We are using various utils within the Aztec library: - `context` - exposes things such as the contract address, msg_sender, etc -- `oracle::get_secret_key` - get your secret key to help us create a randomized nullifier +- `context.request_nullifier_secret_key` - get your secret key to help us create a randomized nullifier - `FunctionSelector::from_signature` - compute a function selector from signature so we can call functions from other functions - `state_vars::{ map::Map, public_state::PublicState, }` - we will use a Map to store the votes (key = voteId, value = number of votes), and PublicState to hold our public values that we mentioned earlier - `types::type_serialization::{..}` - various serialization methods for defining how to use these types diff --git a/docs/docs/intro.md b/docs/docs/intro.md index f6f5757ad438..ca9ff902fe90 100644 --- a/docs/docs/intro.md +++ b/docs/docs/intro.md @@ -7,66 +7,22 @@ description: "Aztec introduces a privacy-centric zkRollup solution for Ethereum, # Aztec: Ethereum, encrypted -On Ethereum today, everything is publicly visible, by everyone. +On Ethereum today, everything is publicly visible, by everyone. In the real world, people enjoy privacy. Aztec brings privacy to Ethereum. -In the real world, people enjoy privacy. +## Get started -Aztec brings privacy to Ethereum. +### Learn :book: ---- - -## Build with confidence. - -Design, build, and deploy private smart contracts with the following features: - -- Private functions -- Private arguments -- Private persistent state -- Private bytecode -- Private deployments -- Private execution -- Private transactions -- Private contract composability -- Encrypted state transitions -- Encrypted logs - -Plus: - -- Composability with Ethereum L1 -- Access to Ethereum's L1 liquidity -- Cheap, public logic, if you need it -- Cheap, public persistent state, if you need it - ---- - -## Play - -Visit the [getting started](./dev_docs/getting_started/main) section for an introduction. - -Go to the [Tutorials](./dev_docs/tutorials/main.md) section to dive into some more advanced walkthroughs. - ---- - -## But what _is_ Aztec? - -Aztec encrypts Ethereum. - -Aztec is the privacy layer of Ethereum. - -Aztec is a private smart contract platform. - -Aztec is a _fully programmable_ private smart contract platform. - -Aztec is an Ethereum Layer 2. +Start on the [Foundational Concepts page](./concepts/foundation/main.md) to read about how Aztec works. -Aztec is a zk-zk rollup. +### Build :technologist: -Aztec is a hybrid private/public rollup. +Go to the [Getting Started section](./dev_docs/getting_started/main.md) of the developer docs to get your hands dirty and start developing on Aztec. -Aztec is a network. +#### Go deeper 🔬 -Still confused? Explore these docs! +Check out the [Awesome Aztec repo](https://github.com/AztecProtocol/awesome-aztec) for a curated list of learning resources and tools to help you learn more about Aztec. -## Participate +Clone the [Aztec Starter repo](https://github.com/AztecProtocol/aztec-starter) to get a minimal project set up with Sandbox (local developer network), a simple contract and a test suite. -We are building the Aztec network in public. Keep up with the latest discussion and join the conversation in the [Aztec forum](https://discourse.aztec.network) and check out our code on [Github](https://github.com/AztecProtocol). +Jump into one of the [tutorials](./dev_docs/tutorials/main.md) to learn how to build more complex applications on Aztec. diff --git a/docs/docs/misc/migration_notes.md b/docs/docs/misc/migration_notes.md index 262e693d2b55..54a95d598f92 100644 --- a/docs/docs/misc/migration_notes.md +++ b/docs/docs/misc/migration_notes.md @@ -6,6 +6,61 @@ keywords: [sandbox, cli, aztec, notes, migration, updating, upgrading] Aztec is in full-speed development. Literally every version breaks compatibility with the previous ones. This page attempts to target errors and difficulties you might encounter when upgrading, and how to resolve them. +## 0.20.0 + +### [Aztec.nr] Changes to `NoteInterface` + +1. Changing `compute_nullifier()` to `compute_nullifier(private_context: PrivateContext)` + + This API is invoked for nullifier generation within private functions. When using a secret key for nullifier creation, retrieve it through: + + `private_context.request_nullifier_secret_key(account_address)` + + The private context will generate a request for the kernel circuit to validate that the secret key does belong to the account. + + Before: + + ```rust + pub fn compute_nullifier(self) -> Field { + let secret = oracle.get_secret_key(self.owner); + pedersen_hash([ + self.value, + secret.low, + secret.high, + ]) + } + ``` + + Now: + + ```rust + pub fn compute_nullifier(self, context: &mut PrivateContext) -> Field { + let secret = context.request_nullifier_secret_key(self.owner); + pedersen_hash([ + self.value, + secret.low, + secret.high, + ]) + } + ``` + +2. New API `compute_nullifier_without_context()`. + + This API is used within unconstrained functions where the private context is not available, and using an unverified nullifier key won't affect the network or other users. For example, it's used in `compute_note_hash_and_nullifier()` to compute values for the user's own notes. + + ```rust + pub fn compute_nullifier_without_context(self) -> Field { + let secret = oracle.get_nullifier_secret_key(self.owner); + pedersen_hash([ + self.value, + secret.low, + secret.high, + ]) + } + ``` + + > Note that the `get_secret_key` oracle API has been renamed to `get_nullifier_secret_key`. + ## 0.18.0 ### [Aztec.nr] Remove `protocol_types` from Nargo.toml @@ -18,9 +73,10 @@ aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_ ### [Aztec.nr] key type definition in Map -The `Map` class now requires defining the key type in its declaration which *must* implement the `ToField` trait. +The `Map` class now requires defining the key type in its declaration which _must_ implement the `ToField` trait. Before: + ```rust struct Storage { balances: Map> @@ -30,6 +86,7 @@ let user_balance = balances.at(owner.to_field()) ``` Now: + ```rust struct Storage { balances: Map> @@ -40,29 +97,31 @@ let user_balance = balances.at(owner) ### [js] Updated function names -- `waitForSandbox` renamed to `waitForPXE` in `@aztec/aztec.js` +- `waitForSandbox` renamed to `waitForPXE` in `@aztec/aztec.js` - `getSandboxAccountsWallets` renamed to `getInitialTestAccountsWallets` in `@aztec/accounts/testing` ## 0.17.0 ### [js] New `@aztec/accounts` package -Before: +Before: ```js -import { getSchnorrAccount } from "@aztec/aztec.js" // previously you would get the default accounts from the `aztec.js` package: +import { getSchnorrAccount } from "@aztec/aztec.js"; // previously you would get the default accounts from the `aztec.js` package: ``` Now, import them from the new package `@aztec/accounts` ```js -import { getSchnorrAccount } from "@aztec/accounts" +import { getSchnorrAccount } from "@aztec/accounts"; ``` ### Typed Addresses + Address fields in Aztec.nr now is of type `AztecAddress` as opposed to `Field` Before: + ```rust unconstrained fn compute_note_hash_and_nullifier(contract_address: Field, nonce: Field, storage_slot: Field, serialized_note: [Field; VALUE_NOTE_LEN]) -> [Field; 4] { let note_header = NoteHeader::new(_address, nonce, storage_slot); @@ -70,6 +129,7 @@ unconstrained fn compute_note_hash_and_nullifier(contract_address: Field, nonce: ``` Now: + ```rust unconstrained fn compute_note_hash_and_nullifier( contract_address: AztecAddress, @@ -84,39 +144,48 @@ Similarly, there are changes when using aztec.js to call functions. To parse a `AztecAddress` to BigInt, use `.inner` Before: + ```js -const tokenBigInt = await bridge.methods.token().view() +const tokenBigInt = await bridge.methods.token().view(); ``` Now: + ```js -const tokenBigInt = (await bridge.methods.token().view()).inner +const tokenBigInt = (await bridge.methods.token().view()).inner; ``` ### [Aztec.nr] Add `protocol_types` to Nargo.toml + ```toml aztec = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/aztec-nr/aztec" } protocol_types = { git="https://github.com/AztecProtocol/aztec-packages/", tag="#include_aztec_version", directory="yarn-project/noir-protocol-circuits/src/crates/types"} ``` ### [Aztec.nr] moving compute_address func to AztecAddress + Before: + ```rust let calculated_address = compute_address(pub_key_x, pub_key_y, partial_address); ``` Now: + ```rust let calculated_address = AztecAddress::compute(pub_key_x, pub_key_y, partial_address); ``` ### [Aztec.nr] moving `compute_selector` to FunctionSelector + Before: + ```rust let selector = compute_selector("_initialize((Field))"); ``` Now: + ```rust let selector = FunctionSelector::from_signature("_initialize((Field))"); ``` @@ -126,11 +195,13 @@ let selector = FunctionSelector::from_signature("_initialize((Field))"); Contracts are now imported from a file with the type's name. Before: + ```js import { TokenContract } from "@aztec/noir-contracts/types"; ``` Now: + ```js import { TokenContract } from "@aztec/noir-contracts/Token"; ``` @@ -140,6 +211,7 @@ import { TokenContract } from "@aztec/noir-contracts/Token"; Aztec contracts are now moved outside of the `src` folder, so you need to update your imports. Before: + ```rust easy_private_token_contract = {git = "https://github.com/AztecProtocol/aztec-packages/", tag ="v0.16.9", directory = "yarn-project/noir-contracts/src/contracts/easy_private_token_contract"} ``` diff --git a/docs/sidebars.js b/docs/sidebars.js index bfa154565249..1e94f85f3544 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -32,7 +32,7 @@ const sidebars = { label: "What is Aztec?", type: "category", link: { type: "doc", id: "intro" }, - items: ["about_aztec/history/history", "about_aztec/overview"], + items: ["about_aztec/overview"], }, "about_aztec/vision", @@ -217,8 +217,8 @@ const sidebars = { items: [ "dev_docs/getting_started/quickstart", "dev_docs/getting_started/core-concepts", - "dev_docs/getting_started/aztecjs-getting-started", "dev_docs/getting_started/aztecnr-getting-started", + "dev_docs/getting_started/aztecjs-getting-started", ], }, @@ -330,7 +330,16 @@ const sidebars = { }, "dev_docs/contracts/syntax/events", "dev_docs/contracts/syntax/functions", + { + label: "Proving Historical Blockchain Data", + type: "category", + items: [ + "dev_docs/contracts/syntax/historical_access/how_to_prove_history", + "dev_docs/contracts/syntax/historical_access/history_lib_reference", + ], + }, "dev_docs/contracts/syntax/slow_updates_tree", + "dev_docs/contracts/syntax/context", "dev_docs/contracts/syntax/globals", ], diff --git a/docs/yarn.lock b/docs/yarn.lock index 3ac7b7d4c221..be4e6d0886b7 100644 --- a/docs/yarn.lock +++ b/docs/yarn.lock @@ -2,153 +2,162 @@ # yarn lockfile v1 -"@algolia/autocomplete-core@1.7.4": - version "1.7.4" - resolved "https://registry.yarnpkg.com/@algolia/autocomplete-core/-/autocomplete-core-1.7.4.tgz#85ff36b2673654a393c8c505345eaedd6eaa4f70" - integrity sha512-daoLpQ3ps/VTMRZDEBfU8ixXd+amZcNJ4QSP3IERGyzqnL5Ch8uSRFt/4G8pUvW9c3o6GA4vtVv4I4lmnkdXyg== +"@algolia/autocomplete-core@1.9.3": + version "1.9.3" + resolved "https://registry.yarnpkg.com/@algolia/autocomplete-core/-/autocomplete-core-1.9.3.tgz#1d56482a768c33aae0868c8533049e02e8961be7" + integrity sha512-009HdfugtGCdC4JdXUbVJClA0q0zh24yyePn+KUGk3rP7j8FEe/m5Yo/z65gn6nP/cM39PxpzqKrL7A6fP6PPw== dependencies: - "@algolia/autocomplete-shared" "1.7.4" + "@algolia/autocomplete-plugin-algolia-insights" "1.9.3" + "@algolia/autocomplete-shared" "1.9.3" -"@algolia/autocomplete-preset-algolia@1.7.4": - version "1.7.4" - resolved "https://registry.yarnpkg.com/@algolia/autocomplete-preset-algolia/-/autocomplete-preset-algolia-1.7.4.tgz#610ee1d887962f230b987cba2fd6556478000bc3" - integrity sha512-s37hrvLEIfcmKY8VU9LsAXgm2yfmkdHT3DnA3SgHaY93yjZ2qL57wzb5QweVkYuEBZkT2PIREvRoLXC2sxTbpQ== +"@algolia/autocomplete-plugin-algolia-insights@1.9.3": + version "1.9.3" + resolved "https://registry.yarnpkg.com/@algolia/autocomplete-plugin-algolia-insights/-/autocomplete-plugin-algolia-insights-1.9.3.tgz#9b7f8641052c8ead6d66c1623d444cbe19dde587" + integrity sha512-a/yTUkcO/Vyy+JffmAnTWbr4/90cLzw+CC3bRbhnULr/EM0fGNvM13oQQ14f2moLMcVDyAx/leczLlAOovhSZg== dependencies: - "@algolia/autocomplete-shared" "1.7.4" + "@algolia/autocomplete-shared" "1.9.3" -"@algolia/autocomplete-shared@1.7.4": - version "1.7.4" - resolved "https://registry.yarnpkg.com/@algolia/autocomplete-shared/-/autocomplete-shared-1.7.4.tgz#78aea1140a50c4d193e1f06a13b7f12c5e2cbeea" - integrity sha512-2VGCk7I9tA9Ge73Km99+Qg87w0wzW4tgUruvWAn/gfey1ZXgmxZtyIRBebk35R1O8TbK77wujVtCnpsGpRy1kg== +"@algolia/autocomplete-preset-algolia@1.9.3": + version "1.9.3" + resolved "https://registry.yarnpkg.com/@algolia/autocomplete-preset-algolia/-/autocomplete-preset-algolia-1.9.3.tgz#64cca4a4304cfcad2cf730e83067e0c1b2f485da" + integrity sha512-d4qlt6YmrLMYy95n5TB52wtNDr6EgAIPH81dvvvW8UmuWRgxEtY0NJiPwl/h95JtG2vmRM804M0DSwMCNZlzRA== + dependencies: + "@algolia/autocomplete-shared" "1.9.3" + +"@algolia/autocomplete-shared@1.9.3": + version "1.9.3" + resolved "https://registry.yarnpkg.com/@algolia/autocomplete-shared/-/autocomplete-shared-1.9.3.tgz#2e22e830d36f0a9cf2c0ccd3c7f6d59435b77dfa" + integrity sha512-Wnm9E4Ye6Rl6sTTqjoymD+l8DjSTHsHboVRYrKgEt8Q7UHm9nYbqhN/i0fhUYA3OAEH7WA8x3jfpnmJm3rKvaQ== -"@algolia/cache-browser-local-storage@4.14.3": - version "4.14.3" - resolved "https://registry.yarnpkg.com/@algolia/cache-browser-local-storage/-/cache-browser-local-storage-4.14.3.tgz#b9e0da012b2f124f785134a4d468ee0841b2399d" - integrity sha512-hWH1yCxgG3+R/xZIscmUrWAIBnmBFHH5j30fY/+aPkEZWt90wYILfAHIOZ1/Wxhho5SkPfwFmT7ooX2d9JeQBw== +"@algolia/cache-browser-local-storage@4.22.1": + version "4.22.1" + resolved "https://registry.yarnpkg.com/@algolia/cache-browser-local-storage/-/cache-browser-local-storage-4.22.1.tgz#14b6dc9abc9e3a304a5fffb063d15f30af1032d1" + integrity sha512-Sw6IAmOCvvP6QNgY9j+Hv09mvkvEIDKjYW8ow0UDDAxSXy664RBNQk3i/0nt7gvceOJ6jGmOTimaZoY1THmU7g== dependencies: - "@algolia/cache-common" "4.14.3" + "@algolia/cache-common" "4.22.1" -"@algolia/cache-common@4.14.3": - version "4.14.3" - resolved "https://registry.yarnpkg.com/@algolia/cache-common/-/cache-common-4.14.3.tgz#a78e9faee3dfec018eab7b0996e918e06b476ac7" - integrity sha512-oZJofOoD9FQOwiGTzyRnmzvh3ZP8WVTNPBLH5xU5JNF7drDbRT0ocVT0h/xB2rPHYzOeXRrLaQQBwRT/CKom0Q== +"@algolia/cache-common@4.22.1": + version "4.22.1" + resolved "https://registry.yarnpkg.com/@algolia/cache-common/-/cache-common-4.22.1.tgz#c625dff4bc2a74e79f9aed67b4e053b0ef1b3ec1" + integrity sha512-TJMBKqZNKYB9TptRRjSUtevJeQVXRmg6rk9qgFKWvOy8jhCPdyNZV1nB3SKGufzvTVbomAukFR8guu/8NRKBTA== -"@algolia/cache-in-memory@4.14.3": - version "4.14.3" - resolved "https://registry.yarnpkg.com/@algolia/cache-in-memory/-/cache-in-memory-4.14.3.tgz#96cefb942aeb80e51e6a7e29f25f4f7f3439b736" - integrity sha512-ES0hHQnzWjeioLQf5Nq+x1AWdZJ50znNPSH3puB/Y4Xsg4Av1bvLmTJe7SY2uqONaeMTvL0OaVcoVtQgJVw0vg== +"@algolia/cache-in-memory@4.22.1": + version "4.22.1" + resolved "https://registry.yarnpkg.com/@algolia/cache-in-memory/-/cache-in-memory-4.22.1.tgz#858a3d887f521362e87d04f3943e2810226a0d71" + integrity sha512-ve+6Ac2LhwpufuWavM/aHjLoNz/Z/sYSgNIXsinGofWOysPilQZPUetqLj8vbvi+DHZZaYSEP9H5SRVXnpsNNw== dependencies: - "@algolia/cache-common" "4.14.3" + "@algolia/cache-common" "4.22.1" -"@algolia/client-account@4.14.3": - version "4.14.3" - resolved "https://registry.yarnpkg.com/@algolia/client-account/-/client-account-4.14.3.tgz#6d7d032a65c600339ce066505c77013d9a9e4966" - integrity sha512-PBcPb0+f5Xbh5UfLZNx2Ow589OdP8WYjB4CnvupfYBrl9JyC1sdH4jcq/ri8osO/mCZYjZrQsKAPIqW/gQmizQ== +"@algolia/client-account@4.22.1": + version "4.22.1" + resolved "https://registry.yarnpkg.com/@algolia/client-account/-/client-account-4.22.1.tgz#a7fb8b66b9a4f0a428e1426b2561144267d76d43" + integrity sha512-k8m+oegM2zlns/TwZyi4YgCtyToackkOpE+xCaKCYfBfDtdGOaVZCM5YvGPtK+HGaJMIN/DoTL8asbM3NzHonw== dependencies: - "@algolia/client-common" "4.14.3" - "@algolia/client-search" "4.14.3" - "@algolia/transporter" "4.14.3" + "@algolia/client-common" "4.22.1" + "@algolia/client-search" "4.22.1" + "@algolia/transporter" "4.22.1" -"@algolia/client-analytics@4.14.3": - version "4.14.3" - resolved "https://registry.yarnpkg.com/@algolia/client-analytics/-/client-analytics-4.14.3.tgz#ca409d00a8fff98fdcc215dc96731039900055dc" - integrity sha512-eAwQq0Hb/aauv9NhCH5Dp3Nm29oFx28sayFN2fdOWemwSeJHIl7TmcsxVlRsO50fsD8CtPcDhtGeD3AIFLNvqw== +"@algolia/client-analytics@4.22.1": + version "4.22.1" + resolved "https://registry.yarnpkg.com/@algolia/client-analytics/-/client-analytics-4.22.1.tgz#506558740b4d49b1b1e3393861f729a8ce921851" + integrity sha512-1ssi9pyxyQNN4a7Ji9R50nSdISIumMFDwKNuwZipB6TkauJ8J7ha/uO60sPJFqQyqvvI+px7RSNRQT3Zrvzieg== dependencies: - "@algolia/client-common" "4.14.3" - "@algolia/client-search" "4.14.3" - "@algolia/requester-common" "4.14.3" - "@algolia/transporter" "4.14.3" + "@algolia/client-common" "4.22.1" + "@algolia/client-search" "4.22.1" + "@algolia/requester-common" "4.22.1" + "@algolia/transporter" "4.22.1" -"@algolia/client-common@4.14.3": - version "4.14.3" - resolved "https://registry.yarnpkg.com/@algolia/client-common/-/client-common-4.14.3.tgz#c44e48652b2121a20d7a40cfd68d095ebb4191a8" - integrity sha512-jkPPDZdi63IK64Yg4WccdCsAP4pHxSkr4usplkUZM5C1l1oEpZXsy2c579LQ0rvwCs5JFmwfNG4ahOszidfWPw== +"@algolia/client-common@4.22.1": + version "4.22.1" + resolved "https://registry.yarnpkg.com/@algolia/client-common/-/client-common-4.22.1.tgz#042b19c1b6157c485fa1b551349ab313944d2b05" + integrity sha512-IvaL5v9mZtm4k4QHbBGDmU3wa/mKokmqNBqPj0K7lcR8ZDKzUorhcGp/u8PkPC/e0zoHSTvRh7TRkGX3Lm7iOQ== dependencies: - "@algolia/requester-common" "4.14.3" - "@algolia/transporter" "4.14.3" + "@algolia/requester-common" "4.22.1" + "@algolia/transporter" "4.22.1" -"@algolia/client-personalization@4.14.3": - version "4.14.3" - resolved "https://registry.yarnpkg.com/@algolia/client-personalization/-/client-personalization-4.14.3.tgz#8f71325035aa2a5fa7d1d567575235cf1d6c654f" - integrity sha512-UCX1MtkVNgaOL9f0e22x6tC9e2H3unZQlSUdnVaSKpZ+hdSChXGaRjp2UIT7pxmPqNCyv51F597KEX5WT60jNg== +"@algolia/client-personalization@4.22.1": + version "4.22.1" + resolved "https://registry.yarnpkg.com/@algolia/client-personalization/-/client-personalization-4.22.1.tgz#ff088d797648224fb582e9fe5828f8087835fa3d" + integrity sha512-sl+/klQJ93+4yaqZ7ezOttMQ/nczly/3GmgZXJ1xmoewP5jmdP/X/nV5U7EHHH3hCUEHeN7X1nsIhGPVt9E1cQ== dependencies: - "@algolia/client-common" "4.14.3" - "@algolia/requester-common" "4.14.3" - "@algolia/transporter" "4.14.3" + "@algolia/client-common" "4.22.1" + "@algolia/requester-common" "4.22.1" + "@algolia/transporter" "4.22.1" -"@algolia/client-search@4.14.3": - version "4.14.3" - resolved "https://registry.yarnpkg.com/@algolia/client-search/-/client-search-4.14.3.tgz#cf1e77549f5c3e73408ffe6441ede985fde69da0" - integrity sha512-I2U7xBx5OPFdPLA8AXKUPPxGY3HDxZ4r7+mlZ8ZpLbI8/ri6fnu6B4z3wcL7sgHhDYMwnAE8Xr0AB0h3Hnkp4A== +"@algolia/client-search@4.22.1": + version "4.22.1" + resolved "https://registry.yarnpkg.com/@algolia/client-search/-/client-search-4.22.1.tgz#508cc6ab3d1f4e9c02735a630d4dff6fbb8514a2" + integrity sha512-yb05NA4tNaOgx3+rOxAmFztgMTtGBi97X7PC3jyNeGiwkAjOZc2QrdZBYyIdcDLoI09N0gjtpClcackoTN0gPA== dependencies: - "@algolia/client-common" "4.14.3" - "@algolia/requester-common" "4.14.3" - "@algolia/transporter" "4.14.3" + "@algolia/client-common" "4.22.1" + "@algolia/requester-common" "4.22.1" + "@algolia/transporter" "4.22.1" "@algolia/events@^4.0.1": version "4.0.1" resolved "https://registry.yarnpkg.com/@algolia/events/-/events-4.0.1.tgz#fd39e7477e7bc703d7f893b556f676c032af3950" integrity sha512-FQzvOCgoFXAbf5Y6mYozw2aj5KCJoA3m4heImceldzPSMbdyS4atVjJzXKMsfX3wnZTFYwkkt8/z8UesLHlSBQ== -"@algolia/logger-common@4.14.3": - version "4.14.3" - resolved "https://registry.yarnpkg.com/@algolia/logger-common/-/logger-common-4.14.3.tgz#87d4725e7f56ea5a39b605771b7149fff62032a7" - integrity sha512-kUEAZaBt/J3RjYi8MEBT2QEexJR2kAE2mtLmezsmqMQZTV502TkHCxYzTwY2dE7OKcUTxi4OFlMuS4GId9CWPw== +"@algolia/logger-common@4.22.1": + version "4.22.1" + resolved "https://registry.yarnpkg.com/@algolia/logger-common/-/logger-common-4.22.1.tgz#79cf4cd295de0377a94582c6aaac59b1ded731d9" + integrity sha512-OnTFymd2odHSO39r4DSWRFETkBufnY2iGUZNrMXpIhF5cmFE8pGoINNPzwg02QLBlGSaLqdKy0bM8S0GyqPLBg== -"@algolia/logger-console@4.14.3": - version "4.14.3" - resolved "https://registry.yarnpkg.com/@algolia/logger-console/-/logger-console-4.14.3.tgz#1f19f8f0a5ef11f01d1f9545290eb6a89b71fb8a" - integrity sha512-ZWqAlUITktiMN2EiFpQIFCJS10N96A++yrexqC2Z+3hgF/JcKrOxOdT4nSCQoEPvU4Ki9QKbpzbebRDemZt/hw== +"@algolia/logger-console@4.22.1": + version "4.22.1" + resolved "https://registry.yarnpkg.com/@algolia/logger-console/-/logger-console-4.22.1.tgz#0355345f6940f67aaa78ae9b81c06e44e49f2336" + integrity sha512-O99rcqpVPKN1RlpgD6H3khUWylU24OXlzkavUAMy6QZd1776QAcauE3oP8CmD43nbaTjBexZj2nGsBH9Tc0FVA== dependencies: - "@algolia/logger-common" "4.14.3" + "@algolia/logger-common" "4.22.1" -"@algolia/requester-browser-xhr@4.14.3": - version "4.14.3" - resolved "https://registry.yarnpkg.com/@algolia/requester-browser-xhr/-/requester-browser-xhr-4.14.3.tgz#bcf55cba20f58fd9bc95ee55793b5219f3ce8888" - integrity sha512-AZeg2T08WLUPvDncl2XLX2O67W5wIO8MNaT7z5ii5LgBTuk/rU4CikTjCe2xsUleIZeFl++QrPAi4Bdxws6r/Q== +"@algolia/requester-browser-xhr@4.22.1": + version "4.22.1" + resolved "https://registry.yarnpkg.com/@algolia/requester-browser-xhr/-/requester-browser-xhr-4.22.1.tgz#f04df6fe9690a071b267c77d26b83a3be9280361" + integrity sha512-dtQGYIg6MteqT1Uay3J/0NDqD+UciHy3QgRbk7bNddOJu+p3hzjTRYESqEnoX/DpEkaNYdRHUKNylsqMpgwaEw== dependencies: - "@algolia/requester-common" "4.14.3" + "@algolia/requester-common" "4.22.1" -"@algolia/requester-common@4.14.3": - version "4.14.3" - resolved "https://registry.yarnpkg.com/@algolia/requester-common/-/requester-common-4.14.3.tgz#2d02fbe01afb7ae5651ae8dfe62d6c089f103714" - integrity sha512-RrRzqNyKFDP7IkTuV3XvYGF9cDPn9h6qEDl595lXva3YUk9YSS8+MGZnnkOMHvjkrSCKfoLeLbm/T4tmoIeclw== +"@algolia/requester-common@4.22.1": + version "4.22.1" + resolved "https://registry.yarnpkg.com/@algolia/requester-common/-/requester-common-4.22.1.tgz#27be35f3718aafcb6b388ff9c3aa2defabd559ff" + integrity sha512-dgvhSAtg2MJnR+BxrIFqlLtkLlVVhas9HgYKMk2Uxiy5m6/8HZBL40JVAMb2LovoPFs9I/EWIoFVjOrFwzn5Qg== -"@algolia/requester-node-http@4.14.3": - version "4.14.3" - resolved "https://registry.yarnpkg.com/@algolia/requester-node-http/-/requester-node-http-4.14.3.tgz#72389e1c2e5d964702451e75e368eefe85a09d8f" - integrity sha512-O5wnPxtDRPuW2U0EaOz9rMMWdlhwP0J0eSL1Z7TtXF8xnUeeUyNJrdhV5uy2CAp6RbhM1VuC3sOJcIR6Av+vbA== +"@algolia/requester-node-http@4.22.1": + version "4.22.1" + resolved "https://registry.yarnpkg.com/@algolia/requester-node-http/-/requester-node-http-4.22.1.tgz#589a6fa828ad0f325e727a6fcaf4e1a2343cc62b" + integrity sha512-JfmZ3MVFQkAU+zug8H3s8rZ6h0ahHZL/SpMaSasTCGYR5EEJsCc8SI5UZ6raPN2tjxa5bxS13BRpGSBUens7EA== dependencies: - "@algolia/requester-common" "4.14.3" + "@algolia/requester-common" "4.22.1" -"@algolia/transporter@4.14.3": - version "4.14.3" - resolved "https://registry.yarnpkg.com/@algolia/transporter/-/transporter-4.14.3.tgz#5593036bd9cf2adfd077fdc3e81d2e6118660a7a" - integrity sha512-2qlKlKsnGJ008exFRb5RTeTOqhLZj0bkMCMVskxoqWejs2Q2QtWmsiH98hDfpw0fmnyhzHEt0Z7lqxBYp8bW2w== +"@algolia/transporter@4.22.1": + version "4.22.1" + resolved "https://registry.yarnpkg.com/@algolia/transporter/-/transporter-4.22.1.tgz#8843841b857dc021668f31647aa557ff19cd9cb1" + integrity sha512-kzWgc2c9IdxMa3YqA6TN0NW5VrKYYW/BELIn7vnLyn+U/RFdZ4lxxt9/8yq3DKV5snvoDzzO4ClyejZRdV3lMQ== dependencies: - "@algolia/cache-common" "4.14.3" - "@algolia/logger-common" "4.14.3" - "@algolia/requester-common" "4.14.3" + "@algolia/cache-common" "4.22.1" + "@algolia/logger-common" "4.22.1" + "@algolia/requester-common" "4.22.1" "@ampproject/remapping@^2.2.0": - version "2.2.0" - resolved "https://registry.yarnpkg.com/@ampproject/remapping/-/remapping-2.2.0.tgz#56c133824780de3174aed5ab6834f3026790154d" - integrity sha512-qRmjj8nj9qmLTQXXmaR1cck3UXSRMPrbsLJAasZpF+t3riI71BXed5ebIOYwQntykeZuhjsdweEc9BxH5Jc26w== + version "2.2.1" + resolved "https://registry.yarnpkg.com/@ampproject/remapping/-/remapping-2.2.1.tgz#99e8e11851128b8702cd57c33684f1d0f260b630" + integrity sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg== dependencies: - "@jridgewell/gen-mapping" "^0.1.0" + "@jridgewell/gen-mapping" "^0.3.0" "@jridgewell/trace-mapping" "^0.3.9" -"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.10.4", "@babel/code-frame@^7.16.0", "@babel/code-frame@^7.18.6", "@babel/code-frame@^7.8.3": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.18.6.tgz#3b25d38c89600baa2dcc219edfa88a74eb2c427a" - integrity sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q== +"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.10.4", "@babel/code-frame@^7.16.0", "@babel/code-frame@^7.22.13", "@babel/code-frame@^7.23.5", "@babel/code-frame@^7.8.3": + version "7.23.5" + resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.23.5.tgz#9009b69a8c602293476ad598ff53e4562e15c244" + integrity sha512-CgH3s1a96LipHCmSUmYFPwY7MNx8C3avkq7i4Wl3cfa662ldtUe4VM1TPXX70pfmrlWTb6jLqTYrZyT2ZTJBgA== dependencies: - "@babel/highlight" "^7.18.6" + "@babel/highlight" "^7.23.4" + chalk "^2.4.2" -"@babel/compat-data@^7.17.7", "@babel/compat-data@^7.20.1", "@babel/compat-data@^7.20.5": - version "7.21.0" - resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.21.0.tgz#c241dc454e5b5917e40d37e525e2f4530c399298" - integrity sha512-gMuZsmsgxk/ENC3O/fRw5QY8A9/uxQbbCEypnLIiYYc/qVJtEV7ouxC3EllIIwNzMqAQee5tanFabWsUOutS7g== +"@babel/compat-data@^7.22.6", "@babel/compat-data@^7.23.3", "@babel/compat-data@^7.23.5": + version "7.23.5" + resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.23.5.tgz#ffb878728bb6bdcb6f4510aa51b1be9afb8cfd98" + integrity sha512-uU27kfDRlhfKl+w1U6vp16IuvSLtjAxdArVXPa9BvLkrr7CYIsxH5adpHObeAGY/41+syctUWOZ140a2Rvkgjw== "@babel/core@7.12.9": version "7.12.9" @@ -173,349 +182,278 @@ source-map "^0.5.0" "@babel/core@^7.18.6", "@babel/core@^7.19.6": - version "7.21.0" - resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.21.0.tgz#1341aefdcc14ccc7553fcc688dd8986a2daffc13" - integrity sha512-PuxUbxcW6ZYe656yL3EAhpy7qXKq0DmYsrJLpbB8XrsCP9Nm+XCg9XFMb5vIDliPD7+U/+M+QJlH17XOcB7eXA== + version "7.23.7" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.23.7.tgz#4d8016e06a14b5f92530a13ed0561730b5c6483f" + integrity sha512-+UpDgowcmqe36d4NwqvKsyPMlOLNGMsfMmQ5WGCu+siCe3t3dfe9njrzGfdN4qq+bcNUt0+Vw6haRxBOycs4dw== dependencies: "@ampproject/remapping" "^2.2.0" - "@babel/code-frame" "^7.18.6" - "@babel/generator" "^7.21.0" - "@babel/helper-compilation-targets" "^7.20.7" - "@babel/helper-module-transforms" "^7.21.0" - "@babel/helpers" "^7.21.0" - "@babel/parser" "^7.21.0" - "@babel/template" "^7.20.7" - "@babel/traverse" "^7.21.0" - "@babel/types" "^7.21.0" - convert-source-map "^1.7.0" + "@babel/code-frame" "^7.23.5" + "@babel/generator" "^7.23.6" + "@babel/helper-compilation-targets" "^7.23.6" + "@babel/helper-module-transforms" "^7.23.3" + "@babel/helpers" "^7.23.7" + "@babel/parser" "^7.23.6" + "@babel/template" "^7.22.15" + "@babel/traverse" "^7.23.7" + "@babel/types" "^7.23.6" + convert-source-map "^2.0.0" debug "^4.1.0" gensync "^1.0.0-beta.2" - json5 "^2.2.2" - semver "^6.3.0" + json5 "^2.2.3" + semver "^6.3.1" -"@babel/generator@^7.12.5", "@babel/generator@^7.18.7", "@babel/generator@^7.21.0", "@babel/generator@^7.21.1": - version "7.21.1" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.21.1.tgz#951cc626057bc0af2c35cd23e9c64d384dea83dd" - integrity sha512-1lT45bAYlQhFn/BHivJs43AiW2rg3/UbLyShGfF3C0KmHvO5fSghWd5kBJy30kpRRucGzXStvnnCFniCR2kXAA== +"@babel/generator@^7.12.5", "@babel/generator@^7.18.7", "@babel/generator@^7.23.6": + version "7.23.6" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.23.6.tgz#9e1fca4811c77a10580d17d26b57b036133f3c2e" + integrity sha512-qrSfCYxYQB5owCmGLbl8XRpX1ytXlpueOb0N0UmQwA073KZxejgQTzAmJezxvpwQD9uGtK2shHdi55QT+MbjIw== dependencies: - "@babel/types" "^7.21.0" + "@babel/types" "^7.23.6" "@jridgewell/gen-mapping" "^0.3.2" "@jridgewell/trace-mapping" "^0.3.17" jsesc "^2.5.1" -"@babel/helper-annotate-as-pure@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.18.6.tgz#eaa49f6f80d5a33f9a5dd2276e6d6e451be0a6bb" - integrity sha512-duORpUiYrEpzKIop6iNbjnwKLAKnJ47csTyRACyEmWj0QdUrm5aqNJGHSSEQSUAvNW0ojX0dOmK9dZduvkfeXA== +"@babel/helper-annotate-as-pure@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.22.5.tgz#e7f06737b197d580a01edf75d97e2c8be99d3882" + integrity sha512-LvBTxu8bQSQkcyKOU+a1btnNFQ1dMAd0R6PyW3arXes06F6QLWLIrd681bxRPIXlrMGR3XYnW9JyML7dP3qgxg== dependencies: - "@babel/types" "^7.18.6" + "@babel/types" "^7.22.5" -"@babel/helper-builder-binary-assignment-operator-visitor@^7.18.6": - version "7.18.9" - resolved "https://registry.yarnpkg.com/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.18.9.tgz#acd4edfd7a566d1d51ea975dff38fd52906981bb" - integrity sha512-yFQ0YCHoIqarl8BCRwBL8ulYUaZpz3bNsA7oFepAzee+8/+ImtADXNOmO5vJvsPff3qi+hvpkY/NYBTrBQgdNw== +"@babel/helper-builder-binary-assignment-operator-visitor@^7.22.15": + version "7.22.15" + resolved "https://registry.yarnpkg.com/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.22.15.tgz#5426b109cf3ad47b91120f8328d8ab1be8b0b956" + integrity sha512-QkBXwGgaoC2GtGZRoma6kv7Szfv06khvhFav67ZExau2RaXzy8MpHSMO2PNoP2XtmQphJQRHFfg77Bq731Yizw== dependencies: - "@babel/helper-explode-assignable-expression" "^7.18.6" - "@babel/types" "^7.18.9" + "@babel/types" "^7.22.15" -"@babel/helper-compilation-targets@^7.17.7", "@babel/helper-compilation-targets@^7.18.9", "@babel/helper-compilation-targets@^7.20.0", "@babel/helper-compilation-targets@^7.20.7": - version "7.20.7" - resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.20.7.tgz#a6cd33e93629f5eb473b021aac05df62c4cd09bb" - integrity sha512-4tGORmfQcrc+bvrjb5y3dG9Mx1IOZjsHqQVUz7XCNHO+iTmqxWnVg3KRygjGmpRLJGdQSKuvFinbIb0CnZwHAQ== +"@babel/helper-compilation-targets@^7.22.15", "@babel/helper-compilation-targets@^7.22.6", "@babel/helper-compilation-targets@^7.23.6": + version "7.23.6" + resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.23.6.tgz#4d79069b16cbcf1461289eccfbbd81501ae39991" + integrity sha512-9JB548GZoQVmzrFgp8o7KxdgkTGm6xs9DW0o/Pim72UDjzr5ObUQ6ZzYPqA+g9OTS2bBQoctLJrky0RDCAWRgQ== dependencies: - "@babel/compat-data" "^7.20.5" - "@babel/helper-validator-option" "^7.18.6" - browserslist "^4.21.3" + "@babel/compat-data" "^7.23.5" + "@babel/helper-validator-option" "^7.23.5" + browserslist "^4.22.2" lru-cache "^5.1.1" - semver "^6.3.0" - -"@babel/helper-create-class-features-plugin@^7.18.6", "@babel/helper-create-class-features-plugin@^7.21.0": - version "7.21.0" - resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.21.0.tgz#64f49ecb0020532f19b1d014b03bccaa1ab85fb9" - integrity sha512-Q8wNiMIdwsv5la5SPxNYzzkPnjgC0Sy0i7jLkVOCdllu/xcVNkr3TeZzbHBJrj+XXRqzX5uCyCoV9eu6xUG7KQ== - dependencies: - "@babel/helper-annotate-as-pure" "^7.18.6" - "@babel/helper-environment-visitor" "^7.18.9" - "@babel/helper-function-name" "^7.21.0" - "@babel/helper-member-expression-to-functions" "^7.21.0" - "@babel/helper-optimise-call-expression" "^7.18.6" - "@babel/helper-replace-supers" "^7.20.7" - "@babel/helper-skip-transparent-expression-wrappers" "^7.20.0" - "@babel/helper-split-export-declaration" "^7.18.6" - -"@babel/helper-create-regexp-features-plugin@^7.18.6", "@babel/helper-create-regexp-features-plugin@^7.20.5": - version "7.21.0" - resolved "https://registry.yarnpkg.com/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.21.0.tgz#53ff78472e5ce10a52664272a239787107603ebb" - integrity sha512-N+LaFW/auRSWdx7SHD/HiARwXQju1vXTW4fKr4u5SgBUTm51OKEjKgj+cs00ggW3kEvNqwErnlwuq7Y3xBe4eg== - dependencies: - "@babel/helper-annotate-as-pure" "^7.18.6" + semver "^6.3.1" + +"@babel/helper-create-class-features-plugin@^7.22.15", "@babel/helper-create-class-features-plugin@^7.23.6": + version "7.23.7" + resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.23.7.tgz#b2e6826e0e20d337143655198b79d58fdc9bd43d" + integrity sha512-xCoqR/8+BoNnXOY7RVSgv6X+o7pmT5q1d+gGcRlXYkI+9B31glE4jeejhKVpA04O1AtzOt7OSQ6VYKP5FcRl9g== + dependencies: + "@babel/helper-annotate-as-pure" "^7.22.5" + "@babel/helper-environment-visitor" "^7.22.20" + "@babel/helper-function-name" "^7.23.0" + "@babel/helper-member-expression-to-functions" "^7.23.0" + "@babel/helper-optimise-call-expression" "^7.22.5" + "@babel/helper-replace-supers" "^7.22.20" + "@babel/helper-skip-transparent-expression-wrappers" "^7.22.5" + "@babel/helper-split-export-declaration" "^7.22.6" + semver "^6.3.1" + +"@babel/helper-create-regexp-features-plugin@^7.18.6", "@babel/helper-create-regexp-features-plugin@^7.22.15", "@babel/helper-create-regexp-features-plugin@^7.22.5": + version "7.22.15" + resolved "https://registry.yarnpkg.com/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.22.15.tgz#5ee90093914ea09639b01c711db0d6775e558be1" + integrity sha512-29FkPLFjn4TPEa3RE7GpW+qbE8tlsu3jntNYNfcGsc49LphF1PQIiD+vMZ1z1xVOKt+93khA9tc2JBs3kBjA7w== + dependencies: + "@babel/helper-annotate-as-pure" "^7.22.5" regexpu-core "^5.3.1" + semver "^6.3.1" -"@babel/helper-define-polyfill-provider@^0.3.3": - version "0.3.3" - resolved "https://registry.yarnpkg.com/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.3.3.tgz#8612e55be5d51f0cd1f36b4a5a83924e89884b7a" - integrity sha512-z5aQKU4IzbqCC1XH0nAqfsFLMVSo22SBKUc0BxGrLkolTdPTructy0ToNnlO2zA4j9Q/7pjMZf0DSY+DSTYzww== +"@babel/helper-define-polyfill-provider@^0.4.4": + version "0.4.4" + resolved "https://registry.yarnpkg.com/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.4.4.tgz#64df615451cb30e94b59a9696022cffac9a10088" + integrity sha512-QcJMILQCu2jm5TFPGA3lCpJJTeEP+mqeXooG/NZbg/h5FTFi6V0+99ahlRsW8/kRLyb24LZVCCiclDedhLKcBA== + dependencies: + "@babel/helper-compilation-targets" "^7.22.6" + "@babel/helper-plugin-utils" "^7.22.5" + debug "^4.1.1" + lodash.debounce "^4.0.8" + resolve "^1.14.2" + +"@babel/helper-define-polyfill-provider@^0.5.0": + version "0.5.0" + resolved "https://registry.yarnpkg.com/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.5.0.tgz#465805b7361f461e86c680f1de21eaf88c25901b" + integrity sha512-NovQquuQLAQ5HuyjCz7WQP9MjRj7dx++yspwiyUiGl9ZyadHRSql1HZh5ogRd8W8w6YM6EQ/NTB8rgjLt5W65Q== dependencies: - "@babel/helper-compilation-targets" "^7.17.7" - "@babel/helper-plugin-utils" "^7.16.7" + "@babel/helper-compilation-targets" "^7.22.6" + "@babel/helper-plugin-utils" "^7.22.5" debug "^4.1.1" lodash.debounce "^4.0.8" resolve "^1.14.2" - semver "^6.1.2" -"@babel/helper-environment-visitor@^7.18.9": - version "7.18.9" - resolved "https://registry.yarnpkg.com/@babel/helper-environment-visitor/-/helper-environment-visitor-7.18.9.tgz#0c0cee9b35d2ca190478756865bb3528422f51be" - integrity sha512-3r/aACDJ3fhQ/EVgFy0hpj8oHyHpQc+LPtJoY9SzTThAsStm4Ptegq92vqKoE3vD706ZVFWITnMnxucw+S9Ipg== +"@babel/helper-environment-visitor@^7.22.20": + version "7.22.20" + resolved "https://registry.yarnpkg.com/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz#96159db61d34a29dba454c959f5ae4a649ba9167" + integrity sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA== -"@babel/helper-explode-assignable-expression@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.18.6.tgz#41f8228ef0a6f1a036b8dfdfec7ce94f9a6bc096" - integrity sha512-eyAYAsQmB80jNfg4baAtLeWAQHfHFiR483rzFK+BhETlGZaQC9bsfrugfXDCbRHLQbIA7U5NxhhOxN7p/dWIcg== +"@babel/helper-function-name@^7.22.5", "@babel/helper-function-name@^7.23.0": + version "7.23.0" + resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.23.0.tgz#1f9a3cdbd5b2698a670c30d2735f9af95ed52759" + integrity sha512-OErEqsrxjZTJciZ4Oo+eoZqeW9UIiOcuYKRJA4ZAgV9myA+pOXhhmpfNCKjEH/auVfEYVFJ6y1Tc4r0eIApqiw== dependencies: - "@babel/types" "^7.18.6" + "@babel/template" "^7.22.15" + "@babel/types" "^7.23.0" -"@babel/helper-function-name@^7.18.9", "@babel/helper-function-name@^7.19.0", "@babel/helper-function-name@^7.21.0": - version "7.21.0" - resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.21.0.tgz#d552829b10ea9f120969304023cd0645fa00b1b4" - integrity sha512-HfK1aMRanKHpxemaY2gqBmL04iAPOPRj7DxtNbiDOrJK+gdwkiNRVpCpUJYbUT+aZyemKN8brqTOxzCaG6ExRg== +"@babel/helper-hoist-variables@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/helper-hoist-variables/-/helper-hoist-variables-7.22.5.tgz#c01a007dac05c085914e8fb652b339db50d823bb" + integrity sha512-wGjk9QZVzvknA6yKIUURb8zY3grXCcOZt+/7Wcy8O2uctxhplmUPkOdlgoNhmdVee2c92JXbf1xpMtVNbfoxRw== dependencies: - "@babel/template" "^7.20.7" - "@babel/types" "^7.21.0" + "@babel/types" "^7.22.5" -"@babel/helper-hoist-variables@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/helper-hoist-variables/-/helper-hoist-variables-7.18.6.tgz#d4d2c8fb4baeaa5c68b99cc8245c56554f926678" - integrity sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q== +"@babel/helper-member-expression-to-functions@^7.22.15", "@babel/helper-member-expression-to-functions@^7.23.0": + version "7.23.0" + resolved "https://registry.yarnpkg.com/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.23.0.tgz#9263e88cc5e41d39ec18c9a3e0eced59a3e7d366" + integrity sha512-6gfrPwh7OuT6gZyJZvd6WbTfrqAo7vm4xCzAXOusKqq/vWdKXphTpj5klHKNmRUU6/QRGlBsyU9mAIPaWHlqJA== dependencies: - "@babel/types" "^7.18.6" + "@babel/types" "^7.23.0" -"@babel/helper-member-expression-to-functions@^7.20.7", "@babel/helper-member-expression-to-functions@^7.21.0": - version "7.21.0" - resolved "https://registry.yarnpkg.com/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.21.0.tgz#319c6a940431a133897148515877d2f3269c3ba5" - integrity sha512-Muu8cdZwNN6mRRNG6lAYErJ5X3bRevgYR2O8wN0yn7jJSnGDu6eG59RfT29JHxGUovyfrh6Pj0XzmR7drNVL3Q== +"@babel/helper-module-imports@^7.22.15": + version "7.22.15" + resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.22.15.tgz#16146307acdc40cc00c3b2c647713076464bdbf0" + integrity sha512-0pYVBnDKZO2fnSPCrgM/6WMc7eS20Fbok+0r88fp+YtWVLZrp4CkafFGIp+W0VKw4a22sgebPT99y+FDNMdP4w== dependencies: - "@babel/types" "^7.21.0" + "@babel/types" "^7.22.15" -"@babel/helper-module-imports@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.18.6.tgz#1e3ebdbbd08aad1437b428c50204db13c5a3ca6e" - integrity sha512-0NFvs3VkuSYbFi1x2Vd6tKrywq+z/cLeYC/RJNFrIX/30Bf5aiGYbtvGXolEktzJH8o5E5KJ3tT+nkxuuZFVlA== - dependencies: - "@babel/types" "^7.18.6" - -"@babel/helper-module-transforms@^7.12.1", "@babel/helper-module-transforms@^7.18.6", "@babel/helper-module-transforms@^7.20.11", "@babel/helper-module-transforms@^7.21.0", "@babel/helper-module-transforms@^7.21.2": - version "7.21.2" - resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.21.2.tgz#160caafa4978ac8c00ac66636cb0fa37b024e2d2" - integrity sha512-79yj2AR4U/Oqq/WOV7Lx6hUjau1Zfo4cI+JLAVYeMV5XIlbOhmjEk5ulbTc9fMpmlojzZHkUUxAiK+UKn+hNQQ== - dependencies: - "@babel/helper-environment-visitor" "^7.18.9" - "@babel/helper-module-imports" "^7.18.6" - "@babel/helper-simple-access" "^7.20.2" - "@babel/helper-split-export-declaration" "^7.18.6" - "@babel/helper-validator-identifier" "^7.19.1" - "@babel/template" "^7.20.7" - "@babel/traverse" "^7.21.2" - "@babel/types" "^7.21.2" - -"@babel/helper-optimise-call-expression@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.18.6.tgz#9369aa943ee7da47edab2cb4e838acf09d290ffe" - integrity sha512-HP59oD9/fEHQkdcbgFCnbmgH5vIQTJbxh2yf+CdM89/glUNnuzr87Q8GIjGEnOktTROemO0Pe0iPAYbqZuOUiA== +"@babel/helper-module-transforms@^7.12.1", "@babel/helper-module-transforms@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.23.3.tgz#d7d12c3c5d30af5b3c0fcab2a6d5217773e2d0f1" + integrity sha512-7bBs4ED9OmswdfDzpz4MpWgSrV7FXlc3zIagvLFjS5H+Mk7Snr21vQ6QwrsoCGMfNC4e4LQPdoULEt4ykz0SRQ== + dependencies: + "@babel/helper-environment-visitor" "^7.22.20" + "@babel/helper-module-imports" "^7.22.15" + "@babel/helper-simple-access" "^7.22.5" + "@babel/helper-split-export-declaration" "^7.22.6" + "@babel/helper-validator-identifier" "^7.22.20" + +"@babel/helper-optimise-call-expression@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.22.5.tgz#f21531a9ccbff644fdd156b4077c16ff0c3f609e" + integrity sha512-HBwaojN0xFRx4yIvpwGqxiV2tUfl7401jlok564NgB9EHS1y6QT17FmKWm4ztqjeVdXLuC4fSvHc5ePpQjoTbw== dependencies: - "@babel/types" "^7.18.6" + "@babel/types" "^7.22.5" "@babel/helper-plugin-utils@7.10.4": version "7.10.4" resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.10.4.tgz#2f75a831269d4f677de49986dff59927533cf375" integrity sha512-O4KCvQA6lLiMU9l2eawBPMf1xPP8xPfB3iEQw150hOVTqj/rfXz0ThTb4HEzqQfs2Bmo5Ay8BzxfzVtBrr9dVg== -"@babel/helper-plugin-utils@^7.0.0", "@babel/helper-plugin-utils@^7.10.4", "@babel/helper-plugin-utils@^7.12.13", "@babel/helper-plugin-utils@^7.14.5", "@babel/helper-plugin-utils@^7.16.7", "@babel/helper-plugin-utils@^7.18.6", "@babel/helper-plugin-utils@^7.18.9", "@babel/helper-plugin-utils@^7.19.0", "@babel/helper-plugin-utils@^7.20.2", "@babel/helper-plugin-utils@^7.8.0", "@babel/helper-plugin-utils@^7.8.3": - version "7.20.2" - resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.20.2.tgz#d1b9000752b18d0877cff85a5c376ce5c3121629" - integrity sha512-8RvlJG2mj4huQ4pZ+rU9lqKi9ZKiRmuvGuM2HlWmkmgOhbs6zEAw6IEiJ5cQqGbDzGZOhwuOQNtZMi/ENLjZoQ== - -"@babel/helper-remap-async-to-generator@^7.18.9": - version "7.18.9" - resolved "https://registry.yarnpkg.com/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.18.9.tgz#997458a0e3357080e54e1d79ec347f8a8cd28519" - integrity sha512-dI7q50YKd8BAv3VEfgg7PS7yD3Rtbi2J1XMXaalXO0W0164hYLnh8zpjRS0mte9MfVp/tltvr/cfdXPvJr1opA== - dependencies: - "@babel/helper-annotate-as-pure" "^7.18.6" - "@babel/helper-environment-visitor" "^7.18.9" - "@babel/helper-wrap-function" "^7.18.9" - "@babel/types" "^7.18.9" - -"@babel/helper-replace-supers@^7.18.6", "@babel/helper-replace-supers@^7.20.7": - version "7.20.7" - resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.20.7.tgz#243ecd2724d2071532b2c8ad2f0f9f083bcae331" - integrity sha512-vujDMtB6LVfNW13jhlCrp48QNslK6JXi7lQG736HVbHz/mbf4Dc7tIRh1Xf5C0rF7BP8iiSxGMCmY6Ci1ven3A== - dependencies: - "@babel/helper-environment-visitor" "^7.18.9" - "@babel/helper-member-expression-to-functions" "^7.20.7" - "@babel/helper-optimise-call-expression" "^7.18.6" - "@babel/template" "^7.20.7" - "@babel/traverse" "^7.20.7" - "@babel/types" "^7.20.7" - -"@babel/helper-simple-access@^7.20.2": - version "7.20.2" - resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.20.2.tgz#0ab452687fe0c2cfb1e2b9e0015de07fc2d62dd9" - integrity sha512-+0woI/WPq59IrqDYbVGfshjT5Dmk/nnbdpcF8SnMhhXObpTq2KNBdLFRFrkVdbDOyUmHBCxzm5FHV1rACIkIbA== - dependencies: - "@babel/types" "^7.20.2" - -"@babel/helper-skip-transparent-expression-wrappers@^7.20.0": - version "7.20.0" - resolved "https://registry.yarnpkg.com/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.20.0.tgz#fbe4c52f60518cab8140d77101f0e63a8a230684" - integrity sha512-5y1JYeNKfvnT8sZcK9DVRtpTbGiomYIHviSP3OQWmDPU3DeH4a1ZlT/N2lyQ5P8egjcRaT/Y9aNqUxK0WsnIIg== - dependencies: - "@babel/types" "^7.20.0" - -"@babel/helper-split-export-declaration@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz#7367949bc75b20c6d5a5d4a97bba2824ae8ef075" - integrity sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA== - dependencies: - "@babel/types" "^7.18.6" - -"@babel/helper-string-parser@^7.19.4": - version "7.19.4" - resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.19.4.tgz#38d3acb654b4701a9b77fb0615a96f775c3a9e63" - integrity sha512-nHtDoQcuqFmwYNYPz3Rah5ph2p8PFeFCsZk9A/48dPc/rGocJ5J3hAAZ7pb76VWX3fZKu+uEr/FhH5jLx7umrw== - -"@babel/helper-validator-identifier@^7.18.6", "@babel/helper-validator-identifier@^7.19.1": - version "7.19.1" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz#7eea834cf32901ffdc1a7ee555e2f9c27e249ca2" - integrity sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w== - -"@babel/helper-validator-option@^7.18.6", "@babel/helper-validator-option@^7.21.0": - version "7.21.0" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.21.0.tgz#8224c7e13ace4bafdc4004da2cf064ef42673180" - integrity sha512-rmL/B8/f0mKS2baE9ZpyTcTavvEuWhTTW8amjzXNvYG4AwBsqTLikfXsEofsJEfKHf+HQVQbFOHy6o+4cnC/fQ== - -"@babel/helper-wrap-function@^7.18.9": - version "7.20.5" - resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.20.5.tgz#75e2d84d499a0ab3b31c33bcfe59d6b8a45f62e3" - integrity sha512-bYMxIWK5mh+TgXGVqAtnu5Yn1un+v8DDZtqyzKRLUzrh70Eal2O3aZ7aPYiMADO4uKlkzOiRiZ6GX5q3qxvW9Q== - dependencies: - "@babel/helper-function-name" "^7.19.0" - "@babel/template" "^7.18.10" - "@babel/traverse" "^7.20.5" - "@babel/types" "^7.20.5" - -"@babel/helpers@^7.12.5", "@babel/helpers@^7.21.0": - version "7.21.0" - resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.21.0.tgz#9dd184fb5599862037917cdc9eecb84577dc4e7e" - integrity sha512-XXve0CBtOW0pd7MRzzmoyuSj0e3SEzj8pgyFxnTT1NJZL38BD1MK7yYrm8yefRPIDvNNe14xR4FdbHwpInD4rA== - dependencies: - "@babel/template" "^7.20.7" - "@babel/traverse" "^7.21.0" - "@babel/types" "^7.21.0" - -"@babel/highlight@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.18.6.tgz#81158601e93e2563795adcbfbdf5d64be3f2ecdf" - integrity sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g== - dependencies: - "@babel/helper-validator-identifier" "^7.18.6" - chalk "^2.0.0" - js-tokens "^4.0.0" - -"@babel/parser@^7.12.7", "@babel/parser@^7.18.8", "@babel/parser@^7.20.7", "@babel/parser@^7.21.0", "@babel/parser@^7.21.2": - version "7.21.2" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.21.2.tgz#dacafadfc6d7654c3051a66d6fe55b6cb2f2a0b3" - integrity sha512-URpaIJQwEkEC2T9Kn+Ai6Xe/02iNaVCuT/PtoRz3GPVJVDpPd7mLo+VddTbhCRU9TXqW5mSrQfXZyi8kDKOVpQ== - -"@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/-/plugin-bugfix-safari-id-destructuring-collision-in-function-expression-7.18.6.tgz#da5b8f9a580acdfbe53494dba45ea389fb09a4d2" - integrity sha512-Dgxsyg54Fx1d4Nge8UnvTrED63vrwOdPmyvPzlNN/boaliRP54pm3pGzZD1SJUwrBA+Cs/xdG8kXX6Mn/RfISQ== - dependencies: - "@babel/helper-plugin-utils" "^7.18.6" +"@babel/helper-plugin-utils@^7.0.0", "@babel/helper-plugin-utils@^7.10.4", "@babel/helper-plugin-utils@^7.12.13", "@babel/helper-plugin-utils@^7.14.5", "@babel/helper-plugin-utils@^7.18.6", "@babel/helper-plugin-utils@^7.22.5", "@babel/helper-plugin-utils@^7.8.0", "@babel/helper-plugin-utils@^7.8.3": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.22.5.tgz#dd7ee3735e8a313b9f7b05a773d892e88e6d7295" + integrity sha512-uLls06UVKgFG9QD4OeFYLEGteMIAa5kpTPcFL28yuCIIzsf6ZyKZMllKVOCZFhiZ5ptnwX4mtKdWCBE/uT4amg== -"@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@^7.18.9": - version "7.20.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/-/plugin-bugfix-v8-spread-parameters-in-optional-chaining-7.20.7.tgz#d9c85589258539a22a901033853101a6198d4ef1" - integrity sha512-sbr9+wNE5aXMBBFBICk01tt7sBf2Oc9ikRFEcem/ZORup9IMUdNhW7/wVLEbbtlWOsEubJet46mHAL2C8+2jKQ== +"@babel/helper-remap-async-to-generator@^7.22.20": + version "7.22.20" + resolved "https://registry.yarnpkg.com/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.22.20.tgz#7b68e1cb4fa964d2996fd063723fb48eca8498e0" + integrity sha512-pBGyV4uBqOns+0UvhsTO8qgl8hO89PmiDYv+/COyp1aeMcmfrfruz+/nCMFiYyFF/Knn0yfrC85ZzNFjembFTw== dependencies: - "@babel/helper-plugin-utils" "^7.20.2" - "@babel/helper-skip-transparent-expression-wrappers" "^7.20.0" - "@babel/plugin-proposal-optional-chaining" "^7.20.7" + "@babel/helper-annotate-as-pure" "^7.22.5" + "@babel/helper-environment-visitor" "^7.22.20" + "@babel/helper-wrap-function" "^7.22.20" -"@babel/plugin-proposal-async-generator-functions@^7.20.1": - version "7.20.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.20.7.tgz#bfb7276d2d573cb67ba379984a2334e262ba5326" - integrity sha512-xMbiLsn/8RK7Wq7VeVytytS2L6qE69bXPB10YCmMdDZbKF4okCqY74pI/jJQ/8U0b/F6NrT2+14b8/P9/3AMGA== +"@babel/helper-replace-supers@^7.22.20": + version "7.22.20" + resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.22.20.tgz#e37d367123ca98fe455a9887734ed2e16eb7a793" + integrity sha512-qsW0In3dbwQUbK8kejJ4R7IHVGwHJlV6lpG6UA7a9hSa2YEiAib+N1T2kr6PEeUT+Fl7najmSOS6SmAwCHK6Tw== dependencies: - "@babel/helper-environment-visitor" "^7.18.9" - "@babel/helper-plugin-utils" "^7.20.2" - "@babel/helper-remap-async-to-generator" "^7.18.9" - "@babel/plugin-syntax-async-generators" "^7.8.4" + "@babel/helper-environment-visitor" "^7.22.20" + "@babel/helper-member-expression-to-functions" "^7.22.15" + "@babel/helper-optimise-call-expression" "^7.22.5" -"@babel/plugin-proposal-class-properties@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.18.6.tgz#b110f59741895f7ec21a6fff696ec46265c446a3" - integrity sha512-cumfXOF0+nzZrrN8Rf0t7M+tF6sZc7vhQwYQck9q1/5w2OExlD+b4v4RpMJFaV1Z7WcDRgO6FqvxqxGlwo+RHQ== +"@babel/helper-simple-access@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.22.5.tgz#4938357dc7d782b80ed6dbb03a0fba3d22b1d5de" + integrity sha512-n0H99E/K+Bika3++WNL17POvo4rKWZ7lZEp1Q+fStVbUi8nxPQEBOlTmCOxW/0JsS56SKKQ+ojAe2pHKJHN35w== dependencies: - "@babel/helper-create-class-features-plugin" "^7.18.6" - "@babel/helper-plugin-utils" "^7.18.6" + "@babel/types" "^7.22.5" -"@babel/plugin-proposal-class-static-block@^7.18.6": - version "7.21.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-static-block/-/plugin-proposal-class-static-block-7.21.0.tgz#77bdd66fb7b605f3a61302d224bdfacf5547977d" - integrity sha512-XP5G9MWNUskFuP30IfFSEFB0Z6HzLIUcjYM4bYOPHXl7eiJ9HFv8tWj6TXTN5QODiEhDZAeI4hLok2iHFFV4hw== +"@babel/helper-skip-transparent-expression-wrappers@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.22.5.tgz#007f15240b5751c537c40e77abb4e89eeaaa8847" + integrity sha512-tK14r66JZKiC43p8Ki33yLBVJKlQDFoA8GYN67lWCDCqoL6EMMSuM9b+Iff2jHaM/RRFYl7K+iiru7hbRqNx8Q== dependencies: - "@babel/helper-create-class-features-plugin" "^7.21.0" - "@babel/helper-plugin-utils" "^7.20.2" - "@babel/plugin-syntax-class-static-block" "^7.14.5" + "@babel/types" "^7.22.5" -"@babel/plugin-proposal-dynamic-import@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.18.6.tgz#72bcf8d408799f547d759298c3c27c7e7faa4d94" - integrity sha512-1auuwmK+Rz13SJj36R+jqFPMJWyKEDd7lLSdOj4oJK0UTgGueSAtkrCvz9ewmgyU/P941Rv2fQwZJN8s6QruXw== - dependencies: - "@babel/helper-plugin-utils" "^7.18.6" - "@babel/plugin-syntax-dynamic-import" "^7.8.3" +"@babel/helper-split-export-declaration@^7.22.6": + version "7.22.6" + resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.6.tgz#322c61b7310c0997fe4c323955667f18fcefb91c" + integrity sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g== + dependencies: + "@babel/types" "^7.22.5" + +"@babel/helper-string-parser@^7.23.4": + version "7.23.4" + resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.23.4.tgz#9478c707febcbbe1ddb38a3d91a2e054ae622d83" + integrity sha512-803gmbQdqwdf4olxrX4AJyFBV/RTr3rSmOj0rKwesmzlfhYNDEs+/iOcznzpNWlJlIlTJC2QfPFcHB6DlzdVLQ== + +"@babel/helper-validator-identifier@^7.22.20": + version "7.22.20" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz#c4ae002c61d2879e724581d96665583dbc1dc0e0" + integrity sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A== + +"@babel/helper-validator-option@^7.22.15", "@babel/helper-validator-option@^7.23.5": + version "7.23.5" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.23.5.tgz#907a3fbd4523426285365d1206c423c4c5520307" + integrity sha512-85ttAOMLsr53VgXkTbkx8oA6YTfT4q7/HzXSLEYmjcSTJPMPQtvq1BD79Byep5xMUYbGRzEpDsjUf3dyp54IKw== + +"@babel/helper-wrap-function@^7.22.20": + version "7.22.20" + resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.22.20.tgz#15352b0b9bfb10fc9c76f79f6342c00e3411a569" + integrity sha512-pms/UwkOpnQe/PDAEdV/d7dVCoBbB+R4FvYoHGZz+4VPcg7RtYy2KP7S2lbuWM6FCSgob5wshfGESbC/hzNXZw== + dependencies: + "@babel/helper-function-name" "^7.22.5" + "@babel/template" "^7.22.15" + "@babel/types" "^7.22.19" + +"@babel/helpers@^7.12.5", "@babel/helpers@^7.23.7": + version "7.23.8" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.23.8.tgz#fc6b2d65b16847fd50adddbd4232c76378959e34" + integrity sha512-KDqYz4PiOWvDFrdHLPhKtCThtIcKVy6avWD2oG4GEvyQ+XDZwHD4YQd+H2vNMnq2rkdxsDkU82T+Vk8U/WXHRQ== + dependencies: + "@babel/template" "^7.22.15" + "@babel/traverse" "^7.23.7" + "@babel/types" "^7.23.6" + +"@babel/highlight@^7.23.4": + version "7.23.4" + resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.23.4.tgz#edaadf4d8232e1a961432db785091207ead0621b" + integrity sha512-acGdbYSfp2WheJoJm/EBBBLh/ID8KDc64ISZ9DYtBmC8/Q204PZJLHyzeB5qMzJ5trcOkybd78M4x2KWsUq++A== + dependencies: + "@babel/helper-validator-identifier" "^7.22.20" + chalk "^2.4.2" + js-tokens "^4.0.0" -"@babel/plugin-proposal-export-namespace-from@^7.18.9": - version "7.18.9" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-export-namespace-from/-/plugin-proposal-export-namespace-from-7.18.9.tgz#5f7313ab348cdb19d590145f9247540e94761203" - integrity sha512-k1NtHyOMvlDDFeb9G5PhUXuGj8m/wiwojgQVEhJ/fsVsMCpLyOP4h0uGEjYJKrRI+EVPlb5Jk+Gt9P97lOGwtA== - dependencies: - "@babel/helper-plugin-utils" "^7.18.9" - "@babel/plugin-syntax-export-namespace-from" "^7.8.3" +"@babel/parser@^7.12.7", "@babel/parser@^7.18.8", "@babel/parser@^7.22.15", "@babel/parser@^7.23.6": + version "7.23.6" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.23.6.tgz#ba1c9e512bda72a47e285ae42aff9d2a635a9e3b" + integrity sha512-Z2uID7YJ7oNvAI20O9X0bblw7Qqs8Q2hFy0R9tAfnfLkp5MW0UH9eUvnDSnFwKZ0AvgS1ucqR4KzvVHgnke1VQ== -"@babel/plugin-proposal-json-strings@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.18.6.tgz#7e8788c1811c393aff762817e7dbf1ebd0c05f0b" - integrity sha512-lr1peyn9kOdbYc0xr0OdHTZ5FMqS6Di+H0Fz2I/JwMzGmzJETNeOFq2pBySw6X/KFL5EWDjlJuMsUGRFb8fQgQ== +"@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/-/plugin-bugfix-safari-id-destructuring-collision-in-function-expression-7.23.3.tgz#5cd1c87ba9380d0afb78469292c954fee5d2411a" + integrity sha512-iRkKcCqb7iGnq9+3G6rZ+Ciz5VywC4XNRHe57lKM+jOeYAoR0lVqdeeDRfh0tQcTfw/+vBhHn926FmQhLtlFLQ== dependencies: - "@babel/helper-plugin-utils" "^7.18.6" - "@babel/plugin-syntax-json-strings" "^7.8.3" + "@babel/helper-plugin-utils" "^7.22.5" -"@babel/plugin-proposal-logical-assignment-operators@^7.18.9": - version "7.20.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-logical-assignment-operators/-/plugin-proposal-logical-assignment-operators-7.20.7.tgz#dfbcaa8f7b4d37b51e8bfb46d94a5aea2bb89d83" - integrity sha512-y7C7cZgpMIjWlKE5T7eJwp+tnRYM89HmRvWM5EQuB5BoHEONjmQ8lSNmBUwOyy/GFRsohJED51YBF79hE1djug== +"@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/-/plugin-bugfix-v8-spread-parameters-in-optional-chaining-7.23.3.tgz#f6652bb16b94f8f9c20c50941e16e9756898dc5d" + integrity sha512-WwlxbfMNdVEpQjZmK5mhm7oSwD3dS6eU+Iwsi4Knl9wAletWem7kaRsGOG+8UEbRyqxY4SS5zvtfXwX+jMxUwQ== dependencies: - "@babel/helper-plugin-utils" "^7.20.2" - "@babel/plugin-syntax-logical-assignment-operators" "^7.10.4" + "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-skip-transparent-expression-wrappers" "^7.22.5" + "@babel/plugin-transform-optional-chaining" "^7.23.3" -"@babel/plugin-proposal-nullish-coalescing-operator@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.18.6.tgz#fdd940a99a740e577d6c753ab6fbb43fdb9467e1" - integrity sha512-wQxQzxYeJqHcfppzBDnm1yAY0jSRkUXR2z8RePZYrKwMKgMlE8+Z6LUno+bd6LvbGh8Gltvy74+9pIYkr+XkKA== +"@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly@^7.23.7": + version "7.23.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly/-/plugin-bugfix-v8-static-class-fields-redefine-readonly-7.23.7.tgz#516462a95d10a9618f197d39ad291a9b47ae1d7b" + integrity sha512-LlRT7HgaifEpQA1ZgLVOIJZZFVPWN5iReq/7/JixwBtwcoeVGDBD53ZV28rrsLYOZs1Y/EHhA8N/Z6aazHR8cw== dependencies: - "@babel/helper-plugin-utils" "^7.18.6" - "@babel/plugin-syntax-nullish-coalescing-operator" "^7.8.3" - -"@babel/plugin-proposal-numeric-separator@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-numeric-separator/-/plugin-proposal-numeric-separator-7.18.6.tgz#899b14fbafe87f053d2c5ff05b36029c62e13c75" - integrity sha512-ozlZFogPqoLm8WBr5Z8UckIoE4YQ5KESVcNudyXOR8uqIkliTEgJ3RoketfG6pmzLdeZF0H/wjE9/cCEitBl7Q== - dependencies: - "@babel/helper-plugin-utils" "^7.18.6" - "@babel/plugin-syntax-numeric-separator" "^7.10.4" + "@babel/helper-environment-visitor" "^7.22.20" + "@babel/helper-plugin-utils" "^7.22.5" "@babel/plugin-proposal-object-rest-spread@7.12.1": version "7.12.1" @@ -526,59 +464,10 @@ "@babel/plugin-syntax-object-rest-spread" "^7.8.0" "@babel/plugin-transform-parameters" "^7.12.1" -"@babel/plugin-proposal-object-rest-spread@^7.20.2": - version "7.20.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.20.7.tgz#aa662940ef425779c75534a5c41e9d936edc390a" - integrity sha512-d2S98yCiLxDVmBmE8UjGcfPvNEUbA1U5q5WxaWFUGRzJSVAZqm5W6MbPct0jxnegUZ0niLeNX+IOzEs7wYg9Dg== - dependencies: - "@babel/compat-data" "^7.20.5" - "@babel/helper-compilation-targets" "^7.20.7" - "@babel/helper-plugin-utils" "^7.20.2" - "@babel/plugin-syntax-object-rest-spread" "^7.8.3" - "@babel/plugin-transform-parameters" "^7.20.7" - -"@babel/plugin-proposal-optional-catch-binding@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.18.6.tgz#f9400d0e6a3ea93ba9ef70b09e72dd6da638a2cb" - integrity sha512-Q40HEhs9DJQyaZfUjjn6vE8Cv4GmMHCYuMGIWUnlxH6400VGxOuwWsPt4FxXxJkC/5eOzgn0z21M9gMT4MOhbw== - dependencies: - "@babel/helper-plugin-utils" "^7.18.6" - "@babel/plugin-syntax-optional-catch-binding" "^7.8.3" - -"@babel/plugin-proposal-optional-chaining@^7.18.9", "@babel/plugin-proposal-optional-chaining@^7.20.7": - version "7.21.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.21.0.tgz#886f5c8978deb7d30f678b2e24346b287234d3ea" - integrity sha512-p4zeefM72gpmEe2fkUr/OnOXpWEf8nAgk7ZYVqqfFiyIG7oFfVZcCrU64hWn5xp4tQ9LkV4bTIa5rD0KANpKNA== - dependencies: - "@babel/helper-plugin-utils" "^7.20.2" - "@babel/helper-skip-transparent-expression-wrappers" "^7.20.0" - "@babel/plugin-syntax-optional-chaining" "^7.8.3" - -"@babel/plugin-proposal-private-methods@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-private-methods/-/plugin-proposal-private-methods-7.18.6.tgz#5209de7d213457548a98436fa2882f52f4be6bea" - integrity sha512-nutsvktDItsNn4rpGItSNV2sz1XwS+nfU0Rg8aCx3W3NOKVzdMjJRu0O5OkgDp3ZGICSTbgRpxZoWsxoKRvbeA== - dependencies: - "@babel/helper-create-class-features-plugin" "^7.18.6" - "@babel/helper-plugin-utils" "^7.18.6" - -"@babel/plugin-proposal-private-property-in-object@^7.18.6": - version "7.21.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.0.tgz#19496bd9883dd83c23c7d7fc45dcd9ad02dfa1dc" - integrity sha512-ha4zfehbJjc5MmXBlHec1igel5TJXXLDDRbuJ4+XT2TJcyD9/V1919BA8gMvsdHcNMBy4WBUBiRb3nw/EQUtBw== - dependencies: - "@babel/helper-annotate-as-pure" "^7.18.6" - "@babel/helper-create-class-features-plugin" "^7.21.0" - "@babel/helper-plugin-utils" "^7.20.2" - "@babel/plugin-syntax-private-property-in-object" "^7.14.5" - -"@babel/plugin-proposal-unicode-property-regex@^7.18.6", "@babel/plugin-proposal-unicode-property-regex@^7.4.4": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.18.6.tgz#af613d2cd5e643643b65cded64207b15c85cb78e" - integrity sha512-2BShG/d5yoZyXZfVePH91urL5wTG6ASZU9M4o03lKK8u8UW1y08OMttBSOADTcJrnPMpvDXRG3G8fyLh4ovs8w== - dependencies: - "@babel/helper-create-regexp-features-plugin" "^7.18.6" - "@babel/helper-plugin-utils" "^7.18.6" +"@babel/plugin-proposal-private-property-in-object@7.21.0-placeholder-for-preset-env.2": + version "7.21.0-placeholder-for-preset-env.2" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.0-placeholder-for-preset-env.2.tgz#7844f9289546efa9febac2de4cfe358a050bd703" + integrity sha512-SOSkfJDddaM7mak6cPEpswyTRnuRltl429hMraQEglW+OkovnCzsiszTmsrlY//qLFjCpQDFRvjdm2wA5pPm9w== "@babel/plugin-syntax-async-generators@^7.8.4": version "7.8.4" @@ -615,12 +504,26 @@ dependencies: "@babel/helper-plugin-utils" "^7.8.3" -"@babel/plugin-syntax-import-assertions@^7.20.0": - version "7.20.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-import-assertions/-/plugin-syntax-import-assertions-7.20.0.tgz#bb50e0d4bea0957235390641209394e87bdb9cc4" - integrity sha512-IUh1vakzNoWalR8ch/areW7qFopR2AEw03JlG7BbrDqmQ4X3q9uuipQwSGrUn7oGiemKjtSLDhNtQHzMHr1JdQ== +"@babel/plugin-syntax-import-assertions@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-import-assertions/-/plugin-syntax-import-assertions-7.23.3.tgz#9c05a7f592982aff1a2768260ad84bcd3f0c77fc" + integrity sha512-lPgDSU+SJLK3xmFDTV2ZRQAiM7UuUjGidwBywFavObCiZc1BeAAcMtHJKUya92hPHO+at63JJPLygilZard8jw== + dependencies: + "@babel/helper-plugin-utils" "^7.22.5" + +"@babel/plugin-syntax-import-attributes@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-import-attributes/-/plugin-syntax-import-attributes-7.23.3.tgz#992aee922cf04512461d7dae3ff6951b90a2dc06" + integrity sha512-pawnE0P9g10xgoP7yKr6CK63K2FMsTE+FZidZO/1PwRdzmAPVs+HS1mAURUsgaoxammTJvULUdIkEK0gOcU2tA== + dependencies: + "@babel/helper-plugin-utils" "^7.22.5" + +"@babel/plugin-syntax-import-meta@^7.10.4": + version "7.10.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-import-meta/-/plugin-syntax-import-meta-7.10.4.tgz#ee601348c370fa334d2207be158777496521fd51" + integrity sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g== dependencies: - "@babel/helper-plugin-utils" "^7.19.0" + "@babel/helper-plugin-utils" "^7.10.4" "@babel/plugin-syntax-json-strings@^7.8.3": version "7.8.3" @@ -636,12 +539,12 @@ dependencies: "@babel/helper-plugin-utils" "^7.10.4" -"@babel/plugin-syntax-jsx@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.18.6.tgz#a8feef63b010150abd97f1649ec296e849943ca0" - integrity sha512-6mmljtAedFGTWu2p/8WIORGwy+61PLgOMPOdazc7YoJ9ZCWUyFy3A6CpPkRKLKD1ToAesxX8KGEViAiLo9N+7Q== +"@babel/plugin-syntax-jsx@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.23.3.tgz#8f2e4f8a9b5f9aa16067e142c1ac9cd9f810f473" + integrity sha512-EB2MELswq55OHUoRZLGg/zC7QWUKfNLpE57m/S2yr1uEneIgsTgrSzXP3NXEsMkVn76OlaVVnzN+ugObuYGwhg== dependencies: - "@babel/helper-plugin-utils" "^7.18.6" + "@babel/helper-plugin-utils" "^7.22.5" "@babel/plugin-syntax-logical-assignment-operators@^7.10.4": version "7.10.4" @@ -699,357 +602,492 @@ dependencies: "@babel/helper-plugin-utils" "^7.14.5" -"@babel/plugin-syntax-typescript@^7.20.0": - version "7.20.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.20.0.tgz#4e9a0cfc769c85689b77a2e642d24e9f697fc8c7" - integrity sha512-rd9TkG+u1CExzS4SM1BlMEhMXwFLKVjOAFFCDx9PbX5ycJWDoWMcwdJH9RhkPu1dOgn5TrxLot/Gx6lWFuAUNQ== +"@babel/plugin-syntax-typescript@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.23.3.tgz#24f460c85dbbc983cd2b9c4994178bcc01df958f" + integrity sha512-9EiNjVJOMwCO+43TqoTrgQ8jMwcAd0sWyXi9RPfIsLTj4R2MADDDQXELhffaUx/uJv2AYcxBgPwH6j4TIA4ytQ== dependencies: - "@babel/helper-plugin-utils" "^7.19.0" + "@babel/helper-plugin-utils" "^7.22.5" -"@babel/plugin-transform-arrow-functions@^7.18.6": - version "7.20.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.20.7.tgz#bea332b0e8b2dab3dafe55a163d8227531ab0551" - integrity sha512-3poA5E7dzDomxj9WXWwuD6A5F3kc7VXwIJO+E+J8qtDtS+pXPAhrgEyh+9GBwBgPq1Z+bB+/JD60lp5jsN7JPQ== +"@babel/plugin-syntax-unicode-sets-regex@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-unicode-sets-regex/-/plugin-syntax-unicode-sets-regex-7.18.6.tgz#d49a3b3e6b52e5be6740022317580234a6a47357" + integrity sha512-727YkEAPwSIQTv5im8QHz3upqp92JTWhidIC81Tdx4VJYIte/VndKf1qKrfnnhPLiPghStWfvC/iFaMCQu7Nqg== dependencies: - "@babel/helper-plugin-utils" "^7.20.2" + "@babel/helper-create-regexp-features-plugin" "^7.18.6" + "@babel/helper-plugin-utils" "^7.18.6" -"@babel/plugin-transform-async-to-generator@^7.18.6": - version "7.20.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.20.7.tgz#dfee18623c8cb31deb796aa3ca84dda9cea94354" - integrity sha512-Uo5gwHPT9vgnSXQxqGtpdufUiWp96gk7yiP4Mp5bm1QMkEmLXBO7PAGYbKoJ6DhAwiNkcHFBol/x5zZZkL/t0Q== +"@babel/plugin-transform-arrow-functions@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.23.3.tgz#94c6dcfd731af90f27a79509f9ab7fb2120fc38b" + integrity sha512-NzQcQrzaQPkaEwoTm4Mhyl8jI1huEL/WWIEvudjTCMJ9aBZNpsJbMASx7EQECtQQPS/DcnFpo0FIh3LvEO9cxQ== dependencies: - "@babel/helper-module-imports" "^7.18.6" - "@babel/helper-plugin-utils" "^7.20.2" - "@babel/helper-remap-async-to-generator" "^7.18.9" + "@babel/helper-plugin-utils" "^7.22.5" -"@babel/plugin-transform-block-scoped-functions@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.18.6.tgz#9187bf4ba302635b9d70d986ad70f038726216a8" - integrity sha512-ExUcOqpPWnliRcPqves5HJcJOvHvIIWfuS4sroBUenPuMdmW+SMHDakmtS7qOo13sVppmUijqeTv7qqGsvURpQ== +"@babel/plugin-transform-async-generator-functions@^7.23.7": + version "7.23.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-async-generator-functions/-/plugin-transform-async-generator-functions-7.23.7.tgz#3aa0b4f2fa3788b5226ef9346cf6d16ec61f99cd" + integrity sha512-PdxEpL71bJp1byMG0va5gwQcXHxuEYC/BgI/e88mGTtohbZN28O5Yit0Plkkm/dBzCF/BxmbNcses1RH1T+urA== dependencies: - "@babel/helper-plugin-utils" "^7.18.6" + "@babel/helper-environment-visitor" "^7.22.20" + "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-remap-async-to-generator" "^7.22.20" + "@babel/plugin-syntax-async-generators" "^7.8.4" + +"@babel/plugin-transform-async-to-generator@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.23.3.tgz#d1f513c7a8a506d43f47df2bf25f9254b0b051fa" + integrity sha512-A7LFsKi4U4fomjqXJlZg/u0ft/n8/7n7lpffUP/ZULx/DtV9SGlNKZolHH6PE8Xl1ngCc0M11OaeZptXVkfKSw== + dependencies: + "@babel/helper-module-imports" "^7.22.15" + "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-remap-async-to-generator" "^7.22.20" + +"@babel/plugin-transform-block-scoped-functions@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.23.3.tgz#fe1177d715fb569663095e04f3598525d98e8c77" + integrity sha512-vI+0sIaPIO6CNuM9Kk5VmXcMVRiOpDh7w2zZt9GXzmE/9KD70CUEVhvPR/etAeNK/FAEkhxQtXOzVF3EuRL41A== + dependencies: + "@babel/helper-plugin-utils" "^7.22.5" + +"@babel/plugin-transform-block-scoping@^7.23.4": + version "7.23.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.23.4.tgz#b2d38589531c6c80fbe25e6b58e763622d2d3cf5" + integrity sha512-0QqbP6B6HOh7/8iNR4CQU2Th/bbRtBp4KS9vcaZd1fZ0wSh5Fyssg0UCIHwxh+ka+pNDREbVLQnHCMHKZfPwfw== + dependencies: + "@babel/helper-plugin-utils" "^7.22.5" -"@babel/plugin-transform-block-scoping@^7.20.2": - version "7.21.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.21.0.tgz#e737b91037e5186ee16b76e7ae093358a5634f02" - integrity sha512-Mdrbunoh9SxwFZapeHVrwFmri16+oYotcZysSzhNIVDwIAb1UV+kvnxULSYq9J3/q5MDG+4X6w8QVgD1zhBXNQ== - dependencies: - "@babel/helper-plugin-utils" "^7.20.2" - -"@babel/plugin-transform-classes@^7.20.2": - version "7.21.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-classes/-/plugin-transform-classes-7.21.0.tgz#f469d0b07a4c5a7dbb21afad9e27e57b47031665" - integrity sha512-RZhbYTCEUAe6ntPehC4hlslPWosNHDox+vAs4On/mCLRLfoDVHf6hVEd7kuxr1RnHwJmxFfUM3cZiZRmPxJPXQ== - dependencies: - "@babel/helper-annotate-as-pure" "^7.18.6" - "@babel/helper-compilation-targets" "^7.20.7" - "@babel/helper-environment-visitor" "^7.18.9" - "@babel/helper-function-name" "^7.21.0" - "@babel/helper-optimise-call-expression" "^7.18.6" - "@babel/helper-plugin-utils" "^7.20.2" - "@babel/helper-replace-supers" "^7.20.7" - "@babel/helper-split-export-declaration" "^7.18.6" +"@babel/plugin-transform-class-properties@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-class-properties/-/plugin-transform-class-properties-7.23.3.tgz#35c377db11ca92a785a718b6aa4e3ed1eb65dc48" + integrity sha512-uM+AN8yCIjDPccsKGlw271xjJtGii+xQIF/uMPS8H15L12jZTsLfF4o5vNO7d/oUguOyfdikHGc/yi9ge4SGIg== + dependencies: + "@babel/helper-create-class-features-plugin" "^7.22.15" + "@babel/helper-plugin-utils" "^7.22.5" + +"@babel/plugin-transform-class-static-block@^7.23.4": + version "7.23.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-class-static-block/-/plugin-transform-class-static-block-7.23.4.tgz#2a202c8787a8964dd11dfcedf994d36bfc844ab5" + integrity sha512-nsWu/1M+ggti1SOALj3hfx5FXzAY06fwPJsUZD4/A5e1bWi46VUIWtD+kOX6/IdhXGsXBWllLFDSnqSCdUNydQ== + dependencies: + "@babel/helper-create-class-features-plugin" "^7.22.15" + "@babel/helper-plugin-utils" "^7.22.5" + "@babel/plugin-syntax-class-static-block" "^7.14.5" + +"@babel/plugin-transform-classes@^7.23.8": + version "7.23.8" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-classes/-/plugin-transform-classes-7.23.8.tgz#d08ae096c240347badd68cdf1b6d1624a6435d92" + integrity sha512-yAYslGsY1bX6Knmg46RjiCiNSwJKv2IUC8qOdYKqMMr0491SXFhcHqOdRDeCRohOOIzwN/90C6mQ9qAKgrP7dg== + dependencies: + "@babel/helper-annotate-as-pure" "^7.22.5" + "@babel/helper-compilation-targets" "^7.23.6" + "@babel/helper-environment-visitor" "^7.22.20" + "@babel/helper-function-name" "^7.23.0" + "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-replace-supers" "^7.22.20" + "@babel/helper-split-export-declaration" "^7.22.6" globals "^11.1.0" -"@babel/plugin-transform-computed-properties@^7.18.9": - version "7.20.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.20.7.tgz#704cc2fd155d1c996551db8276d55b9d46e4d0aa" - integrity sha512-Lz7MvBK6DTjElHAmfu6bfANzKcxpyNPeYBGEafyA6E5HtRpjpZwU+u7Qrgz/2OR0z+5TvKYbPdphfSaAcZBrYQ== +"@babel/plugin-transform-computed-properties@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.23.3.tgz#652e69561fcc9d2b50ba4f7ac7f60dcf65e86474" + integrity sha512-dTj83UVTLw/+nbiHqQSFdwO9CbTtwq1DsDqm3CUEtDrZNET5rT5E6bIdTlOftDTDLMYxvxHNEYO4B9SLl8SLZw== dependencies: - "@babel/helper-plugin-utils" "^7.20.2" - "@babel/template" "^7.20.7" + "@babel/helper-plugin-utils" "^7.22.5" + "@babel/template" "^7.22.15" -"@babel/plugin-transform-destructuring@^7.20.2": - version "7.20.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.20.7.tgz#8bda578f71620c7de7c93af590154ba331415454" - integrity sha512-Xwg403sRrZb81IVB79ZPqNQME23yhugYVqgTxAhT99h485F4f+GMELFhhOsscDUB7HCswepKeCKLn/GZvUKoBA== +"@babel/plugin-transform-destructuring@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.23.3.tgz#8c9ee68228b12ae3dff986e56ed1ba4f3c446311" + integrity sha512-n225npDqjDIr967cMScVKHXJs7rout1q+tt50inyBCPkyZ8KxeI6d+GIbSBTT/w/9WdlWDOej3V9HE5Lgk57gw== dependencies: - "@babel/helper-plugin-utils" "^7.20.2" + "@babel/helper-plugin-utils" "^7.22.5" -"@babel/plugin-transform-dotall-regex@^7.18.6", "@babel/plugin-transform-dotall-regex@^7.4.4": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.18.6.tgz#b286b3e7aae6c7b861e45bed0a2fafd6b1a4fef8" - integrity sha512-6S3jpun1eEbAxq7TdjLotAsl4WpQI9DxfkycRcKrjhQYzU87qpXdknpBg/e+TdcMehqGnLFi7tnFUBR02Vq6wg== +"@babel/plugin-transform-dotall-regex@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.23.3.tgz#3f7af6054882ede89c378d0cf889b854a993da50" + integrity sha512-vgnFYDHAKzFaTVp+mneDsIEbnJ2Np/9ng9iviHw3P/KVcgONxpNULEW/51Z/BaFojG2GI2GwwXck5uV1+1NOYQ== dependencies: - "@babel/helper-create-regexp-features-plugin" "^7.18.6" - "@babel/helper-plugin-utils" "^7.18.6" + "@babel/helper-create-regexp-features-plugin" "^7.22.15" + "@babel/helper-plugin-utils" "^7.22.5" -"@babel/plugin-transform-duplicate-keys@^7.18.9": - version "7.18.9" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.18.9.tgz#687f15ee3cdad6d85191eb2a372c4528eaa0ae0e" - integrity sha512-d2bmXCtZXYc59/0SanQKbiWINadaJXqtvIQIzd4+hNwkWBgyCd5F/2t1kXoUdvPMrxzPvhK6EMQRROxsue+mfw== +"@babel/plugin-transform-duplicate-keys@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.23.3.tgz#664706ca0a5dfe8d066537f99032fc1dc8b720ce" + integrity sha512-RrqQ+BQmU3Oyav3J+7/myfvRCq7Tbz+kKLLshUmMwNlDHExbGL7ARhajvoBJEvc+fCguPPu887N+3RRXBVKZUA== dependencies: - "@babel/helper-plugin-utils" "^7.18.9" + "@babel/helper-plugin-utils" "^7.22.5" -"@babel/plugin-transform-exponentiation-operator@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.18.6.tgz#421c705f4521888c65e91fdd1af951bfefd4dacd" - integrity sha512-wzEtc0+2c88FVR34aQmiz56dxEkxr2g8DQb/KfaFa1JYXOFVsbhvAonFN6PwVWj++fKmku8NP80plJ5Et4wqHw== +"@babel/plugin-transform-dynamic-import@^7.23.4": + version "7.23.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-dynamic-import/-/plugin-transform-dynamic-import-7.23.4.tgz#c7629e7254011ac3630d47d7f34ddd40ca535143" + integrity sha512-V6jIbLhdJK86MaLh4Jpghi8ho5fGzt3imHOBu/x0jlBaPYqDoWz4RDXjmMOfnh+JWNaQleEAByZLV0QzBT4YQQ== dependencies: - "@babel/helper-builder-binary-assignment-operator-visitor" "^7.18.6" - "@babel/helper-plugin-utils" "^7.18.6" + "@babel/helper-plugin-utils" "^7.22.5" + "@babel/plugin-syntax-dynamic-import" "^7.8.3" -"@babel/plugin-transform-for-of@^7.18.8": - version "7.21.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.21.0.tgz#964108c9988de1a60b4be2354a7d7e245f36e86e" - integrity sha512-LlUYlydgDkKpIY7mcBWvyPPmMcOphEyYA27Ef4xpbh1IiDNLr0kZsos2nf92vz3IccvJI25QUwp86Eo5s6HmBQ== +"@babel/plugin-transform-exponentiation-operator@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.23.3.tgz#ea0d978f6b9232ba4722f3dbecdd18f450babd18" + integrity sha512-5fhCsl1odX96u7ILKHBj4/Y8vipoqwsJMh4csSA8qFfxrZDEA4Ssku2DyNvMJSmZNOEBT750LfFPbtrnTP90BQ== dependencies: - "@babel/helper-plugin-utils" "^7.20.2" + "@babel/helper-builder-binary-assignment-operator-visitor" "^7.22.15" + "@babel/helper-plugin-utils" "^7.22.5" -"@babel/plugin-transform-function-name@^7.18.9": - version "7.18.9" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.18.9.tgz#cc354f8234e62968946c61a46d6365440fc764e0" - integrity sha512-WvIBoRPaJQ5yVHzcnJFor7oS5Ls0PYixlTYE63lCj2RtdQEl15M68FXQlxnG6wdraJIXRdR7KI+hQ7q/9QjrCQ== +"@babel/plugin-transform-export-namespace-from@^7.23.4": + version "7.23.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-export-namespace-from/-/plugin-transform-export-namespace-from-7.23.4.tgz#084c7b25e9a5c8271e987a08cf85807b80283191" + integrity sha512-GzuSBcKkx62dGzZI1WVgTWvkkz84FZO5TC5T8dl/Tht/rAla6Dg/Mz9Yhypg+ezVACf/rgDuQt3kbWEv7LdUDQ== dependencies: - "@babel/helper-compilation-targets" "^7.18.9" - "@babel/helper-function-name" "^7.18.9" - "@babel/helper-plugin-utils" "^7.18.9" + "@babel/helper-plugin-utils" "^7.22.5" + "@babel/plugin-syntax-export-namespace-from" "^7.8.3" -"@babel/plugin-transform-literals@^7.18.9": - version "7.18.9" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-literals/-/plugin-transform-literals-7.18.9.tgz#72796fdbef80e56fba3c6a699d54f0de557444bc" - integrity sha512-IFQDSRoTPnrAIrI5zoZv73IFeZu2dhu6irxQjY9rNjTT53VmKg9fenjvoiOWOkJ6mm4jKVPtdMzBY98Fp4Z4cg== +"@babel/plugin-transform-for-of@^7.23.6": + version "7.23.6" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.23.6.tgz#81c37e24171b37b370ba6aaffa7ac86bcb46f94e" + integrity sha512-aYH4ytZ0qSuBbpfhuofbg/e96oQ7U2w1Aw/UQmKT+1l39uEhUPoFS3fHevDc1G0OvewyDudfMKY1OulczHzWIw== dependencies: - "@babel/helper-plugin-utils" "^7.18.9" + "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-skip-transparent-expression-wrappers" "^7.22.5" -"@babel/plugin-transform-member-expression-literals@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.18.6.tgz#ac9fdc1a118620ac49b7e7a5d2dc177a1bfee88e" - integrity sha512-qSF1ihLGO3q+/g48k85tUjD033C29TNTVB2paCwZPVmOsjn9pClvYYrM2VeJpBY2bcNkuny0YUyTNRyRxJ54KA== +"@babel/plugin-transform-function-name@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.23.3.tgz#8f424fcd862bf84cb9a1a6b42bc2f47ed630f8dc" + integrity sha512-I1QXp1LxIvt8yLaib49dRW5Okt7Q4oaxao6tFVKS/anCdEOMtYwWVKoiOA1p34GOWIZjUK0E+zCp7+l1pfQyiw== dependencies: - "@babel/helper-plugin-utils" "^7.18.6" + "@babel/helper-compilation-targets" "^7.22.15" + "@babel/helper-function-name" "^7.23.0" + "@babel/helper-plugin-utils" "^7.22.5" -"@babel/plugin-transform-modules-amd@^7.19.6": - version "7.20.11" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.20.11.tgz#3daccca8e4cc309f03c3a0c4b41dc4b26f55214a" - integrity sha512-NuzCt5IIYOW0O30UvqktzHYR2ud5bOWbY0yaxWZ6G+aFzOMJvrs5YHNikrbdaT15+KNO31nPOy5Fim3ku6Zb5g== +"@babel/plugin-transform-json-strings@^7.23.4": + version "7.23.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-json-strings/-/plugin-transform-json-strings-7.23.4.tgz#a871d9b6bd171976efad2e43e694c961ffa3714d" + integrity sha512-81nTOqM1dMwZ/aRXQ59zVubN9wHGqk6UtqRK+/q+ciXmRy8fSolhGVvG09HHRGo4l6fr/c4ZhXUQH0uFW7PZbg== dependencies: - "@babel/helper-module-transforms" "^7.20.11" - "@babel/helper-plugin-utils" "^7.20.2" + "@babel/helper-plugin-utils" "^7.22.5" + "@babel/plugin-syntax-json-strings" "^7.8.3" -"@babel/plugin-transform-modules-commonjs@^7.19.6": - version "7.21.2" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.21.2.tgz#6ff5070e71e3192ef2b7e39820a06fb78e3058e7" - integrity sha512-Cln+Yy04Gxua7iPdj6nOV96smLGjpElir5YwzF0LBPKoPlLDNJePNlrGGaybAJkd0zKRnOVXOgizSqPYMNYkzA== +"@babel/plugin-transform-literals@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-literals/-/plugin-transform-literals-7.23.3.tgz#8214665f00506ead73de157eba233e7381f3beb4" + integrity sha512-wZ0PIXRxnwZvl9AYpqNUxpZ5BiTGrYt7kueGQ+N5FiQ7RCOD4cm8iShd6S6ggfVIWaJf2EMk8eRzAh52RfP4rQ== dependencies: - "@babel/helper-module-transforms" "^7.21.2" - "@babel/helper-plugin-utils" "^7.20.2" - "@babel/helper-simple-access" "^7.20.2" + "@babel/helper-plugin-utils" "^7.22.5" -"@babel/plugin-transform-modules-systemjs@^7.19.6": - version "7.20.11" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.20.11.tgz#467ec6bba6b6a50634eea61c9c232654d8a4696e" - integrity sha512-vVu5g9BPQKSFEmvt2TA4Da5N+QVS66EX21d8uoOihC+OCpUoGvzVsXeqFdtAEfVa5BILAeFt+U7yVmLbQnAJmw== +"@babel/plugin-transform-logical-assignment-operators@^7.23.4": + version "7.23.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-logical-assignment-operators/-/plugin-transform-logical-assignment-operators-7.23.4.tgz#e599f82c51d55fac725f62ce55d3a0886279ecb5" + integrity sha512-Mc/ALf1rmZTP4JKKEhUwiORU+vcfarFVLfcFiolKUo6sewoxSEgl36ak5t+4WamRsNr6nzjZXQjM35WsU+9vbg== dependencies: - "@babel/helper-hoist-variables" "^7.18.6" - "@babel/helper-module-transforms" "^7.20.11" - "@babel/helper-plugin-utils" "^7.20.2" - "@babel/helper-validator-identifier" "^7.19.1" + "@babel/helper-plugin-utils" "^7.22.5" + "@babel/plugin-syntax-logical-assignment-operators" "^7.10.4" -"@babel/plugin-transform-modules-umd@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.18.6.tgz#81d3832d6034b75b54e62821ba58f28ed0aab4b9" - integrity sha512-dcegErExVeXcRqNtkRU/z8WlBLnvD4MRnHgNs3MytRO1Mn1sHRyhbcpYbVMGclAqOjdW+9cfkdZno9dFdfKLfQ== +"@babel/plugin-transform-member-expression-literals@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.23.3.tgz#e37b3f0502289f477ac0e776b05a833d853cabcc" + integrity sha512-sC3LdDBDi5x96LA+Ytekz2ZPk8i/Ck+DEuDbRAll5rknJ5XRTSaPKEYwomLcs1AA8wg9b3KjIQRsnApj+q51Ag== dependencies: - "@babel/helper-module-transforms" "^7.18.6" - "@babel/helper-plugin-utils" "^7.18.6" + "@babel/helper-plugin-utils" "^7.22.5" -"@babel/plugin-transform-named-capturing-groups-regex@^7.19.1": - version "7.20.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.20.5.tgz#626298dd62ea51d452c3be58b285d23195ba69a8" - integrity sha512-mOW4tTzi5iTLnw+78iEq3gr8Aoq4WNRGpmSlrogqaiCBoR1HFhpU4JkpQFOHfeYx3ReVIFWOQJS4aZBRvuZ6mA== +"@babel/plugin-transform-modules-amd@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.23.3.tgz#e19b55436a1416829df0a1afc495deedfae17f7d" + integrity sha512-vJYQGxeKM4t8hYCKVBlZX/gtIY2I7mRGFNcm85sgXGMTBcoV3QdVtdpbcWEbzbfUIUZKwvgFT82mRvaQIebZzw== dependencies: - "@babel/helper-create-regexp-features-plugin" "^7.20.5" - "@babel/helper-plugin-utils" "^7.20.2" + "@babel/helper-module-transforms" "^7.23.3" + "@babel/helper-plugin-utils" "^7.22.5" -"@babel/plugin-transform-new-target@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.18.6.tgz#d128f376ae200477f37c4ddfcc722a8a1b3246a8" - integrity sha512-DjwFA/9Iu3Z+vrAn+8pBUGcjhxKguSMlsFqeCKbhb9BAV756v0krzVK04CRDi/4aqmk8BsHb4a/gFcaA5joXRw== +"@babel/plugin-transform-modules-commonjs@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.23.3.tgz#661ae831b9577e52be57dd8356b734f9700b53b4" + integrity sha512-aVS0F65LKsdNOtcz6FRCpE4OgsP2OFnW46qNxNIX9h3wuzaNcSQsJysuMwqSibC98HPrf2vCgtxKNwS0DAlgcA== dependencies: - "@babel/helper-plugin-utils" "^7.18.6" + "@babel/helper-module-transforms" "^7.23.3" + "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-simple-access" "^7.22.5" -"@babel/plugin-transform-object-super@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.18.6.tgz#fb3c6ccdd15939b6ff7939944b51971ddc35912c" - integrity sha512-uvGz6zk+pZoS1aTZrOvrbj6Pp/kK2mp45t2B+bTDre2UgsZZ8EZLSJtUg7m/no0zOJUWgFONpB7Zv9W2tSaFlA== +"@babel/plugin-transform-modules-systemjs@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.23.3.tgz#fa7e62248931cb15b9404f8052581c302dd9de81" + integrity sha512-ZxyKGTkF9xT9YJuKQRo19ewf3pXpopuYQd8cDXqNzc3mUNbOME0RKMoZxviQk74hwzfQsEe66dE92MaZbdHKNQ== dependencies: - "@babel/helper-plugin-utils" "^7.18.6" - "@babel/helper-replace-supers" "^7.18.6" + "@babel/helper-hoist-variables" "^7.22.5" + "@babel/helper-module-transforms" "^7.23.3" + "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-validator-identifier" "^7.22.20" -"@babel/plugin-transform-parameters@^7.12.1", "@babel/plugin-transform-parameters@^7.20.1", "@babel/plugin-transform-parameters@^7.20.7": - version "7.20.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.20.7.tgz#0ee349e9d1bc96e78e3b37a7af423a4078a7083f" - integrity sha512-WiWBIkeHKVOSYPO0pWkxGPfKeWrCJyD3NJ53+Lrp/QMSZbsVPovrVl2aWZ19D/LTVnaDv5Ap7GJ/B2CTOZdrfA== +"@babel/plugin-transform-modules-umd@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.23.3.tgz#5d4395fccd071dfefe6585a4411aa7d6b7d769e9" + integrity sha512-zHsy9iXX2nIsCBFPud3jKn1IRPWg3Ing1qOZgeKV39m1ZgIdpJqvlWVeiHBZC6ITRG0MfskhYe9cLgntfSFPIg== dependencies: - "@babel/helper-plugin-utils" "^7.20.2" + "@babel/helper-module-transforms" "^7.23.3" + "@babel/helper-plugin-utils" "^7.22.5" -"@babel/plugin-transform-property-literals@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.18.6.tgz#e22498903a483448e94e032e9bbb9c5ccbfc93a3" - integrity sha512-cYcs6qlgafTud3PAzrrRNbQtfpQ8+y/+M5tKmksS9+M1ckbH6kzY8MrexEM9mcA6JDsukE19iIRvAyYl463sMg== +"@babel/plugin-transform-named-capturing-groups-regex@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.22.5.tgz#67fe18ee8ce02d57c855185e27e3dc959b2e991f" + integrity sha512-YgLLKmS3aUBhHaxp5hi1WJTgOUb/NCuDHzGT9z9WTt3YG+CPRhJs6nprbStx6DnWM4dh6gt7SU3sZodbZ08adQ== dependencies: - "@babel/helper-plugin-utils" "^7.18.6" + "@babel/helper-create-regexp-features-plugin" "^7.22.5" + "@babel/helper-plugin-utils" "^7.22.5" + +"@babel/plugin-transform-new-target@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.23.3.tgz#5491bb78ed6ac87e990957cea367eab781c4d980" + integrity sha512-YJ3xKqtJMAT5/TIZnpAR3I+K+WaDowYbN3xyxI8zxx/Gsypwf9B9h0VB+1Nh6ACAAPRS5NSRje0uVv5i79HYGQ== + dependencies: + "@babel/helper-plugin-utils" "^7.22.5" + +"@babel/plugin-transform-nullish-coalescing-operator@^7.23.4": + version "7.23.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-nullish-coalescing-operator/-/plugin-transform-nullish-coalescing-operator-7.23.4.tgz#45556aad123fc6e52189ea749e33ce090637346e" + integrity sha512-jHE9EVVqHKAQx+VePv5LLGHjmHSJR76vawFPTdlxR/LVJPfOEGxREQwQfjuZEOPTwG92X3LINSh3M40Rv4zpVA== + dependencies: + "@babel/helper-plugin-utils" "^7.22.5" + "@babel/plugin-syntax-nullish-coalescing-operator" "^7.8.3" + +"@babel/plugin-transform-numeric-separator@^7.23.4": + version "7.23.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-numeric-separator/-/plugin-transform-numeric-separator-7.23.4.tgz#03d08e3691e405804ecdd19dd278a40cca531f29" + integrity sha512-mps6auzgwjRrwKEZA05cOwuDc9FAzoyFS4ZsG/8F43bTLf/TgkJg7QXOrPO1JO599iA3qgK9MXdMGOEC8O1h6Q== + dependencies: + "@babel/helper-plugin-utils" "^7.22.5" + "@babel/plugin-syntax-numeric-separator" "^7.10.4" + +"@babel/plugin-transform-object-rest-spread@^7.23.4": + version "7.23.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-object-rest-spread/-/plugin-transform-object-rest-spread-7.23.4.tgz#2b9c2d26bf62710460bdc0d1730d4f1048361b83" + integrity sha512-9x9K1YyeQVw0iOXJlIzwm8ltobIIv7j2iLyP2jIhEbqPRQ7ScNgwQufU2I0Gq11VjyG4gI4yMXt2VFags+1N3g== + dependencies: + "@babel/compat-data" "^7.23.3" + "@babel/helper-compilation-targets" "^7.22.15" + "@babel/helper-plugin-utils" "^7.22.5" + "@babel/plugin-syntax-object-rest-spread" "^7.8.3" + "@babel/plugin-transform-parameters" "^7.23.3" + +"@babel/plugin-transform-object-super@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.23.3.tgz#81fdb636dcb306dd2e4e8fd80db5b2362ed2ebcd" + integrity sha512-BwQ8q0x2JG+3lxCVFohg+KbQM7plfpBwThdW9A6TMtWwLsbDA01Ek2Zb/AgDN39BiZsExm4qrXxjk+P1/fzGrA== + dependencies: + "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-replace-supers" "^7.22.20" + +"@babel/plugin-transform-optional-catch-binding@^7.23.4": + version "7.23.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-optional-catch-binding/-/plugin-transform-optional-catch-binding-7.23.4.tgz#318066de6dacce7d92fa244ae475aa8d91778017" + integrity sha512-XIq8t0rJPHf6Wvmbn9nFxU6ao4c7WhghTR5WyV8SrJfUFzyxhCm4nhC+iAp3HFhbAKLfYpgzhJ6t4XCtVwqO5A== + dependencies: + "@babel/helper-plugin-utils" "^7.22.5" + "@babel/plugin-syntax-optional-catch-binding" "^7.8.3" + +"@babel/plugin-transform-optional-chaining@^7.23.3", "@babel/plugin-transform-optional-chaining@^7.23.4": + version "7.23.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-optional-chaining/-/plugin-transform-optional-chaining-7.23.4.tgz#6acf61203bdfc4de9d4e52e64490aeb3e52bd017" + integrity sha512-ZU8y5zWOfjM5vZ+asjgAPwDaBjJzgufjES89Rs4Lpq63O300R/kOz30WCLo6BxxX6QVEilwSlpClnG5cZaikTA== + dependencies: + "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-skip-transparent-expression-wrappers" "^7.22.5" + "@babel/plugin-syntax-optional-chaining" "^7.8.3" + +"@babel/plugin-transform-parameters@^7.12.1", "@babel/plugin-transform-parameters@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.23.3.tgz#83ef5d1baf4b1072fa6e54b2b0999a7b2527e2af" + integrity sha512-09lMt6UsUb3/34BbECKVbVwrT9bO6lILWln237z7sLaWnMsTi7Yc9fhX5DLpkJzAGfaReXI22wP41SZmnAA3Vw== + dependencies: + "@babel/helper-plugin-utils" "^7.22.5" + +"@babel/plugin-transform-private-methods@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-private-methods/-/plugin-transform-private-methods-7.23.3.tgz#b2d7a3c97e278bfe59137a978d53b2c2e038c0e4" + integrity sha512-UzqRcRtWsDMTLrRWFvUBDwmw06tCQH9Rl1uAjfh6ijMSmGYQ+fpdB+cnqRC8EMh5tuuxSv0/TejGL+7vyj+50g== + dependencies: + "@babel/helper-create-class-features-plugin" "^7.22.15" + "@babel/helper-plugin-utils" "^7.22.5" + +"@babel/plugin-transform-private-property-in-object@^7.23.4": + version "7.23.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-private-property-in-object/-/plugin-transform-private-property-in-object-7.23.4.tgz#3ec711d05d6608fd173d9b8de39872d8dbf68bf5" + integrity sha512-9G3K1YqTq3F4Vt88Djx1UZ79PDyj+yKRnUy7cZGSMe+a7jkwD259uKKuUzQlPkGam7R+8RJwh5z4xO27fA1o2A== + dependencies: + "@babel/helper-annotate-as-pure" "^7.22.5" + "@babel/helper-create-class-features-plugin" "^7.22.15" + "@babel/helper-plugin-utils" "^7.22.5" + "@babel/plugin-syntax-private-property-in-object" "^7.14.5" + +"@babel/plugin-transform-property-literals@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.23.3.tgz#54518f14ac4755d22b92162e4a852d308a560875" + integrity sha512-jR3Jn3y7cZp4oEWPFAlRsSWjxKe4PZILGBSd4nis1TsC5qeSpb+nrtihJuDhNI7QHiVbUaiXa0X2RZY3/TI6Nw== + dependencies: + "@babel/helper-plugin-utils" "^7.22.5" "@babel/plugin-transform-react-constant-elements@^7.18.12": - version "7.20.2" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-constant-elements/-/plugin-transform-react-constant-elements-7.20.2.tgz#3f02c784e0b711970d7d8ccc96c4359d64e27ac7" - integrity sha512-KS/G8YI8uwMGKErLFOHS/ekhqdHhpEloxs43NecQHVgo2QuQSyJhGIY1fL8UGl9wy5ItVwwoUL4YxVqsplGq2g== + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-constant-elements/-/plugin-transform-react-constant-elements-7.23.3.tgz#5efc001d07ef0f7da0d73c3a86c132f73d28e43c" + integrity sha512-zP0QKq/p6O42OL94udMgSfKXyse4RyJ0JqbQ34zDAONWjyrEsghYEyTSK5FIpmXmCpB55SHokL1cRRKHv8L2Qw== dependencies: - "@babel/helper-plugin-utils" "^7.20.2" + "@babel/helper-plugin-utils" "^7.22.5" -"@babel/plugin-transform-react-display-name@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-display-name/-/plugin-transform-react-display-name-7.18.6.tgz#8b1125f919ef36ebdfff061d664e266c666b9415" - integrity sha512-TV4sQ+T013n61uMoygyMRm+xf04Bd5oqFpv2jAEQwSZ8NwQA7zeRPg1LMVg2PWi3zWBz+CLKD+v5bcpZ/BS0aA== +"@babel/plugin-transform-react-display-name@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-display-name/-/plugin-transform-react-display-name-7.23.3.tgz#70529f034dd1e561045ad3c8152a267f0d7b6200" + integrity sha512-GnvhtVfA2OAtzdX58FJxU19rhoGeQzyVndw3GgtdECQvQFXPEZIOVULHVZGAYmOgmqjXpVpfocAbSjh99V/Fqw== dependencies: - "@babel/helper-plugin-utils" "^7.18.6" + "@babel/helper-plugin-utils" "^7.22.5" -"@babel/plugin-transform-react-jsx-development@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx-development/-/plugin-transform-react-jsx-development-7.18.6.tgz#dbe5c972811e49c7405b630e4d0d2e1380c0ddc5" - integrity sha512-SA6HEjwYFKF7WDjWcMcMGUimmw/nhNRDWxr+KaLSCrkD/LMDBvWRmHAYgE1HDeF8KUuI8OAu+RT6EOtKxSW2qA== +"@babel/plugin-transform-react-jsx-development@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx-development/-/plugin-transform-react-jsx-development-7.22.5.tgz#e716b6edbef972a92165cd69d92f1255f7e73e87" + integrity sha512-bDhuzwWMuInwCYeDeMzyi7TaBgRQei6DqxhbyniL7/VG4RSS7HtSL2QbY4eESy1KJqlWt8g3xeEBGPuo+XqC8A== dependencies: - "@babel/plugin-transform-react-jsx" "^7.18.6" + "@babel/plugin-transform-react-jsx" "^7.22.5" -"@babel/plugin-transform-react-jsx@^7.18.6": - version "7.21.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx/-/plugin-transform-react-jsx-7.21.0.tgz#656b42c2fdea0a6d8762075d58ef9d4e3c4ab8a2" - integrity sha512-6OAWljMvQrZjR2DaNhVfRz6dkCAVV+ymcLUmaf8bccGOHn2v5rHJK3tTpij0BuhdYWP4LLaqj5lwcdlpAAPuvg== +"@babel/plugin-transform-react-jsx@^7.22.15", "@babel/plugin-transform-react-jsx@^7.22.5": + version "7.23.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx/-/plugin-transform-react-jsx-7.23.4.tgz#393f99185110cea87184ea47bcb4a7b0c2e39312" + integrity sha512-5xOpoPguCZCRbo/JeHlloSkTA8Bld1J/E1/kLfD1nsuiW1m8tduTA1ERCgIZokDflX/IBzKcqR3l7VlRgiIfHA== dependencies: - "@babel/helper-annotate-as-pure" "^7.18.6" - "@babel/helper-module-imports" "^7.18.6" - "@babel/helper-plugin-utils" "^7.20.2" - "@babel/plugin-syntax-jsx" "^7.18.6" - "@babel/types" "^7.21.0" + "@babel/helper-annotate-as-pure" "^7.22.5" + "@babel/helper-module-imports" "^7.22.15" + "@babel/helper-plugin-utils" "^7.22.5" + "@babel/plugin-syntax-jsx" "^7.23.3" + "@babel/types" "^7.23.4" -"@babel/plugin-transform-react-pure-annotations@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-pure-annotations/-/plugin-transform-react-pure-annotations-7.18.6.tgz#561af267f19f3e5d59291f9950fd7b9663d0d844" - integrity sha512-I8VfEPg9r2TRDdvnHgPepTKvuRomzA8+u+nhY7qSI1fR2hRNebasZEETLyM5mAUr0Ku56OkXJ0I7NHJnO6cJiQ== +"@babel/plugin-transform-react-pure-annotations@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-pure-annotations/-/plugin-transform-react-pure-annotations-7.23.3.tgz#fabedbdb8ee40edf5da96f3ecfc6958e3783b93c" + integrity sha512-qMFdSS+TUhB7Q/3HVPnEdYJDQIk57jkntAwSuz9xfSE4n+3I+vHYCli3HoHawN1Z3RfCz/y1zXA/JXjG6cVImQ== dependencies: - "@babel/helper-annotate-as-pure" "^7.18.6" - "@babel/helper-plugin-utils" "^7.18.6" + "@babel/helper-annotate-as-pure" "^7.22.5" + "@babel/helper-plugin-utils" "^7.22.5" -"@babel/plugin-transform-regenerator@^7.18.6": - version "7.20.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.20.5.tgz#57cda588c7ffb7f4f8483cc83bdcea02a907f04d" - integrity sha512-kW/oO7HPBtntbsahzQ0qSE3tFvkFwnbozz3NWFhLGqH75vLEg+sCGngLlhVkePlCs3Jv0dBBHDzCHxNiFAQKCQ== +"@babel/plugin-transform-regenerator@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.23.3.tgz#141afd4a2057298602069fce7f2dc5173e6c561c" + integrity sha512-KP+75h0KghBMcVpuKisx3XTu9Ncut8Q8TuvGO4IhY+9D5DFEckQefOuIsB/gQ2tG71lCke4NMrtIPS8pOj18BQ== dependencies: - "@babel/helper-plugin-utils" "^7.20.2" - regenerator-transform "^0.15.1" + "@babel/helper-plugin-utils" "^7.22.5" + regenerator-transform "^0.15.2" -"@babel/plugin-transform-reserved-words@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-reserved-words/-/plugin-transform-reserved-words-7.18.6.tgz#b1abd8ebf8edaa5f7fe6bbb8d2133d23b6a6f76a" - integrity sha512-oX/4MyMoypzHjFrT1CdivfKZ+XvIPMFXwwxHp/r0Ddy2Vuomt4HDFGmft1TAY2yiTKiNSsh3kjBAzcM8kSdsjA== +"@babel/plugin-transform-reserved-words@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-reserved-words/-/plugin-transform-reserved-words-7.23.3.tgz#4130dcee12bd3dd5705c587947eb715da12efac8" + integrity sha512-QnNTazY54YqgGxwIexMZva9gqbPa15t/x9VS+0fsEFWplwVpXYZivtgl43Z1vMpc1bdPP2PP8siFeVcnFvA3Cg== dependencies: - "@babel/helper-plugin-utils" "^7.18.6" + "@babel/helper-plugin-utils" "^7.22.5" "@babel/plugin-transform-runtime@^7.18.6": - version "7.21.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.21.0.tgz#2a884f29556d0a68cd3d152dcc9e6c71dfb6eee8" - integrity sha512-ReY6pxwSzEU0b3r2/T/VhqMKg/AkceBT19X0UptA3/tYi5Pe2eXgEUH+NNMC5nok6c6XQz5tyVTUpuezRfSMSg== - dependencies: - "@babel/helper-module-imports" "^7.18.6" - "@babel/helper-plugin-utils" "^7.20.2" - babel-plugin-polyfill-corejs2 "^0.3.3" - babel-plugin-polyfill-corejs3 "^0.6.0" - babel-plugin-polyfill-regenerator "^0.4.1" - semver "^6.3.0" + version "7.23.7" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.23.7.tgz#52bbd20054855beb9deae3bee9ceb05289c343e6" + integrity sha512-fa0hnfmiXc9fq/weK34MUV0drz2pOL/vfKWvN7Qw127hiUPabFCUMgAbYWcchRzMJit4o5ARsK/s+5h0249pLw== + dependencies: + "@babel/helper-module-imports" "^7.22.15" + "@babel/helper-plugin-utils" "^7.22.5" + babel-plugin-polyfill-corejs2 "^0.4.7" + babel-plugin-polyfill-corejs3 "^0.8.7" + babel-plugin-polyfill-regenerator "^0.5.4" + semver "^6.3.1" -"@babel/plugin-transform-shorthand-properties@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.18.6.tgz#6d6df7983d67b195289be24909e3f12a8f664dc9" - integrity sha512-eCLXXJqv8okzg86ywZJbRn19YJHU4XUa55oz2wbHhaQVn/MM+XhukiT7SYqp/7o00dg52Rj51Ny+Ecw4oyoygw== +"@babel/plugin-transform-shorthand-properties@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.23.3.tgz#97d82a39b0e0c24f8a981568a8ed851745f59210" + integrity sha512-ED2fgqZLmexWiN+YNFX26fx4gh5qHDhn1O2gvEhreLW2iI63Sqm4llRLCXALKrCnbN4Jy0VcMQZl/SAzqug/jg== dependencies: - "@babel/helper-plugin-utils" "^7.18.6" + "@babel/helper-plugin-utils" "^7.22.5" -"@babel/plugin-transform-spread@^7.19.0": - version "7.20.7" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-spread/-/plugin-transform-spread-7.20.7.tgz#c2d83e0b99d3bf83e07b11995ee24bf7ca09401e" - integrity sha512-ewBbHQ+1U/VnH1fxltbJqDeWBU1oNLG8Dj11uIv3xVf7nrQu0bPGe5Rf716r7K5Qz+SqtAOVswoVunoiBtGhxw== +"@babel/plugin-transform-spread@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-spread/-/plugin-transform-spread-7.23.3.tgz#41d17aacb12bde55168403c6f2d6bdca563d362c" + integrity sha512-VvfVYlrlBVu+77xVTOAoxQ6mZbnIq5FM0aGBSFEcIh03qHf+zNqA4DC/3XMUozTg7bZV3e3mZQ0i13VB6v5yUg== dependencies: - "@babel/helper-plugin-utils" "^7.20.2" - "@babel/helper-skip-transparent-expression-wrappers" "^7.20.0" + "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-skip-transparent-expression-wrappers" "^7.22.5" -"@babel/plugin-transform-sticky-regex@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.18.6.tgz#c6706eb2b1524028e317720339583ad0f444adcc" - integrity sha512-kfiDrDQ+PBsQDO85yj1icueWMfGfJFKN1KCkndygtu/C9+XUfydLC8Iv5UYJqRwy4zk8EcplRxEOeLyjq1gm6Q== +"@babel/plugin-transform-sticky-regex@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.23.3.tgz#dec45588ab4a723cb579c609b294a3d1bd22ff04" + integrity sha512-HZOyN9g+rtvnOU3Yh7kSxXrKbzgrm5X4GncPY1QOquu7epga5MxKHVpYu2hvQnry/H+JjckSYRb93iNfsioAGg== dependencies: - "@babel/helper-plugin-utils" "^7.18.6" + "@babel/helper-plugin-utils" "^7.22.5" -"@babel/plugin-transform-template-literals@^7.18.9": - version "7.18.9" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.18.9.tgz#04ec6f10acdaa81846689d63fae117dd9c243a5e" - integrity sha512-S8cOWfT82gTezpYOiVaGHrCbhlHgKhQt8XH5ES46P2XWmX92yisoZywf5km75wv5sYcXDUCLMmMxOLCtthDgMA== +"@babel/plugin-transform-template-literals@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.23.3.tgz#5f0f028eb14e50b5d0f76be57f90045757539d07" + integrity sha512-Flok06AYNp7GV2oJPZZcP9vZdszev6vPBkHLwxwSpaIqx75wn6mUd3UFWsSsA0l8nXAKkyCmL/sR02m8RYGeHg== dependencies: - "@babel/helper-plugin-utils" "^7.18.9" + "@babel/helper-plugin-utils" "^7.22.5" -"@babel/plugin-transform-typeof-symbol@^7.18.9": - version "7.18.9" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.18.9.tgz#c8cea68263e45addcd6afc9091429f80925762c0" - integrity sha512-SRfwTtF11G2aemAZWivL7PD+C9z52v9EvMqH9BuYbabyPuKUvSWks3oCg6041pT925L4zVFqaVBeECwsmlguEw== +"@babel/plugin-transform-typeof-symbol@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.23.3.tgz#9dfab97acc87495c0c449014eb9c547d8966bca4" + integrity sha512-4t15ViVnaFdrPC74be1gXBSMzXk3B4Us9lP7uLRQHTFpV5Dvt33pn+2MyyNxmN3VTTm3oTrZVMUmuw3oBnQ2oQ== dependencies: - "@babel/helper-plugin-utils" "^7.18.9" + "@babel/helper-plugin-utils" "^7.22.5" -"@babel/plugin-transform-typescript@^7.21.0": - version "7.21.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.21.0.tgz#f0956a153679e3b377ae5b7f0143427151e4c848" - integrity sha512-xo///XTPp3mDzTtrqXoBlK9eiAYW3wv9JXglcn/u1bi60RW11dEUxIgA8cbnDhutS1zacjMRmAwxE0gMklLnZg== +"@babel/plugin-transform-typescript@^7.23.3": + version "7.23.6" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.23.6.tgz#aa36a94e5da8d94339ae3a4e22d40ed287feb34c" + integrity sha512-6cBG5mBvUu4VUD04OHKnYzbuHNP8huDsD3EDqqpIpsswTDoqHCjLoHb6+QgsV1WsT2nipRqCPgxD3LXnEO7XfA== dependencies: - "@babel/helper-create-class-features-plugin" "^7.21.0" - "@babel/helper-plugin-utils" "^7.20.2" - "@babel/plugin-syntax-typescript" "^7.20.0" + "@babel/helper-annotate-as-pure" "^7.22.5" + "@babel/helper-create-class-features-plugin" "^7.23.6" + "@babel/helper-plugin-utils" "^7.22.5" + "@babel/plugin-syntax-typescript" "^7.23.3" -"@babel/plugin-transform-unicode-escapes@^7.18.10": - version "7.18.10" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.18.10.tgz#1ecfb0eda83d09bbcb77c09970c2dd55832aa246" - integrity sha512-kKAdAI+YzPgGY/ftStBFXTI1LZFju38rYThnfMykS+IXy8BVx+res7s2fxf1l8I35DV2T97ezo6+SGrXz6B3iQ== +"@babel/plugin-transform-unicode-escapes@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.23.3.tgz#1f66d16cab01fab98d784867d24f70c1ca65b925" + integrity sha512-OMCUx/bU6ChE3r4+ZdylEqAjaQgHAgipgW8nsCfu5pGqDcFytVd91AwRvUJSBZDz0exPGgnjoqhgRYLRjFZc9Q== dependencies: - "@babel/helper-plugin-utils" "^7.18.9" + "@babel/helper-plugin-utils" "^7.22.5" -"@babel/plugin-transform-unicode-regex@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.18.6.tgz#194317225d8c201bbae103364ffe9e2cea36cdca" - integrity sha512-gE7A6Lt7YLnNOL3Pb9BNeZvi+d8l7tcRrG4+pwJjK9hD2xX4mEvjlQW60G9EEmfXVYRPv9VRQcyegIVHCql/AA== +"@babel/plugin-transform-unicode-property-regex@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-property-regex/-/plugin-transform-unicode-property-regex-7.23.3.tgz#19e234129e5ffa7205010feec0d94c251083d7ad" + integrity sha512-KcLIm+pDZkWZQAFJ9pdfmh89EwVfmNovFBcXko8szpBeF8z68kWIPeKlmSOkT9BXJxs2C0uk+5LxoxIv62MROA== dependencies: - "@babel/helper-create-regexp-features-plugin" "^7.18.6" - "@babel/helper-plugin-utils" "^7.18.6" + "@babel/helper-create-regexp-features-plugin" "^7.22.15" + "@babel/helper-plugin-utils" "^7.22.5" + +"@babel/plugin-transform-unicode-regex@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.23.3.tgz#26897708d8f42654ca4ce1b73e96140fbad879dc" + integrity sha512-wMHpNA4x2cIA32b/ci3AfwNgheiva2W0WUKWTK7vBHBhDKfPsc5cFGNWm69WBqpwd86u1qwZ9PWevKqm1A3yAw== + dependencies: + "@babel/helper-create-regexp-features-plugin" "^7.22.15" + "@babel/helper-plugin-utils" "^7.22.5" + +"@babel/plugin-transform-unicode-sets-regex@^7.23.3": + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-sets-regex/-/plugin-transform-unicode-sets-regex-7.23.3.tgz#4fb6f0a719c2c5859d11f6b55a050cc987f3799e" + integrity sha512-W7lliA/v9bNR83Qc3q1ip9CQMZ09CcHDbHfbLRDNuAhn1Mvkr1ZNF7hPmztMQvtTGVLJ9m8IZqWsTkXOml8dbw== + dependencies: + "@babel/helper-create-regexp-features-plugin" "^7.22.15" + "@babel/helper-plugin-utils" "^7.22.5" "@babel/preset-env@^7.18.6", "@babel/preset-env@^7.19.4": - version "7.20.2" - resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.20.2.tgz#9b1642aa47bb9f43a86f9630011780dab7f86506" - integrity sha512-1G0efQEWR1EHkKvKHqbG+IN/QdgwfByUpM5V5QroDzGV2t3S/WXNQd693cHiHTlCFMpr9B6FkPFXDA2lQcKoDg== - dependencies: - "@babel/compat-data" "^7.20.1" - "@babel/helper-compilation-targets" "^7.20.0" - "@babel/helper-plugin-utils" "^7.20.2" - "@babel/helper-validator-option" "^7.18.6" - "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression" "^7.18.6" - "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining" "^7.18.9" - "@babel/plugin-proposal-async-generator-functions" "^7.20.1" - "@babel/plugin-proposal-class-properties" "^7.18.6" - "@babel/plugin-proposal-class-static-block" "^7.18.6" - "@babel/plugin-proposal-dynamic-import" "^7.18.6" - "@babel/plugin-proposal-export-namespace-from" "^7.18.9" - "@babel/plugin-proposal-json-strings" "^7.18.6" - "@babel/plugin-proposal-logical-assignment-operators" "^7.18.9" - "@babel/plugin-proposal-nullish-coalescing-operator" "^7.18.6" - "@babel/plugin-proposal-numeric-separator" "^7.18.6" - "@babel/plugin-proposal-object-rest-spread" "^7.20.2" - "@babel/plugin-proposal-optional-catch-binding" "^7.18.6" - "@babel/plugin-proposal-optional-chaining" "^7.18.9" - "@babel/plugin-proposal-private-methods" "^7.18.6" - "@babel/plugin-proposal-private-property-in-object" "^7.18.6" - "@babel/plugin-proposal-unicode-property-regex" "^7.18.6" + version "7.23.8" + resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.23.8.tgz#7d6f8171ea7c221ecd28059e65ad37c20e441e3e" + integrity sha512-lFlpmkApLkEP6woIKprO6DO60RImpatTQKtz4sUcDjVcK8M8mQ4sZsuxaTMNOZf0sqAq/ReYW1ZBHnOQwKpLWA== + dependencies: + "@babel/compat-data" "^7.23.5" + "@babel/helper-compilation-targets" "^7.23.6" + "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-validator-option" "^7.23.5" + "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression" "^7.23.3" + "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining" "^7.23.3" + "@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly" "^7.23.7" + "@babel/plugin-proposal-private-property-in-object" "7.21.0-placeholder-for-preset-env.2" "@babel/plugin-syntax-async-generators" "^7.8.4" "@babel/plugin-syntax-class-properties" "^7.12.13" "@babel/plugin-syntax-class-static-block" "^7.14.5" "@babel/plugin-syntax-dynamic-import" "^7.8.3" "@babel/plugin-syntax-export-namespace-from" "^7.8.3" - "@babel/plugin-syntax-import-assertions" "^7.20.0" + "@babel/plugin-syntax-import-assertions" "^7.23.3" + "@babel/plugin-syntax-import-attributes" "^7.23.3" + "@babel/plugin-syntax-import-meta" "^7.10.4" "@babel/plugin-syntax-json-strings" "^7.8.3" "@babel/plugin-syntax-logical-assignment-operators" "^7.10.4" "@babel/plugin-syntax-nullish-coalescing-operator" "^7.8.3" @@ -1059,77 +1097,93 @@ "@babel/plugin-syntax-optional-chaining" "^7.8.3" "@babel/plugin-syntax-private-property-in-object" "^7.14.5" "@babel/plugin-syntax-top-level-await" "^7.14.5" - "@babel/plugin-transform-arrow-functions" "^7.18.6" - "@babel/plugin-transform-async-to-generator" "^7.18.6" - "@babel/plugin-transform-block-scoped-functions" "^7.18.6" - "@babel/plugin-transform-block-scoping" "^7.20.2" - "@babel/plugin-transform-classes" "^7.20.2" - "@babel/plugin-transform-computed-properties" "^7.18.9" - "@babel/plugin-transform-destructuring" "^7.20.2" - "@babel/plugin-transform-dotall-regex" "^7.18.6" - "@babel/plugin-transform-duplicate-keys" "^7.18.9" - "@babel/plugin-transform-exponentiation-operator" "^7.18.6" - "@babel/plugin-transform-for-of" "^7.18.8" - "@babel/plugin-transform-function-name" "^7.18.9" - "@babel/plugin-transform-literals" "^7.18.9" - "@babel/plugin-transform-member-expression-literals" "^7.18.6" - "@babel/plugin-transform-modules-amd" "^7.19.6" - "@babel/plugin-transform-modules-commonjs" "^7.19.6" - "@babel/plugin-transform-modules-systemjs" "^7.19.6" - "@babel/plugin-transform-modules-umd" "^7.18.6" - "@babel/plugin-transform-named-capturing-groups-regex" "^7.19.1" - "@babel/plugin-transform-new-target" "^7.18.6" - "@babel/plugin-transform-object-super" "^7.18.6" - "@babel/plugin-transform-parameters" "^7.20.1" - "@babel/plugin-transform-property-literals" "^7.18.6" - "@babel/plugin-transform-regenerator" "^7.18.6" - "@babel/plugin-transform-reserved-words" "^7.18.6" - "@babel/plugin-transform-shorthand-properties" "^7.18.6" - "@babel/plugin-transform-spread" "^7.19.0" - "@babel/plugin-transform-sticky-regex" "^7.18.6" - "@babel/plugin-transform-template-literals" "^7.18.9" - "@babel/plugin-transform-typeof-symbol" "^7.18.9" - "@babel/plugin-transform-unicode-escapes" "^7.18.10" - "@babel/plugin-transform-unicode-regex" "^7.18.6" - "@babel/preset-modules" "^0.1.5" - "@babel/types" "^7.20.2" - babel-plugin-polyfill-corejs2 "^0.3.3" - babel-plugin-polyfill-corejs3 "^0.6.0" - babel-plugin-polyfill-regenerator "^0.4.1" - core-js-compat "^3.25.1" - semver "^6.3.0" - -"@babel/preset-modules@^0.1.5": - version "0.1.5" - resolved "https://registry.yarnpkg.com/@babel/preset-modules/-/preset-modules-0.1.5.tgz#ef939d6e7f268827e1841638dc6ff95515e115d9" - integrity sha512-A57th6YRG7oR3cq/yt/Y84MvGgE0eJG2F1JLhKuyG+jFxEgrd/HAMJatiFtmOiZurz+0DkrvbheCLaV5f2JfjA== + "@babel/plugin-syntax-unicode-sets-regex" "^7.18.6" + "@babel/plugin-transform-arrow-functions" "^7.23.3" + "@babel/plugin-transform-async-generator-functions" "^7.23.7" + "@babel/plugin-transform-async-to-generator" "^7.23.3" + "@babel/plugin-transform-block-scoped-functions" "^7.23.3" + "@babel/plugin-transform-block-scoping" "^7.23.4" + "@babel/plugin-transform-class-properties" "^7.23.3" + "@babel/plugin-transform-class-static-block" "^7.23.4" + "@babel/plugin-transform-classes" "^7.23.8" + "@babel/plugin-transform-computed-properties" "^7.23.3" + "@babel/plugin-transform-destructuring" "^7.23.3" + "@babel/plugin-transform-dotall-regex" "^7.23.3" + "@babel/plugin-transform-duplicate-keys" "^7.23.3" + "@babel/plugin-transform-dynamic-import" "^7.23.4" + "@babel/plugin-transform-exponentiation-operator" "^7.23.3" + "@babel/plugin-transform-export-namespace-from" "^7.23.4" + "@babel/plugin-transform-for-of" "^7.23.6" + "@babel/plugin-transform-function-name" "^7.23.3" + "@babel/plugin-transform-json-strings" "^7.23.4" + "@babel/plugin-transform-literals" "^7.23.3" + "@babel/plugin-transform-logical-assignment-operators" "^7.23.4" + "@babel/plugin-transform-member-expression-literals" "^7.23.3" + "@babel/plugin-transform-modules-amd" "^7.23.3" + "@babel/plugin-transform-modules-commonjs" "^7.23.3" + "@babel/plugin-transform-modules-systemjs" "^7.23.3" + "@babel/plugin-transform-modules-umd" "^7.23.3" + "@babel/plugin-transform-named-capturing-groups-regex" "^7.22.5" + "@babel/plugin-transform-new-target" "^7.23.3" + "@babel/plugin-transform-nullish-coalescing-operator" "^7.23.4" + "@babel/plugin-transform-numeric-separator" "^7.23.4" + "@babel/plugin-transform-object-rest-spread" "^7.23.4" + "@babel/plugin-transform-object-super" "^7.23.3" + "@babel/plugin-transform-optional-catch-binding" "^7.23.4" + "@babel/plugin-transform-optional-chaining" "^7.23.4" + "@babel/plugin-transform-parameters" "^7.23.3" + "@babel/plugin-transform-private-methods" "^7.23.3" + "@babel/plugin-transform-private-property-in-object" "^7.23.4" + "@babel/plugin-transform-property-literals" "^7.23.3" + "@babel/plugin-transform-regenerator" "^7.23.3" + "@babel/plugin-transform-reserved-words" "^7.23.3" + "@babel/plugin-transform-shorthand-properties" "^7.23.3" + "@babel/plugin-transform-spread" "^7.23.3" + "@babel/plugin-transform-sticky-regex" "^7.23.3" + "@babel/plugin-transform-template-literals" "^7.23.3" + "@babel/plugin-transform-typeof-symbol" "^7.23.3" + "@babel/plugin-transform-unicode-escapes" "^7.23.3" + "@babel/plugin-transform-unicode-property-regex" "^7.23.3" + "@babel/plugin-transform-unicode-regex" "^7.23.3" + "@babel/plugin-transform-unicode-sets-regex" "^7.23.3" + "@babel/preset-modules" "0.1.6-no-external-plugins" + babel-plugin-polyfill-corejs2 "^0.4.7" + babel-plugin-polyfill-corejs3 "^0.8.7" + babel-plugin-polyfill-regenerator "^0.5.4" + core-js-compat "^3.31.0" + semver "^6.3.1" + +"@babel/preset-modules@0.1.6-no-external-plugins": + version "0.1.6-no-external-plugins" + resolved "https://registry.yarnpkg.com/@babel/preset-modules/-/preset-modules-0.1.6-no-external-plugins.tgz#ccb88a2c49c817236861fee7826080573b8a923a" + integrity sha512-HrcgcIESLm9aIR842yhJ5RWan/gebQUJ6E/E5+rf0y9o6oj7w0Br+sWuL6kEQ/o/AdfvR1Je9jG18/gnpwjEyA== dependencies: "@babel/helper-plugin-utils" "^7.0.0" - "@babel/plugin-proposal-unicode-property-regex" "^7.4.4" - "@babel/plugin-transform-dotall-regex" "^7.4.4" "@babel/types" "^7.4.4" esutils "^2.0.2" "@babel/preset-react@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/preset-react/-/preset-react-7.18.6.tgz#979f76d6277048dc19094c217b507f3ad517dd2d" - integrity sha512-zXr6atUmyYdiWRVLOZahakYmOBHtWc2WGCkP8PYTgZi0iJXDY2CN180TdrIW4OGOAdLc7TifzDIvtx6izaRIzg== + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/preset-react/-/preset-react-7.23.3.tgz#f73ca07e7590f977db07eb54dbe46538cc015709" + integrity sha512-tbkHOS9axH6Ysf2OUEqoSZ6T3Fa2SrNH6WTWSPBboxKzdxNc9qOICeLXkNG0ZEwbQ1HY8liwOce4aN/Ceyuq6w== dependencies: - "@babel/helper-plugin-utils" "^7.18.6" - "@babel/helper-validator-option" "^7.18.6" - "@babel/plugin-transform-react-display-name" "^7.18.6" - "@babel/plugin-transform-react-jsx" "^7.18.6" - "@babel/plugin-transform-react-jsx-development" "^7.18.6" - "@babel/plugin-transform-react-pure-annotations" "^7.18.6" + "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-validator-option" "^7.22.15" + "@babel/plugin-transform-react-display-name" "^7.23.3" + "@babel/plugin-transform-react-jsx" "^7.22.15" + "@babel/plugin-transform-react-jsx-development" "^7.22.5" + "@babel/plugin-transform-react-pure-annotations" "^7.23.3" "@babel/preset-typescript@^7.18.6": - version "7.21.0" - resolved "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.21.0.tgz#bcbbca513e8213691fe5d4b23d9251e01f00ebff" - integrity sha512-myc9mpoVA5m1rF8K8DgLEatOYFDpwC+RkMkjZ0Du6uI62YvDe8uxIEYVs/VCdSJ097nlALiU/yBC7//3nI+hNg== + version "7.23.3" + resolved "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.23.3.tgz#14534b34ed5b6d435aa05f1ae1c5e7adcc01d913" + integrity sha512-17oIGVlqz6CchO9RFYn5U6ZpWRZIngayYCtrPRSgANSwC2V1Jb+iP74nVxzzXJte8b8BYxrL1yY96xfhTBrNNQ== dependencies: - "@babel/helper-plugin-utils" "^7.20.2" - "@babel/helper-validator-option" "^7.21.0" - "@babel/plugin-transform-typescript" "^7.21.0" + "@babel/helper-plugin-utils" "^7.22.5" + "@babel/helper-validator-option" "^7.22.15" + "@babel/plugin-syntax-jsx" "^7.23.3" + "@babel/plugin-transform-modules-commonjs" "^7.23.3" + "@babel/plugin-transform-typescript" "^7.23.3" "@babel/regjsgen@^0.8.0": version "0.8.0" @@ -1137,72 +1191,58 @@ integrity sha512-x/rqGMdzj+fWZvCOYForTghzbtqPDZ5gPwaoNGHdgDfF2QA/XZbCBp4Moo5scrkAMPhB7z26XM/AaHuIJdgauA== "@babel/runtime-corejs3@^7.18.6": - version "7.21.0" - resolved "https://registry.yarnpkg.com/@babel/runtime-corejs3/-/runtime-corejs3-7.21.0.tgz#6e4939d9d9789ff63e2dc58e88f13a3913a24eba" - integrity sha512-TDD4UJzos3JJtM+tHX+w2Uc+KWj7GV+VKKFdMVd2Rx8sdA19hcc3P3AHFYd5LVOw+pYuSd5lICC3gm52B6Rwxw== - dependencies: - core-js-pure "^3.25.1" - regenerator-runtime "^0.13.11" - -"@babel/runtime@^7.1.2", "@babel/runtime@^7.10.3", "@babel/runtime@^7.12.13", "@babel/runtime@^7.12.5", "@babel/runtime@^7.18.6", "@babel/runtime@^7.8.4": - version "7.21.0" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.21.0.tgz#5b55c9d394e5fcf304909a8b00c07dc217b56673" - integrity sha512-xwII0//EObnq89Ji5AKYQaRYiW/nZ3llSv29d49IuxPhKbtJoLP+9QUUZ4nVragQVtaVGeZrpB+ZtG/Pdy/POw== - dependencies: - regenerator-runtime "^0.13.11" - -"@babel/runtime@^7.10.2": - version "7.20.7" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.20.7.tgz#fcb41a5a70550e04a7b708037c7c32f7f356d8fd" - integrity sha512-UF0tvkUtxwAgZ5W/KrkHf0Rn0fdnLDU9ScxBrEVNUprE/MzirjK4MJUX1/BVDv00Sv8cljtukVK1aky++X1SjQ== - dependencies: - regenerator-runtime "^0.13.11" - -"@babel/runtime@^7.21.0": - version "7.22.6" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.22.6.tgz#57d64b9ae3cff1d67eb067ae117dac087f5bd438" - integrity sha512-wDb5pWm4WDdF6LFUde3Jl8WzPA+3ZbxYqkC6xAXuD3irdEHN1k0NfTRrJD8ZD378SJ61miMLCqIOXYhd8x+AJQ== - dependencies: - regenerator-runtime "^0.13.11" - -"@babel/template@^7.12.7", "@babel/template@^7.18.10", "@babel/template@^7.20.7": - version "7.20.7" - resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.20.7.tgz#a15090c2839a83b02aa996c0b4994005841fd5a8" - integrity sha512-8SegXApWe6VoNw0r9JHpSteLKTpTiLZ4rMlGIm9JQ18KiCtyQiAMEazujAHrUS5flrcqYZa75ukev3P6QmUwUw== - dependencies: - "@babel/code-frame" "^7.18.6" - "@babel/parser" "^7.20.7" - "@babel/types" "^7.20.7" - -"@babel/traverse@^7.12.9", "@babel/traverse@^7.18.8", "@babel/traverse@^7.20.5", "@babel/traverse@^7.20.7", "@babel/traverse@^7.21.0", "@babel/traverse@^7.21.2": - version "7.21.2" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.21.2.tgz#ac7e1f27658750892e815e60ae90f382a46d8e75" - integrity sha512-ts5FFU/dSUPS13tv8XiEObDu9K+iagEKME9kAbaP7r0Y9KtZJZ+NGndDvWoRAYNpeWafbpFeki3q9QoMD6gxyw== - dependencies: - "@babel/code-frame" "^7.18.6" - "@babel/generator" "^7.21.1" - "@babel/helper-environment-visitor" "^7.18.9" - "@babel/helper-function-name" "^7.21.0" - "@babel/helper-hoist-variables" "^7.18.6" - "@babel/helper-split-export-declaration" "^7.18.6" - "@babel/parser" "^7.21.2" - "@babel/types" "^7.21.2" - debug "^4.1.0" + version "7.23.8" + resolved "https://registry.yarnpkg.com/@babel/runtime-corejs3/-/runtime-corejs3-7.23.8.tgz#b8aa3d47570bdd08fed77fdfd69542118af0df26" + integrity sha512-2ZzmcDugdm0/YQKFVYsXiwUN7USPX8PM7cytpb4PFl87fM+qYPSvTZX//8tyeJB1j0YDmafBJEbl5f8NfLyuKw== + dependencies: + core-js-pure "^3.30.2" + regenerator-runtime "^0.14.0" + +"@babel/runtime@^7.1.2", "@babel/runtime@^7.10.3", "@babel/runtime@^7.12.13", "@babel/runtime@^7.12.5", "@babel/runtime@^7.18.6", "@babel/runtime@^7.20.13", "@babel/runtime@^7.21.0", "@babel/runtime@^7.8.4": + version "7.23.8" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.23.8.tgz#8ee6fe1ac47add7122902f257b8ddf55c898f650" + integrity sha512-Y7KbAP984rn1VGMbGqKmBLio9V7y5Je9GvU4rQPCPinCyNfUcToxIXl06d59URp/F3LwinvODxab5N/G6qggkw== + dependencies: + regenerator-runtime "^0.14.0" + +"@babel/template@^7.12.7", "@babel/template@^7.22.15": + version "7.22.15" + resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.22.15.tgz#09576efc3830f0430f4548ef971dde1350ef2f38" + integrity sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w== + dependencies: + "@babel/code-frame" "^7.22.13" + "@babel/parser" "^7.22.15" + "@babel/types" "^7.22.15" + +"@babel/traverse@^7.12.9", "@babel/traverse@^7.18.8", "@babel/traverse@^7.23.7": + version "7.23.7" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.23.7.tgz#9a7bf285c928cb99b5ead19c3b1ce5b310c9c305" + integrity sha512-tY3mM8rH9jM0YHFGyfC0/xf+SB5eKUu7HPj7/k3fpi9dAlsMc5YbQvDi0Sh2QTPXqMhyaAtzAr807TIyfQrmyg== + dependencies: + "@babel/code-frame" "^7.23.5" + "@babel/generator" "^7.23.6" + "@babel/helper-environment-visitor" "^7.22.20" + "@babel/helper-function-name" "^7.23.0" + "@babel/helper-hoist-variables" "^7.22.5" + "@babel/helper-split-export-declaration" "^7.22.6" + "@babel/parser" "^7.23.6" + "@babel/types" "^7.23.6" + debug "^4.3.1" globals "^11.1.0" -"@babel/types@^7.12.7", "@babel/types@^7.18.6", "@babel/types@^7.18.9", "@babel/types@^7.20.0", "@babel/types@^7.20.2", "@babel/types@^7.20.5", "@babel/types@^7.20.7", "@babel/types@^7.21.0", "@babel/types@^7.21.2", "@babel/types@^7.4.4": - version "7.21.2" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.21.2.tgz#92246f6e00f91755893c2876ad653db70c8310d1" - integrity sha512-3wRZSs7jiFaB8AjxiiD+VqN5DTG2iRvJGQ+qYFrs/654lg6kGTQWIOFjlBo5RaXuAZjBmP3+OQH4dmhqiiyYxw== +"@babel/types@^7.12.7", "@babel/types@^7.20.0", "@babel/types@^7.22.15", "@babel/types@^7.22.19", "@babel/types@^7.22.5", "@babel/types@^7.23.0", "@babel/types@^7.23.4", "@babel/types@^7.23.6", "@babel/types@^7.4.4": + version "7.23.6" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.23.6.tgz#be33fdb151e1f5a56877d704492c240fc71c7ccd" + integrity sha512-+uarb83brBzPKN38NX1MkB6vb6+mwvR6amUulqAE7ccQw1pEl+bCia9TbdG1lsnFP7lZySvUn37CHyXQdfTwzg== dependencies: - "@babel/helper-string-parser" "^7.19.4" - "@babel/helper-validator-identifier" "^7.19.1" + "@babel/helper-string-parser" "^7.23.4" + "@babel/helper-validator-identifier" "^7.22.20" to-fast-properties "^2.0.0" "@braintree/sanitize-url@^6.0.0": - version "6.0.2" - resolved "https://registry.yarnpkg.com/@braintree/sanitize-url/-/sanitize-url-6.0.2.tgz#6110f918d273fe2af8ea1c4398a88774bb9fc12f" - integrity sha512-Tbsj02wXCbqGmzdnXNk0SOF19ChhRU70BsroIi4Pm6Ehp56in6vch94mfbdQ17DozxkL3BAVjbZ4Qc1a0HFRAg== + version "6.0.4" + resolved "https://registry.yarnpkg.com/@braintree/sanitize-url/-/sanitize-url-6.0.4.tgz#923ca57e173c6b232bbbb07347b1be982f03e783" + integrity sha512-s3jaWicZd0pkP0jf5ysyHUI/RE7MHos6qlToFcGWXVp+ykHOy77OUMrfbgJ9it2C5bow7OIQwYYaHjk9XlBQ2A== "@colors/colors@1.5.0": version "1.5.0" @@ -1214,25 +1254,25 @@ resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz#1d572bfbbe14b7704e0ba0f39b74815b84870d70" integrity sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw== -"@docsearch/css@3.3.2": - version "3.3.2" - resolved "https://registry.yarnpkg.com/@docsearch/css/-/css-3.3.2.tgz#2c49995e6fbc7834c75f317b277ed6e4019223a4" - integrity sha512-dctFYiwbvDZkksMlsmc7pj6W6By/EjnVXJq5TEPd05MwQe+dcdHJgaIn1c8wfsucxHpIsdrUcgSkACHCq6aIhw== +"@docsearch/css@3.5.2": + version "3.5.2" + resolved "https://registry.yarnpkg.com/@docsearch/css/-/css-3.5.2.tgz#610f47b48814ca94041df969d9fcc47b91fc5aac" + integrity sha512-SPiDHaWKQZpwR2siD0KQUwlStvIAnEyK6tAE2h2Wuoq8ue9skzhlyVQ1ddzOxX6khULnAALDiR/isSF3bnuciA== "@docsearch/react@^3.1.1": - version "3.3.2" - resolved "https://registry.yarnpkg.com/@docsearch/react/-/react-3.3.2.tgz#252b659c66682f24902bf6db257f63ee73ffe8fa" - integrity sha512-ugILab2TYKSh6IEHf6Z9xZbOovsYbsdfo60PBj+Bw+oMJ1MHJ7pBt1TTcmPki1hSgg8mysgKy2hDiVdPm7XWSQ== + version "3.5.2" + resolved "https://registry.yarnpkg.com/@docsearch/react/-/react-3.5.2.tgz#2e6bbee00eb67333b64906352734da6aef1232b9" + integrity sha512-9Ahcrs5z2jq/DcAvYtvlqEBHImbm4YJI8M9y0x6Tqg598P40HTEkX7hsMcIuThI+hTFxRGZ9hll0Wygm2yEjng== dependencies: - "@algolia/autocomplete-core" "1.7.4" - "@algolia/autocomplete-preset-algolia" "1.7.4" - "@docsearch/css" "3.3.2" - algoliasearch "^4.0.0" + "@algolia/autocomplete-core" "1.9.3" + "@algolia/autocomplete-preset-algolia" "1.9.3" + "@docsearch/css" "3.5.2" + algoliasearch "^4.19.1" -"@docusaurus/core@2.4.1", "@docusaurus/core@^2.4.1": - version "2.4.1" - resolved "https://registry.yarnpkg.com/@docusaurus/core/-/core-2.4.1.tgz#4b8ff5766131ce3fbccaad0b1daf2ad4dc76f62d" - integrity sha512-SNsY7PshK3Ri7vtsLXVeAJGS50nJN3RgF836zkyUfAD01Fq+sAk5EwWgLw+nnm5KVNGDu7PRR2kRGDsWvqpo0g== +"@docusaurus/core@2.4.3", "@docusaurus/core@^2.4.1": + version "2.4.3" + resolved "https://registry.yarnpkg.com/@docusaurus/core/-/core-2.4.3.tgz#d86624901386fd8164ce4bff9cc7f16fde57f523" + integrity sha512-dWH5P7cgeNSIg9ufReX6gaCl/TmrGKD38Orbwuz05WPhAQtFXHd5B8Qym1TiXfvUNvwoYKkAJOJuGe8ou0Z7PA== dependencies: "@babel/core" "^7.18.6" "@babel/generator" "^7.18.7" @@ -1244,13 +1284,13 @@ "@babel/runtime" "^7.18.6" "@babel/runtime-corejs3" "^7.18.6" "@babel/traverse" "^7.18.8" - "@docusaurus/cssnano-preset" "2.4.1" - "@docusaurus/logger" "2.4.1" - "@docusaurus/mdx-loader" "2.4.1" + "@docusaurus/cssnano-preset" "2.4.3" + "@docusaurus/logger" "2.4.3" + "@docusaurus/mdx-loader" "2.4.3" "@docusaurus/react-loadable" "5.5.2" - "@docusaurus/utils" "2.4.1" - "@docusaurus/utils-common" "2.4.1" - "@docusaurus/utils-validation" "2.4.1" + "@docusaurus/utils" "2.4.3" + "@docusaurus/utils-common" "2.4.3" + "@docusaurus/utils-validation" "2.4.3" "@slorber/static-site-generator-webpack-plugin" "^4.0.7" "@svgr/webpack" "^6.2.1" autoprefixer "^10.4.7" @@ -1306,44 +1346,44 @@ webpack-merge "^5.8.0" webpackbar "^5.0.2" -"@docusaurus/cssnano-preset@2.4.1": - version "2.4.1" - resolved "https://registry.yarnpkg.com/@docusaurus/cssnano-preset/-/cssnano-preset-2.4.1.tgz#eacadefb1e2e0f59df3467a0fe83e4ff79eed163" - integrity sha512-ka+vqXwtcW1NbXxWsh6yA1Ckii1klY9E53cJ4O9J09nkMBgrNX3iEFED1fWdv8wf4mJjvGi5RLZ2p9hJNjsLyQ== +"@docusaurus/cssnano-preset@2.4.3": + version "2.4.3" + resolved "https://registry.yarnpkg.com/@docusaurus/cssnano-preset/-/cssnano-preset-2.4.3.tgz#1d7e833c41ce240fcc2812a2ac27f7b862f32de0" + integrity sha512-ZvGSRCi7z9wLnZrXNPG6DmVPHdKGd8dIn9pYbEOFiYihfv4uDR3UtxogmKf+rT8ZlKFf5Lqne8E8nt08zNM8CA== dependencies: cssnano-preset-advanced "^5.3.8" postcss "^8.4.14" postcss-sort-media-queries "^4.2.1" tslib "^2.4.0" -"@docusaurus/logger@2.4.1": - version "2.4.1" - resolved "https://registry.yarnpkg.com/@docusaurus/logger/-/logger-2.4.1.tgz#4d2c0626b40752641f9fdd93ad9b5a7a0792f767" - integrity sha512-5h5ysIIWYIDHyTVd8BjheZmQZmEgWDR54aQ1BX9pjFfpyzFo5puKXKYrYJXbjEHGyVhEzmB9UXwbxGfaZhOjcg== +"@docusaurus/logger@2.4.3": + version "2.4.3" + resolved "https://registry.yarnpkg.com/@docusaurus/logger/-/logger-2.4.3.tgz#518bbc965fb4ebe8f1d0b14e5f4161607552d34c" + integrity sha512-Zxws7r3yLufk9xM1zq9ged0YHs65mlRmtsobnFkdZTxWXdTYlWWLWdKyNKAsVC+D7zg+pv2fGbyabdOnyZOM3w== dependencies: chalk "^4.1.2" tslib "^2.4.0" -"@docusaurus/lqip-loader@2.4.1": - version "2.4.1" - resolved "https://registry.yarnpkg.com/@docusaurus/lqip-loader/-/lqip-loader-2.4.1.tgz#5e6a279982af898e646f042097fc4053fa15b4b8" - integrity sha512-XJ0z/xSx5HtAQ+/xBoAiRZ7DY9zEP6IImAKlAk6RxuFzyB4HT8eINWN+LwLnOsTh5boIj37JCX+T76bH0ieULA== +"@docusaurus/lqip-loader@2.4.3": + version "2.4.3" + resolved "https://registry.yarnpkg.com/@docusaurus/lqip-loader/-/lqip-loader-2.4.3.tgz#aab8b7d873317e7490f29027047a05076d499746" + integrity sha512-hdumVOGbI4eiQQsZvbbosnm86FNkp23GikNanC0MJIIz8j3sCg8I0GEmg9nnVZor/2tE4ud5AWqjsVrx1CwcjA== dependencies: - "@docusaurus/logger" "2.4.1" + "@docusaurus/logger" "2.4.3" file-loader "^6.2.0" lodash "^4.17.21" sharp "^0.30.7" tslib "^2.4.0" -"@docusaurus/mdx-loader@2.4.1": - version "2.4.1" - resolved "https://registry.yarnpkg.com/@docusaurus/mdx-loader/-/mdx-loader-2.4.1.tgz#6425075d7fc136dbfdc121349060cedd64118393" - integrity sha512-4KhUhEavteIAmbBj7LVFnrVYDiU51H5YWW1zY6SmBSte/YLhDutztLTBE0PQl1Grux1jzUJeaSvAzHpTn6JJDQ== +"@docusaurus/mdx-loader@2.4.3": + version "2.4.3" + resolved "https://registry.yarnpkg.com/@docusaurus/mdx-loader/-/mdx-loader-2.4.3.tgz#e8ff37f30a060eaa97b8121c135f74cb531a4a3e" + integrity sha512-b1+fDnWtl3GiqkL0BRjYtc94FZrcDDBV1j8446+4tptB9BAOlePwG2p/pK6vGvfL53lkOsszXMghr2g67M0vCw== dependencies: "@babel/parser" "^7.18.8" "@babel/traverse" "^7.18.8" - "@docusaurus/logger" "2.4.1" - "@docusaurus/utils" "2.4.1" + "@docusaurus/logger" "2.4.3" + "@docusaurus/utils" "2.4.3" "@mdx-js/mdx" "^1.6.22" escape-html "^1.0.3" file-loader "^6.2.0" @@ -1358,13 +1398,13 @@ url-loader "^4.1.1" webpack "^5.73.0" -"@docusaurus/module-type-aliases@2.4.1", "@docusaurus/module-type-aliases@^2.4.1": - version "2.4.1" - resolved "https://registry.yarnpkg.com/@docusaurus/module-type-aliases/-/module-type-aliases-2.4.1.tgz#38b3c2d2ae44bea6d57506eccd84280216f0171c" - integrity sha512-gLBuIFM8Dp2XOCWffUDSjtxY7jQgKvYujt7Mx5s4FCTfoL5dN1EVbnrn+O2Wvh8b0a77D57qoIDY7ghgmatR1A== +"@docusaurus/module-type-aliases@2.4.3", "@docusaurus/module-type-aliases@^2.4.1": + version "2.4.3" + resolved "https://registry.yarnpkg.com/@docusaurus/module-type-aliases/-/module-type-aliases-2.4.3.tgz#d08ef67e4151e02f352a2836bcf9ecde3b9c56ac" + integrity sha512-cwkBkt1UCiduuvEAo7XZY01dJfRn7UR/75mBgOdb1hKknhrabJZ8YH+7savd/y9kLExPyrhe0QwdS9GuzsRRIA== dependencies: "@docusaurus/react-loadable" "5.5.2" - "@docusaurus/types" "2.4.1" + "@docusaurus/types" "2.4.3" "@types/history" "^4.7.11" "@types/react" "*" "@types/react-router-config" "*" @@ -1372,18 +1412,18 @@ react-helmet-async "*" react-loadable "npm:@docusaurus/react-loadable@5.5.2" -"@docusaurus/plugin-content-blog@2.4.1": - version "2.4.1" - resolved "https://registry.yarnpkg.com/@docusaurus/plugin-content-blog/-/plugin-content-blog-2.4.1.tgz#c705a8b1a36a34f181dcf43b7770532e4dcdc4a3" - integrity sha512-E2i7Knz5YIbE1XELI6RlTnZnGgS52cUO4BlCiCUCvQHbR+s1xeIWz4C6BtaVnlug0Ccz7nFSksfwDpVlkujg5Q== - dependencies: - "@docusaurus/core" "2.4.1" - "@docusaurus/logger" "2.4.1" - "@docusaurus/mdx-loader" "2.4.1" - "@docusaurus/types" "2.4.1" - "@docusaurus/utils" "2.4.1" - "@docusaurus/utils-common" "2.4.1" - "@docusaurus/utils-validation" "2.4.1" +"@docusaurus/plugin-content-blog@2.4.3": + version "2.4.3" + resolved "https://registry.yarnpkg.com/@docusaurus/plugin-content-blog/-/plugin-content-blog-2.4.3.tgz#6473b974acab98e967414d8bbb0d37e0cedcea14" + integrity sha512-PVhypqaA0t98zVDpOeTqWUTvRqCEjJubtfFUQ7zJNYdbYTbS/E/ytq6zbLVsN/dImvemtO/5JQgjLxsh8XLo8Q== + dependencies: + "@docusaurus/core" "2.4.3" + "@docusaurus/logger" "2.4.3" + "@docusaurus/mdx-loader" "2.4.3" + "@docusaurus/types" "2.4.3" + "@docusaurus/utils" "2.4.3" + "@docusaurus/utils-common" "2.4.3" + "@docusaurus/utils-validation" "2.4.3" cheerio "^1.0.0-rc.12" feed "^4.2.2" fs-extra "^10.1.0" @@ -1394,18 +1434,18 @@ utility-types "^3.10.0" webpack "^5.73.0" -"@docusaurus/plugin-content-docs@2.4.1": - version "2.4.1" - resolved "https://registry.yarnpkg.com/@docusaurus/plugin-content-docs/-/plugin-content-docs-2.4.1.tgz#ed94d9721b5ce7a956fb01cc06c40d8eee8dfca7" - integrity sha512-Lo7lSIcpswa2Kv4HEeUcGYqaasMUQNpjTXpV0N8G6jXgZaQurqp7E8NGYeGbDXnb48czmHWbzDL4S3+BbK0VzA== - dependencies: - "@docusaurus/core" "2.4.1" - "@docusaurus/logger" "2.4.1" - "@docusaurus/mdx-loader" "2.4.1" - "@docusaurus/module-type-aliases" "2.4.1" - "@docusaurus/types" "2.4.1" - "@docusaurus/utils" "2.4.1" - "@docusaurus/utils-validation" "2.4.1" +"@docusaurus/plugin-content-docs@2.4.3": + version "2.4.3" + resolved "https://registry.yarnpkg.com/@docusaurus/plugin-content-docs/-/plugin-content-docs-2.4.3.tgz#aa224c0512351e81807adf778ca59fd9cd136973" + integrity sha512-N7Po2LSH6UejQhzTCsvuX5NOzlC+HiXOVvofnEPj0WhMu1etpLEXE6a4aTxrtg95lQ5kf0xUIdjX9sh3d3G76A== + dependencies: + "@docusaurus/core" "2.4.3" + "@docusaurus/logger" "2.4.3" + "@docusaurus/mdx-loader" "2.4.3" + "@docusaurus/module-type-aliases" "2.4.3" + "@docusaurus/types" "2.4.3" + "@docusaurus/utils" "2.4.3" + "@docusaurus/utils-validation" "2.4.3" "@types/react-router-config" "^5.0.6" combine-promises "^1.1.0" fs-extra "^10.1.0" @@ -1416,112 +1456,112 @@ utility-types "^3.10.0" webpack "^5.73.0" -"@docusaurus/plugin-content-pages@2.4.1": - version "2.4.1" - resolved "https://registry.yarnpkg.com/@docusaurus/plugin-content-pages/-/plugin-content-pages-2.4.1.tgz#c534f7e49967699a45bbe67050d1605ebbf3d285" - integrity sha512-/UjuH/76KLaUlL+o1OvyORynv6FURzjurSjvn2lbWTFc4tpYY2qLYTlKpTCBVPhlLUQsfyFnshEJDLmPneq2oA== - dependencies: - "@docusaurus/core" "2.4.1" - "@docusaurus/mdx-loader" "2.4.1" - "@docusaurus/types" "2.4.1" - "@docusaurus/utils" "2.4.1" - "@docusaurus/utils-validation" "2.4.1" +"@docusaurus/plugin-content-pages@2.4.3": + version "2.4.3" + resolved "https://registry.yarnpkg.com/@docusaurus/plugin-content-pages/-/plugin-content-pages-2.4.3.tgz#7f285e718b53da8c8d0101e70840c75b9c0a1ac0" + integrity sha512-txtDVz7y3zGk67q0HjG0gRttVPodkHqE0bpJ+7dOaTH40CQFLSh7+aBeGnPOTl+oCPG+hxkim4SndqPqXjQ8Bg== + dependencies: + "@docusaurus/core" "2.4.3" + "@docusaurus/mdx-loader" "2.4.3" + "@docusaurus/types" "2.4.3" + "@docusaurus/utils" "2.4.3" + "@docusaurus/utils-validation" "2.4.3" fs-extra "^10.1.0" tslib "^2.4.0" webpack "^5.73.0" -"@docusaurus/plugin-debug@2.4.1": - version "2.4.1" - resolved "https://registry.yarnpkg.com/@docusaurus/plugin-debug/-/plugin-debug-2.4.1.tgz#461a2c77b0c5a91b2c05257c8f9585412aaa59dc" - integrity sha512-7Yu9UPzRShlrH/G8btOpR0e6INFZr0EegWplMjOqelIwAcx3PKyR8mgPTxGTxcqiYj6hxSCRN0D8R7YrzImwNA== +"@docusaurus/plugin-debug@2.4.3": + version "2.4.3" + resolved "https://registry.yarnpkg.com/@docusaurus/plugin-debug/-/plugin-debug-2.4.3.tgz#2f90eb0c9286a9f225444e3a88315676fe02c245" + integrity sha512-LkUbuq3zCmINlFb+gAd4ZvYr+bPAzMC0hwND4F7V9bZ852dCX8YoWyovVUBKq4er1XsOwSQaHmNGtObtn8Av8Q== dependencies: - "@docusaurus/core" "2.4.1" - "@docusaurus/types" "2.4.1" - "@docusaurus/utils" "2.4.1" + "@docusaurus/core" "2.4.3" + "@docusaurus/types" "2.4.3" + "@docusaurus/utils" "2.4.3" fs-extra "^10.1.0" react-json-view "^1.21.3" tslib "^2.4.0" -"@docusaurus/plugin-google-analytics@2.4.1": - version "2.4.1" - resolved "https://registry.yarnpkg.com/@docusaurus/plugin-google-analytics/-/plugin-google-analytics-2.4.1.tgz#30de1c35773bf9d52bb2d79b201b23eb98022613" - integrity sha512-dyZJdJiCoL+rcfnm0RPkLt/o732HvLiEwmtoNzOoz9MSZz117UH2J6U2vUDtzUzwtFLIf32KkeyzisbwUCgcaQ== +"@docusaurus/plugin-google-analytics@2.4.3": + version "2.4.3" + resolved "https://registry.yarnpkg.com/@docusaurus/plugin-google-analytics/-/plugin-google-analytics-2.4.3.tgz#0d19993136ade6f7a7741251b4f617400d92ab45" + integrity sha512-KzBV3k8lDkWOhg/oYGxlK5o9bOwX7KpPc/FTWoB+SfKhlHfhq7qcQdMi1elAaVEIop8tgK6gD1E58Q+XC6otSQ== dependencies: - "@docusaurus/core" "2.4.1" - "@docusaurus/types" "2.4.1" - "@docusaurus/utils-validation" "2.4.1" + "@docusaurus/core" "2.4.3" + "@docusaurus/types" "2.4.3" + "@docusaurus/utils-validation" "2.4.3" tslib "^2.4.0" -"@docusaurus/plugin-google-gtag@2.4.1": - version "2.4.1" - resolved "https://registry.yarnpkg.com/@docusaurus/plugin-google-gtag/-/plugin-google-gtag-2.4.1.tgz#6a3eb91022714735e625c7ca70ef5188fa7bd0dc" - integrity sha512-mKIefK+2kGTQBYvloNEKtDmnRD7bxHLsBcxgnbt4oZwzi2nxCGjPX6+9SQO2KCN5HZbNrYmGo5GJfMgoRvy6uA== +"@docusaurus/plugin-google-gtag@2.4.3": + version "2.4.3" + resolved "https://registry.yarnpkg.com/@docusaurus/plugin-google-gtag/-/plugin-google-gtag-2.4.3.tgz#e1a80b0696771b488562e5b60eff21c9932d9e1c" + integrity sha512-5FMg0rT7sDy4i9AGsvJC71MQrqQZwgLNdDetLEGDHLfSHLvJhQbTCUGbGXknUgWXQJckcV/AILYeJy+HhxeIFA== dependencies: - "@docusaurus/core" "2.4.1" - "@docusaurus/types" "2.4.1" - "@docusaurus/utils-validation" "2.4.1" + "@docusaurus/core" "2.4.3" + "@docusaurus/types" "2.4.3" + "@docusaurus/utils-validation" "2.4.3" tslib "^2.4.0" -"@docusaurus/plugin-google-tag-manager@2.4.1": - version "2.4.1" - resolved "https://registry.yarnpkg.com/@docusaurus/plugin-google-tag-manager/-/plugin-google-tag-manager-2.4.1.tgz#b99f71aec00b112bbf509ef2416e404a95eb607e" - integrity sha512-Zg4Ii9CMOLfpeV2nG74lVTWNtisFaH9QNtEw48R5QE1KIwDBdTVaiSA18G1EujZjrzJJzXN79VhINSbOJO/r3g== +"@docusaurus/plugin-google-tag-manager@2.4.3": + version "2.4.3" + resolved "https://registry.yarnpkg.com/@docusaurus/plugin-google-tag-manager/-/plugin-google-tag-manager-2.4.3.tgz#e41fbf79b0ffc2de1cc4013eb77798cff0ad98e3" + integrity sha512-1jTzp71yDGuQiX9Bi0pVp3alArV0LSnHXempvQTxwCGAEzUWWaBg4d8pocAlTpbP9aULQQqhgzrs8hgTRPOM0A== dependencies: - "@docusaurus/core" "2.4.1" - "@docusaurus/types" "2.4.1" - "@docusaurus/utils-validation" "2.4.1" + "@docusaurus/core" "2.4.3" + "@docusaurus/types" "2.4.3" + "@docusaurus/utils-validation" "2.4.3" tslib "^2.4.0" "@docusaurus/plugin-ideal-image@^2.4.1": - version "2.4.1" - resolved "https://registry.yarnpkg.com/@docusaurus/plugin-ideal-image/-/plugin-ideal-image-2.4.1.tgz#110e9814ad3af66235c849d2e00c9e84f552c961" - integrity sha512-jxvgCGPmHxdae2Y2uskzxIbMCA4WLTfzkufsLbD4mEAjCRIkt6yzux6q5kqKTrO+AxzpANVcJNGmaBtKZGv5aw== + version "2.4.3" + resolved "https://registry.yarnpkg.com/@docusaurus/plugin-ideal-image/-/plugin-ideal-image-2.4.3.tgz#b4988f4e82c3351596c54474eb35bddd9c827deb" + integrity sha512-cwnOKz5HwR/WwNL5lzGOWppyhaHQ2dPj1/x9hwv5VPwNmDDnWsYEwfBOTq8AYT27vFrYAH1tx9UX7QurRaIa4A== dependencies: - "@docusaurus/core" "2.4.1" - "@docusaurus/lqip-loader" "2.4.1" + "@docusaurus/core" "2.4.3" + "@docusaurus/lqip-loader" "2.4.3" "@docusaurus/responsive-loader" "^1.7.0" - "@docusaurus/theme-translations" "2.4.1" - "@docusaurus/types" "2.4.1" - "@docusaurus/utils-validation" "2.4.1" + "@docusaurus/theme-translations" "2.4.3" + "@docusaurus/types" "2.4.3" + "@docusaurus/utils-validation" "2.4.3" "@endiliey/react-ideal-image" "^0.0.11" react-waypoint "^10.3.0" sharp "^0.30.7" tslib "^2.4.0" webpack "^5.73.0" -"@docusaurus/plugin-sitemap@2.4.1": - version "2.4.1" - resolved "https://registry.yarnpkg.com/@docusaurus/plugin-sitemap/-/plugin-sitemap-2.4.1.tgz#8a7a76ed69dc3e6b4474b6abb10bb03336a9de6d" - integrity sha512-lZx+ijt/+atQ3FVE8FOHV/+X3kuok688OydDXrqKRJyXBJZKgGjA2Qa8RjQ4f27V2woaXhtnyrdPop/+OjVMRg== - dependencies: - "@docusaurus/core" "2.4.1" - "@docusaurus/logger" "2.4.1" - "@docusaurus/types" "2.4.1" - "@docusaurus/utils" "2.4.1" - "@docusaurus/utils-common" "2.4.1" - "@docusaurus/utils-validation" "2.4.1" +"@docusaurus/plugin-sitemap@2.4.3": + version "2.4.3" + resolved "https://registry.yarnpkg.com/@docusaurus/plugin-sitemap/-/plugin-sitemap-2.4.3.tgz#1b3930900a8f89670ce7e8f83fb4730cd3298c32" + integrity sha512-LRQYrK1oH1rNfr4YvWBmRzTL0LN9UAPxBbghgeFRBm5yloF6P+zv1tm2pe2hQTX/QP5bSKdnajCvfnScgKXMZQ== + dependencies: + "@docusaurus/core" "2.4.3" + "@docusaurus/logger" "2.4.3" + "@docusaurus/types" "2.4.3" + "@docusaurus/utils" "2.4.3" + "@docusaurus/utils-common" "2.4.3" + "@docusaurus/utils-validation" "2.4.3" fs-extra "^10.1.0" sitemap "^7.1.1" tslib "^2.4.0" "@docusaurus/preset-classic@^2.4.1": - version "2.4.1" - resolved "https://registry.yarnpkg.com/@docusaurus/preset-classic/-/preset-classic-2.4.1.tgz#072f22d0332588e9c5f512d4bded8d7c99f91497" - integrity sha512-P4//+I4zDqQJ+UDgoFrjIFaQ1MeS9UD1cvxVQaI6O7iBmiHQm0MGROP1TbE7HlxlDPXFJjZUK3x3cAoK63smGQ== - dependencies: - "@docusaurus/core" "2.4.1" - "@docusaurus/plugin-content-blog" "2.4.1" - "@docusaurus/plugin-content-docs" "2.4.1" - "@docusaurus/plugin-content-pages" "2.4.1" - "@docusaurus/plugin-debug" "2.4.1" - "@docusaurus/plugin-google-analytics" "2.4.1" - "@docusaurus/plugin-google-gtag" "2.4.1" - "@docusaurus/plugin-google-tag-manager" "2.4.1" - "@docusaurus/plugin-sitemap" "2.4.1" - "@docusaurus/theme-classic" "2.4.1" - "@docusaurus/theme-common" "2.4.1" - "@docusaurus/theme-search-algolia" "2.4.1" - "@docusaurus/types" "2.4.1" + version "2.4.3" + resolved "https://registry.yarnpkg.com/@docusaurus/preset-classic/-/preset-classic-2.4.3.tgz#074c57ebf29fa43d23bd1c8ce691226f542bc262" + integrity sha512-tRyMliepY11Ym6hB1rAFSNGwQDpmszvWYJvlK1E+md4SW8i6ylNHtpZjaYFff9Mdk3i/Pg8ItQq9P0daOJAvQw== + dependencies: + "@docusaurus/core" "2.4.3" + "@docusaurus/plugin-content-blog" "2.4.3" + "@docusaurus/plugin-content-docs" "2.4.3" + "@docusaurus/plugin-content-pages" "2.4.3" + "@docusaurus/plugin-debug" "2.4.3" + "@docusaurus/plugin-google-analytics" "2.4.3" + "@docusaurus/plugin-google-gtag" "2.4.3" + "@docusaurus/plugin-google-tag-manager" "2.4.3" + "@docusaurus/plugin-sitemap" "2.4.3" + "@docusaurus/theme-classic" "2.4.3" + "@docusaurus/theme-common" "2.4.3" + "@docusaurus/theme-search-algolia" "2.4.3" + "@docusaurus/types" "2.4.3" "@docusaurus/react-loadable@5.5.2", "react-loadable@npm:@docusaurus/react-loadable@5.5.2": version "5.5.2" @@ -1538,23 +1578,23 @@ dependencies: loader-utils "^2.0.0" -"@docusaurus/theme-classic@2.4.1": - version "2.4.1" - resolved "https://registry.yarnpkg.com/@docusaurus/theme-classic/-/theme-classic-2.4.1.tgz#0060cb263c1a73a33ac33f79bb6bc2a12a56ad9e" - integrity sha512-Rz0wKUa+LTW1PLXmwnf8mn85EBzaGSt6qamqtmnh9Hflkc+EqiYMhtUJeLdV+wsgYq4aG0ANc+bpUDpsUhdnwg== - dependencies: - "@docusaurus/core" "2.4.1" - "@docusaurus/mdx-loader" "2.4.1" - "@docusaurus/module-type-aliases" "2.4.1" - "@docusaurus/plugin-content-blog" "2.4.1" - "@docusaurus/plugin-content-docs" "2.4.1" - "@docusaurus/plugin-content-pages" "2.4.1" - "@docusaurus/theme-common" "2.4.1" - "@docusaurus/theme-translations" "2.4.1" - "@docusaurus/types" "2.4.1" - "@docusaurus/utils" "2.4.1" - "@docusaurus/utils-common" "2.4.1" - "@docusaurus/utils-validation" "2.4.1" +"@docusaurus/theme-classic@2.4.3": + version "2.4.3" + resolved "https://registry.yarnpkg.com/@docusaurus/theme-classic/-/theme-classic-2.4.3.tgz#29360f2eb03a0e1686eb19668633ef313970ee8f" + integrity sha512-QKRAJPSGPfDY2yCiPMIVyr+MqwZCIV2lxNzqbyUW0YkrlmdzzP3WuQJPMGLCjWgQp/5c9kpWMvMxjhpZx1R32Q== + dependencies: + "@docusaurus/core" "2.4.3" + "@docusaurus/mdx-loader" "2.4.3" + "@docusaurus/module-type-aliases" "2.4.3" + "@docusaurus/plugin-content-blog" "2.4.3" + "@docusaurus/plugin-content-docs" "2.4.3" + "@docusaurus/plugin-content-pages" "2.4.3" + "@docusaurus/theme-common" "2.4.3" + "@docusaurus/theme-translations" "2.4.3" + "@docusaurus/types" "2.4.3" + "@docusaurus/utils" "2.4.3" + "@docusaurus/utils-common" "2.4.3" + "@docusaurus/utils-validation" "2.4.3" "@mdx-js/react" "^1.6.22" clsx "^1.2.1" copy-text-to-clipboard "^3.0.1" @@ -1569,18 +1609,18 @@ tslib "^2.4.0" utility-types "^3.10.0" -"@docusaurus/theme-common@2.4.1": - version "2.4.1" - resolved "https://registry.yarnpkg.com/@docusaurus/theme-common/-/theme-common-2.4.1.tgz#03e16f7aa96455e952f3243ac99757b01a3c83d4" - integrity sha512-G7Zau1W5rQTaFFB3x3soQoZpkgMbl/SYNG8PfMFIjKa3M3q8n0m/GRf5/H/e5BqOvt8c+ZWIXGCiz+kUCSHovA== - dependencies: - "@docusaurus/mdx-loader" "2.4.1" - "@docusaurus/module-type-aliases" "2.4.1" - "@docusaurus/plugin-content-blog" "2.4.1" - "@docusaurus/plugin-content-docs" "2.4.1" - "@docusaurus/plugin-content-pages" "2.4.1" - "@docusaurus/utils" "2.4.1" - "@docusaurus/utils-common" "2.4.1" +"@docusaurus/theme-common@2.4.3": + version "2.4.3" + resolved "https://registry.yarnpkg.com/@docusaurus/theme-common/-/theme-common-2.4.3.tgz#bb31d70b6b67d0bdef9baa343192dcec49946a2e" + integrity sha512-7KaDJBXKBVGXw5WOVt84FtN8czGWhM0lbyWEZXGp8AFfL6sZQfRTluFp4QriR97qwzSyOfQb+nzcDZZU4tezUw== + dependencies: + "@docusaurus/mdx-loader" "2.4.3" + "@docusaurus/module-type-aliases" "2.4.3" + "@docusaurus/plugin-content-blog" "2.4.3" + "@docusaurus/plugin-content-docs" "2.4.3" + "@docusaurus/plugin-content-pages" "2.4.3" + "@docusaurus/utils" "2.4.3" + "@docusaurus/utils-common" "2.4.3" "@types/history" "^4.7.11" "@types/react" "*" "@types/react-router-config" "*" @@ -1592,32 +1632,32 @@ utility-types "^3.10.0" "@docusaurus/theme-mermaid@^2.4.1": - version "2.4.1" - resolved "https://registry.yarnpkg.com/@docusaurus/theme-mermaid/-/theme-mermaid-2.4.1.tgz#6bf644f9f7ef3db0e938b484f510d6d80d601419" - integrity sha512-cM0ImKIqZfjmlaC+uAjep39kNBvb1bjz429QBHGs32maob4+UnRzVPPpCUCltyPVb4xjG5h1Tyq4pHzhtIikqA== - dependencies: - "@docusaurus/core" "2.4.1" - "@docusaurus/module-type-aliases" "2.4.1" - "@docusaurus/theme-common" "2.4.1" - "@docusaurus/types" "2.4.1" - "@docusaurus/utils-validation" "2.4.1" + version "2.4.3" + resolved "https://registry.yarnpkg.com/@docusaurus/theme-mermaid/-/theme-mermaid-2.4.3.tgz#b40194fb4f46813a18d1350a188d43b68a8192dd" + integrity sha512-S1tZ3xpowtFiTrpTKmvVbRHUYGOlEG5CnPzWlO4huJT1sAwLR+pD6f9DYUlPv2+9NezF3EfUrUyW9xLH0UP58w== + dependencies: + "@docusaurus/core" "2.4.3" + "@docusaurus/module-type-aliases" "2.4.3" + "@docusaurus/theme-common" "2.4.3" + "@docusaurus/types" "2.4.3" + "@docusaurus/utils-validation" "2.4.3" "@mdx-js/react" "^1.6.22" mermaid "^9.2.2" tslib "^2.4.0" -"@docusaurus/theme-search-algolia@2.4.1": - version "2.4.1" - resolved "https://registry.yarnpkg.com/@docusaurus/theme-search-algolia/-/theme-search-algolia-2.4.1.tgz#906bd2cca3fced0241985ef502c892f58ff380fc" - integrity sha512-6BcqW2lnLhZCXuMAvPRezFs1DpmEKzXFKlYjruuas+Xy3AQeFzDJKTJFIm49N77WFCTyxff8d3E4Q9pi/+5McQ== +"@docusaurus/theme-search-algolia@2.4.3": + version "2.4.3" + resolved "https://registry.yarnpkg.com/@docusaurus/theme-search-algolia/-/theme-search-algolia-2.4.3.tgz#32d4cbefc3deba4112068fbdb0bde11ac51ece53" + integrity sha512-jziq4f6YVUB5hZOB85ELATwnxBz/RmSLD3ksGQOLDPKVzat4pmI8tddNWtriPpxR04BNT+ZfpPUMFkNFetSW1Q== dependencies: "@docsearch/react" "^3.1.1" - "@docusaurus/core" "2.4.1" - "@docusaurus/logger" "2.4.1" - "@docusaurus/plugin-content-docs" "2.4.1" - "@docusaurus/theme-common" "2.4.1" - "@docusaurus/theme-translations" "2.4.1" - "@docusaurus/utils" "2.4.1" - "@docusaurus/utils-validation" "2.4.1" + "@docusaurus/core" "2.4.3" + "@docusaurus/logger" "2.4.3" + "@docusaurus/plugin-content-docs" "2.4.3" + "@docusaurus/theme-common" "2.4.3" + "@docusaurus/theme-translations" "2.4.3" + "@docusaurus/utils" "2.4.3" + "@docusaurus/utils-validation" "2.4.3" algoliasearch "^4.13.1" algoliasearch-helper "^3.10.0" clsx "^1.2.1" @@ -1627,18 +1667,18 @@ tslib "^2.4.0" utility-types "^3.10.0" -"@docusaurus/theme-translations@2.4.1": - version "2.4.1" - resolved "https://registry.yarnpkg.com/@docusaurus/theme-translations/-/theme-translations-2.4.1.tgz#4d49df5865dae9ef4b98a19284ede62ae6f98726" - integrity sha512-T1RAGP+f86CA1kfE8ejZ3T3pUU3XcyvrGMfC/zxCtc2BsnoexuNI9Vk2CmuKCb+Tacvhxjv5unhxXce0+NKyvA== +"@docusaurus/theme-translations@2.4.3": + version "2.4.3" + resolved "https://registry.yarnpkg.com/@docusaurus/theme-translations/-/theme-translations-2.4.3.tgz#91ac73fc49b8c652b7a54e88b679af57d6ac6102" + integrity sha512-H4D+lbZbjbKNS/Zw1Lel64PioUAIT3cLYYJLUf3KkuO/oc9e0QCVhIYVtUI2SfBCF2NNdlyhBDQEEMygsCedIg== dependencies: fs-extra "^10.1.0" tslib "^2.4.0" -"@docusaurus/types@2.4.1": - version "2.4.1" - resolved "https://registry.yarnpkg.com/@docusaurus/types/-/types-2.4.1.tgz#d8e82f9e0f704984f98df1f93d6b4554d5458705" - integrity sha512-0R+cbhpMkhbRXX138UOc/2XZFF8hiZa6ooZAEEJFp5scytzCw4tC1gChMFXrpa3d2tYE6AX8IrOEpSonLmfQuQ== +"@docusaurus/types@2.4.3": + version "2.4.3" + resolved "https://registry.yarnpkg.com/@docusaurus/types/-/types-2.4.3.tgz#4aead281ca09f721b3c0a9b926818450cfa3db31" + integrity sha512-W6zNLGQqfrp/EoPD0bhb9n7OobP+RHpmvVzpA+Z/IuU3Q63njJM24hmT0GYboovWcDtFmnIJC9wcyx4RVPQscw== dependencies: "@types/history" "^4.7.11" "@types/react" "*" @@ -1649,30 +1689,30 @@ webpack "^5.73.0" webpack-merge "^5.8.0" -"@docusaurus/utils-common@2.4.1": - version "2.4.1" - resolved "https://registry.yarnpkg.com/@docusaurus/utils-common/-/utils-common-2.4.1.tgz#7f72e873e49bd5179588869cc3ab7449a56aae63" - integrity sha512-bCVGdZU+z/qVcIiEQdyx0K13OC5mYwxhSuDUR95oFbKVuXYRrTVrwZIqQljuo1fyJvFTKHiL9L9skQOPokuFNQ== +"@docusaurus/utils-common@2.4.3": + version "2.4.3" + resolved "https://registry.yarnpkg.com/@docusaurus/utils-common/-/utils-common-2.4.3.tgz#30656c39ef1ce7e002af7ba39ea08330f58efcfb" + integrity sha512-/jascp4GbLQCPVmcGkPzEQjNaAk3ADVfMtudk49Ggb+131B1WDD6HqlSmDf8MxGdy7Dja2gc+StHf01kiWoTDQ== dependencies: tslib "^2.4.0" -"@docusaurus/utils-validation@2.4.1": - version "2.4.1" - resolved "https://registry.yarnpkg.com/@docusaurus/utils-validation/-/utils-validation-2.4.1.tgz#19959856d4a886af0c5cfb357f4ef68b51151244" - integrity sha512-unII3hlJlDwZ3w8U+pMO3Lx3RhI4YEbY3YNsQj4yzrkZzlpqZOLuAiZK2JyULnD+TKbceKU0WyWkQXtYbLNDFA== +"@docusaurus/utils-validation@2.4.3": + version "2.4.3" + resolved "https://registry.yarnpkg.com/@docusaurus/utils-validation/-/utils-validation-2.4.3.tgz#8122c394feef3e96c73f6433987837ec206a63fb" + integrity sha512-G2+Vt3WR5E/9drAobP+hhZQMaswRwDlp6qOMi7o7ZypB+VO7N//DZWhZEwhcRGepMDJGQEwtPv7UxtYwPL9PBw== dependencies: - "@docusaurus/logger" "2.4.1" - "@docusaurus/utils" "2.4.1" + "@docusaurus/logger" "2.4.3" + "@docusaurus/utils" "2.4.3" joi "^17.6.0" js-yaml "^4.1.0" tslib "^2.4.0" -"@docusaurus/utils@2.4.1": - version "2.4.1" - resolved "https://registry.yarnpkg.com/@docusaurus/utils/-/utils-2.4.1.tgz#9c5f76eae37b71f3819c1c1f0e26e6807c99a4fc" - integrity sha512-1lvEZdAQhKNht9aPXPoh69eeKnV0/62ROhQeFKKxmzd0zkcuE/Oc5Gpnt00y/f5bIsmOsYMY7Pqfm/5rteT5GA== +"@docusaurus/utils@2.4.3": + version "2.4.3" + resolved "https://registry.yarnpkg.com/@docusaurus/utils/-/utils-2.4.3.tgz#52b000d989380a2125831b84e3a7327bef471e89" + integrity sha512-fKcXsjrD86Smxv8Pt0TBFqYieZZCPh4cbf9oszUq/AMhZn3ujwpKaVYZACPX8mmjtYx0JOgNx52CREBfiGQB4A== dependencies: - "@docusaurus/logger" "2.4.1" + "@docusaurus/logger" "2.4.3" "@svgr/webpack" "^6.2.1" escape-string-regexp "^4.0.0" file-loader "^6.2.0" @@ -1694,84 +1734,76 @@ resolved "https://registry.yarnpkg.com/@endiliey/react-ideal-image/-/react-ideal-image-0.0.11.tgz#dc3803d04e1409cf88efa4bba0f67667807bdf27" integrity sha512-QxMjt/Gvur/gLxSoCy7VIyGGGrGmDN+VHcXkN3R2ApoWX0EYUE+hMgPHSW/PV6VVebZ1Nd4t2UnGRBDihu16JQ== -"@hapi/hoek@^9.0.0": +"@hapi/hoek@^9.0.0", "@hapi/hoek@^9.3.0": version "9.3.0" resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.3.0.tgz#8368869dcb735be2e7f5cb7647de78e167a251fb" integrity sha512-/c6rf4UJlmHlC9b5BaNvzAcFv7HZ2QHaV0D4/HNlBdvFnvQq8RI4kYdhyPCl7Xj+oWvTWQ8ujhqS53LIgAe6KQ== -"@hapi/topo@^5.0.0": +"@hapi/topo@^5.1.0": version "5.1.0" resolved "https://registry.yarnpkg.com/@hapi/topo/-/topo-5.1.0.tgz#dc448e332c6c6e37a4dc02fd84ba8d44b9afb012" integrity sha512-foQZKJig7Ob0BMAYBfcJk8d77QtOe7Wo4ox7ff1lQYoNNAb6jwcY1ncdoy2e9wQZzvNy7ODZCYJkK8kzmcAnAg== dependencies: "@hapi/hoek" "^9.0.0" -"@jest/schemas@^29.4.3": - version "29.4.3" - resolved "https://registry.yarnpkg.com/@jest/schemas/-/schemas-29.4.3.tgz#39cf1b8469afc40b6f5a2baaa146e332c4151788" - integrity sha512-VLYKXQmtmuEz6IxJsrZwzG9NvtkQsWNnWMsKxqWNu3+CnfzJQhp0WDDKWLVV9hLKr0l3SLLFRqcYHjhtyuDVxg== +"@jest/schemas@^29.6.3": + version "29.6.3" + resolved "https://registry.yarnpkg.com/@jest/schemas/-/schemas-29.6.3.tgz#430b5ce8a4e0044a7e3819663305a7b3091c8e03" + integrity sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA== dependencies: - "@sinclair/typebox" "^0.25.16" + "@sinclair/typebox" "^0.27.8" -"@jest/types@^29.5.0": - version "29.5.0" - resolved "https://registry.yarnpkg.com/@jest/types/-/types-29.5.0.tgz#f59ef9b031ced83047c67032700d8c807d6e1593" - integrity sha512-qbu7kN6czmVRc3xWFQcAN03RAUamgppVUdXrvl1Wr3jlNF93o9mJbGcDWrwGB6ht44u7efB1qCFgVQmca24Uog== +"@jest/types@^29.6.3": + version "29.6.3" + resolved "https://registry.yarnpkg.com/@jest/types/-/types-29.6.3.tgz#1131f8cf634e7e84c5e77bab12f052af585fba59" + integrity sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw== dependencies: - "@jest/schemas" "^29.4.3" + "@jest/schemas" "^29.6.3" "@types/istanbul-lib-coverage" "^2.0.0" "@types/istanbul-reports" "^3.0.0" "@types/node" "*" "@types/yargs" "^17.0.8" chalk "^4.0.0" -"@jridgewell/gen-mapping@^0.1.0": - version "0.1.1" - resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz#e5d2e450306a9491e3bd77e323e38d7aff315996" - integrity sha512-sQXCasFk+U8lWYEe66WxRDOE9PjVz4vSM51fTu3Hw+ClTpUSQb718772vH3pyS5pShp6lvQM7SxgIDXXXmOX7w== - dependencies: - "@jridgewell/set-array" "^1.0.0" - "@jridgewell/sourcemap-codec" "^1.4.10" - "@jridgewell/gen-mapping@^0.3.0", "@jridgewell/gen-mapping@^0.3.2": - version "0.3.2" - resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz#c1aedc61e853f2bb9f5dfe6d4442d3b565b253b9" - integrity sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A== + version "0.3.3" + resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz#7e02e6eb5df901aaedb08514203b096614024098" + integrity sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ== dependencies: "@jridgewell/set-array" "^1.0.1" "@jridgewell/sourcemap-codec" "^1.4.10" "@jridgewell/trace-mapping" "^0.3.9" -"@jridgewell/resolve-uri@3.1.0": - version "3.1.0" - resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz#2203b118c157721addfe69d47b70465463066d78" - integrity sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w== +"@jridgewell/resolve-uri@^3.1.0": + version "3.1.1" + resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz#c08679063f279615a3326583ba3a90d1d82cc721" + integrity sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA== -"@jridgewell/set-array@^1.0.0", "@jridgewell/set-array@^1.0.1": +"@jridgewell/set-array@^1.0.1": version "1.1.2" resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.2.tgz#7c6cf998d6d20b914c0a55a91ae928ff25965e72" integrity sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw== -"@jridgewell/source-map@^0.3.2": - version "0.3.2" - resolved "https://registry.yarnpkg.com/@jridgewell/source-map/-/source-map-0.3.2.tgz#f45351aaed4527a298512ec72f81040c998580fb" - integrity sha512-m7O9o2uR8k2ObDysZYzdfhb08VuEml5oWGiosa1VdaPZ/A6QyPkAJuwN0Q1lhULOf6B7MtQmHENS743hWtCrgw== +"@jridgewell/source-map@^0.3.3": + version "0.3.5" + resolved "https://registry.yarnpkg.com/@jridgewell/source-map/-/source-map-0.3.5.tgz#a3bb4d5c6825aab0d281268f47f6ad5853431e91" + integrity sha512-UTYAUj/wviwdsMfzoSJspJxbkH5o1snzwX0//0ENX1u/55kkZZkcTZP6u9bwKGkv+dkk9at4m1Cpt0uY80kcpQ== dependencies: "@jridgewell/gen-mapping" "^0.3.0" "@jridgewell/trace-mapping" "^0.3.9" -"@jridgewell/sourcemap-codec@1.4.14", "@jridgewell/sourcemap-codec@^1.4.10": - version "1.4.14" - resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24" - integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw== +"@jridgewell/sourcemap-codec@^1.4.10", "@jridgewell/sourcemap-codec@^1.4.14": + version "1.4.15" + resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz#d7c6e6755c78567a951e04ab52ef0fd26de59f32" + integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg== -"@jridgewell/trace-mapping@^0.3.14", "@jridgewell/trace-mapping@^0.3.17", "@jridgewell/trace-mapping@^0.3.9": - version "0.3.17" - resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.17.tgz#793041277af9073b0951a7fe0f0d8c4c98c36985" - integrity sha512-MCNzAp77qzKca9+W/+I0+sEpaUnZoeasnghNeVc41VZCEKaCH73Vq3BZZ/SzWIgrqE4H4ceI+p+b6C0mHf9T4g== +"@jridgewell/trace-mapping@^0.3.17", "@jridgewell/trace-mapping@^0.3.20", "@jridgewell/trace-mapping@^0.3.9": + version "0.3.21" + resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.21.tgz#5dc1df7b3dc4a6209e503a924e1ca56097a2bb15" + integrity sha512-SRfKmRe1KvYnxjEMtxEr+J4HIeMX5YBg/qhRHpxEIGjhX1rshcHlnFUE9K0GazhVKWM7B+nARSkV8LuvJdJ5/g== dependencies: - "@jridgewell/resolve-uri" "3.1.0" - "@jridgewell/sourcemap-codec" "1.4.14" + "@jridgewell/resolve-uri" "^3.1.0" + "@jridgewell/sourcemap-codec" "^1.4.14" "@leichtgewicht/ip-codec@^2.0.1": version "2.0.4" @@ -1834,12 +1866,12 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" -"@polka/url@^1.0.0-next.20": - version "1.0.0-next.21" - resolved "https://registry.yarnpkg.com/@polka/url/-/url-1.0.0-next.21.tgz#5de5a2385a35309427f6011992b544514d559aa1" - integrity sha512-a5Sab1C4/icpTZVzZc5Ghpz88yQtGOyNqYXcZgOssB2uuAr+wF/MvN6bgtW32q7HHrvBki+BsZ0OuNv6EV3K9g== +"@polka/url@^1.0.0-next.24": + version "1.0.0-next.24" + resolved "https://registry.yarnpkg.com/@polka/url/-/url-1.0.0-next.24.tgz#58601079e11784d20f82d0585865bb42305c4df3" + integrity sha512-2LuNTFBIO0m7kKIQvvPHN6UE63VjpmL9rnEEaOOaiSPbZK+zUOYIzBAWcED+3XYzhYsd/0mD57VdxAEqqV52CQ== -"@sideway/address@^4.1.3": +"@sideway/address@^4.1.4": version "4.1.4" resolved "https://registry.yarnpkg.com/@sideway/address/-/address-4.1.4.tgz#03dccebc6ea47fdc226f7d3d1ad512955d4783f0" integrity sha512-7vwq+rOHVWjyXxVlR76Agnvhy8I9rpzjosTESvmhNeXOXdZZB15Fl+TI9x1SiHZH5Jv2wTGduSxFDIaq0m3DUw== @@ -1856,10 +1888,10 @@ resolved "https://registry.yarnpkg.com/@sideway/pinpoint/-/pinpoint-2.0.0.tgz#cff8ffadc372ad29fd3f78277aeb29e632cc70df" integrity sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ== -"@sinclair/typebox@^0.25.16": - version "0.25.24" - resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.25.24.tgz#8c7688559979f7079aacaf31aa881c3aa410b718" - integrity sha512-XJfwUVUKDHF5ugKwIcxEgc9k8b7HbznCp6eUfWgu710hMPNIO4aw4/zB5RogDQz8nd6gyCDpU9O/m6qYEWY6yQ== +"@sinclair/typebox@^0.27.8": + version "0.27.8" + resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.27.8.tgz#6667fac16c436b5434a387a34dedb013198f6e6e" + integrity sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA== "@sindresorhus/is@^0.14.0": version "0.14.0" @@ -1881,14 +1913,14 @@ integrity sha512-9PYGcXrAxitycIjRmZB+Q0JaN07GZIWaTBIGQzfaZv+qr1n8X1XUEJ5rZ/vx6OVD9RRYlrNnXWExQXcmZeD/BQ== "@svgr/babel-plugin-remove-jsx-attribute@*": - version "6.5.0" - resolved "https://registry.yarnpkg.com/@svgr/babel-plugin-remove-jsx-attribute/-/babel-plugin-remove-jsx-attribute-6.5.0.tgz#652bfd4ed0a0699843585cda96faeb09d6e1306e" - integrity sha512-8zYdkym7qNyfXpWvu4yq46k41pyNM9SOstoWhKlm+IfdCE1DdnRKeMUPsWIEO/DEkaWxJ8T9esNdG3QwQ93jBA== + version "8.0.0" + resolved "https://registry.yarnpkg.com/@svgr/babel-plugin-remove-jsx-attribute/-/babel-plugin-remove-jsx-attribute-8.0.0.tgz#69177f7937233caca3a1afb051906698f2f59186" + integrity sha512-BcCkm/STipKvbCl6b7QFrMh/vx00vIP63k2eM66MfHJzPr6O2U0jYEViXkHJWqXqQYjdeA9cuCl5KWmlwjDvbA== "@svgr/babel-plugin-remove-jsx-empty-expression@*": - version "6.5.0" - resolved "https://registry.yarnpkg.com/@svgr/babel-plugin-remove-jsx-empty-expression/-/babel-plugin-remove-jsx-empty-expression-6.5.0.tgz#4b78994ab7d39032c729903fc2dd5c0fa4565cb8" - integrity sha512-NFdxMq3xA42Kb1UbzCVxplUc0iqSyM9X8kopImvFnB+uSDdzIHOdbs1op8ofAvVRtbg4oZiyRl3fTYeKcOe9Iw== + version "8.0.0" + resolved "https://registry.yarnpkg.com/@svgr/babel-plugin-remove-jsx-empty-expression/-/babel-plugin-remove-jsx-empty-expression-8.0.0.tgz#c2c48104cfd7dcd557f373b70a56e9e3bdae1d44" + integrity sha512-5BcGCBfBxB5+XSDSWnhTThfI9jcO5f0Ai2V24gZpG+wXF14BzwxxdDb4g6trdOux0rhibGs385BeFMSmxtS3uA== "@svgr/babel-plugin-replace-jsx-attribute-value@^6.5.1": version "6.5.1" @@ -1994,79 +2026,75 @@ integrity sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA== "@tsconfig/docusaurus@^1.0.5": - version "1.0.6" - resolved "https://registry.yarnpkg.com/@tsconfig/docusaurus/-/docusaurus-1.0.6.tgz#7305a7fa590decc0d5968500234e95fd68788978" - integrity sha512-1QxDaP54hpzM6bq9E+yFEo4F9WbWHhsDe4vktZXF/iDlc9FqGr9qlg+3X/nuKQXx8QxHV7ue8NXFazzajsxFBA== + version "1.0.7" + resolved "https://registry.yarnpkg.com/@tsconfig/docusaurus/-/docusaurus-1.0.7.tgz#a3ee3c8109b3fec091e3d61a61834e563aeee3c3" + integrity sha512-ffTXxGIP/IRMCjuzHd6M4/HdIrw1bMfC7Bv8hMkTadnePkpe0lG0oDSdbRpSDZb2rQMAgpbWiR10BvxvNYwYrg== "@types/body-parser@*": - version "1.19.2" - resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.19.2.tgz#aea2059e28b7658639081347ac4fab3de166e6f0" - integrity sha512-ALYone6pm6QmwZoAgeyNksccT9Q4AWZQ6PvfwR37GT6r6FWUPguq6sUmNGSMV2Wr761oQoBxwGGa6DR5o1DC9g== + version "1.19.5" + resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.19.5.tgz#04ce9a3b677dc8bd681a17da1ab9835dc9d3ede4" + integrity sha512-fB3Zu92ucau0iQ0JMCFQE7b/dv8Ot07NI3KaZIkIUNXq82k4eBAqUaneXfleGY9JWskeS9y+u0nXMyspcuQrCg== dependencies: "@types/connect" "*" "@types/node" "*" "@types/bonjour@^3.5.9": - version "3.5.10" - resolved "https://registry.yarnpkg.com/@types/bonjour/-/bonjour-3.5.10.tgz#0f6aadfe00ea414edc86f5d106357cda9701e275" - integrity sha512-p7ienRMiS41Nu2/igbJxxLDWrSZ0WxM8UQgCeO9KhoVF7cOVFkrKsiDr1EsJIla8vV3oEEjGcz11jc5yimhzZw== + version "3.5.13" + resolved "https://registry.yarnpkg.com/@types/bonjour/-/bonjour-3.5.13.tgz#adf90ce1a105e81dd1f9c61fdc5afda1bfb92956" + integrity sha512-z9fJ5Im06zvUL548KvYNecEVlA7cVDkGUi6kZusb04mpyEFKCIZJvloCcmpmLaIahDpOQGHaHmG6imtPMmPXGQ== dependencies: "@types/node" "*" "@types/connect-history-api-fallback@^1.3.5": - version "1.3.5" - resolved "https://registry.yarnpkg.com/@types/connect-history-api-fallback/-/connect-history-api-fallback-1.3.5.tgz#d1f7a8a09d0ed5a57aee5ae9c18ab9b803205dae" - integrity sha512-h8QJa8xSb1WD4fpKBDcATDNGXghFj6/3GRWG6dhmRcu0RX1Ubasur2Uvx5aeEwlf0MwblEC2bMzzMQntxnw/Cw== + version "1.5.4" + resolved "https://registry.yarnpkg.com/@types/connect-history-api-fallback/-/connect-history-api-fallback-1.5.4.tgz#7de71645a103056b48ac3ce07b3520b819c1d5b3" + integrity sha512-n6Cr2xS1h4uAulPRdlw6Jl6s1oG8KrVilPN2yUITEs+K48EzMJJ3W1xy8K5eWuFvjp3R74AOIGSmp2UfBJ8HFw== dependencies: "@types/express-serve-static-core" "*" "@types/node" "*" "@types/connect@*": - version "3.4.35" - resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.35.tgz#5fcf6ae445e4021d1fc2219a4873cc73a3bb2ad1" - integrity sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ== + version "3.4.38" + resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.38.tgz#5ba7f3bc4fbbdeaff8dded952e5ff2cc53f8d858" + integrity sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug== dependencies: "@types/node" "*" "@types/eslint-scope@^3.7.3": - version "3.7.4" - resolved "https://registry.yarnpkg.com/@types/eslint-scope/-/eslint-scope-3.7.4.tgz#37fc1223f0786c39627068a12e94d6e6fc61de16" - integrity sha512-9K4zoImiZc3HlIp6AVUDE4CWYx22a+lhSZMYNpbjW04+YF0KWj4pJXnEMjdnFTiQibFFmElcsasJXDbdI/EPhA== + version "3.7.7" + resolved "https://registry.yarnpkg.com/@types/eslint-scope/-/eslint-scope-3.7.7.tgz#3108bd5f18b0cdb277c867b3dd449c9ed7079ac5" + integrity sha512-MzMFlSLBqNF2gcHWO0G1vP/YQyfvrxZ0bF+u7mzUdZ1/xK4A4sru+nraZz5i3iEIk1l1uyicaDVTB4QbbEkAYg== dependencies: "@types/eslint" "*" "@types/estree" "*" "@types/eslint@*": - version "8.21.1" - resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-8.21.1.tgz#110b441a210d53ab47795124dbc3e9bb993d1e7c" - integrity sha512-rc9K8ZpVjNcLs8Fp0dkozd5Pt2Apk1glO4Vgz8ix1u6yFByxfqo5Yavpy65o+93TAe24jr7v+eSBtFLvOQtCRQ== + version "8.56.2" + resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-8.56.2.tgz#1c72a9b794aa26a8b94ad26d5b9aa51c8a6384bb" + integrity sha512-uQDwm1wFHmbBbCZCqAlq6Do9LYwByNZHWzXppSnay9SuwJ+VRbjkbLABer54kcPnMSlG6Fdiy2yaFXm/z9Z5gw== dependencies: "@types/estree" "*" "@types/json-schema" "*" -"@types/estree@*": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.0.tgz#5fb2e536c1ae9bf35366eed879e827fa59ca41c2" - integrity sha512-WulqXMDUTYAXCjZnk6JtIHPigp55cVtDgDrO2gHRwhyJto21+1zbVCtOYB2L1F9w4qCQ0rOGWBnBe0FNTiEJIQ== - -"@types/estree@^0.0.51": - version "0.0.51" - resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.51.tgz#cfd70924a25a3fd32b218e5e420e6897e1ac4f40" - integrity sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ== +"@types/estree@*", "@types/estree@^1.0.0": + version "1.0.5" + resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.5.tgz#a6ce3e556e00fd9895dd872dd172ad0d4bd687f4" + integrity sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw== "@types/express-serve-static-core@*", "@types/express-serve-static-core@^4.17.33": - version "4.17.33" - resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.17.33.tgz#de35d30a9d637dc1450ad18dd583d75d5733d543" - integrity sha512-TPBqmR/HRYI3eC2E5hmiivIzv+bidAfXofM+sbonAGvyDhySGw9/PQZFt2BLOrjUUR++4eJVpx6KnLQK1Fk9tA== + version "4.17.41" + resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.17.41.tgz#5077defa630c2e8d28aa9ffc2c01c157c305bef6" + integrity sha512-OaJ7XLaelTgrvlZD8/aa0vvvxZdUmlCn6MtWeB7TkiKW70BQLc9XEPpDLPdbo52ZhXUCrznlWdCHWxJWtdyajA== dependencies: "@types/node" "*" "@types/qs" "*" "@types/range-parser" "*" + "@types/send" "*" "@types/express@*", "@types/express@^4.17.13": - version "4.17.17" - resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.17.tgz#01d5437f6ef9cfa8668e616e13c2f2ac9a491ae4" - integrity sha512-Q4FmmuLGBG58btUnfS1c1r/NQdlp3DMfGDGig8WhfpA2YRUtEkxAjkZb0yvplJGYdF1fsQ81iMDcH24sSCNC/Q== + version "4.17.21" + resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.21.tgz#c26d4a151e60efe0084b23dc3369ebc631ed192d" + integrity sha512-ejlPM315qwLpaQlQDTjPdsUFSc6ZsP4AN6AlWnogPjQ7CVi7PYF3YVz+CY3jE2pwYf7E/7HlDAN0rV2GxTG0HQ== dependencies: "@types/body-parser" "*" "@types/express-serve-static-core" "^4.17.33" @@ -2074,11 +2102,11 @@ "@types/serve-static" "*" "@types/hast@^2.0.0": - version "2.3.4" - resolved "https://registry.yarnpkg.com/@types/hast/-/hast-2.3.4.tgz#8aa5ef92c117d20d974a82bdfb6a648b08c0bafc" - integrity sha512-wLEm0QvaoawEDoTRwzTXp4b4jpwiJDvR5KMnFnVodm3scufTlBOWRD6N1OBf9TZMhjlNsSfcO5V+7AF4+Vy+9g== + version "2.3.9" + resolved "https://registry.yarnpkg.com/@types/hast/-/hast-2.3.9.tgz#a9a1b5bbce46e8a1312e977364bacabc8e93d2cf" + integrity sha512-pTHyNlaMD/oKJmS+ZZUyFUcsZeBZpC0lmGquw98CqRVNgAdJZJeD7GoeLiT6Xbx5rU9VCjSt0RwEvDgzh4obFw== dependencies: - "@types/unist" "*" + "@types/unist" "^2" "@types/history@^4.7.11": version "4.7.11" @@ -2090,36 +2118,41 @@ resolved "https://registry.yarnpkg.com/@types/html-minifier-terser/-/html-minifier-terser-6.1.0.tgz#4fc33a00c1d0c16987b1a20cf92d20614c55ac35" integrity sha512-oh/6byDPnL1zeNXFrDXFLyZjkr1MsBG667IM792caf1L2UPOOMf65NFzjUH/ltyfwjAGfs1rsX1eftK0jC/KIg== +"@types/http-errors@*": + version "2.0.4" + resolved "https://registry.yarnpkg.com/@types/http-errors/-/http-errors-2.0.4.tgz#7eb47726c391b7345a6ec35ad7f4de469cf5ba4f" + integrity sha512-D0CFMMtydbJAegzOyHjtiKPLlvnm3iTZyZRSZoLq2mRhDdmLfIWOCYPfQJ4cu2erKghU++QvjcUjp/5h7hESpA== + "@types/http-proxy@^1.17.8": - version "1.17.10" - resolved "https://registry.yarnpkg.com/@types/http-proxy/-/http-proxy-1.17.10.tgz#e576c8e4a0cc5c6a138819025a88e167ebb38d6c" - integrity sha512-Qs5aULi+zV1bwKAg5z1PWnDXWmsn+LxIvUGv6E2+OOMYhclZMO+OXd9pYVf2gLykf2I7IV2u7oTHwChPNsvJ7g== + version "1.17.14" + resolved "https://registry.yarnpkg.com/@types/http-proxy/-/http-proxy-1.17.14.tgz#57f8ccaa1c1c3780644f8a94f9c6b5000b5e2eec" + integrity sha512-SSrD0c1OQzlFX7pGu1eXxSEjemej64aaNPRhhVYUGqXh0BtldAAx37MG8btcumvpgKyZp1F5Gn3JkktdxiFv6w== dependencies: "@types/node" "*" "@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0": - version "2.0.4" - resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz#8467d4b3c087805d63580480890791277ce35c44" - integrity sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g== + version "2.0.6" + resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz#7739c232a1fee9b4d3ce8985f314c0c6d33549d7" + integrity sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w== "@types/istanbul-lib-report@*": - version "3.0.0" - resolved "https://registry.yarnpkg.com/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz#c14c24f18ea8190c118ee7562b7ff99a36552686" - integrity sha512-plGgXAPfVKFoYfa9NpYDAkseG+g6Jr294RqeqcqDixSbU34MZVJRi/P+7Y8GDpzkEwLaGZZOpKIEmeVZNtKsrg== + version "3.0.3" + resolved "https://registry.yarnpkg.com/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.3.tgz#53047614ae72e19fc0401d872de3ae2b4ce350bf" + integrity sha512-NQn7AHQnk/RSLOxrBbGyJM/aVQ+pjj5HCgasFxc0K/KhoATfQ/47AyUl15I2yBUpihjmas+a+VJBOqecrFH+uA== dependencies: "@types/istanbul-lib-coverage" "*" "@types/istanbul-reports@^3.0.0": - version "3.0.1" - resolved "https://registry.yarnpkg.com/@types/istanbul-reports/-/istanbul-reports-3.0.1.tgz#9153fe98bba2bd565a63add9436d6f0d7f8468ff" - integrity sha512-c3mAZEuK0lvBp8tmuL74XRKn1+y2dcwOUpH7x4WrF6gk1GIgiluDRgMYQtw2OFcBvAJWlt6ASU3tSqxp0Uu0Aw== + version "3.0.4" + resolved "https://registry.yarnpkg.com/@types/istanbul-reports/-/istanbul-reports-3.0.4.tgz#0f03e3d2f670fbdac586e34b433783070cc16f54" + integrity sha512-pk2B1NWalF9toCRu6gjBzR69syFjP4Od8WRAX+0mmf9lAjCRicLOWc+ZrxZHx/0XRjotgkF9t6iaMJ+aXcOdZQ== dependencies: "@types/istanbul-lib-report" "*" "@types/json-schema@*", "@types/json-schema@^7.0.4", "@types/json-schema@^7.0.5", "@types/json-schema@^7.0.8", "@types/json-schema@^7.0.9": - version "7.0.11" - resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3" - integrity sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ== + version "7.0.15" + resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841" + integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA== "@types/katex@^0.11.0": version "0.11.1" @@ -2127,21 +2160,35 @@ integrity sha512-DUlIj2nk0YnJdlWgsFuVKcX27MLW0KbKmGVoUHmFr+74FYYNUDAaj9ZqTADvsbE8rfxuVmSFc7KczYn5Y09ozg== "@types/mdast@^3.0.0": - version "3.0.10" - resolved "https://registry.yarnpkg.com/@types/mdast/-/mdast-3.0.10.tgz#4724244a82a4598884cbbe9bcfd73dff927ee8af" - integrity sha512-W864tg/Osz1+9f4lrGTZpCSO5/z4608eUp19tbozkq2HJK6i3z1kT0H9tlADXuYIb1YYOBByU4Jsqkk75q48qA== + version "3.0.15" + resolved "https://registry.yarnpkg.com/@types/mdast/-/mdast-3.0.15.tgz#49c524a263f30ffa28b71ae282f813ed000ab9f5" + integrity sha512-LnwD+mUEfxWMa1QpDraczIn6k0Ee3SMicuYSSzS6ZYl2gKS09EClnJYGd8Du6rfc5r/GZEk5o1mRb8TaTj03sQ== dependencies: - "@types/unist" "*" + "@types/unist" "^2" "@types/mime@*": - version "3.0.1" - resolved "https://registry.yarnpkg.com/@types/mime/-/mime-3.0.1.tgz#5f8f2bca0a5863cb69bc0b0acd88c96cb1d4ae10" - integrity sha512-Y4XFY5VJAuw0FgAqPNd6NNoV44jbq9Bz2L7Rh/J6jLTiHBSBJa9fxqQIvkIld4GsoDOcCbvzOUAbLPsSKKg+uA== + version "3.0.4" + resolved "https://registry.yarnpkg.com/@types/mime/-/mime-3.0.4.tgz#2198ac274de6017b44d941e00261d5bc6a0e0a45" + integrity sha512-iJt33IQnVRkqeqC7PzBHPTC6fDlRNRW8vjrgqtScAhrmMwe8c4Eo7+fUGTa+XdWrpEgpyKWMYmi2dIwMAYRzPw== + +"@types/mime@^1": + version "1.3.5" + resolved "https://registry.yarnpkg.com/@types/mime/-/mime-1.3.5.tgz#1ef302e01cf7d2b5a0fa526790c9123bf1d06690" + integrity sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w== + +"@types/node-forge@^1.3.0": + version "1.3.11" + resolved "https://registry.yarnpkg.com/@types/node-forge/-/node-forge-1.3.11.tgz#0972ea538ddb0f4d9c2fa0ec5db5724773a604da" + integrity sha512-FQx220y22OKNTqaByeBGqHWYz4cl94tpcxeFdvBo3wjG6XPBuZ0BNgNZRV5J5TFmmcsJ4IzsLkmGRiQbnYsBEQ== + dependencies: + "@types/node" "*" "@types/node@*": - version "18.14.6" - resolved "https://registry.yarnpkg.com/@types/node/-/node-18.14.6.tgz#ae1973dd2b1eeb1825695bb11ebfb746d27e3e93" - integrity sha512-93+VvleD3mXwlLI/xASjw0FzKcwzl3OdTCzm1LaRfqgS21gfFtK3zDXM5Op9TeeMsJVOaJ2VRDpT9q4Y3d0AvA== + version "20.11.5" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.11.5.tgz#be10c622ca7fcaa3cf226cf80166abc31389d86e" + integrity sha512-g557vgQjUUfN76MZAN/dt1z3dzcUsimuysco0KeluHgrPdJXkP/XdAURgyO2W9fZWHRtRBiVKzKn8vyOAwlG+w== + dependencies: + undici-types "~5.26.4" "@types/node@^17.0.5": version "17.0.45" @@ -2149,9 +2196,9 @@ integrity sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw== "@types/parse-json@^4.0.0": - version "4.0.0" - resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0" - integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA== + version "4.0.2" + resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.2.tgz#5950e50960793055845e956c427fc2b0d70c5239" + integrity sha512-dISoDXWWQwUquiKsyZ4Ng+HX2KsPL7LyHKHQwgGFEA3IaKac4Obd+h2a/a6waisAoepJlBcx9paWqjA8/HVjCw== "@types/parse5@^5.0.0": version "5.0.3" @@ -2159,28 +2206,28 @@ integrity sha512-kUNnecmtkunAoQ3CnjmMkzNU/gtxG8guhi+Fk2U/kOpIKjIMKnXGp4IJCgQJrXSgMsWYimYG4TGjz/UzbGEBTw== "@types/prop-types@*": - version "15.7.5" - resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.5.tgz#5f19d2b85a98e9558036f6a3cacc8819420f05cf" - integrity sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w== + version "15.7.11" + resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.11.tgz#2596fb352ee96a1379c657734d4b913a613ad563" + integrity sha512-ga8y9v9uyeiLdpKddhxYQkxNDrfvuPrlFb0N1qnZZByvcElJaXthF1UhvCh9TLWJBEHeNtdnbysW7Y6Uq8CVng== "@types/qs@*": - version "6.9.7" - resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.7.tgz#63bb7d067db107cc1e457c303bc25d511febf6cb" - integrity sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw== + version "6.9.11" + resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.11.tgz#208d8a30bc507bd82e03ada29e4732ea46a6bbda" + integrity sha512-oGk0gmhnEJK4Yyk+oI7EfXsLayXatCWPHary1MtcmbAifkobT9cM9yutG/hZKIseOU0MqbIwQ/u2nn/Gb+ltuQ== "@types/range-parser@*": - version "1.2.4" - resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.4.tgz#cd667bcfdd025213aafb7ca5915a932590acdcdc" - integrity sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw== + version "1.2.7" + resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.7.tgz#50ae4353eaaddc04044279812f52c8c65857dbcb" + integrity sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ== "@types/react-router-config@*", "@types/react-router-config@^5.0.6": - version "5.0.6" - resolved "https://registry.yarnpkg.com/@types/react-router-config/-/react-router-config-5.0.6.tgz#87c5c57e72d241db900d9734512c50ccec062451" - integrity sha512-db1mx37a1EJDf1XeX8jJN7R3PZABmJQXR8r28yUjVMFSjkmnQo6X6pOEEmNl+Tp2gYQOGPdYbFIipBtdElZ3Yg== + version "5.0.11" + resolved "https://registry.yarnpkg.com/@types/react-router-config/-/react-router-config-5.0.11.tgz#2761a23acc7905a66a94419ee40294a65aaa483a" + integrity sha512-WmSAg7WgqW7m4x8Mt4N6ZyKz0BubSj/2tVUMsAHp+Yd2AMwcSbeFq9WympT19p5heCFmF97R9eD5uUR/t4HEqw== dependencies: "@types/history" "^4.7.11" "@types/react" "*" - "@types/react-router" "*" + "@types/react-router" "^5.1.0" "@types/react-router-dom@*": version "5.3.3" @@ -2191,7 +2238,7 @@ "@types/react" "*" "@types/react-router" "*" -"@types/react-router@*": +"@types/react-router@*", "@types/react-router@^5.1.0": version "5.1.20" resolved "https://registry.yarnpkg.com/@types/react-router/-/react-router-5.1.20.tgz#88eccaa122a82405ef3efbcaaa5dcdd9f021387c" integrity sha512-jGjmu/ZqS7FjSH6owMcD5qpq19+1RS9DeVRqfl1FeBMxTDQAGwlMWOcs52NDoXaNKyG3d1cYQFMs9rCrb88o9Q== @@ -2200,9 +2247,9 @@ "@types/react" "*" "@types/react@*": - version "18.0.28" - resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.28.tgz#accaeb8b86f4908057ad629a26635fe641480065" - integrity sha512-RD0ivG1kEztNBdoAK7lekI9M+azSnitIn85h4iOiaLjaTrMjzslhaqCGaI4IyCJ1RljWiLCEu4jyrLLgqxBTew== + version "18.2.48" + resolved "https://registry.yarnpkg.com/@types/react/-/react-18.2.48.tgz#11df5664642d0bd879c1f58bc1d37205b064e8f1" + integrity sha512-qboRCl6Ie70DQQG9hhNREz81jqC1cs9EVNcjQ1AU+jH6NFfSAhVVbrrY/+nSF+Bsk4AOwm9Qa61InvMCyV+H3w== dependencies: "@types/prop-types" "*" "@types/scheduler" "*" @@ -2214,182 +2261,191 @@ integrity sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA== "@types/sax@^1.2.1": - version "1.2.4" - resolved "https://registry.yarnpkg.com/@types/sax/-/sax-1.2.4.tgz#8221affa7f4f3cb21abd22f244cfabfa63e6a69e" - integrity sha512-pSAff4IAxJjfAXUG6tFkO7dsSbTmf8CtUpfhhZ5VhkRpC4628tJhh3+V6H1E+/Gs9piSzYKT5yzHO5M4GG9jkw== + version "1.2.7" + resolved "https://registry.yarnpkg.com/@types/sax/-/sax-1.2.7.tgz#ba5fe7df9aa9c89b6dff7688a19023dd2963091d" + integrity sha512-rO73L89PJxeYM3s3pPPjiPgVVcymqU490g0YO5n5By0k2Erzj6tay/4lr1CHAAU4JyOWd1rpQ8bCf6cZfHU96A== dependencies: "@types/node" "*" "@types/scheduler@*": - version "0.16.2" - resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.2.tgz#1a62f89525723dde24ba1b01b092bf5df8ad4d39" - integrity sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew== + version "0.16.8" + resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.8.tgz#ce5ace04cfeabe7ef87c0091e50752e36707deff" + integrity sha512-WZLiwShhwLRmeV6zH+GkbOFT6Z6VklCItrDioxUnv+u4Ll+8vKeFySoFyK/0ctcRpOmwAicELfmys1sDc/Rw+A== + +"@types/send@*": + version "0.17.4" + resolved "https://registry.yarnpkg.com/@types/send/-/send-0.17.4.tgz#6619cd24e7270793702e4e6a4b958a9010cfc57a" + integrity sha512-x2EM6TJOybec7c52BX0ZspPodMsQUd5L6PRwOunVyVUhXiBSKf3AezDL8Dgvgt5o0UfKNfuA0eMLr2wLT4AiBA== + dependencies: + "@types/mime" "^1" + "@types/node" "*" "@types/serve-index@^1.9.1": - version "1.9.1" - resolved "https://registry.yarnpkg.com/@types/serve-index/-/serve-index-1.9.1.tgz#1b5e85370a192c01ec6cec4735cf2917337a6278" - integrity sha512-d/Hs3nWDxNL2xAczmOVZNj92YZCS6RGxfBPjKzuu/XirCgXdpKEb88dYNbrYGint6IVWLNP+yonwVAuRC0T2Dg== + version "1.9.4" + resolved "https://registry.yarnpkg.com/@types/serve-index/-/serve-index-1.9.4.tgz#e6ae13d5053cb06ed36392110b4f9a49ac4ec898" + integrity sha512-qLpGZ/c2fhSs5gnYsQxtDEq3Oy8SXPClIXkW5ghvAvsNuVSA8k+gCONcUCS/UjLEYvYps+e8uBtfgXgvhwfNug== dependencies: "@types/express" "*" "@types/serve-static@*", "@types/serve-static@^1.13.10": - version "1.15.1" - resolved "https://registry.yarnpkg.com/@types/serve-static/-/serve-static-1.15.1.tgz#86b1753f0be4f9a1bee68d459fcda5be4ea52b5d" - integrity sha512-NUo5XNiAdULrJENtJXZZ3fHtfMolzZwczzBbnAeBbqBwG+LaG6YaJtuwzwGSQZ2wsCrxjEhNNjAkKigy3n8teQ== + version "1.15.5" + resolved "https://registry.yarnpkg.com/@types/serve-static/-/serve-static-1.15.5.tgz#15e67500ec40789a1e8c9defc2d32a896f05b033" + integrity sha512-PDRk21MnK70hja/YF8AHfC7yIsiQHn1rcXx7ijCFBX/k+XQJhQT/gw3xekXKJvx+5SXaMMS8oqQy09Mzvz2TuQ== dependencies: + "@types/http-errors" "*" "@types/mime" "*" "@types/node" "*" "@types/sockjs@^0.3.33": - version "0.3.33" - resolved "https://registry.yarnpkg.com/@types/sockjs/-/sockjs-0.3.33.tgz#570d3a0b99ac995360e3136fd6045113b1bd236f" - integrity sha512-f0KEEe05NvUnat+boPTZ0dgaLZ4SfSouXUgv5noUiefG2ajgKjmETo9ZJyuqsl7dfl2aHlLJUiki6B4ZYldiiw== + version "0.3.36" + resolved "https://registry.yarnpkg.com/@types/sockjs/-/sockjs-0.3.36.tgz#ce322cf07bcc119d4cbf7f88954f3a3bd0f67535" + integrity sha512-MK9V6NzAS1+Ud7JV9lJLFqW85VbC9dq3LmwZCuBe4wBDgKC0Kj/jd8Xl+nSviU+Qc3+m7umHHyHg//2KSa0a0Q== dependencies: "@types/node" "*" -"@types/unist@*", "@types/unist@^2.0.0", "@types/unist@^2.0.2", "@types/unist@^2.0.3": - version "2.0.6" - resolved "https://registry.yarnpkg.com/@types/unist/-/unist-2.0.6.tgz#250a7b16c3b91f672a24552ec64678eeb1d3a08d" - integrity sha512-PBjIUxZHOuj0R15/xuwJYjFi+KZdNFrehocChv4g5hu6aFroHue8m0lBP0POdK2nKzbw0cgV1mws8+V/JAcEkQ== +"@types/unist@^2", "@types/unist@^2.0.0", "@types/unist@^2.0.2", "@types/unist@^2.0.3": + version "2.0.10" + resolved "https://registry.yarnpkg.com/@types/unist/-/unist-2.0.10.tgz#04ffa7f406ab628f7f7e97ca23e290cd8ab15efc" + integrity sha512-IfYcSBWE3hLpBg8+X2SEa8LVkJdJEkT2Ese2aaLs3ptGdVtABxndrMaxuFlQ1qdFf9Q5rDvDpxI3WwgvKFAsQA== -"@types/ws@^8.5.1": - version "8.5.4" - resolved "https://registry.yarnpkg.com/@types/ws/-/ws-8.5.4.tgz#bb10e36116d6e570dd943735f86c933c1587b8a5" - integrity sha512-zdQDHKUgcX/zBc4GrwsE/7dVdAD8JR4EuiAXiiUhhfyIJXXb2+PrGshFyeXWQPMmmZ2XxgaqclgpIC7eTXc1mg== +"@types/ws@^8.5.5": + version "8.5.10" + resolved "https://registry.yarnpkg.com/@types/ws/-/ws-8.5.10.tgz#4acfb517970853fa6574a3a6886791d04a396787" + integrity sha512-vmQSUcfalpIq0R9q7uTo2lXs6eGIpt9wtnLdMv9LVpIjCA/+ufZRozlVoVelIYixx1ugCBKDhn89vnsEGOCx9A== dependencies: "@types/node" "*" "@types/yargs-parser@*": - version "21.0.0" - resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-21.0.0.tgz#0c60e537fa790f5f9472ed2776c2b71ec117351b" - integrity sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA== + version "21.0.3" + resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-21.0.3.tgz#815e30b786d2e8f0dcd85fd5bcf5e1a04d008f15" + integrity sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ== "@types/yargs@^17.0.8": - version "17.0.22" - resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.22.tgz#7dd37697691b5f17d020f3c63e7a45971ff71e9a" - integrity sha512-pet5WJ9U8yPVRhkwuEIp5ktAeAqRZOq4UdAyWLWzxbtpyXnzbtLdKiXAjJzi/KLmPGS9wk86lUFWZFN6sISo4g== + version "17.0.32" + resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.32.tgz#030774723a2f7faafebf645f4e5a48371dca6229" + integrity sha512-xQ67Yc/laOG5uMfX/093MRlGGCIBzZMarVa+gfNKJxWAIgykYpVGkBdbqEzGDDfCrVUj6Hiff4mTZ5BA6TmAog== dependencies: "@types/yargs-parser" "*" -"@webassemblyjs/ast@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.11.1.tgz#2bfd767eae1a6996f432ff7e8d7fc75679c0b6a7" - integrity sha512-ukBh14qFLjxTQNTXocdyksN5QdM28S1CxHt2rdskFyL+xFV7VremuBLVbmCePj+URalXBENx/9Lm7lnhihtCSw== +"@webassemblyjs/ast@1.11.6", "@webassemblyjs/ast@^1.11.5": + version "1.11.6" + resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.11.6.tgz#db046555d3c413f8966ca50a95176a0e2c642e24" + integrity sha512-IN1xI7PwOvLPgjcf180gC1bqn3q/QaOCwYUahIOhbYUu8KA/3tw2RT/T0Gidi1l7Hhj5D/INhJxiICObqpMu4Q== dependencies: - "@webassemblyjs/helper-numbers" "1.11.1" - "@webassemblyjs/helper-wasm-bytecode" "1.11.1" + "@webassemblyjs/helper-numbers" "1.11.6" + "@webassemblyjs/helper-wasm-bytecode" "1.11.6" -"@webassemblyjs/floating-point-hex-parser@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.1.tgz#f6c61a705f0fd7a6aecaa4e8198f23d9dc179e4f" - integrity sha512-iGRfyc5Bq+NnNuX8b5hwBrRjzf0ocrJPI6GWFodBFzmFnyvrQ83SHKhmilCU/8Jv67i4GJZBMhEzltxzcNagtQ== +"@webassemblyjs/floating-point-hex-parser@1.11.6": + version "1.11.6" + resolved "https://registry.yarnpkg.com/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.6.tgz#dacbcb95aff135c8260f77fa3b4c5fea600a6431" + integrity sha512-ejAj9hfRJ2XMsNHk/v6Fu2dGS+i4UaXBXGemOfQ/JfQ6mdQg/WXtwleQRLLS4OvfDhv8rYnVwH27YJLMyYsxhw== -"@webassemblyjs/helper-api-error@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.1.tgz#1a63192d8788e5c012800ba6a7a46c705288fd16" - integrity sha512-RlhS8CBCXfRUR/cwo2ho9bkheSXG0+NwooXcc3PAILALf2QLdFyj7KGsKRbVc95hZnhnERon4kW/D3SZpp6Tcg== +"@webassemblyjs/helper-api-error@1.11.6": + version "1.11.6" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.6.tgz#6132f68c4acd59dcd141c44b18cbebbd9f2fa768" + integrity sha512-o0YkoP4pVu4rN8aTJgAyj9hC2Sv5UlkzCHhxqWj8butaLvnpdc2jOwh4ewE6CX0txSfLn/UYaV/pheS2Txg//Q== -"@webassemblyjs/helper-buffer@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-buffer/-/helper-buffer-1.11.1.tgz#832a900eb444884cde9a7cad467f81500f5e5ab5" - integrity sha512-gwikF65aDNeeXa8JxXa2BAk+REjSyhrNC9ZwdT0f8jc4dQQeDQ7G4m0f2QCLPJiMTTO6wfDmRmj/pW0PsUvIcA== +"@webassemblyjs/helper-buffer@1.11.6": + version "1.11.6" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-buffer/-/helper-buffer-1.11.6.tgz#b66d73c43e296fd5e88006f18524feb0f2c7c093" + integrity sha512-z3nFzdcp1mb8nEOFFk8DrYLpHvhKC3grJD2ardfKOzmbmJvEf/tPIqCY+sNcwZIY8ZD7IkB2l7/pqhUhqm7hLA== -"@webassemblyjs/helper-numbers@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.1.tgz#64d81da219fbbba1e3bd1bfc74f6e8c4e10a62ae" - integrity sha512-vDkbxiB8zfnPdNK9Rajcey5C0w+QJugEglN0of+kmO8l7lDb77AnlKYQF7aarZuCrv+l0UvqL+68gSDr3k9LPQ== +"@webassemblyjs/helper-numbers@1.11.6": + version "1.11.6" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.6.tgz#cbce5e7e0c1bd32cf4905ae444ef64cea919f1b5" + integrity sha512-vUIhZ8LZoIWHBohiEObxVm6hwP034jwmc9kuq5GdHZH0wiLVLIPcMCdpJzG4C11cHoQ25TFIQj9kaVADVX7N3g== dependencies: - "@webassemblyjs/floating-point-hex-parser" "1.11.1" - "@webassemblyjs/helper-api-error" "1.11.1" + "@webassemblyjs/floating-point-hex-parser" "1.11.6" + "@webassemblyjs/helper-api-error" "1.11.6" "@xtuc/long" "4.2.2" -"@webassemblyjs/helper-wasm-bytecode@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.1.tgz#f328241e41e7b199d0b20c18e88429c4433295e1" - integrity sha512-PvpoOGiJwXeTrSf/qfudJhwlvDQxFgelbMqtq52WWiXC6Xgg1IREdngmPN3bs4RoO83PnL/nFrxucXj1+BX62Q== +"@webassemblyjs/helper-wasm-bytecode@1.11.6": + version "1.11.6" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.6.tgz#bb2ebdb3b83aa26d9baad4c46d4315283acd51e9" + integrity sha512-sFFHKwcmBprO9e7Icf0+gddyWYDViL8bpPjJJl0WHxCdETktXdmtWLGVzoHbqUcY4Be1LkNfwTmXOJUFZYSJdA== -"@webassemblyjs/helper-wasm-section@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.11.1.tgz#21ee065a7b635f319e738f0dd73bfbda281c097a" - integrity sha512-10P9No29rYX1j7F3EVPX3JvGPQPae+AomuSTPiF9eBQeChHI6iqjMIwR9JmOJXwpnn/oVGDk7I5IlskuMwU/pg== +"@webassemblyjs/helper-wasm-section@1.11.6": + version "1.11.6" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.11.6.tgz#ff97f3863c55ee7f580fd5c41a381e9def4aa577" + integrity sha512-LPpZbSOwTpEC2cgn4hTydySy1Ke+XEu+ETXuoyvuyezHO3Kjdu90KK95Sh9xTbmjrCsUwvWwCOQQNta37VrS9g== dependencies: - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/helper-buffer" "1.11.1" - "@webassemblyjs/helper-wasm-bytecode" "1.11.1" - "@webassemblyjs/wasm-gen" "1.11.1" + "@webassemblyjs/ast" "1.11.6" + "@webassemblyjs/helper-buffer" "1.11.6" + "@webassemblyjs/helper-wasm-bytecode" "1.11.6" + "@webassemblyjs/wasm-gen" "1.11.6" -"@webassemblyjs/ieee754@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/ieee754/-/ieee754-1.11.1.tgz#963929e9bbd05709e7e12243a099180812992614" - integrity sha512-hJ87QIPtAMKbFq6CGTkZYJivEwZDbQUgYd3qKSadTNOhVY7p+gfP6Sr0lLRVTaG1JjFj+r3YchoqRYxNH3M0GQ== +"@webassemblyjs/ieee754@1.11.6": + version "1.11.6" + resolved "https://registry.yarnpkg.com/@webassemblyjs/ieee754/-/ieee754-1.11.6.tgz#bb665c91d0b14fffceb0e38298c329af043c6e3a" + integrity sha512-LM4p2csPNvbij6U1f19v6WR56QZ8JcHg3QIJTlSwzFcmx6WSORicYj6I63f9yU1kEUtrpG+kjkiIAkevHpDXrg== dependencies: "@xtuc/ieee754" "^1.2.0" -"@webassemblyjs/leb128@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/leb128/-/leb128-1.11.1.tgz#ce814b45574e93d76bae1fb2644ab9cdd9527aa5" - integrity sha512-BJ2P0hNZ0u+Th1YZXJpzW6miwqQUGcIHT1G/sf72gLVD9DZ5AdYTqPNbHZh6K1M5VmKvFXwGSWZADz+qBWxeRw== +"@webassemblyjs/leb128@1.11.6": + version "1.11.6" + resolved "https://registry.yarnpkg.com/@webassemblyjs/leb128/-/leb128-1.11.6.tgz#70e60e5e82f9ac81118bc25381a0b283893240d7" + integrity sha512-m7a0FhE67DQXgouf1tbN5XQcdWoNgaAuoULHIfGFIEVKA6tu/edls6XnIlkmS6FrXAquJRPni3ZZKjw6FSPjPQ== dependencies: "@xtuc/long" "4.2.2" -"@webassemblyjs/utf8@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/utf8/-/utf8-1.11.1.tgz#d1f8b764369e7c6e6bae350e854dec9a59f0a3ff" - integrity sha512-9kqcxAEdMhiwQkHpkNiorZzqpGrodQQ2IGrHHxCy+Ozng0ofyMA0lTqiLkVs1uzTRejX+/O0EOT7KxqVPuXosQ== - -"@webassemblyjs/wasm-edit@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-edit/-/wasm-edit-1.11.1.tgz#ad206ebf4bf95a058ce9880a8c092c5dec8193d6" - integrity sha512-g+RsupUC1aTHfR8CDgnsVRVZFJqdkFHpsHMfJuWQzWU3tvnLC07UqHICfP+4XyL2tnr1amvl1Sdp06TnYCmVkA== - dependencies: - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/helper-buffer" "1.11.1" - "@webassemblyjs/helper-wasm-bytecode" "1.11.1" - "@webassemblyjs/helper-wasm-section" "1.11.1" - "@webassemblyjs/wasm-gen" "1.11.1" - "@webassemblyjs/wasm-opt" "1.11.1" - "@webassemblyjs/wasm-parser" "1.11.1" - "@webassemblyjs/wast-printer" "1.11.1" - -"@webassemblyjs/wasm-gen@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-gen/-/wasm-gen-1.11.1.tgz#86c5ea304849759b7d88c47a32f4f039ae3c8f76" - integrity sha512-F7QqKXwwNlMmsulj6+O7r4mmtAlCWfO/0HdgOxSklZfQcDu0TpLiD1mRt/zF25Bk59FIjEuGAIyn5ei4yMfLhA== - dependencies: - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/helper-wasm-bytecode" "1.11.1" - "@webassemblyjs/ieee754" "1.11.1" - "@webassemblyjs/leb128" "1.11.1" - "@webassemblyjs/utf8" "1.11.1" - -"@webassemblyjs/wasm-opt@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-opt/-/wasm-opt-1.11.1.tgz#657b4c2202f4cf3b345f8a4c6461c8c2418985f2" - integrity sha512-VqnkNqnZlU5EB64pp1l7hdm3hmQw7Vgqa0KF/KCNO9sIpI6Fk6brDEiX+iCOYrvMuBWDws0NkTOxYEb85XQHHw== - dependencies: - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/helper-buffer" "1.11.1" - "@webassemblyjs/wasm-gen" "1.11.1" - "@webassemblyjs/wasm-parser" "1.11.1" - -"@webassemblyjs/wasm-parser@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-parser/-/wasm-parser-1.11.1.tgz#86ca734534f417e9bd3c67c7a1c75d8be41fb199" - integrity sha512-rrBujw+dJu32gYB7/Lup6UhdkPx9S9SnobZzRVL7VcBH9Bt9bCBLEuX/YXOOtBsOZ4NQrRykKhffRWHvigQvOA== - dependencies: - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/helper-api-error" "1.11.1" - "@webassemblyjs/helper-wasm-bytecode" "1.11.1" - "@webassemblyjs/ieee754" "1.11.1" - "@webassemblyjs/leb128" "1.11.1" - "@webassemblyjs/utf8" "1.11.1" - -"@webassemblyjs/wast-printer@1.11.1": - version "1.11.1" - resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-printer/-/wast-printer-1.11.1.tgz#d0c73beda8eec5426f10ae8ef55cee5e7084c2f0" - integrity sha512-IQboUWM4eKzWW+N/jij2sRatKMh99QEelo3Eb2q0qXkvPRISAj8Qxtmw5itwqK+TTkBuUIE45AxYPToqPtL5gg== - dependencies: - "@webassemblyjs/ast" "1.11.1" +"@webassemblyjs/utf8@1.11.6": + version "1.11.6" + resolved "https://registry.yarnpkg.com/@webassemblyjs/utf8/-/utf8-1.11.6.tgz#90f8bc34c561595fe156603be7253cdbcd0fab5a" + integrity sha512-vtXf2wTQ3+up9Zsg8sa2yWiQpzSsMyXj0qViVP6xKGCUT8p8YJ6HqI7l5eCnWx1T/FYdsv07HQs2wTFbbof/RA== + +"@webassemblyjs/wasm-edit@^1.11.5": + version "1.11.6" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-edit/-/wasm-edit-1.11.6.tgz#c72fa8220524c9b416249f3d94c2958dfe70ceab" + integrity sha512-Ybn2I6fnfIGuCR+Faaz7YcvtBKxvoLV3Lebn1tM4o/IAJzmi9AWYIPWpyBfU8cC+JxAO57bk4+zdsTjJR+VTOw== + dependencies: + "@webassemblyjs/ast" "1.11.6" + "@webassemblyjs/helper-buffer" "1.11.6" + "@webassemblyjs/helper-wasm-bytecode" "1.11.6" + "@webassemblyjs/helper-wasm-section" "1.11.6" + "@webassemblyjs/wasm-gen" "1.11.6" + "@webassemblyjs/wasm-opt" "1.11.6" + "@webassemblyjs/wasm-parser" "1.11.6" + "@webassemblyjs/wast-printer" "1.11.6" + +"@webassemblyjs/wasm-gen@1.11.6": + version "1.11.6" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-gen/-/wasm-gen-1.11.6.tgz#fb5283e0e8b4551cc4e9c3c0d7184a65faf7c268" + integrity sha512-3XOqkZP/y6B4F0PBAXvI1/bky7GryoogUtfwExeP/v7Nzwo1QLcq5oQmpKlftZLbT+ERUOAZVQjuNVak6UXjPA== + dependencies: + "@webassemblyjs/ast" "1.11.6" + "@webassemblyjs/helper-wasm-bytecode" "1.11.6" + "@webassemblyjs/ieee754" "1.11.6" + "@webassemblyjs/leb128" "1.11.6" + "@webassemblyjs/utf8" "1.11.6" + +"@webassemblyjs/wasm-opt@1.11.6": + version "1.11.6" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-opt/-/wasm-opt-1.11.6.tgz#d9a22d651248422ca498b09aa3232a81041487c2" + integrity sha512-cOrKuLRE7PCe6AsOVl7WasYf3wbSo4CeOk6PkrjS7g57MFfVUF9u6ysQBBODX0LdgSvQqRiGz3CXvIDKcPNy4g== + dependencies: + "@webassemblyjs/ast" "1.11.6" + "@webassemblyjs/helper-buffer" "1.11.6" + "@webassemblyjs/wasm-gen" "1.11.6" + "@webassemblyjs/wasm-parser" "1.11.6" + +"@webassemblyjs/wasm-parser@1.11.6", "@webassemblyjs/wasm-parser@^1.11.5": + version "1.11.6" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-parser/-/wasm-parser-1.11.6.tgz#bb85378c527df824004812bbdb784eea539174a1" + integrity sha512-6ZwPeGzMJM3Dqp3hCsLgESxBGtT/OeCvCZ4TA1JUPYgmhAx38tTPR9JaKy0S5H3evQpO/h2uWs2j6Yc/fjkpTQ== + dependencies: + "@webassemblyjs/ast" "1.11.6" + "@webassemblyjs/helper-api-error" "1.11.6" + "@webassemblyjs/helper-wasm-bytecode" "1.11.6" + "@webassemblyjs/ieee754" "1.11.6" + "@webassemblyjs/leb128" "1.11.6" + "@webassemblyjs/utf8" "1.11.6" + +"@webassemblyjs/wast-printer@1.11.6": + version "1.11.6" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-printer/-/wast-printer-1.11.6.tgz#a7bf8dd7e362aeb1668ff43f35cb849f188eff20" + integrity sha512-JM7AhRcE+yW2GWYaKeHL5vt4xqee5N2WcezptmgyhNS+ScggqcT1OtXykhAb13Sn5Yas0j2uv9tHgrjwvzAP4A== + dependencies: + "@webassemblyjs/ast" "1.11.6" "@xtuc/long" "4.2.2" "@xtuc/ieee754@^1.2.0": @@ -2415,20 +2471,20 @@ accepts@~1.3.4, accepts@~1.3.5, accepts@~1.3.8: mime-types "~2.1.34" negotiator "0.6.3" -acorn-import-assertions@^1.7.6: - version "1.8.0" - resolved "https://registry.yarnpkg.com/acorn-import-assertions/-/acorn-import-assertions-1.8.0.tgz#ba2b5939ce62c238db6d93d81c9b111b29b855e9" - integrity sha512-m7VZ3jwz4eK6A4Vtt8Ew1/mNbP24u0FhdyfA7fSvnJR6LMdfOYnmuIrrJAgrYfYJ10F/otaHTtrtrtmHdMNzEw== +acorn-import-assertions@^1.9.0: + version "1.9.0" + resolved "https://registry.yarnpkg.com/acorn-import-assertions/-/acorn-import-assertions-1.9.0.tgz#507276249d684797c84e0734ef84860334cfb1ac" + integrity sha512-cmMwop9x+8KFhxvKrKfPYmN6/pKTYYHBqLa0DfvVZcKMJWNyWLnaqND7dx/qn66R7ewM1UX5XMaDVP5wlVTaVA== acorn-walk@^8.0.0: - version "8.2.0" - resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1" - integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA== + version "8.3.2" + resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.3.2.tgz#7703af9415f1b6db9315d6895503862e231d34aa" + integrity sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A== -acorn@^8.0.4, acorn@^8.5.0, acorn@^8.7.1: - version "8.8.2" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.2.tgz#1b2f25db02af965399b9776b0c2c391276d37c4a" - integrity sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw== +acorn@^8.0.4, acorn@^8.7.1, acorn@^8.8.2: + version "8.11.3" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.11.3.tgz#71e0b14e13a4ec160724b38fb7b0f233b1b81d7a" + integrity sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg== address@^1.0.1, address@^1.1.2: version "1.2.2" @@ -2455,7 +2511,7 @@ ajv-keywords@^3.4.1, ajv-keywords@^3.5.2: resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d" integrity sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ== -ajv-keywords@^5.0.0: +ajv-keywords@^5.1.0: version "5.1.0" resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-5.1.0.tgz#69d4d385a4733cdbeab44964a1170a88f87f0e16" integrity sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw== @@ -2472,7 +2528,7 @@ ajv@^6.12.2, ajv@^6.12.4, ajv@^6.12.5: json-schema-traverse "^0.4.1" uri-js "^4.2.2" -ajv@^8.0.0, ajv@^8.8.0: +ajv@^8.0.0, ajv@^8.9.0: version "8.12.0" resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.12.0.tgz#d1a0527323e22f53562c567c00991577dfbe19d1" integrity sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA== @@ -2483,31 +2539,31 @@ ajv@^8.0.0, ajv@^8.8.0: uri-js "^4.2.2" algoliasearch-helper@^3.10.0: - version "3.11.2" - resolved "https://registry.yarnpkg.com/algoliasearch-helper/-/algoliasearch-helper-3.11.2.tgz#f42db10433e6264f1d1ba503699cbdbff7b48dff" - integrity sha512-eKvSM5hz5w9RcUowu8LnQ5v0KRrFLCvF4K3KF/Ab3VwCT726rWgZUWUIQUPjr9qDENUMukQ/IHZ7bGUVYRGP0g== + version "3.16.1" + resolved "https://registry.yarnpkg.com/algoliasearch-helper/-/algoliasearch-helper-3.16.1.tgz#421e3554ec86e14e60e7e0bf796aef61cf4a06ec" + integrity sha512-qxAHVjjmT7USVvrM8q6gZGaJlCK1fl4APfdAA7o8O6iXEc68G0xMNrzRkxoB/HmhhvyHnoteS/iMTiHiTcQQcg== dependencies: "@algolia/events" "^4.0.1" -algoliasearch@^4.0.0, algoliasearch@^4.13.1: - version "4.14.3" - resolved "https://registry.yarnpkg.com/algoliasearch/-/algoliasearch-4.14.3.tgz#f02a77a4db17de2f676018938847494b692035e7" - integrity sha512-GZTEuxzfWbP/vr7ZJfGzIl8fOsoxN916Z6FY2Egc9q2TmZ6hvq5KfAxY89pPW01oW/2HDEKA8d30f9iAH9eXYg== - dependencies: - "@algolia/cache-browser-local-storage" "4.14.3" - "@algolia/cache-common" "4.14.3" - "@algolia/cache-in-memory" "4.14.3" - "@algolia/client-account" "4.14.3" - "@algolia/client-analytics" "4.14.3" - "@algolia/client-common" "4.14.3" - "@algolia/client-personalization" "4.14.3" - "@algolia/client-search" "4.14.3" - "@algolia/logger-common" "4.14.3" - "@algolia/logger-console" "4.14.3" - "@algolia/requester-browser-xhr" "4.14.3" - "@algolia/requester-common" "4.14.3" - "@algolia/requester-node-http" "4.14.3" - "@algolia/transporter" "4.14.3" +algoliasearch@^4.13.1, algoliasearch@^4.19.1: + version "4.22.1" + resolved "https://registry.yarnpkg.com/algoliasearch/-/algoliasearch-4.22.1.tgz#f10fbecdc7654639ec20d62f109c1b3a46bc6afc" + integrity sha512-jwydKFQJKIx9kIZ8Jm44SdpigFwRGPESaxZBaHSV0XWN2yBJAOT4mT7ppvlrpA4UGzz92pqFnVKr/kaZXrcreg== + dependencies: + "@algolia/cache-browser-local-storage" "4.22.1" + "@algolia/cache-common" "4.22.1" + "@algolia/cache-in-memory" "4.22.1" + "@algolia/client-account" "4.22.1" + "@algolia/client-analytics" "4.22.1" + "@algolia/client-common" "4.22.1" + "@algolia/client-personalization" "4.22.1" + "@algolia/client-search" "4.22.1" + "@algolia/logger-common" "4.22.1" + "@algolia/logger-console" "4.22.1" + "@algolia/requester-browser-xhr" "4.22.1" + "@algolia/requester-common" "4.22.1" + "@algolia/requester-node-http" "4.22.1" + "@algolia/transporter" "4.22.1" ansi-align@^3.0.0, ansi-align@^3.0.1: version "3.0.1" @@ -2585,11 +2641,6 @@ array-flatten@1.1.1: resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" integrity sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg== -array-flatten@^2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-2.1.2.tgz#24ef80a28c1a893617e2149b0c6d0d788293b099" - integrity sha512-hNfzcOV8W4NdualtqBFPyVO+54DSJuZGY9qT4pRroB6S9e3iiido2ISIC5h9R2sPJ8H3FHCIiEnsv1lPXO3KtQ== - array-union@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d" @@ -2611,13 +2662,13 @@ at-least-node@^1.0.0: integrity sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg== autoprefixer@^10.4.12, autoprefixer@^10.4.7: - version "10.4.13" - resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-10.4.13.tgz#b5136b59930209a321e9fa3dca2e7c4d223e83a8" - integrity sha512-49vKpMqcZYsJjwotvt4+h/BCjJVnhGwcLpDt5xkcaOG3eLrG/HUYLagrihYsQ+qrIBgIzX1Rw7a6L8I/ZA1Atg== + version "10.4.17" + resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-10.4.17.tgz#35cd5695cbbe82f536a50fa025d561b01fdec8be" + integrity sha512-/cpVNRLSfhOtcGflT13P2794gVSgmPgTR+erw5ifnMLZb0UnSlkK4tquLmkd3BhA+nLo5tX8Cu0upUsGKvKbmg== dependencies: - browserslist "^4.21.4" - caniuse-lite "^1.0.30001426" - fraction.js "^4.2.0" + browserslist "^4.22.2" + caniuse-lite "^1.0.30001578" + fraction.js "^4.3.7" normalize-range "^0.1.2" picocolors "^1.0.0" postcss-value-parser "^4.2.0" @@ -2630,11 +2681,11 @@ axios@^0.25.0: follow-redirects "^1.14.7" axios@^1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/axios/-/axios-1.4.0.tgz#38a7bf1224cd308de271146038b551d725f0be1f" - integrity sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA== + version "1.6.5" + resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.5.tgz#2c090da14aeeab3770ad30c3a1461bc970fb0cd8" + integrity sha512-Ii012v05KEVuUoFWmMW/UQv9aRIc3ZwkWDcM+h5Il8izZCtRVpDUfwpoFf7eOtajT3QiGR4yDUx7lPqHJULgbg== dependencies: - follow-redirects "^1.15.0" + follow-redirects "^1.15.4" form-data "^4.0.0" proxy-from-env "^1.1.0" @@ -2670,29 +2721,29 @@ babel-plugin-extract-import-names@1.6.22: dependencies: "@babel/helper-plugin-utils" "7.10.4" -babel-plugin-polyfill-corejs2@^0.3.3: - version "0.3.3" - resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.3.3.tgz#5d1bd3836d0a19e1b84bbf2d9640ccb6f951c122" - integrity sha512-8hOdmFYFSZhqg2C/JgLUQ+t52o5nirNwaWM2B9LWteozwIvM14VSwdsCAUET10qT+kmySAlseadmfeeSWFCy+Q== +babel-plugin-polyfill-corejs2@^0.4.7: + version "0.4.8" + resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.4.8.tgz#dbcc3c8ca758a290d47c3c6a490d59429b0d2269" + integrity sha512-OtIuQfafSzpo/LhnJaykc0R/MMnuLSSVjVYy9mHArIZ9qTCSZ6TpWCuEKZYVoN//t8HqBNScHrOtCrIK5IaGLg== dependencies: - "@babel/compat-data" "^7.17.7" - "@babel/helper-define-polyfill-provider" "^0.3.3" - semver "^6.1.1" + "@babel/compat-data" "^7.22.6" + "@babel/helper-define-polyfill-provider" "^0.5.0" + semver "^6.3.1" -babel-plugin-polyfill-corejs3@^0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.6.0.tgz#56ad88237137eade485a71b52f72dbed57c6230a" - integrity sha512-+eHqR6OPcBhJOGgsIar7xoAB1GcSwVUA3XjAd7HJNzOXT4wv6/H7KIdA/Nc60cvUlDbKApmqNvD1B1bzOt4nyA== +babel-plugin-polyfill-corejs3@^0.8.7: + version "0.8.7" + resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.8.7.tgz#941855aa7fdaac06ed24c730a93450d2b2b76d04" + integrity sha512-KyDvZYxAzkC0Aj2dAPyDzi2Ym15e5JKZSK+maI7NAwSqofvuFglbSsxE7wUOvTg9oFVnHMzVzBKcqEb4PJgtOA== dependencies: - "@babel/helper-define-polyfill-provider" "^0.3.3" - core-js-compat "^3.25.1" + "@babel/helper-define-polyfill-provider" "^0.4.4" + core-js-compat "^3.33.1" -babel-plugin-polyfill-regenerator@^0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.4.1.tgz#390f91c38d90473592ed43351e801a9d3e0fd747" - integrity sha512-NtQGmyQDXjQqQ+IzRkBVwEOz9lQ4zxAQZgoAYEtU9dJjnl1Oc98qnN7jcp+bE7O7aYzVpavXE3/VKXNzUbh7aw== +babel-plugin-polyfill-regenerator@^0.5.4: + version "0.5.5" + resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.5.5.tgz#8b0c8fc6434239e5d7b8a9d1f832bb2b0310f06a" + integrity sha512-OJGYZlhLqBh2DDHeqAxWB1XIvr49CxiJ2gIt61/PU55CQK4Z58OzMqjDe1zwQdQk+rBYsRc+1rJmdajM3gimHg== dependencies: - "@babel/helper-define-polyfill-provider" "^0.3.3" + "@babel/helper-define-polyfill-provider" "^0.5.0" bail@^1.0.0: version "1.0.5" @@ -2757,12 +2808,10 @@ body-parser@1.20.1: unpipe "1.0.0" bonjour-service@^1.0.11: - version "1.1.0" - resolved "https://registry.yarnpkg.com/bonjour-service/-/bonjour-service-1.1.0.tgz#424170268d68af26ff83a5c640b95def01803a13" - integrity sha512-LVRinRB3k1/K0XzZ2p58COnWvkQknIY6sf0zF2rpErvcJXpMBttEPQSxK+HEXSS9VmpZlDoDnQWv8ftJT20B0Q== + version "1.2.1" + resolved "https://registry.yarnpkg.com/bonjour-service/-/bonjour-service-1.2.1.tgz#eb41b3085183df3321da1264719fbada12478d02" + integrity sha512-oSzCS2zV14bh2kji6vNe7vrpJYCHGvcZnlffFQ1MEoX/WOeQ/teD8SYWKR942OI3INjq8OMNJlbPK5LLLUxFDw== dependencies: - array-flatten "^2.1.2" - dns-equal "^1.0.0" fast-deep-equal "^3.1.3" multicast-dns "^7.2.5" @@ -2821,15 +2870,15 @@ braces@^3.0.2, braces@~3.0.2: dependencies: fill-range "^7.0.1" -browserslist@^4.0.0, browserslist@^4.14.5, browserslist@^4.18.1, browserslist@^4.21.3, browserslist@^4.21.4, browserslist@^4.21.5: - version "4.21.5" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.21.5.tgz#75c5dae60063ee641f977e00edd3cfb2fb7af6a7" - integrity sha512-tUkiguQGW7S3IhB7N+c2MV/HZPSCPAAiYBZXLsBhFB/PCy6ZKKsZrmBayHV9fdGV/ARIfJ14NkxKzRDjvp7L6w== +browserslist@^4.0.0, browserslist@^4.14.5, browserslist@^4.18.1, browserslist@^4.21.4, browserslist@^4.22.2: + version "4.22.2" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.22.2.tgz#704c4943072bd81ea18997f3bd2180e89c77874b" + integrity sha512-0UgcrvQmBDvZHFGdYUehrCNIazki7/lUP3kkoi/r3YB2amZbFM9J43ZRkJTXBUZK4gmx56+Sqk9+Vs9mwZx9+A== dependencies: - caniuse-lite "^1.0.30001449" - electron-to-chromium "^1.4.284" - node-releases "^2.0.8" - update-browserslist-db "^1.0.10" + caniuse-lite "^1.0.30001565" + electron-to-chromium "^1.4.601" + node-releases "^2.0.14" + update-browserslist-db "^1.0.13" buffer-from@^1.0.0: version "1.1.2" @@ -2867,13 +2916,14 @@ cacheable-request@^6.0.0: normalize-url "^4.1.0" responselike "^1.0.2" -call-bind@^1.0.0, call-bind@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.2.tgz#b1d4e89e688119c3c9a903ad30abb2f6a919be3c" - integrity sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA== +call-bind@^1.0.0, call-bind@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.5.tgz#6fa2b7845ce0ea49bf4d8b9ef64727a2c2e2e513" + integrity sha512-C3nQxfFZxFRVoJoGKKI8y3MOEo129NQ+FgQ08iye+Mk4zNZZGdjfs06bVTr+DBSlA66Q2VEcMki/cUCP4SercQ== dependencies: - function-bind "^1.1.1" - get-intrinsic "^1.0.2" + function-bind "^1.1.2" + get-intrinsic "^1.2.1" + set-function-length "^1.1.1" callsites@^3.0.0: version "3.1.0" @@ -2908,17 +2958,17 @@ caniuse-api@^3.0.0: lodash.memoize "^4.1.2" lodash.uniq "^4.5.0" -caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001426, caniuse-lite@^1.0.30001449: - version "1.0.30001525" - resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001525.tgz" - integrity sha512-/3z+wB4icFt3r0USMwxujAqRvaD/B7rvGTsKhbhSQErVrJvkZCLhgNLJxU8MevahQVH6hCU9FsHdNUFbiwmE7Q== +caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001565, caniuse-lite@^1.0.30001578: + version "1.0.30001579" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001579.tgz#45c065216110f46d6274311a4b3fcf6278e0852a" + integrity sha512-u5AUVkixruKHJjw/pj9wISlcMpgFWzSrczLZbrqBSxukQixmg0SJ5sZTpvaFvxU0HoQKd4yoyAogyrAz9pzJnA== ccount@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/ccount/-/ccount-1.1.0.tgz#246687debb6014735131be8abab2d93898f8d043" integrity sha512-vlNK021QdI7PNeiUh/lKkC/mNHHfV0m/Ad5JoI0TYtlBnJAslM/JIkm/tGC88bkLIwO6OQ5uV6ztS6kVAtCDlg== -chalk@^2.0.0: +chalk@^2.4.2: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== @@ -3006,14 +3056,14 @@ ci-info@^2.0.0: integrity sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ== ci-info@^3.2.0: - version "3.8.0" - resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.8.0.tgz#81408265a5380c929f0bc665d62256628ce9ef91" - integrity sha512-eXTggHWSooYhq49F2opQhuHWgzucfF2YgODK4e1566GQs5BIfP30B0oenwBJHfWxAs2fyPB1s7Mg949zLf61Yw== + version "3.9.0" + resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.9.0.tgz#4279a62028a7b1f262f3473fc9605f5e218c59b4" + integrity sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ== clean-css@^5.2.2, clean-css@^5.3.0: - version "5.3.2" - resolved "https://registry.yarnpkg.com/clean-css/-/clean-css-5.3.2.tgz#70ecc7d4d4114921f5d298349ff86a31a9975224" - integrity sha512-JVJbM+f3d3Q704rF4bqQ5UUyTtuJ0JRKNbTKVEeujCCBoMdkEi+V+e8oktO9qGQNSvHrFTM6JZRXrUvGR1czww== + version "5.3.3" + resolved "https://registry.yarnpkg.com/clean-css/-/clean-css-5.3.3.tgz#b330653cd3bd6b75009cc25c714cae7b93351ccd" + integrity sha512-D5J+kHaVb/wKSFcyyV75uCn8fiY4sV38XJoe4CUyGQ+mOU/fMVYUdH1hJC+CJQ5uY3EnW27SbJYS4X8BiLrAFg== dependencies: source-map "~0.6.0" @@ -3122,14 +3172,14 @@ colord@^2.9.1: integrity sha512-jeC1axXpnb0/2nn/Y1LPuLdgXBLH7aDcHu4KEKfqw3CUhX7ZpfBSlPKyqXE6btIgEzfWtrX3/tyBCaCvXvMkOw== colorette@^2.0.10: - version "2.0.19" - resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.19.tgz#cdf044f47ad41a0f4b56b3a0d5b4e6e1a2d5a798" - integrity sha512-3tlv/dIP7FWvj3BsbHrGLJ6l/oKh1O3TcgBqMn+yyCagOxc23fyzDS6HypQbgxWbkpDnf52p1LuR4eWDQ/K9WQ== + version "2.0.20" + resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.20.tgz#9eb793e6833067f7235902fcd3b09917a000a95a" + integrity sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w== combine-promises@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/combine-promises/-/combine-promises-1.1.0.tgz#72db90743c0ca7aab7d0d8d2052fd7b0f674de71" - integrity sha512-ZI9jvcLDxqwaXEixOhArm3r7ReIivsXkpbyEWyeOhzz1QS0iSgBPnWvEqvIQtYyamGCYA88gFhmUrs9hrrQ0pg== + version "1.2.0" + resolved "https://registry.yarnpkg.com/combine-promises/-/combine-promises-1.2.0.tgz#5f2e68451862acf85761ded4d9e2af7769c2ca6a" + integrity sha512-VcQB1ziGD0NXrhKxiwyNbCDmRzs/OShMs2GqW2DlU2A/Sd0nQxE1oWDAE5O0ygSx5mgQOn9eIFh7yKPgFRVkPQ== combined-stream@^1.0.8: version "1.0.8" @@ -3194,9 +3244,9 @@ concat-map@0.0.1: integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== concurrently@^8.0.1: - version "8.2.0" - resolved "https://registry.yarnpkg.com/concurrently/-/concurrently-8.2.0.tgz#cdc9f621a4d913366600355d68254df2c5e782f3" - integrity sha512-nnLMxO2LU492mTUj9qX/az/lESonSZu81UznYDoXtz1IQf996ixVqPAgHXwvHiHCAef/7S8HIK+fTFK7Ifk8YA== + version "8.2.2" + resolved "https://registry.yarnpkg.com/concurrently/-/concurrently-8.2.2.tgz#353141985c198cfa5e4a3ef90082c336b5851784" + integrity sha512-1dP4gpXFhei8IOtlXRE/T/4H88ElHgTiUzh71YUmtjTEHMSRS2Z/fgOxHSxxusGHogsRfxNq1vyAwxSC+EVyDg== dependencies: chalk "^4.1.2" date-fns "^2.30.0" @@ -3257,6 +3307,11 @@ convert-source-map@^1.7.0: resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.9.0.tgz#7faae62353fb4213366d0ca98358d22e8368b05f" integrity sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A== +convert-source-map@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-2.0.0.tgz#4b560f649fc4e918dd0ab75cf4961e8bc882d82a" + integrity sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg== + cookie-signature@1.0.6: version "1.0.6" resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.6.tgz#e303a882b342cc3ee8ca513a79999734dab3ae2c" @@ -3268,9 +3323,9 @@ cookie@0.5.0: integrity sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw== copy-text-to-clipboard@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/copy-text-to-clipboard/-/copy-text-to-clipboard-3.0.1.tgz#8cbf8f90e0a47f12e4a24743736265d157bce69c" - integrity sha512-rvVsHrpFcL4F2P8ihsoLdFHmd404+CMg71S756oRSeQgqk51U3kicGdnvfkrxva0xXH92SjGS62B0XIJsbh+9Q== + version "3.2.0" + resolved "https://registry.yarnpkg.com/copy-text-to-clipboard/-/copy-text-to-clipboard-3.2.0.tgz#0202b2d9bdae30a49a53f898626dcc3b49ad960b" + integrity sha512-RnJFp1XR/LOBDckxTib5Qjr/PMfkatD0MUCQgdpqS8MdKiNUzBjAQBEN6oUy+jW7LI93BBG3DtMB2KOOKpGs2Q== copy-webpack-plugin@^11.0.0: version "11.0.0" @@ -3284,22 +3339,22 @@ copy-webpack-plugin@^11.0.0: schema-utils "^4.0.0" serialize-javascript "^6.0.0" -core-js-compat@^3.25.1: - version "3.29.0" - resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.29.0.tgz#1b8d9eb4191ab112022e7f6364b99b65ea52f528" - integrity sha512-ScMn3uZNAFhK2DGoEfErguoiAHhV2Ju+oJo/jK08p7B3f3UhocUrCCkTvnZaiS+edl5nlIoiBXKcwMc6elv4KQ== +core-js-compat@^3.31.0, core-js-compat@^3.33.1: + version "3.35.0" + resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.35.0.tgz#c149a3d1ab51e743bc1da61e39cb51f461a41873" + integrity sha512-5blwFAddknKeNgsjBzilkdQ0+YK8L1PfqPYq40NOYMYFSS38qj+hpTcLLWwpIwA2A5bje/x5jmVn2tzUMg9IVw== dependencies: - browserslist "^4.21.5" + browserslist "^4.22.2" -core-js-pure@^3.25.1: - version "3.29.0" - resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.29.0.tgz#0e1ac889214398641ea4bb1c6cf25ff0959ec1d2" - integrity sha512-v94gUjN5UTe1n0yN/opTihJ8QBWD2O8i19RfTZR7foONPWArnjB96QA/wk5ozu1mm6ja3udQCzOzwQXTxi3xOQ== +core-js-pure@^3.30.2: + version "3.35.0" + resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.35.0.tgz#4660033304a050215ae82e476bd2513a419fbb34" + integrity sha512-f+eRYmkou59uh7BPcyJ8MC76DiGhspj1KMxVIcF24tzP8NA9HVa1uC7BTW2tgx7E1QVCzDzsgp7kArrzhlz8Ew== core-js@^3.23.3: - version "3.29.0" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.29.0.tgz#0273e142b67761058bcde5615c503c7406b572d6" - integrity sha512-VG23vuEisJNkGl6XQmFJd3rEG/so/CNatqeE+7uZAwTSwFeB/qaO0be8xZYUNWprJ/GIwL8aMt9cj1kvbpTZhg== + version "3.35.0" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.35.0.tgz#58e651688484f83c34196ca13f099574ee53d6b4" + integrity sha512-ntakECeqg81KqMueeGJ79Q5ZgQNR+6eaE8sxGCx62zMbAIj65q+uYvatToew3m6eAGdU4gNZwpZ34NMe4GYswg== core-util-is@~1.0.0: version "1.0.3" @@ -3331,7 +3386,7 @@ cosmiconfig@^6.0.0: path-type "^4.0.0" yaml "^1.7.2" -cosmiconfig@^7.0.0, cosmiconfig@^7.0.1: +cosmiconfig@^7.0.1: version "7.1.0" resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-7.1.0.tgz#1443b9afa596b670082ea46cbd8f6a62b84635f6" integrity sha512-AdmX6xUzdNASswsFtmwSt7Vj8po9IuqXm0UXz7QKPuEUmPB4XyjGfaAr2PSuELMwkRMVH1EpIkX5bTZGRB3eCA== @@ -3342,12 +3397,22 @@ cosmiconfig@^7.0.0, cosmiconfig@^7.0.1: path-type "^4.0.0" yaml "^1.10.0" +cosmiconfig@^8.3.5: + version "8.3.6" + resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-8.3.6.tgz#060a2b871d66dba6c8538ea1118ba1ac16f5fae3" + integrity sha512-kcZ6+W5QzcJ3P1Mt+83OUv/oHFqZHIx8DuxG6eZ5RGMERoLqp4BuGjhHLYGK+Kf5XVkQvqBSmAy/nGWN3qDgEA== + dependencies: + import-fresh "^3.3.0" + js-yaml "^4.1.0" + parse-json "^5.2.0" + path-type "^4.0.0" + cross-fetch@^3.1.5: - version "3.1.5" - resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.5.tgz#e1389f44d9e7ba767907f7af8454787952ab534f" - integrity sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw== + version "3.1.8" + resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.8.tgz#0327eba65fd68a7d119f8fb2bf9334a1a7956f82" + integrity sha512-cvA+JwZoU0Xq+h6WkMvAUqPEYy92Obet6UdKLfW60qn99ftItKjB5T+BkyWOFWe2pUyfQ+IJHmpOTznqk1M6Kg== dependencies: - node-fetch "2.6.7" + node-fetch "^2.6.12" cross-spawn@^7.0.3: version "7.0.3" @@ -3364,23 +3429,23 @@ crypto-random-string@^2.0.0: integrity sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA== css-declaration-sorter@^6.3.1: - version "6.3.1" - resolved "https://registry.yarnpkg.com/css-declaration-sorter/-/css-declaration-sorter-6.3.1.tgz#be5e1d71b7a992433fb1c542c7a1b835e45682ec" - integrity sha512-fBffmak0bPAnyqc/HO8C3n2sHrp9wcqQz6ES9koRF2/mLOVAx9zIQ3Y7R29sYCteTPqMCwns4WYQoCX91Xl3+w== + version "6.4.1" + resolved "https://registry.yarnpkg.com/css-declaration-sorter/-/css-declaration-sorter-6.4.1.tgz#28beac7c20bad7f1775be3a7129d7eae409a3a71" + integrity sha512-rtdthzxKuyq6IzqX6jEcIzQF/YqccluefyCYheovBOLhFT/drQA9zj/UbRAa9J7C0o6EG6u3E6g+vKkay7/k3g== css-loader@^6.7.1: - version "6.7.3" - resolved "https://registry.yarnpkg.com/css-loader/-/css-loader-6.7.3.tgz#1e8799f3ccc5874fdd55461af51137fcc5befbcd" - integrity sha512-qhOH1KlBMnZP8FzRO6YCH9UHXQhVMcEGLyNdb7Hv2cpcmJbW0YrddO+tG1ab5nT41KpHIYGsbeHqxB9xPu1pKQ== + version "6.9.1" + resolved "https://registry.yarnpkg.com/css-loader/-/css-loader-6.9.1.tgz#9ec9a434368f2bdfeffbf8f6901a1ce773586c6b" + integrity sha512-OzABOh0+26JKFdMzlK6PY1u5Zx8+Ck7CVRlcGNZoY9qwJjdfu2VWFuprTIpPW+Av5TZTVViYWcFQaEEQURLknQ== dependencies: icss-utils "^5.1.0" - postcss "^8.4.19" + postcss "^8.4.33" postcss-modules-extract-imports "^3.0.0" - postcss-modules-local-by-default "^4.0.0" - postcss-modules-scope "^3.0.0" + postcss-modules-local-by-default "^4.0.4" + postcss-modules-scope "^3.1.1" postcss-modules-values "^4.0.0" postcss-value-parser "^4.2.0" - semver "^7.3.8" + semver "^7.5.4" css-minimizer-webpack-plugin@^4.0.0: version "4.2.2" @@ -3503,9 +3568,9 @@ csso@^4.2.0: css-tree "^1.1.2" csstype@^3.0.2: - version "3.1.1" - resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.1.tgz#841b532c45c758ee546a11d5bd7b7b473c8c30b9" - integrity sha512-DJR/VvkAvSZW9bTouZue2sSxDwdTN92uHjqeKVm+0dAqdfNykRzQ95tay8aXMBAAPpUiq4Qcug2L7neoRh2Egw== + version "3.1.3" + resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.3.tgz#d80ff294d114fb0e6ac500fbf85b60137d7eff81" + integrity sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw== cytoscape-cose-bilkent@^4.1.0: version "4.1.0" @@ -3522,17 +3587,17 @@ cytoscape-fcose@^2.1.0: cose-base "^2.2.0" cytoscape@^3.23.0: - version "3.23.0" - resolved "https://registry.yarnpkg.com/cytoscape/-/cytoscape-3.23.0.tgz#054ee05a6d0aa3b4f139382bbf2f4e5226df3c6d" - integrity sha512-gRZqJj/1kiAVPkrVFvz/GccxsXhF3Qwpptl32gKKypO4IlqnKBjTOu+HbXtEggSGzC5KCaHp3/F7GgENrtsFkA== + version "3.28.1" + resolved "https://registry.yarnpkg.com/cytoscape/-/cytoscape-3.28.1.tgz#f32c3e009bdf32d47845a16a4cd2be2bbc01baf7" + integrity sha512-xyItz4O/4zp9/239wCcH8ZcFuuZooEeF8KHRmzjDfGdXsj3OG9MFSMA0pJE0uX3uCN/ygof6hHf4L7lst+JaDg== dependencies: heap "^0.2.6" lodash "^4.17.21" "d3-array@2 - 3", "d3-array@2.10.0 - 3", "d3-array@2.5.0 - 3", d3-array@3, d3-array@^3.2.0: - version "3.2.2" - resolved "https://registry.yarnpkg.com/d3-array/-/d3-array-3.2.2.tgz#f8ac4705c5b06914a7e0025bbf8d5f1513f6a86e" - integrity sha512-yEEyEAbDrF8C6Ob2myOBLjwBLck1Z89jMGFee0oPsn95GqjerpaOA4ch+vc2l0FNFFwMD5N7OCSEN5eAlsUbgQ== + version "3.2.4" + resolved "https://registry.yarnpkg.com/d3-array/-/d3-array-3.2.4.tgz#15fec33b237f97ac5d7c986dc77da273a8ed0bb5" + integrity sha512-tdQAmyA18i4J7wprpYq8ClcxZy3SC31QMeByyCFyRt7BVHdREQZ5lpzoe5mFEYZUWe+oq8HBvk9JjpibyEV4Jg== dependencies: internmap "1 - 2" @@ -3572,9 +3637,9 @@ d3-contour@4: d3-array "^3.2.0" d3-delaunay@6: - version "6.0.2" - resolved "https://registry.yarnpkg.com/d3-delaunay/-/d3-delaunay-6.0.2.tgz#7fd3717ad0eade2fc9939f4260acfb503f984e92" - integrity sha512-IMLNldruDQScrcfT+MWnazhHbDJhcRJyOEBAJfwQnHle1RPh6WDuLvxNArUju2VSMSUuKlY5BGHRJ2cYyoFLQQ== + version "6.0.4" + resolved "https://registry.yarnpkg.com/d3-delaunay/-/d3-delaunay-6.0.4.tgz#98169038733a0a5babbeda55054f795bb9e4a58b" + integrity sha512-mdjtIZ1XLAM8bm/hx3WwjfHt6Sggek7qH043O8KEjDXN40xi3vx/6pYSVTwLjEgiXQTbvaouWKynLBiUZ6SK6A== dependencies: delaunator "5" @@ -3738,9 +3803,9 @@ d3-zoom@3: d3-transition "2 - 3" d3@^7.4.0, d3@^7.8.2: - version "7.8.2" - resolved "https://registry.yarnpkg.com/d3/-/d3-7.8.2.tgz#2bdb3c178d095ae03b107a18837ae049838e372d" - integrity sha512-WXty7qOGSHb7HR7CfOzwN1Gw04MUOzN8qh9ZUsvwycIMb4DYMpY9xczZ6jUorGtO6bR9BPMPaueIKwiDxu9uiQ== + version "7.8.5" + resolved "https://registry.yarnpkg.com/d3/-/d3-7.8.5.tgz#fde4b760d4486cdb6f0cc8e2cbff318af844635c" + integrity sha512-JgoahDG51ncUfJu6wX/1vWQEqOflgXyl4MaHqlcSruTez7yhaRKR9i8VjjcQGeS2en/jnFivXuaIMnseMMt0XA== dependencies: d3-array "3" d3-axis "3" @@ -3789,9 +3854,14 @@ date-fns@^2.30.0: "@babel/runtime" "^7.21.0" dayjs@^1.11.7: - version "1.11.7" - resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.7.tgz#4b296922642f70999544d1144a2c25730fce63e2" - integrity sha512-+Yw9U6YO5TQohxLcIkrXBeY73WP3ejHWVvx8XCk3gxvQDCTEmS48ZrSZCKciI7Bhl/uCMyxYtE9UqRILmFphkQ== + version "1.11.10" + resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.10.tgz#68acea85317a6e164457d6d6947564029a6a16a0" + integrity sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ== + +debounce@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/debounce/-/debounce-1.2.1.tgz#38881d8f4166a5c5848020c11827b834bcb3e0a5" + integrity sha512-XRRe6Glud4rd/ZGQfiV1ruXSfbvfJedlV9Y6zOlP+2K04vBYiJEte6stfFkCP03aMnY5tsipamumUjL14fofug== debug@2.6.9, debug@^2.6.0: version "2.6.9" @@ -3800,20 +3870,13 @@ debug@2.6.9, debug@^2.6.0: dependencies: ms "2.0.0" -debug@4, debug@^4.1.0, debug@^4.1.1: +debug@4, debug@^4, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1: version "4.3.4" resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== dependencies: ms "2.1.2" -debug@^3.2.7: - version "3.2.7" - resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a" - integrity sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ== - dependencies: - ms "^2.1.1" - decompress-response@^3.3.0: version "3.3.0" resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-3.3.0.tgz#80a4dd323748384bfa248083622aedec982adff3" @@ -3834,9 +3897,9 @@ deep-extend@^0.6.0: integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== deepmerge@^4.0.0, deepmerge@^4.2.2: - version "4.3.0" - resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.3.0.tgz#65491893ec47756d44719ae520e0e2609233b59b" - integrity sha512-z2wJZXrmeHdvYJp/Ux55wIjqo81G5Bp4c+oELTW+7ar6SogWHajt5a9gO3s3IDaGSAXjDk0vlQKN3rms8ab3og== + version "4.3.1" + resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.3.1.tgz#44b5f2147cd3b00d4b56137685966f26fd25dd4a" + integrity sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A== default-gateway@^6.0.3: version "6.0.3" @@ -3850,16 +3913,26 @@ defer-to-connect@^1.0.1: resolved "https://registry.yarnpkg.com/defer-to-connect/-/defer-to-connect-1.1.3.tgz#331ae050c08dcf789f8c83a7b81f0ed94f4ac591" integrity sha512-0ISdNousHvZT2EiFlZeZAHBUvSxmKswVCEf8hW7KWgG4a8MVEu/3Vb6uWYozkjylyCxe0JBIiRB1jV45S70WVQ== +define-data-property@^1.0.1, define-data-property@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/define-data-property/-/define-data-property-1.1.1.tgz#c35f7cd0ab09883480d12ac5cb213715587800b3" + integrity sha512-E7uGkTzkk1d0ByLeSc6ZsFS79Axg+m1P/VsgYsxHgiuc3tFSj+MjMIwe90FC4lOAZzNBdY7kkO2P2wKdsQ1vgQ== + dependencies: + get-intrinsic "^1.2.1" + gopd "^1.0.1" + has-property-descriptors "^1.0.0" + define-lazy-prop@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz#3f7ae421129bcaaac9bc74905c98a0009ec9ee7f" integrity sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og== -define-properties@^1.1.4: - version "1.2.0" - resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.2.0.tgz#52988570670c9eacedd8064f4a990f2405849bd5" - integrity sha512-xvqAVKGfT1+UAvPwKTVw/njhdQ8ZhXK4lI0bCIuCMrp2up9nPnaDftrLtmpTazqd1o+UY4zgzU+avtMbDP+ldA== +define-properties@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.2.1.tgz#10781cc616eb951a80a034bafcaa7377f6af2b6c" + integrity sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg== dependencies: + define-data-property "^1.0.1" has-property-descriptors "^1.0.0" object-keys "^1.1.1" @@ -3912,9 +3985,9 @@ detab@2.0.4: repeat-string "^1.5.4" detect-libc@^2.0.0, detect-libc@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-2.0.1.tgz#e1897aa88fa6ad197862937fbc0441ef352ee0cd" - integrity sha512-463v3ZeIrcWtdgIg6vI6XUncguvr2TnGl4SzDXinkt9mSLpBJKXT3mW6xT3VQdDN11+WVs29pgvivTc4Lp8v+w== + version "2.0.2" + resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-2.0.2.tgz#8ccf2ba9315350e1241b88d0ac3b0e1fbd99605d" + integrity sha512-UX6sGumvvqSaXgdKGUsgZWqcUyIXZ/vZTrlRT/iobiKhGL0zL4d3osHj3uqllWJK+i+sixDS/3COVEOFbupFyw== detect-node@^2.0.4: version "2.1.0" @@ -3944,15 +4017,10 @@ dir-glob@^3.0.1: dependencies: path-type "^4.0.0" -dns-equal@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/dns-equal/-/dns-equal-1.0.0.tgz#b39e7f1da6eb0a75ba9c17324b34753c47e0654d" - integrity sha512-z+paD6YUQsk+AbGCEM4PrOXSss5gd66QfcVBFTKR/HpFL9jCqikS94HYwKww6fQyO7IxrIIyUu+g0Ka9tUS2Cg== - dns-packet@^5.2.2: - version "5.4.0" - resolved "https://registry.yarnpkg.com/dns-packet/-/dns-packet-5.4.0.tgz#1f88477cf9f27e78a213fb6d118ae38e759a879b" - integrity sha512-EgqGeaBB8hLiHLZtp/IbaDQTL8pZ0+IvwzSHA6d7VyMDM+B9hgddEMa9xjK5oYnw0ci0JQ6g2XCD7/f6cafU6g== + version "5.6.1" + resolved "https://registry.yarnpkg.com/dns-packet/-/dns-packet-5.6.1.tgz#ae888ad425a9d1478a0674256ab866de1012cf2f" + integrity sha512-l4gcSouhcgIKRvyy99RNVOgxXiicE+2jZoNmaNmZ6JXiGajBOJAesk1OBlJuM5k2c+eudGdLxDqXuPCKIj6kpw== dependencies: "@leichtgewicht/ip-codec" "^2.0.1" @@ -3998,7 +4066,7 @@ domhandler@^4.0.0, domhandler@^4.2.0, domhandler@^4.3.1: dependencies: domelementtype "^2.2.0" -domhandler@^5.0.1, domhandler@^5.0.2, domhandler@^5.0.3: +domhandler@^5.0.2, domhandler@^5.0.3: version "5.0.3" resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-5.0.3.tgz#cc385f7f751f1d1fc650c21374804254538c7d31" integrity sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w== @@ -4020,13 +4088,13 @@ domutils@^2.5.2, domutils@^2.8.0: domhandler "^4.2.0" domutils@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/domutils/-/domutils-3.0.1.tgz#696b3875238338cb186b6c0612bd4901c89a4f1c" - integrity sha512-z08c1l761iKhDFtfXO04C7kTdPBLi41zwOZl00WS8b5eiaebNpY00HKbztwBq+e3vyqWNwWF3mP9YLUeqIrF+Q== + version "3.1.0" + resolved "https://registry.yarnpkg.com/domutils/-/domutils-3.1.0.tgz#c47f551278d3dc4b0b1ab8cbb42d751a6f0d824e" + integrity sha512-H78uMmQtI2AhgDJjWeQmHwJJ2bLPD3GMmO7Zja/ZZh84wkm+4ut+IUnUdRa8uCGX88DiVx1j6FRe1XfxEgjEZA== dependencies: dom-serializer "^2.0.0" domelementtype "^2.3.0" - domhandler "^5.0.1" + domhandler "^5.0.3" dot-case@^3.0.4: version "3.0.4" @@ -4068,10 +4136,10 @@ ee-first@1.1.1: resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" integrity sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow== -electron-to-chromium@^1.4.284: - version "1.4.325" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.325.tgz#7b97238a61192d85d055d97f3149832b3617d37b" - integrity sha512-K1C03NT4I7BuzsRdCU5RWkgZxtswnKDYM6/eMhkEXqKu4e5T+ck610x3FPzu1y7HVFSiQKZqP16gnJzPpji1TQ== +electron-to-chromium@^1.4.601: + version "1.4.638" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.638.tgz#5564b750c2ceb64c0d2ef5a22b0748f63b66e0a3" + integrity sha512-gpmbAG2LbfPKcDaL5m9IKutKjUx4ZRkvGNkgL/8nKqxkXsBVYykVULboWlqCrHsh3razucgDJDuKoWJmGPdItA== elkjs@^0.8.2: version "0.8.2" @@ -4110,10 +4178,10 @@ end-of-stream@^1.1.0, end-of-stream@^1.4.1: dependencies: once "^1.4.0" -enhanced-resolve@^5.10.0: - version "5.12.0" - resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.12.0.tgz#300e1c90228f5b570c4d35babf263f6da7155634" - integrity sha512-QHTXI/sZQmko1cbDoNAa3mJ5qhWUUNAq3vR0/YiD379fWQrcfuoX1+HW2S0MTt7XmoPLapdaDKUtelUSPic7hQ== +enhanced-resolve@^5.15.0: + version "5.15.0" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.15.0.tgz#1af946c7d93603eb88e9896cee4904dc012e9c35" + integrity sha512-LXYT42KJ7lpIKECr2mAXIaMldcNCh/7E0KBKOu4KSfkHmP+mZmSs+8V5gBAqisWBy0OO4W5Oyys0GO1Y8KtdKg== dependencies: graceful-fs "^4.2.4" tapable "^2.2.0" @@ -4123,10 +4191,10 @@ entities@^2.0.0: resolved "https://registry.yarnpkg.com/entities/-/entities-2.2.0.tgz#098dc90ebb83d8dffa089d55256b351d34c4da55" integrity sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A== -entities@^4.2.0, entities@^4.3.0, entities@^4.4.0: - version "4.4.0" - resolved "https://registry.yarnpkg.com/entities/-/entities-4.4.0.tgz#97bdaba170339446495e653cfd2db78962900174" - integrity sha512-oYp7156SP8LkeGD0GF85ad1X9Ai79WtRsZ2gxJqtBuzH+98YUV6jkHEKlZkMbcrjJjIVJNIDP/3WL9wQkoPbWA== +entities@^4.2.0, entities@^4.4.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/entities/-/entities-4.5.0.tgz#5d268ea5e7113ec74c4d033b79ea5a35a488fb48" + integrity sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw== error-ex@^1.3.1: version "1.3.2" @@ -4135,10 +4203,10 @@ error-ex@^1.3.1: dependencies: is-arrayish "^0.2.1" -es-module-lexer@^0.9.0: - version "0.9.3" - resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-0.9.3.tgz#6f13db00cc38417137daf74366f535c8eb438f19" - integrity sha512-1HQ2M2sPtxwnvOvT1ZClHyQDiggdNjURWpY2we6aMKCQiUVxTmVs2UYPLIrD84sS+kMdUwfBSylbJPwNnBrnHQ== +es-module-lexer@^1.2.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-1.4.1.tgz#41ea21b43908fe6a287ffcbe4300f790555331f5" + integrity sha512-cXLGjP0c4T3flZJKQSuziYoq7MlT+rnvfZjfp7h+I7K9BNX54kP9nyWvdbwjQ4u1iWbOL4u96fgeZLToQlZC7w== escalade@^3.1.1: version "3.1.1" @@ -4201,9 +4269,9 @@ esutils@^2.0.2: integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== eta@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/eta/-/eta-2.0.1.tgz#199e675359cb6e19d38f29e1f405e1ba0e79a6df" - integrity sha512-46E2qDPDm7QA+usjffUWz9KfXsxVZclPOuKsXs4ZWZdI/X1wpDF7AO424pt7fdYohCzWsIkXAhNGXSlwo5naAg== + version "2.2.0" + resolved "https://registry.yarnpkg.com/eta/-/eta-2.2.0.tgz#eb8b5f8c4e8b6306561a455e62cd7492fe3a9b8a" + integrity sha512-UVQ72Rqjy/ZKQalzV5dCCJP80GrmPrMxh6NlNf+erV6ObL0ZFkhCstWRawS85z3smdr3d2wXPsZEY7rDPfGd2g== etag@~1.8.1: version "1.8.1" @@ -4302,10 +4370,10 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== -fast-glob@^3.2.11, fast-glob@^3.2.9: - version "3.2.12" - resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.12.tgz#7f39ec99c2e6ab030337142da9e0c18f37afae80" - integrity sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w== +fast-glob@^3.2.11, fast-glob@^3.2.9, fast-glob@^3.3.0: + version "3.3.2" + resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.2.tgz#a904501e57cfdd2ffcded45e99a54fef55e46129" + integrity sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow== dependencies: "@nodelib/fs.stat" "^2.0.2" "@nodelib/fs.walk" "^1.2.3" @@ -4326,9 +4394,9 @@ fast-url-parser@1.1.3: punycode "^1.3.2" fastq@^1.6.0: - version "1.15.0" - resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.15.0.tgz#d04d07c6a2a68fe4599fea8d2e103a937fae6b3a" - integrity sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw== + version "1.16.0" + resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.16.0.tgz#83b9a9375692db77a822df081edb6a9cf6839320" + integrity sha512-ifCoaXsDrsdkWTtiNJX5uzHDsrck5TzfKKDcuFFTIrrc/BS076qgEIfoIy1VeZqViznfKiysPYTh/QeHtnIsYA== dependencies: reusify "^1.0.4" @@ -4352,9 +4420,9 @@ fbjs-css-vars@^1.0.0: integrity sha512-b2XGFAFdWZWg0phtAWLHCk836A1Xann+I+Dgd3Gk64MHKZO44FfoD1KxyvbSh0qZsIoXQGGlVztIY+oitJPpRQ== fbjs@^3.0.0, fbjs@^3.0.1: - version "3.0.4" - resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-3.0.4.tgz#e1871c6bd3083bac71ff2da868ad5067d37716c6" - integrity sha512-ucV0tDODnGV3JCnnkmoszb5lf4bNpzjv80K41wd4k798Etq+UYD0y0TIfalLjZoKgjive6/adkRnszwapiDgBQ== + version "3.0.5" + resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-3.0.5.tgz#aa0edb7d5caa6340011790bd9249dbef8a81128d" + integrity sha512-ztsSx77JBtkuMrEypfhgc3cI0+0h+svqeie7xHbh1k/IKdcydnvadp/mUaGgjAOXQmQSxsqgaRhS3q9fy+1kxg== dependencies: cross-fetch "^3.1.5" fbjs-css-vars "^1.0.0" @@ -4362,7 +4430,7 @@ fbjs@^3.0.0, fbjs@^3.0.1: object-assign "^4.1.0" promise "^7.1.1" setimmediate "^1.0.5" - ua-parser-js "^0.7.30" + ua-parser-js "^1.0.35" feed@^4.2.2: version "4.2.2" @@ -4436,18 +4504,23 @@ find-up@^5.0.0: locate-path "^6.0.0" path-exists "^4.0.0" +flat@^5.0.2: + version "5.0.2" + resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241" + integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ== + flux@^4.0.1: - version "4.0.3" - resolved "https://registry.yarnpkg.com/flux/-/flux-4.0.3.tgz#573b504a24982c4768fdfb59d8d2ea5637d72ee7" - integrity sha512-yKAbrp7JhZhj6uiT1FTuVMlIAT1J4jqEyBpFApi1kxpGZCvacMVc/t1pMQyotqHhAgvoE3bNvAykhCo2CLjnYw== + version "4.0.4" + resolved "https://registry.yarnpkg.com/flux/-/flux-4.0.4.tgz#9661182ea81d161ee1a6a6af10d20485ef2ac572" + integrity sha512-NCj3XlayA2UsapRpM7va6wU1+9rE5FIL7qoMcmxWHRzbp0yujihMBm9BBHZ1MDIk5h5o2Bl6eGiCe8rYELAmYw== dependencies: fbemitter "^3.0.0" fbjs "^3.0.1" -follow-redirects@^1.0.0, follow-redirects@^1.14.7, follow-redirects@^1.15.0: - version "1.15.2" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13" - integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA== +follow-redirects@^1.0.0, follow-redirects@^1.14.7, follow-redirects@^1.15.4: + version "1.15.5" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.5.tgz#54d4d6d062c0fa7d9d17feb008461550e3ba8020" + integrity sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw== fork-ts-checker-webpack-plugin@^6.5.0: version "6.5.3" @@ -4482,10 +4555,10 @@ forwarded@0.2.0: resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.2.0.tgz#2269936428aad4c15c7ebe9779a84bf0b2a81811" integrity sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow== -fraction.js@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/fraction.js/-/fraction.js-4.2.0.tgz#448e5109a313a3527f5a3ab2119ec4cf0e0e2950" - integrity sha512-MhLuK+2gUcnZe8ZHlaaINnQLl0xRIGRfcGk2yl8xoQAfHrSsL3rYu6FCmBdkdbhc9EPlwyGHewaRsvwRMJtAlA== +fraction.js@^4.3.7: + version "4.3.7" + resolved "https://registry.yarnpkg.com/fraction.js/-/fraction.js-4.3.7.tgz#06ca0085157e42fda7f9e726e79fefc4068840f7" + integrity sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew== fresh@0.5.2: version "0.5.2" @@ -4516,10 +4589,10 @@ fs-extra@^9.0.0: jsonfile "^6.0.1" universalify "^2.0.0" -fs-monkey@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/fs-monkey/-/fs-monkey-1.0.3.tgz#ae3ac92d53bb328efe0e9a1d9541f6ad8d48e2d3" - integrity sha512-cybjIfiiE+pTWicSCLFHSrXZ6EilF30oh91FDP9S2B051prEa7QWfrVTQm10/dDpswBDXZugPa1Ogu8Yh+HV0Q== +fs-monkey@^1.0.4: + version "1.0.5" + resolved "https://registry.yarnpkg.com/fs-monkey/-/fs-monkey-1.0.5.tgz#fe450175f0db0d7ea758102e1d84096acb925788" + integrity sha512-8uMbBjrhzW76TYgEV27Y5E//W2f/lTFmx78P2w19FZSxarhI/798APGQyuGCwmkNxgwGRhrLfvWyLBvNtuOmew== fs.realpath@^1.0.0: version "1.0.0" @@ -4527,14 +4600,14 @@ fs.realpath@^1.0.0: integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== fsevents@~2.3.2: - version "2.3.2" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" - integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== + version "2.3.3" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" + integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== -function-bind@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" - integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== +function-bind@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.2.tgz#2c02d864d97f3ea6c8830c464cbd11ab6eab7a1c" + integrity sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA== gensync@^1.0.0-beta.1, gensync@^1.0.0-beta.2: version "1.0.0-beta.2" @@ -4546,14 +4619,15 @@ get-caller-file@^2.0.5: resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== -get-intrinsic@^1.0.2, get-intrinsic@^1.1.1: - version "1.2.0" - resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.2.0.tgz#7ad1dc0535f3a2904bba075772763e5051f6d05f" - integrity sha512-L049y6nFOuom5wGyRc3/gdTLO94dySVKRACj1RmJZBQXlbTMhtNIgkWkUHq+jYmZvKf14EW1EoJnnjbmoHij0Q== +get-intrinsic@^1.0.2, get-intrinsic@^1.1.3, get-intrinsic@^1.2.1, get-intrinsic@^1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.2.2.tgz#281b7622971123e1ef4b3c90fd7539306da93f3b" + integrity sha512-0gSo4ml/0j98Y3lngkFEot/zhiCeWsbYIlZ+uZOVgzLyLaUw7wxUL+nCTP0XJvJg1AXulJRI3UJi8GsbDuxdGA== dependencies: - function-bind "^1.1.1" - has "^1.0.3" + function-bind "^1.1.2" + has-proto "^1.0.1" has-symbols "^1.0.3" + hasown "^2.0.0" get-own-enumerable-property-symbols@^3.0.0: version "3.0.2" @@ -4661,16 +4735,23 @@ globby@^11.0.1, globby@^11.0.4, globby@^11.1.0: slash "^3.0.0" globby@^13.1.1: - version "13.1.3" - resolved "https://registry.yarnpkg.com/globby/-/globby-13.1.3.tgz#f62baf5720bcb2c1330c8d4ef222ee12318563ff" - integrity sha512-8krCNHXvlCgHDpegPzleMq07yMYTO2sXKASmZmquEYWEmCx6J5UTRbp5RwMJkTJGtcQ44YpiUYUiN0b9mzy8Bw== + version "13.2.2" + resolved "https://registry.yarnpkg.com/globby/-/globby-13.2.2.tgz#63b90b1bf68619c2135475cbd4e71e66aa090592" + integrity sha512-Y1zNGV+pzQdh7H39l9zgB4PJqjRNqydvdYCDG4HFXM4XuvSaQQlEc91IU1yALL8gUTDomgBAfz3XJdmUS+oo0w== dependencies: dir-glob "^3.0.1" - fast-glob "^3.2.11" - ignore "^5.2.0" + fast-glob "^3.3.0" + ignore "^5.2.4" merge2 "^1.4.1" slash "^4.0.0" +gopd@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/gopd/-/gopd-1.0.1.tgz#29ff76de69dac7489b7c0918a5788e56477c332c" + integrity sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA== + dependencies: + get-intrinsic "^1.1.3" + got@^9.6.0: version "9.6.0" resolved "https://registry.yarnpkg.com/got/-/got-9.6.0.tgz#edf45e7d67f99545705de1f7bbeeeb121765ed85" @@ -4689,9 +4770,9 @@ got@^9.6.0: url-parse-lax "^3.0.0" graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.4, graceful-fs@^4.2.6, graceful-fs@^4.2.9: - version "4.2.10" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c" - integrity sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA== + version "4.2.11" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3" + integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ== gray-matter@^4.0.3: version "4.0.3" @@ -4737,12 +4818,17 @@ has-flag@^4.0.0: resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== -has-property-descriptors@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz#610708600606d36961ed04c196193b6a607fa861" - integrity sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ== +has-property-descriptors@^1.0.0, has-property-descriptors@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/has-property-descriptors/-/has-property-descriptors-1.0.1.tgz#52ba30b6c5ec87fd89fa574bc1c39125c6f65340" + integrity sha512-VsX8eaIewvas0xnvinAe9bw4WfIeODpGYikiWYLH+dma0Jw6KHYqWiWfhQlgOVK8D6PvjubK5Uc4P0iIhIcNVg== dependencies: - get-intrinsic "^1.1.1" + get-intrinsic "^1.2.2" + +has-proto@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/has-proto/-/has-proto-1.0.1.tgz#1885c1305538958aff469fef37937c22795408e0" + integrity sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg== has-symbols@^1.0.3: version "1.0.3" @@ -4754,12 +4840,12 @@ has-yarn@^2.1.0: resolved "https://registry.yarnpkg.com/has-yarn/-/has-yarn-2.1.0.tgz#137e11354a7b5bf11aa5cb649cf0c6f3ff2b2e77" integrity sha512-UqBRqi4ju7T+TqGNdqAO0PaSVGsDGJUBQvk9eUWNGRY1CFGDzYhLWoM7JQEemnlvVcv/YEmc2wNW8BC24EnUsw== -has@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" - integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== +hasown@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/hasown/-/hasown-2.0.0.tgz#f4c513d454a57b7c7e1650778de226b11700546c" + integrity sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA== dependencies: - function-bind "^1.1.1" + function-bind "^1.1.2" hast-to-hyperscript@^9.0.0: version "9.0.1" @@ -4883,9 +4969,14 @@ hpack.js@^2.1.6: wbuf "^1.1.0" html-entities@^2.3.2: - version "2.3.3" - resolved "https://registry.yarnpkg.com/html-entities/-/html-entities-2.3.3.tgz#117d7626bece327fc8baace8868fa6f5ef856e46" - integrity sha512-DV5Ln36z34NNTDgnz0EWGBLZENelNAtkiFA4kyNOG2tDI6Mz1uSWiq1wAKdyjnJwyDiDO7Fa2SO1CTxPXL8VxA== + version "2.4.0" + resolved "https://registry.yarnpkg.com/html-entities/-/html-entities-2.4.0.tgz#edd0cee70402584c8c76cc2c0556db09d1f45061" + integrity sha512-igBTJcNNNhvZFRtm8uA6xMY6xYleeDwn3PeBCkDz7tHttv4F2hsDI2aPgNERWzvRcNYHNT3ymRaQzllmXj4YsQ== + +html-escaper@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/html-escaper/-/html-escaper-2.0.2.tgz#dfd60027da36a36dfcbe236262c00a5822681453" + integrity sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg== html-minifier-terser@^6.0.2, html-minifier-terser@^6.1.0: version "6.1.0" @@ -4901,9 +4992,9 @@ html-minifier-terser@^6.0.2, html-minifier-terser@^6.1.0: terser "^5.10.0" html-tags@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/html-tags/-/html-tags-3.2.0.tgz#dbb3518d20b726524e4dd43de397eb0a95726961" - integrity sha512-vy7ClnArOZwCnqZgvv+ddgHgJiAFXe3Ge9ML5/mBctVJoUoYPCdxVucOywjDARn6CVoh3dRSFdPHy2sX80L0Wg== + version "3.3.1" + resolved "https://registry.yarnpkg.com/html-tags/-/html-tags-3.3.1.tgz#a04026a18c882e4bba8a01a3d39cfe465d40b5ce" + integrity sha512-ztqyC3kLto0e9WbNp0aeP+M3kTt+nbaIveGmUxAtZa+8iFgKLUOD4YKM5j+f3QD89bra7UeumolZHKuOXnTmeQ== html-void-elements@^1.0.0: version "1.0.5" @@ -4911,9 +5002,9 @@ html-void-elements@^1.0.0: integrity sha512-uE/TxKuyNIcx44cIWnjr/rfIATDH7ZaOMmstu0CwhFG1Dunhlp4OC6/NMbhiwoq5BpW0ubi303qnEk/PZj614w== html-webpack-plugin@^5.5.0: - version "5.5.0" - resolved "https://registry.yarnpkg.com/html-webpack-plugin/-/html-webpack-plugin-5.5.0.tgz#c3911936f57681c1f9f4d8b68c158cd9dfe52f50" - integrity sha512-sy88PC2cRTVxvETRgUHFrL4No3UxvcH8G1NepGhqaTT+GXN2kTamqasot0inS5hXeg1cMbFDt27zzo9p35lZVw== + version "5.6.0" + resolved "https://registry.yarnpkg.com/html-webpack-plugin/-/html-webpack-plugin-5.6.0.tgz#50a8fa6709245608cb00e811eacecb8e0d7b7ea0" + integrity sha512-iwaY4wzbe48AfKLZ/Cc8k0L+FKG6oSNRaZ8x5A/T/IVDGyXcbHncM9TdDa93wn0FsSm82FhTKW7f3vS61thXAw== dependencies: "@types/html-minifier-terser" "^6.0.0" html-minifier-terser "^6.0.2" @@ -4932,14 +5023,14 @@ htmlparser2@^6.1.0: entities "^2.0.0" htmlparser2@^8.0.1: - version "8.0.1" - resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-8.0.1.tgz#abaa985474fcefe269bc761a779b544d7196d010" - integrity sha512-4lVbmc1diZC7GUJQtRQ5yBAeUCL1exyMwmForWkRLnwyzWBFxN633SALPMGYaWZvKe9j1pRZJpauvmxENSp/EA== + version "8.0.2" + resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-8.0.2.tgz#f002151705b383e62433b5cf466f5b716edaec21" + integrity sha512-GYdjWKDkbRLkZ5geuHs5NY1puJ+PXwP7+fHPRz06Eirsb9ugf6d8kkXav6ADhcODhFFPMIXyxkxSuMf3D6NCFA== dependencies: domelementtype "^2.3.0" - domhandler "^5.0.2" + domhandler "^5.0.3" domutils "^3.0.1" - entities "^4.3.0" + entities "^4.4.0" http-cache-semantics@^4.0.0: version "4.1.1" @@ -5031,22 +5122,22 @@ ignore-by-default@^1.0.1: resolved "https://registry.yarnpkg.com/ignore-by-default/-/ignore-by-default-1.0.1.tgz#48ca6d72f6c6a3af00a9ad4ae6876be3889e2b09" integrity sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA== -ignore@^5.2.0: - version "5.2.4" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.4.tgz#a291c0c6178ff1b960befe47fcdec301674a6324" - integrity sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ== +ignore@^5.2.0, ignore@^5.2.4: + version "5.3.0" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.3.0.tgz#67418ae40d34d6999c95ff56016759c718c82f78" + integrity sha512-g7dmpshy+gD7mh88OC9NwSGTKoc3kyLAZQRU1mt53Aw/vnvfXnbC+F/7F7QoYVKbV+KNvJx8wArewKy1vXMtlg== image-size@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/image-size/-/image-size-1.0.2.tgz#d778b6d0ab75b2737c1556dd631652eb963bc486" - integrity sha512-xfOoWjceHntRb3qFCrh5ZFORYH8XCdYpASltMhZ/Q0KZiOwjdE/Yl2QCiWdwD+lygV5bMCvauzgu5PxBX/Yerg== + version "1.1.1" + resolved "https://registry.yarnpkg.com/image-size/-/image-size-1.1.1.tgz#ddd67d4dc340e52ac29ce5f546a09f4e29e840ac" + integrity sha512-541xKlUw6jr/6gGuk92F+mYM5zaFAc5ahphvkqvNe2bQ6gVBkd6bfrmVJ2t4KDAfikAYZyIqTnktX3i6/aQDrQ== dependencies: queue "6.0.2" immer@^9.0.7: - version "9.0.19" - resolved "https://registry.yarnpkg.com/immer/-/immer-9.0.19.tgz#67fb97310555690b5f9cd8380d38fc0aabb6b38b" - integrity sha512-eY+Y0qcsB4TZKwgQzLaE/lqYMlKhv5J9dyd2RhhtGhNo2njPXDqU9XPfcNfa3MIDsdtZt5KlkIsirlo4dHsWdQ== + version "9.0.21" + resolved "https://registry.yarnpkg.com/immer/-/immer-9.0.21.tgz#1e025ea31a40f24fb064f1fef23e931496330176" + integrity sha512-bc4NBHqOqSfRW7POMkHd51LvClaeMXpm8dx0e8oE2GORbq5aRK7Bxl4FyzVLdGtLmvLKL7BTDBG5ACQm4HWjTA== import-fresh@^3.1.0, import-fresh@^3.2.1, import-fresh@^3.3.0: version "3.3.0" @@ -5132,9 +5223,9 @@ ipaddr.js@1.9.1: integrity sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g== ipaddr.js@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-2.0.1.tgz#eca256a7a877e917aeb368b0a7497ddf42ef81c0" - integrity sha512-1qTgH9NG+IIJ4yfKs2e6Pp1bZg8wbDbKHT21HrLIeYBTRLgMYKnMTPAuI3Lcs61nfx5h1xlXnbJtH1kX5/d/ng== + version "2.1.0" + resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-2.1.0.tgz#2119bc447ff8c257753b196fc5f1ce08a4cdf39f" + integrity sha512-LlbxQ7xKzfBusov6UMi4MFpEg0m+mAm9xyNGEduwXMEDuf4WfzB/RZwMVYEd7IKGvh4IUkEXYxtAVu9T3OelJQ== is-alphabetical@1.0.4, is-alphabetical@^1.0.0: version "1.0.4" @@ -5178,12 +5269,12 @@ is-ci@^2.0.0: dependencies: ci-info "^2.0.0" -is-core-module@^2.9.0: - version "2.11.0" - resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.11.0.tgz#ad4cb3e3863e814523c96f3f58d26cc570ff0144" - integrity sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw== +is-core-module@^2.13.0: + version "2.13.1" + resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.13.1.tgz#ad0d7532c6fea9da1ebdc82742d74525c6273384" + integrity sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw== dependencies: - has "^1.0.3" + hasown "^2.0.0" is-decimal@^1.0.0: version "1.0.4" @@ -5277,6 +5368,11 @@ is-plain-object@^2.0.4: dependencies: isobject "^3.0.1" +is-plain-object@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-5.0.0.tgz#4427f50ab3429e9025ea7d52e9043a9ef4159344" + integrity sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q== + is-regexp@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-regexp/-/is-regexp-1.0.0.tgz#fd2d883545c46bac5a633e7b9a09e87fa2cb5069" @@ -5339,12 +5435,12 @@ isobject@^3.0.1: resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" integrity sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg== -jest-util@^29.5.0: - version "29.5.0" - resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-29.5.0.tgz#24a4d3d92fc39ce90425311b23c27a6e0ef16b8f" - integrity sha512-RYMgG/MTadOr5t8KdhejfvUU82MxsCu5MF6KuDUHl+NuwzUt+Sm6jJWxTJVrDR1j5M/gJVCPKQEpWXY+yIQ6lQ== +jest-util@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-29.7.0.tgz#23c2b62bfb22be82b44de98055802ff3710fc0bc" + integrity sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA== dependencies: - "@jest/types" "^29.5.0" + "@jest/types" "^29.6.3" "@types/node" "*" chalk "^4.0.0" ci-info "^3.2.0" @@ -5361,23 +5457,28 @@ jest-worker@^27.4.5: supports-color "^8.0.0" jest-worker@^29.1.2: - version "29.5.0" - resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-29.5.0.tgz#bdaefb06811bd3384d93f009755014d8acb4615d" - integrity sha512-NcrQnevGoSp4b5kg+akIpthoAFHxPBcb5P6mYPY0fUNT+sSvmtu6jlkEle3anczUKIKEbMxFimk9oTP/tpIPgA== + version "29.7.0" + resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-29.7.0.tgz#acad073acbbaeb7262bd5389e1bcf43e10058d4a" + integrity sha512-eIz2msL/EzL9UFTFFx7jBTkeZfku0yUAyZZZmJ93H2TYEiroIx2PQjEXcwYtYl8zXCxb+PAmA2hLIt/6ZEkPHw== dependencies: "@types/node" "*" - jest-util "^29.5.0" + jest-util "^29.7.0" merge-stream "^2.0.0" supports-color "^8.0.0" +jiti@^1.20.0: + version "1.21.0" + resolved "https://registry.yarnpkg.com/jiti/-/jiti-1.21.0.tgz#7c97f8fe045724e136a397f7340475244156105d" + integrity sha512-gFqAIbuKyyso/3G2qhiO2OM6shY6EPP/R0+mkDbyspxKazh8BXDC5FiFsUjlczgdNz/vfra0da2y+aHrusLG/Q== + joi@^17.6.0: - version "17.8.3" - resolved "https://registry.yarnpkg.com/joi/-/joi-17.8.3.tgz#d772fe27a87a5cda21aace5cf11eee8671ca7e6f" - integrity sha512-q5Fn6Tj/jR8PfrLrx4fpGH4v9qM6o+vDUfD4/3vxxyg34OmKcNqYZ1qn2mpLza96S8tL0p0rIw2gOZX+/cTg9w== + version "17.12.0" + resolved "https://registry.yarnpkg.com/joi/-/joi-17.12.0.tgz#a3fb5715f198beb0471cd551dd26792089c308d5" + integrity sha512-HSLsmSmXz+PV9PYoi3p7cgIbj06WnEBNT28n+bbBNcPZXZFqCzzvGqpTBPujx/Z0nh1+KNQPDrNgdmQ8dq0qYw== dependencies: - "@hapi/hoek" "^9.0.0" - "@hapi/topo" "^5.0.0" - "@sideway/address" "^4.1.3" + "@hapi/hoek" "^9.3.0" + "@hapi/topo" "^5.1.0" + "@sideway/address" "^4.1.4" "@sideway/formula" "^3.0.1" "@sideway/pinpoint" "^2.0.0" @@ -5431,7 +5532,7 @@ json-schema-traverse@^1.0.0: resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz#ae7bcb3656ab77a73ba5c49bf654f38e6b6860e2" integrity sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug== -json5@^2.1.2, json5@^2.2.2: +json5@^2.1.2, json5@^2.2.3: version "2.2.3" resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283" integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg== @@ -5465,9 +5566,9 @@ keyv@^3.0.0: json-buffer "3.0.0" khroma@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/khroma/-/khroma-2.0.0.tgz#7577de98aed9f36c7a474c4d453d94c0d6c6588b" - integrity sha512-2J8rDNlQWbtiNYThZRvmMv5yt44ZakX+Tz5ZIp/mN1pt4snn+m030Va5Z4v8xA0cQFDXBwO/8i42xL4QPsVk3g== + version "2.1.0" + resolved "https://registry.yarnpkg.com/khroma/-/khroma-2.1.0.tgz#45f2ce94ce231a437cf5b63c2e886e6eb42bbbb1" + integrity sha512-Ls993zuzfayK269Svk9hzpeGUKob/sIgZzyHYdjQoAdQetRKpOLj+k/QQQ/6Qi0Yz65mlROrfd+Ev+1+7dz9Kw== kind-of@^6.0.0, kind-of@^6.0.2: version "6.0.3" @@ -5479,11 +5580,6 @@ kleur@^3.0.3: resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e" integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w== -klona@^2.0.5: - version "2.0.6" - resolved "https://registry.yarnpkg.com/klona/-/klona-2.0.6.tgz#85bffbf819c03b2f53270412420a4555ef882e22" - integrity sha512-dhG34DXATL5hSxJbIexCft8FChFXtmskoZYnoPWjXQuebWYCNkVeV3KkGegCK9CP1oswI/vQibS2GY7Em/sJJA== - latest-version@^5.1.0: version "5.1.0" resolved "https://registry.yarnpkg.com/latest-version/-/latest-version-5.1.0.tgz#119dfe908fe38d15dfa43ecd13fa12ec8832face" @@ -5491,6 +5587,14 @@ latest-version@^5.1.0: dependencies: package-json "^6.3.0" +launch-editor@^2.6.0: + version "2.6.1" + resolved "https://registry.yarnpkg.com/launch-editor/-/launch-editor-2.6.1.tgz#f259c9ef95cbc9425620bbbd14b468fcdb4ffe3c" + integrity sha512-eB/uXmFVpY4zezmGp5XtU21kwo7GBbKB+EQ+UZeWtGb9yAM5xt/Evk+lYH3eRNAtId+ej4u7TYPFZ07w4s7rRw== + dependencies: + picocolors "^1.0.0" + shell-quote "^1.8.1" + layout-base@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/layout-base/-/layout-base-1.0.2.tgz#1291e296883c322a9dd4c5dd82063721b53e26e2" @@ -5706,11 +5810,11 @@ media-typer@0.3.0: integrity sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ== memfs@^3.1.2, memfs@^3.4.3: - version "3.4.13" - resolved "https://registry.yarnpkg.com/memfs/-/memfs-3.4.13.tgz#248a8bd239b3c240175cd5ec548de5227fc4f345" - integrity sha512-omTM41g3Skpvx5dSYeZIbXKcXoAVc/AoMNwn9TKx++L/gaen/+4TTttmu8ZSch5vfVJ8uJvGbroTsIlslRg6lg== + version "3.6.0" + resolved "https://registry.yarnpkg.com/memfs/-/memfs-3.6.0.tgz#d7a2110f86f79dd950a8b6df6d57bc984aa185f6" + integrity sha512-EGowvkkgbMcIChjMTMkESFDbZeSh8xZ7kNSF0hAiAN4Jh6jgHCRS0Ga/+C8y6Au+oqpezRHCfPsmJ2+DwAgiwQ== dependencies: - fs-monkey "^1.0.3" + fs-monkey "^1.0.4" memoize-one@^5.1.1: version "5.2.1" @@ -5812,9 +5916,9 @@ mimic-response@^3.1.0: integrity sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ== mini-css-extract-plugin@^2.6.1: - version "2.7.3" - resolved "https://registry.yarnpkg.com/mini-css-extract-plugin/-/mini-css-extract-plugin-2.7.3.tgz#794aa4d598bf178a66b2a35fe287c3df3eac394e" - integrity sha512-CD9cXeKeXLcnMw8FZdtfrRrLaM7gwCl4nKuKn2YkY2Bw5wdlB8zU2cCzw+w2zS9RFvbrufTBkMCJACNPwqQA0w== + version "2.7.7" + resolved "https://registry.yarnpkg.com/mini-css-extract-plugin/-/mini-css-extract-plugin-2.7.7.tgz#4acf02f362c641c38fb913bfcb7ca2fc4a7cf339" + integrity sha512-+0n11YGyRavUR3IlaOzJ0/4Il1avMvJ1VJfhWfCn24ITQXhRr1gghbhhrda6tgtNcpZaWKdSuwKq20Jb7fnlyw== dependencies: schema-utils "^4.0.0" @@ -5837,25 +5941,20 @@ minimatch@^9.0.3: dependencies: brace-expansion "^2.0.1" -minimist@^1.2.0, minimist@^1.2.5: +minimist@^1.2.0, minimist@^1.2.3, minimist@^1.2.5: version "1.2.8" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c" integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA== -minimist@^1.2.3: - version "1.2.7" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.7.tgz#daa1c4d91f507390437c6a8bc01078e7000c4d18" - integrity sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g== - mkdirp-classic@^0.5.2, mkdirp-classic@^0.5.3: version "0.5.3" resolved "https://registry.yarnpkg.com/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz#fa10c9115cc6d8865be221ba47ee9bed78601113" integrity sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A== -mrmime@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/mrmime/-/mrmime-1.0.1.tgz#5f90c825fad4bdd41dc914eff5d1a8cfdaf24f27" - integrity sha512-hzzEagAgDyoU1Q6yg5uI+AorQgdvMCur3FcKf7NhMKWsaYg+RnbTyHRa/9IlLF9rf455MOCtcqqrQQ83pPP7Uw== +mrmime@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/mrmime/-/mrmime-2.0.0.tgz#151082a6e06e59a9a39b46b3e14d5cfe92b3abb4" + integrity sha512-eu38+hdgojoyq63s+yTpN4XMBdt5l8HhMhc4VKLO9KM5caLIBvUm4thi7fFaxyTmCKeNnXZ5pAlBwCUnhA09uw== ms@2.0.0: version "2.0.0" @@ -5867,7 +5966,7 @@ ms@2.1.2: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== -ms@2.1.3, ms@^2.1.1: +ms@2.1.3: version "2.1.3" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== @@ -5880,10 +5979,10 @@ multicast-dns@^7.2.5: dns-packet "^5.2.2" thunky "^1.0.2" -nanoid@^3.3.4: - version "3.3.4" - resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.4.tgz#730b67e3cd09e2deacf03c027c81c9d9dbc5e8ab" - integrity sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw== +nanoid@^3.3.7: + version "3.3.7" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.7.tgz#d0c301a691bc8d54efa0a2226ccf3fe2fd656bd8" + integrity sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g== napi-build-utils@^1.0.1: version "1.0.2" @@ -5909,9 +6008,9 @@ no-case@^3.0.4: tslib "^2.0.3" node-abi@^3.3.0: - version "3.31.0" - resolved "https://registry.yarnpkg.com/node-abi/-/node-abi-3.31.0.tgz#dfb2ea3d01188eb80859f69bb4a4354090c1b355" - integrity sha512-eSKV6s+APenqVh8ubJyiu/YhZgxQpGP66ntzUb3lY1xB9ukSRaGnx0AIxI+IM+1+IVYC1oWobgG5L3Lt9ARykQ== + version "3.54.0" + resolved "https://registry.yarnpkg.com/node-abi/-/node-abi-3.54.0.tgz#f6386f7548817acac6434c6cba02999c9aebcc69" + integrity sha512-p7eGEiQil0YUV3ItH4/tBb781L5impVmmx2E9FRKF7d18XXzp4PGT2tdYMFY6wQqgxD0IwNZOiSJ0/K0fSi/OA== dependencies: semver "^7.3.5" @@ -5927,10 +6026,10 @@ node-emoji@^1.10.0: dependencies: lodash "^4.17.21" -node-fetch@2.6.7: - version "2.6.7" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" - integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== +node-fetch@^2.6.12: + version "2.7.0" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" + integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A== dependencies: whatwg-url "^5.0.0" @@ -5939,18 +6038,18 @@ node-forge@^1: resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-1.3.1.tgz#be8da2af243b2417d5f646a770663a92b7e9ded3" integrity sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA== -node-releases@^2.0.8: - version "2.0.10" - resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.10.tgz#c311ebae3b6a148c89b1813fd7c4d3c024ef537f" - integrity sha512-5GFldHPXVG/YZmFzJvKK2zDSzPKhEp0+ZR5SVaoSag9fsL5YgHbUHDfnG5494ISANDcK4KwPXAx2xqVEydmd7w== +node-releases@^2.0.14: + version "2.0.14" + resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.14.tgz#2ffb053bceb8b2be8495ece1ab6ce600c4461b0b" + integrity sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw== nodemon@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/nodemon/-/nodemon-3.0.1.tgz#affe822a2c5f21354466b2fc8ae83277d27dadc7" - integrity sha512-g9AZ7HmkhQkqXkRc20w+ZfQ73cHLbE8hnPbtaFbFtCumZsjyMhKk9LajQ07U5Ux28lvFjZ5X7HvWR1xzU8jHVw== + version "3.0.3" + resolved "https://registry.yarnpkg.com/nodemon/-/nodemon-3.0.3.tgz#244a62d1c690eece3f6165c6cdb0db03ebd80b76" + integrity sha512-7jH/NXbFPxVaMwmBCC2B9F/V6X1VkEdNgx3iu9jji8WxWcvhMWkmhNWhI5077zknOnZnBzba9hZP6bCPJLSReQ== dependencies: chokidar "^3.5.2" - debug "^3.2.7" + debug "^4" ignore-by-default "^1.0.1" minimatch "^3.1.2" pstree.remy "^1.1.8" @@ -6017,9 +6116,9 @@ object-assign@^4.1.0, object-assign@^4.1.1: integrity sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg== object-inspect@^1.9.0: - version "1.12.3" - resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.12.3.tgz#ba62dffd67ee256c8c086dfae69e016cd1f198b9" - integrity sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g== + version "1.13.1" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.13.1.tgz#b96c6109324ccfef6b12216a956ca4dc2ff94bc2" + integrity sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ== object-keys@^1.1.1: version "1.1.1" @@ -6027,12 +6126,12 @@ object-keys@^1.1.1: integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== object.assign@^4.1.0: - version "4.1.4" - resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.4.tgz#9673c7c7c351ab8c4d0b516f4343ebf4dfb7799f" - integrity sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ== + version "4.1.5" + resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.5.tgz#3a833f9ab7fdb80fc9e8d2300c803d216d8fdbb0" + integrity sha512-byy+U7gp+FVwmyzKPYhW2h5l3crpmGsxl7X2s8y43IgxvG4g3QZ6CffDtsNQy1WsmZpQbO+ybo0AlW7TY6DcBQ== dependencies: - call-bind "^1.0.2" - define-properties "^1.1.4" + call-bind "^1.0.5" + define-properties "^1.2.1" has-symbols "^1.0.3" object-keys "^1.1.1" @@ -6178,7 +6277,7 @@ parse-entities@^2.0.0: is-decimal "^1.0.0" is-hexadecimal "^1.0.0" -parse-json@^5.0.0: +parse-json@^5.0.0, parse-json@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-5.2.0.tgz#c76fc66dee54231c962b22bcc8a72cf2f99753cd" integrity sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg== @@ -6356,13 +6455,13 @@ postcss-discard-unused@^5.1.0: postcss-selector-parser "^6.0.5" postcss-loader@^7.0.0: - version "7.0.2" - resolved "https://registry.yarnpkg.com/postcss-loader/-/postcss-loader-7.0.2.tgz#b53ff44a26fba3688eee92a048c7f2d4802e23bb" - integrity sha512-fUJzV/QH7NXUAqV8dWJ9Lg4aTkDCezpTS5HgJ2DvqznexTbSTxgi/dTECvTZ15BwKTtk8G/bqI/QTu2HPd3ZCg== + version "7.3.4" + resolved "https://registry.yarnpkg.com/postcss-loader/-/postcss-loader-7.3.4.tgz#aed9b79ce4ed7e9e89e56199d25ad1ec8f606209" + integrity sha512-iW5WTTBSC5BfsBJ9daFMPVrLT36MrNiC6fqOZTTaHjBNX6Pfd5p+hSBqe/fEeNd7pc13QiAyGt7VdGMw4eRC4A== dependencies: - cosmiconfig "^7.0.0" - klona "^2.0.5" - semver "^7.3.8" + cosmiconfig "^8.3.5" + jiti "^1.20.0" + semver "^7.5.4" postcss-merge-idents@^5.1.1: version "5.1.1" @@ -6427,19 +6526,19 @@ postcss-modules-extract-imports@^3.0.0: resolved "https://registry.yarnpkg.com/postcss-modules-extract-imports/-/postcss-modules-extract-imports-3.0.0.tgz#cda1f047c0ae80c97dbe28c3e76a43b88025741d" integrity sha512-bdHleFnP3kZ4NYDhuGlVK+CMrQ/pqUm8bx/oGL93K6gVwiclvX5x0n76fYMKuIGKzlABOy13zsvqjb0f92TEXw== -postcss-modules-local-by-default@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/postcss-modules-local-by-default/-/postcss-modules-local-by-default-4.0.0.tgz#ebbb54fae1598eecfdf691a02b3ff3b390a5a51c" - integrity sha512-sT7ihtmGSF9yhm6ggikHdV0hlziDTX7oFoXtuVWeDd3hHObNkcHRo9V3yg7vCAY7cONyxJC/XXCmmiHHcvX7bQ== +postcss-modules-local-by-default@^4.0.4: + version "4.0.4" + resolved "https://registry.yarnpkg.com/postcss-modules-local-by-default/-/postcss-modules-local-by-default-4.0.4.tgz#7cbed92abd312b94aaea85b68226d3dec39a14e6" + integrity sha512-L4QzMnOdVwRm1Qb8m4x8jsZzKAaPAgrUF1r/hjDR2Xj7R+8Zsf97jAlSQzWtKx5YNiNGN8QxmPFIc/sh+RQl+Q== dependencies: icss-utils "^5.0.0" postcss-selector-parser "^6.0.2" postcss-value-parser "^4.1.0" -postcss-modules-scope@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/postcss-modules-scope/-/postcss-modules-scope-3.0.0.tgz#9ef3151456d3bbfa120ca44898dfca6f2fa01f06" - integrity sha512-hncihwFA2yPath8oZ15PZqvWGkWf+XUfQgUGamS4LqoP1anQLOsOJw0vr7J7IwLpoY9fatA2qiGUGmuZL0Iqlg== +postcss-modules-scope@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/postcss-modules-scope/-/postcss-modules-scope-3.1.1.tgz#32cfab55e84887c079a19bbb215e721d683ef134" + integrity sha512-uZgqzdTleelWjzJY+Fhti6F3C9iF1JR/dODLs/JDefozYcKTBCdD8BIl6nNPbTbcLnGrk56hzwZC2DaGNvYjzA== dependencies: postcss-selector-parser "^6.0.4" @@ -6544,17 +6643,17 @@ postcss-reduce-transforms@^5.1.0: postcss-value-parser "^4.2.0" postcss-selector-parser@^6.0.2, postcss-selector-parser@^6.0.4, postcss-selector-parser@^6.0.5, postcss-selector-parser@^6.0.9: - version "6.0.11" - resolved "https://registry.yarnpkg.com/postcss-selector-parser/-/postcss-selector-parser-6.0.11.tgz#2e41dc39b7ad74046e1615185185cd0b17d0c8dc" - integrity sha512-zbARubNdogI9j7WY4nQJBiNqQf3sLS3wCP4WfOidu+p28LofJqDH1tcXypGrcmMHhDk2t9wGhCsYe/+szLTy1g== + version "6.0.15" + resolved "https://registry.yarnpkg.com/postcss-selector-parser/-/postcss-selector-parser-6.0.15.tgz#11cc2b21eebc0b99ea374ffb9887174855a01535" + integrity sha512-rEYkQOMUCEMhsKbK66tbEU9QVIxbhN18YiniAwA7XQYTVBqrBy+P2p5JcdqsHgKM2zWylp8d7J6eszocfds5Sw== dependencies: cssesc "^3.0.0" util-deprecate "^1.0.2" postcss-sort-media-queries@^4.2.1: - version "4.3.0" - resolved "https://registry.yarnpkg.com/postcss-sort-media-queries/-/postcss-sort-media-queries-4.3.0.tgz#f48a77d6ce379e86676fc3f140cf1b10a06f6051" - integrity sha512-jAl8gJM2DvuIJiI9sL1CuiHtKM4s5aEIomkU8G3LFvbP+p8i7Sz8VV63uieTgoewGqKbi+hxBTiOKJlB35upCg== + version "4.4.1" + resolved "https://registry.yarnpkg.com/postcss-sort-media-queries/-/postcss-sort-media-queries-4.4.1.tgz#04a5a78db3921eb78f28a1a781a2e68e65258128" + integrity sha512-QDESFzDDGKgpiIh4GYXsSy6sek2yAwQx1JASl5AxBtU1Lq2JfKBljIPNdil989NcSKRQX1ToiaKphImtBuhXWw== dependencies: sort-css-media-queries "2.1.0" @@ -6583,12 +6682,12 @@ postcss-zindex@^5.1.0: resolved "https://registry.yarnpkg.com/postcss-zindex/-/postcss-zindex-5.1.0.tgz#4a5c7e5ff1050bd4c01d95b1847dfdcc58a496ff" integrity sha512-fgFMf0OtVSBR1va1JNHYgMxYk73yhn/qb4uQDq1DLGYolz8gHCyr/sesEuGUaYs58E3ZJRcpoGuPVoB7Meiq9A== -postcss@^8.3.11, postcss@^8.4.14, postcss@^8.4.17, postcss@^8.4.19: - version "8.4.21" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.21.tgz#c639b719a57efc3187b13a1d765675485f4134f4" - integrity sha512-tP7u/Sn/dVxK2NnruI4H9BG+x+Wxz6oeZ1cJ8P6G/PZY0IKk4k/63TDsQf2kQq3+qoJeLm2kIBUNlZe3zgb4Zg== +postcss@^8.3.11, postcss@^8.4.14, postcss@^8.4.17, postcss@^8.4.33: + version "8.4.33" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.33.tgz#1378e859c9f69bf6f638b990a0212f43e2aaa742" + integrity sha512-Kkpbhhdjw2qQs2O2DGX+8m5OVqEcbB9HRBvuYM9pgrjEFUg30A9LmXNlTAUj4S9kgtGyrMbTzVjH7E+s5Re2yg== dependencies: - nanoid "^3.3.4" + nanoid "^3.3.7" picocolors "^1.0.0" source-map-js "^1.0.2" @@ -6706,9 +6805,9 @@ punycode@^1.3.2: integrity sha512-jmYNElW7yvO7TV33CjSmvSiE2yco3bV2czu/OzDKdMNVZQWfxCblURLhf+47syQRBntjfLdd/H0egrzIG+oaFQ== punycode@^2.1.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.0.tgz#f67fa67c94da8f4d0cfff981aee4118064199b8f" - integrity sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA== + version "2.3.1" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5" + integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg== pupa@^2.1.1: version "2.1.1" @@ -6832,12 +6931,21 @@ react-error-overlay@^6.0.11: resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-6.0.11.tgz#92835de5841c5cf08ba00ddd2d677b6d17ff9adb" integrity sha512-/6UZ2qgEyH2aqzYZgQPxEnz33NJ2gNsnHA2o5+o4wW9bLM/JYQitNP9xPhsXwC08hMMovfGe/8retsdDsczPRg== -react-fast-compare@^3.0.1, react-fast-compare@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/react-fast-compare/-/react-fast-compare-3.2.0.tgz#641a9da81b6a6320f270e89724fb45a0b39e43bb" - integrity sha512-rtGImPZ0YyLrscKI9xTpV8psd6I8VAtjKCzQDlzyDvqJA8XOW78TXYQwNRNd8g8JZnDu8q9Fu/1v4HPAVwVdHA== +react-fast-compare@^3.0.1, react-fast-compare@^3.2.0, react-fast-compare@^3.2.2: + version "3.2.2" + resolved "https://registry.yarnpkg.com/react-fast-compare/-/react-fast-compare-3.2.2.tgz#929a97a532304ce9fee4bcae44234f1ce2c21d49" + integrity sha512-nsO+KSNgo1SbJqJEYRE9ERzo7YtYbou/OqjSQKxV7jcKox7+usiUVZOAC+XnDOABXggQTno0Y1CpVnuWEc1boQ== -react-helmet-async@*, react-helmet-async@^1.3.0: +react-helmet-async@*: + version "2.0.4" + resolved "https://registry.yarnpkg.com/react-helmet-async/-/react-helmet-async-2.0.4.tgz#50a4377778f380ed1d0136303916b38eff1bf153" + integrity sha512-yxjQMWposw+akRfvpl5+8xejl4JtUlHnEBcji6u8/e6oc7ozT+P9PNTWMhCbz2y9tc5zPegw2BvKjQA+NwdEjQ== + dependencies: + invariant "^2.2.4" + react-fast-compare "^3.2.2" + shallowequal "^1.1.0" + +react-helmet-async@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/react-helmet-async/-/react-helmet-async-1.3.0.tgz#7bd5bf8c5c69ea9f02f6083f14ce33ef545c222e" integrity sha512-9jZ57/dAn9t3q6hneQS0wukqC2ENOBgMNVEhb/ZG9ZSxUetzVIw4iAmEU38IaVg3QGYauQPhSeUTuIUtFglWpg== @@ -6881,9 +6989,9 @@ react-loadable-ssr-addon-v5-slorber@^1.0.1: "@babel/runtime" "^7.10.3" react-player@^2.12.0: - version "2.12.0" - resolved "https://registry.yarnpkg.com/react-player/-/react-player-2.12.0.tgz#2fc05dbfec234c829292fbca563b544064bd14f0" - integrity sha512-rymLRz/2GJJD+Wc01S7S+i9pGMFYnNmQibR2gVE3KmHJCBNN8BhPAlOPTGZtn1uKpJ6p4RPLlzPQ1OLreXd8gw== + version "2.14.1" + resolved "https://registry.yarnpkg.com/react-player/-/react-player-2.14.1.tgz#fc434c0e1e6161e76f5d5970721596c4acec52b1" + integrity sha512-jILj7F9o+6NHzrJ1GqZIxfJgskvGmKeJ05FNhPvgiCpvMZFmFneKEkukywHcULDO2lqITm+zcEkLSq42mX0FbA== dependencies: deepmerge "^4.0.0" load-script "^1.0.0" @@ -6927,11 +7035,11 @@ react-router@5.3.4, react-router@^5.3.3: tiny-warning "^1.0.0" react-textarea-autosize@^8.3.2: - version "8.4.0" - resolved "https://registry.yarnpkg.com/react-textarea-autosize/-/react-textarea-autosize-8.4.0.tgz#4d0244d6a50caa897806b8c44abc0540a69bfc8c" - integrity sha512-YrTFaEHLgJsi8sJVYHBzYn+mkP3prGkmP2DKb/tm0t7CLJY5t1Rxix8070LAKb0wby7bl/lf2EeHkuMihMZMwQ== + version "8.5.3" + resolved "https://registry.yarnpkg.com/react-textarea-autosize/-/react-textarea-autosize-8.5.3.tgz#d1e9fe760178413891484847d3378706052dd409" + integrity sha512-XT1024o2pqCuZSuBt9FwHlaDeNtVrtCXu0Rnz88t1jUGheCLa3PhjE1GH8Ctm2axEtvdCl5SUHYschyQ0L5QHQ== dependencies: - "@babel/runtime" "^7.10.2" + "@babel/runtime" "^7.20.13" use-composed-ref "^1.3.0" use-latest "^1.2.1" @@ -6966,19 +7074,10 @@ readable-stream@^2.0.1: string_decoder "~1.1.1" util-deprecate "~1.0.1" -readable-stream@^3.0.6: - version "3.6.1" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.1.tgz#f9f9b5f536920253b3d26e7660e7da4ccff9bb62" - integrity sha512-+rQmrWMYGA90yenhTYsLWAsLsqVC8osOw6PKE1HDYiO0gdPeKe/xDHNzIAIn4C91YQ6oenEhfYqqc1883qHbjQ== - dependencies: - inherits "^2.0.3" - string_decoder "^1.1.1" - util-deprecate "^1.0.1" - -readable-stream@^3.1.1, readable-stream@^3.4.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" - integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== +readable-stream@^3.0.6, readable-stream@^3.1.1, readable-stream@^3.4.0: + version "3.6.2" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.2.tgz#56a9b36ea965c00c5a93ef31eb111a0f11056967" + integrity sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA== dependencies: inherits "^2.0.3" string_decoder "^1.1.1" @@ -7011,9 +7110,9 @@ recursive-readdir@^2.2.2: minimatch "^3.0.5" regenerate-unicode-properties@^10.1.0: - version "10.1.0" - resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-10.1.0.tgz#7c3192cab6dd24e21cb4461e5ddd7dd24fa8374c" - integrity sha512-d1VudCLoIGitcU/hEg2QqvyGZQmdC0Lf8BqdOMXGFSvJP4bNV1+XqbPQeHHLD51Jh4QJJ225dlIFvY4Ly6MXmQ== + version "10.1.1" + resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-10.1.1.tgz#6b0e05489d9076b04c436f318d9b067bba459480" + integrity sha512-X007RyZLsCJVVrjgEFVpLUTZwyOZk3oiL75ZcuYjlIWd6rNJtOjkBwQc5AsRrpbKVkxN6sklw/k/9m2jJYOf8Q== dependencies: regenerate "^1.4.2" @@ -7022,22 +7121,22 @@ regenerate@^1.4.2: resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.2.tgz#b9346d8827e8f5a32f7ba29637d398b69014848a" integrity sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A== -regenerator-runtime@^0.13.11: - version "0.13.11" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz#f6dca3e7ceec20590d07ada785636a90cdca17f9" - integrity sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg== +regenerator-runtime@^0.14.0: + version "0.14.1" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz#356ade10263f685dda125100cd862c1db895327f" + integrity sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw== -regenerator-transform@^0.15.1: - version "0.15.1" - resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.15.1.tgz#f6c4e99fc1b4591f780db2586328e4d9a9d8dc56" - integrity sha512-knzmNAcuyxV+gQCufkYcvOqX/qIIfHLv0u5x79kRxuGojfYVky1f15TzZEu2Avte8QGepvUNTnLskf8E6X6Vyg== +regenerator-transform@^0.15.2: + version "0.15.2" + resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.15.2.tgz#5bbae58b522098ebdf09bca2f83838929001c7a4" + integrity sha512-hfMp2BoF0qOk3uc5V20ALGDS2ddjQaLrdl7xrGXvAIow7qeWRM2VA2HuCHkUKk9slq3VwEwLNK3DFBqDfPGYtg== dependencies: "@babel/runtime" "^7.8.4" regexpu-core@^5.3.1: - version "5.3.1" - resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-5.3.1.tgz#66900860f88def39a5cb79ebd9490e84f17bcdfb" - integrity sha512-nCOzW2V/X15XpLsK2rlgdwrysrBq+AauCn+omItIz4R1pIcmeot5zvjdmOBRLzEH/CkC6IxMJVmxDe3QcMuNVQ== + version "5.3.2" + resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-5.3.2.tgz#11a2b06884f3527aec3e93dbbf4a3b958a95546b" + integrity sha512-RAM5FlZz+Lhmo7db9L298p2vHP5ZywrVXmVXpmAD9GuL5MPH6t9ROw1iA/wfHkQ76Qe7AaPF0nGuim96/IrQMQ== dependencies: "@babel/regjsgen" "^0.8.0" regenerate "^1.4.2" @@ -7201,11 +7300,11 @@ resolve-pathname@^3.0.0: integrity sha512-C7rARubxI8bXFNB/hqcp/4iUeIXJhJZvFPFPiSPRnhU5UPxzMFIl+2E6yY6c4k9giDJAhtV+enfA+G89N6Csng== resolve@^1.1.6, resolve@^1.14.2, resolve@^1.3.2: - version "1.22.1" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.1.tgz#27cb2ebb53f91abb49470a928bba7558066ac177" - integrity sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw== + version "1.22.8" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.8.tgz#b6c87a9f2aa06dfab52e3d70ac8cde321fa5a48d" + integrity sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw== dependencies: - is-core-module "^2.9.0" + is-core-module "^2.13.0" path-parse "^1.0.7" supports-preserve-symlinks-flag "^1.0.0" @@ -7234,14 +7333,14 @@ rimraf@^3.0.2: glob "^7.1.3" robust-predicates@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/robust-predicates/-/robust-predicates-3.0.1.tgz#ecde075044f7f30118682bd9fb3f123109577f9a" - integrity sha512-ndEIpszUHiG4HtDsQLeIuMvRsDnn8c8rYStabochtUeCvfuvNptb5TUbVD68LRAILPX7p9nqQGh4xJgn3EHS/g== + version "3.0.2" + resolved "https://registry.yarnpkg.com/robust-predicates/-/robust-predicates-3.0.2.tgz#d5b28528c4824d20fc48df1928d41d9efa1ad771" + integrity sha512-IXgzBWvWQwE6PrDI05OvmXUIruQTcoMDzRsOd5CDvHCVLcLHMTSYvOK5Cm46kWqlV3yAbuSpBZdJ5oP5OUoStg== rtl-detect@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/rtl-detect/-/rtl-detect-1.0.4.tgz#40ae0ea7302a150b96bc75af7d749607392ecac6" - integrity sha512-EBR4I2VDSSYr7PkBmFy04uhycIpDKp+21p/jARYXlCSjQksTBQcJ0HFUPOO79EPPH5JS6VAhiIQbycf0O3JAxQ== + version "1.1.2" + resolved "https://registry.yarnpkg.com/rtl-detect/-/rtl-detect-1.1.2.tgz#ca7f0330af5c6bb626c15675c642ba85ad6273c6" + integrity sha512-PGMBq03+TTG/p/cRB7HCLKJ1MgDIi07+QU1faSjiYRfmY5UsAttV9Hs08jDAHVwcOwmVLcSJkpwyfXszVjWfIQ== rtlcss@^3.5.0: version "3.5.0" @@ -7265,14 +7364,7 @@ rw@1: resolved "https://registry.yarnpkg.com/rw/-/rw-1.3.3.tgz#3f862dfa91ab766b14885ef4d01124bfda074fb4" integrity sha512-PdhdWy89SiZogBLaw42zdeqtRJ//zFd2PgQavcICDUgJT5oW10QCRKbJ6bg4r0/UY2M6BWd5tkxuGFRvCkgfHQ== -rxjs@^7.5.4: - version "7.8.0" - resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.8.0.tgz#90a938862a82888ff4c7359811a595e14e1e09a4" - integrity sha512-F2+gxDshqmIub1KdvZkaEfGDwLNpPvk9Fs6LD/MyQxNgMds/WH9OdDDXOmxUZpME+iSK3rQCctkL0DYyytUqMg== - dependencies: - tslib "^2.1.0" - -rxjs@^7.8.1: +rxjs@^7.5.4, rxjs@^7.8.1: version "7.8.1" resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.8.1.tgz#6f6f3d99ea8044291efd92e7c7fcf562c4057543" integrity sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg== @@ -7295,9 +7387,9 @@ safe-buffer@5.2.1, safe-buffer@>=5.1.0, safe-buffer@^5.0.1, safe-buffer@^5.1.0, integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== sax@^1.2.4: - version "1.2.4" - resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" - integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw== + version "1.3.0" + resolved "https://registry.yarnpkg.com/sax/-/sax-1.3.0.tgz#a5dbe77db3be05c9d1ee7785dbd3ea9de51593d0" + integrity sha512-0s+oAmw9zLl1V1cS9BtZN7JAd0cW5e0QH4W3LWEK6a4LaLEA2OTpGYWDY+6XasBLtz6wkm3u1xRw95mRuJ59WA== scheduler@^0.20.2: version "0.20.2" @@ -7325,24 +7417,24 @@ schema-utils@^2.6.5: ajv "^6.12.4" ajv-keywords "^3.5.2" -schema-utils@^3.0.0, schema-utils@^3.1.0, schema-utils@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-3.1.1.tgz#bc74c4b6b6995c1d88f76a8b77bea7219e0c8281" - integrity sha512-Y5PQxS4ITlC+EahLuXaY86TXfR7Dc5lw294alXOq86JAHCihAIZfqv8nNCWvaEJvaC51uN9hbLGeV0cFBdH+Fw== +schema-utils@^3.0.0, schema-utils@^3.1.1, schema-utils@^3.2.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-3.3.0.tgz#f50a88877c3c01652a15b622ae9e9795df7a60fe" + integrity sha512-pN/yOAvcC+5rQ5nERGuwrjLlYvLTbCibnZ1I7B1LaiAz9BRBlE9GMgE/eqV30P7aJQUf7Ddimy/RsbYO/GrVGg== dependencies: "@types/json-schema" "^7.0.8" ajv "^6.12.5" ajv-keywords "^3.5.2" schema-utils@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-4.0.0.tgz#60331e9e3ae78ec5d16353c467c34b3a0a1d3df7" - integrity sha512-1edyXKgh6XnJsJSQ8mKWXnN/BVaIbFMLpouRUrXgVq7WYne5kw3MW7UPhO44uRXQSIpTSXoJbmrR2X0w9kUTyg== + version "4.2.0" + resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-4.2.0.tgz#70d7c93e153a273a805801882ebd3bff20d89c8b" + integrity sha512-L0jRsrPpjdckP3oPug3/VxNKt2trR8TcabrM6FOAAlvC/9Phcmm+cuAgTlxBqdBR1WJx7Naj9WHw+aOmheSVbw== dependencies: "@types/json-schema" "^7.0.9" - ajv "^8.8.0" + ajv "^8.9.0" ajv-formats "^2.1.1" - ajv-keywords "^5.0.0" + ajv-keywords "^5.1.0" section-matter@^1.0.0: version "1.0.0" @@ -7358,10 +7450,11 @@ select-hose@^2.0.0: integrity sha512-mEugaLK+YfkijB4fx0e6kImuJdCIt2LxCRcbEYPqRGCs4F2ogyfZU5IAZRdjCP8JPq2AtdNoC/Dux63d9Kiryg== selfsigned@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/selfsigned/-/selfsigned-2.1.1.tgz#18a7613d714c0cd3385c48af0075abf3f266af61" - integrity sha512-GSL3aowiF7wa/WtSFwnUrludWFoNhftq8bUkH9pkzjpN2XSPOAYEgg6e0sS9s0rZwgJzJiQRPU18A6clnoW5wQ== + version "2.4.1" + resolved "https://registry.yarnpkg.com/selfsigned/-/selfsigned-2.4.1.tgz#560d90565442a3ed35b674034cec4e95dceb4ae0" + integrity sha512-th5B4L2U+eGLq1TVh7zNRGBapioSORUeymIydxgFpwww9d2qyKvtuPU2jJuHvYAwwqi2Y596QBL3eEqcPEYL8Q== dependencies: + "@types/node-forge" "^1.3.0" node-forge "^1" semver-diff@^3.1.1: @@ -7372,23 +7465,16 @@ semver-diff@^3.1.1: semver "^6.3.0" semver@^5.4.1: - version "5.7.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" - integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== + version "5.7.2" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8" + integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g== -semver@^6.0.0, semver@^6.1.1, semver@^6.1.2, semver@^6.2.0, semver@^6.3.0: - version "6.3.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" - integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== - -semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7, semver@^7.3.8: - version "7.3.8" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.8.tgz#07a78feafb3f7b32347d725e33de7e2a2df67798" - integrity sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A== - dependencies: - lru-cache "^6.0.0" +semver@^6.0.0, semver@^6.2.0, semver@^6.3.0, semver@^6.3.1: + version "6.3.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4" + integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== -semver@^7.5.3: +semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7, semver@^7.5.3, semver@^7.5.4: version "7.5.4" resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e" integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA== @@ -7414,10 +7500,10 @@ send@0.18.0: range-parser "~1.2.1" statuses "2.0.1" -serialize-javascript@^6.0.0: - version "6.0.1" - resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.1.tgz#b206efb27c3da0b0ab6b52f48d170b7996458e5c" - integrity sha512-owoXEFjWRllis8/M1Q+Cw5k8ZH40e3zhp/ovX+Xr/vi1qj6QesbyXXViFbpNvWvPNAD62SutwEXavefrLJWj7w== +serialize-javascript@^6.0.0, serialize-javascript@^6.0.1: + version "6.0.2" + resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.2.tgz#defa1e055c83bf6d59ea805d8da862254eb6a6c2" + integrity sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g== dependencies: randombytes "^2.1.0" @@ -7458,6 +7544,17 @@ serve-static@1.15.0: parseurl "~1.3.3" send "0.18.0" +set-function-length@^1.1.1: + version "1.2.0" + resolved "https://registry.yarnpkg.com/set-function-length/-/set-function-length-1.2.0.tgz#2f81dc6c16c7059bda5ab7c82c11f03a515ed8e1" + integrity sha512-4DBHDoyHlM1IRPGYcoxexgh67y4ueR53FKV1yyxwFMY7aCqcN/38M1+SwZ/qJQ8iLv7+ck385ot4CcisOAPT9w== + dependencies: + define-data-property "^1.1.1" + function-bind "^1.1.2" + get-intrinsic "^1.2.2" + gopd "^1.0.1" + has-property-descriptors "^1.0.1" + setimmediate@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" @@ -7511,12 +7608,7 @@ shebang-regex@^3.0.0: resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== -shell-quote@^1.7.3: - version "1.8.0" - resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.8.0.tgz#20d078d0eaf71d54f43bd2ba14a1b5b9bfa5c8ba" - integrity sha512-QHsz8GgQIGKlRi24yFc6a6lN69Idnx634w49ay6+jA5yFh7a1UY+4Rp6HPx/L/1zcEDPEij8cIsiqR6bQsE5VQ== - -shell-quote@^1.8.1: +shell-quote@^1.7.3, shell-quote@^1.8.1: version "1.8.1" resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.8.1.tgz#6dbf4db75515ad5bac63b4f1894c3a154c766680" integrity sha512-6j1W9l1iAs/4xYBI1SYOVZyFcCis9b4KCLQ8fgAGG07QvzaRLVVRQvAy85yNmmZSjYjg4MWh4gNvlPujU/5LpA== @@ -7530,10 +7622,10 @@ shelljs@^0.8.5: interpret "^1.0.0" rechoir "^0.6.2" -shiki@^0.14.1: - version "0.14.4" - resolved "https://registry.yarnpkg.com/shiki/-/shiki-0.14.4.tgz#2454969b466a5f75067d0f2fa0d7426d32881b20" - integrity sha512-IXCRip2IQzKwxArNNq1S+On4KPML3Yyn8Zzs/xRgcgOWIr8ntIK3IKzjFPfjy/7kt9ZMjc+FItfqHRBg8b6tNQ== +shiki@^0.14.7: + version "0.14.7" + resolved "https://registry.yarnpkg.com/shiki/-/shiki-0.14.7.tgz#c3c9e1853e9737845f1d2ef81b31bcfb07056d4e" + integrity sha512-dNPAPrxSc87ua2sKJ3H5dQ/6ZaY8RNnaAqK+t0eG7p0Soi2ydiqbGOTaZCqaYvA/uZYfS1LJnemt3Q+mSfcPCg== dependencies: ansi-sequence-parser "^1.1.0" jsonc-parser "^3.2.0" @@ -7582,14 +7674,14 @@ simple-update-notifier@^2.0.0: dependencies: semver "^7.5.3" -sirv@^1.0.7: - version "1.0.19" - resolved "https://registry.yarnpkg.com/sirv/-/sirv-1.0.19.tgz#1d73979b38c7fe91fcba49c85280daa9c2363b49" - integrity sha512-JuLThK3TnZG1TAKDwNIqNq6QA2afLOCcm+iE8D1Kj3GA40pSPsxQjjJl0J8X3tsR7T+CP1GavpzLwYkgVLWrZQ== +sirv@^2.0.3: + version "2.0.4" + resolved "https://registry.yarnpkg.com/sirv/-/sirv-2.0.4.tgz#5dd9a725c578e34e449f332703eb2a74e46a29b0" + integrity sha512-94Bdh3cC2PKrbgSOUqTiGPWVZeSiXfKOVZNJniWoqrWrRkB1CJzBU3NEbiTsPcYy1lDsANA/THzS+9WBiy5nfQ== dependencies: - "@polka/url" "^1.0.0-next.20" - mrmime "^1.0.0" - totalist "^1.0.0" + "@polka/url" "^1.0.0-next.24" + mrmime "^2.0.0" + totalist "^3.0.0" sisteransi@^1.0.5: version "1.0.5" @@ -7712,9 +7804,9 @@ statuses@2.0.1: integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA== std-env@^3.0.1: - version "3.3.2" - resolved "https://registry.yarnpkg.com/std-env/-/std-env-3.3.2.tgz#af27343b001616015534292178327b202b9ee955" - integrity sha512-uUZI65yrV2Qva5gqE0+A7uVAvO40iPo6jGhs7s8keRfHCmtg+uB2X6EiLGCI9IgL1J17xGhvoOqSz79lzICPTA== + version "3.7.0" + resolved "https://registry.yarnpkg.com/std-env/-/std-env-3.7.0.tgz#c9f7386ced6ecf13360b6c6c55b8aaa4ef7481d2" + integrity sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg== string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3: version "4.2.3" @@ -7765,9 +7857,9 @@ strip-ansi@^6.0.0, strip-ansi@^6.0.1: ansi-regex "^5.0.1" strip-ansi@^7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.0.1.tgz#61740a08ce36b61e50e65653f07060d000975fb2" - integrity sha512-cXNxvT8dFNRVfhVME3JAe98mkXDYN2O1l7jmcwMnOslDeESg1rF/OZMtK0nRAhiari1unG5cD4jG3rapUAkLbw== + version "7.1.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" + integrity sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ== dependencies: ansi-regex "^6.0.1" @@ -7807,9 +7899,9 @@ stylehacks@^5.1.1: postcss-selector-parser "^6.0.4" stylis@^4.1.2: - version "4.1.3" - resolved "https://registry.yarnpkg.com/stylis/-/stylis-4.1.3.tgz#fd2fbe79f5fed17c55269e16ed8da14c84d069f7" - integrity sha512-GP6WDNWf+o403jrEp9c5jibKavrtLW+/qYGhFxFrG8maXhwTBI7gLLhiBb0o7uFccWN+EOS9aMO6cGHWAO07OA== + version "4.3.1" + resolved "https://registry.yarnpkg.com/stylis/-/stylis-4.3.1.tgz#ed8a9ebf9f76fe1e12d462f5cc3c4c980b23a7eb" + integrity sha512-EQepAV+wMsIaGVGX1RECzgrcqRRU/0sYOHkeLsZ3fzHaHXZy4DaOOX0vOlGQdlsjkh3mFHAIlVimpwAs4dslyQ== supports-color@^5.3.0, supports-color@^5.5.0: version "5.5.0" @@ -7886,24 +7978,24 @@ tar-stream@^2.1.4: inherits "^2.0.3" readable-stream "^3.1.1" -terser-webpack-plugin@^5.1.3, terser-webpack-plugin@^5.3.3: - version "5.3.6" - resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-5.3.6.tgz#5590aec31aa3c6f771ce1b1acca60639eab3195c" - integrity sha512-kfLFk+PoLUQIbLmB1+PZDMRSZS99Mp+/MHqDNmMA6tOItzRt+Npe3E+fsMs5mfcM0wCtrrdU387UnV+vnSffXQ== +terser-webpack-plugin@^5.3.3, terser-webpack-plugin@^5.3.7: + version "5.3.10" + resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-5.3.10.tgz#904f4c9193c6fd2a03f693a2150c62a92f40d199" + integrity sha512-BKFPWlPDndPs+NGGCr1U59t0XScL5317Y0UReNrHaw9/FwhPENlq6bfgs+4yPfyP51vqC1bQ4rp1EfXW5ZSH9w== dependencies: - "@jridgewell/trace-mapping" "^0.3.14" + "@jridgewell/trace-mapping" "^0.3.20" jest-worker "^27.4.5" schema-utils "^3.1.1" - serialize-javascript "^6.0.0" - terser "^5.14.1" + serialize-javascript "^6.0.1" + terser "^5.26.0" -terser@^5.10.0, terser@^5.14.1: - version "5.16.5" - resolved "https://registry.yarnpkg.com/terser/-/terser-5.16.5.tgz#1c285ca0655f467f92af1bbab46ab72d1cb08e5a" - integrity sha512-qcwfg4+RZa3YvlFh0qjifnzBHjKGNbtDo9yivMqMFDy9Q6FSaQWSB/j1xKhsoUFJIqDOM3TsN6D5xbrMrFcHbg== +terser@^5.10.0, terser@^5.26.0: + version "5.27.0" + resolved "https://registry.yarnpkg.com/terser/-/terser-5.27.0.tgz#70108689d9ab25fef61c4e93e808e9fd092bf20c" + integrity sha512-bi1HRwVRskAjheeYl291n3JC4GgO/Ty4z1nVs5AAsmonJulGxpSektecnNedrwK9C7vpvVtcX3cw00VSLt7U2A== dependencies: - "@jridgewell/source-map" "^0.3.2" - acorn "^8.5.0" + "@jridgewell/source-map" "^0.3.3" + acorn "^8.8.2" commander "^2.20.0" source-map-support "~0.5.20" @@ -7949,10 +8041,10 @@ toidentifier@1.0.1: resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35" integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA== -totalist@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/totalist/-/totalist-1.1.0.tgz#a4d65a3e546517701e3e5c37a47a70ac97fe56df" - integrity sha512-gduQwd1rOdDMGxFG1gEvhV88Oirdo2p+KjoYFU7k2g+i7n6AFFbDQ5kMPUsW0pNbfQsB/cwXvT1i4Bue0s9g5g== +totalist@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/totalist/-/totalist-3.0.1.tgz#ba3a3d600c915b1a97872348f79c127475f6acf8" + integrity sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ== touch@^3.1.0: version "3.1.0" @@ -7992,9 +8084,9 @@ ts-dedent@^2.2.0: integrity sha512-q5W7tVM71e2xjHZTlgfTDoPF/SmqKG5hddq9SzR49CH2hayqRKJtQ4mtRlSxKaJlR/+9rEM+mnBHf7I2/BQcpQ== tslib@^2.0.3, tslib@^2.1.0, tslib@^2.4.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.5.0.tgz#42bfed86f5787aeb41d031866c8f402429e0fddf" - integrity sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg== + version "2.6.2" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" + integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q== tunnel-agent@^0.6.0: version "0.6.0" @@ -8029,31 +8121,31 @@ typedarray-to-buffer@^3.1.5: is-typedarray "^1.0.0" typedoc-plugin-markdown@^3.16.0: - version "3.16.0" - resolved "https://registry.yarnpkg.com/typedoc-plugin-markdown/-/typedoc-plugin-markdown-3.16.0.tgz#98da250271aafade8b6740a8116a97cd3941abcd" - integrity sha512-eeiC78fDNGFwemPIHiwRC+mEC7W5jwt3fceUev2gJ2nFnXpVHo8eRrpC9BLWZDee6ehnz/sPmNjizbXwpfaTBw== + version "3.17.1" + resolved "https://registry.yarnpkg.com/typedoc-plugin-markdown/-/typedoc-plugin-markdown-3.17.1.tgz#c33f42363c185adf842f4699166015f7fe0ed02b" + integrity sha512-QzdU3fj0Kzw2XSdoL15ExLASt2WPqD7FbLeaqwT70+XjKyTshBnUlQA5nNREO1C2P8Uen0CDjsBLMsCQ+zd0lw== dependencies: handlebars "^4.7.7" typedoc@^0.25.1: - version "0.25.1" - resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.25.1.tgz#50de2d8fb93623fbfb59e2fa6407ff40e3d3f438" - integrity sha512-c2ye3YUtGIadxN2O6YwPEXgrZcvhlZ6HlhWZ8jQRNzwLPn2ylhdGqdR8HbyDRyALP8J6lmSANILCkkIdNPFxqA== + version "0.25.7" + resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.25.7.tgz#11e3f527ca80ca3c029cb8e15f362e6d9f715e25" + integrity sha512-m6A6JjQRg39p2ZVRIN3NKXgrN8vzlHhOS+r9ymUYtcUP/TIQPvWSq7YgE5ZjASfv5Vd5BW5xrir6Gm2XNNcOow== dependencies: lunr "^2.3.9" marked "^4.3.0" minimatch "^9.0.3" - shiki "^0.14.1" + shiki "^0.14.7" typescript@^5.0.4: - version "5.2.2" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.2.2.tgz#5ebb5e5a5b75f085f22bc3f8460fba308310fa78" - integrity sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w== + version "5.3.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.3.3.tgz#b3ce6ba258e72e6305ba66f5c9b452aaee3ffe37" + integrity sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw== -ua-parser-js@^0.7.30: - version "0.7.36" - resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.36.tgz#382c5d6fc09141b6541be2cae446ecfcec284db2" - integrity sha512-CPPLoCts2p7D8VbybttE3P2ylv0OBZEAy7a12DsulIEcAiMtWJy+PBgMXgWDI80D5UwqE8oQPHYnk13tm38M2Q== +ua-parser-js@^1.0.35: + version "1.0.37" + resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-1.0.37.tgz#b5dc7b163a5c1f0c510b08446aed4da92c46373f" + integrity sha512-bhTyI94tZofjo+Dn8SN6Zv8nBDvyXTymAdM3LDI/0IboIUwTu1rEhW7v2TfiVsoYWgkQ4kOVqnI8APUFbIQIFQ== uglify-js@^3.1.4: version "3.17.4" @@ -8065,6 +8157,11 @@ undefsafe@^2.0.5: resolved "https://registry.yarnpkg.com/undefsafe/-/undefsafe-2.0.5.tgz#38733b9327bdcd226db889fb723a6efd162e6e2c" integrity sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA== +undici-types@~5.26.4: + version "5.26.5" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" + integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== + unherit@^1.0.4: version "1.1.3" resolved "https://registry.yarnpkg.com/unherit/-/unherit-1.1.3.tgz#6c9b503f2b41b262330c80e91c8614abdaa69c22" @@ -8193,19 +8290,19 @@ unist-util-visit@2.0.3, unist-util-visit@^2.0.0, unist-util-visit@^2.0.3: unist-util-visit-parents "^3.0.0" universalify@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717" - integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ== + version "2.0.1" + resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.1.tgz#168efc2180964e6386d061e094df61afe239b18d" + integrity sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw== unpipe@1.0.0, unpipe@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" integrity sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ== -update-browserslist-db@^1.0.10: - version "1.0.10" - resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.0.10.tgz#0f54b876545726f17d00cd9a2561e6dade943ff3" - integrity sha512-OztqDenkfFkbSG+tRxBeAnCVPckDBcvibKd35yDONx6OU8N7sqgwc7rCbkJ/WcYtVRZ4ba68d6byhC21GFh7sQ== +update-browserslist-db@^1.0.13: + version "1.0.13" + resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz#3c5e4f5c083661bd38ef64b6328c26ed6c8248c4" + integrity sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg== dependencies: escalade "^3.1.1" picocolors "^1.0.0" @@ -8286,9 +8383,9 @@ utila@~0.4: integrity sha512-Z0DbgELS9/L/75wZbro8xAnT50pBVFQZ+hUEueGDU5FN51YSCYM+jdxsfCiHjwNP/4LCDD0i/graKpeBnOXKRA== utility-types@^3.10.0: - version "3.10.0" - resolved "https://registry.yarnpkg.com/utility-types/-/utility-types-3.10.0.tgz#ea4148f9a741015f05ed74fd615e1d20e6bed82b" - integrity sha512-O11mqxmi7wMKCo6HKFt5AhO4BwY3VV68YU07tgxfz8zJTIxr4BpsezN49Ffwy9j3ZpwwJp4fkRwjRzq3uWE6Rg== + version "3.11.0" + resolved "https://registry.yarnpkg.com/utility-types/-/utility-types-3.11.0.tgz#607c40edb4f258915e901ea7995607fdf319424c" + integrity sha512-6Z7Ma2aVEWisaL6TvBCy7P8rm2LQoPv6dJ7ecIaIixHcwfbJ0x7mWdbcwlIM5IGQxPZSFYeqRCqlOOeKoJYMkw== utils-merge@1.0.1: version "1.0.1" @@ -8301,9 +8398,9 @@ uuid@^8.3.2: integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== uuid@^9.0.0: - version "9.0.0" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.0.tgz#592f550650024a38ceb0c562f2f6aa435761efb5" - integrity sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg== + version "9.0.1" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.1.tgz#e188d4c8853cc722220392c424cd637f32293f30" + integrity sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA== value-equal@^1.0.1: version "1.0.1" @@ -8380,9 +8477,9 @@ web-namespaces@^1.0.0: integrity sha512-wYxSGajtmoP4WxfejAPIr4l0fVh+jeMXZb08wNc0tMg6xsfZXj3cECqIK0G7ZAqUq0PP8WlMDtaOGVBTAWztNw== web-worker@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/web-worker/-/web-worker-1.2.0.tgz#5d85a04a7fbc1e7db58f66595d7a3ac7c9c180da" - integrity sha512-PgF341avzqyx60neE9DD+XS26MMNMoUQRz9NOZwW32nPQrF6p77f1htcnjBSEV8BGMKZ16choqUG4hyI0Hx7mA== + version "1.3.0" + resolved "https://registry.yarnpkg.com/web-worker/-/web-worker-1.3.0.tgz#e5f2df5c7fe356755a5fb8f8410d4312627e6776" + integrity sha512-BSR9wyRsy/KOValMgd5kMyr3JzpdeoR9KVId8u5GVlTTAtNChlsE4yTxeY7zMdNSyOmoKBv8NH2qeRY9Tg+IaA== webidl-conversions@^3.0.0: version "3.0.1" @@ -8390,19 +8487,22 @@ webidl-conversions@^3.0.0: integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== webpack-bundle-analyzer@^4.5.0: - version "4.8.0" - resolved "https://registry.yarnpkg.com/webpack-bundle-analyzer/-/webpack-bundle-analyzer-4.8.0.tgz#951b8aaf491f665d2ae325d8b84da229157b1d04" - integrity sha512-ZzoSBePshOKhr+hd8u6oCkZVwpVaXgpw23ScGLFpR6SjYI7+7iIWYarjN6OEYOfRt8o7ZyZZQk0DuMizJ+LEIg== + version "4.10.1" + resolved "https://registry.yarnpkg.com/webpack-bundle-analyzer/-/webpack-bundle-analyzer-4.10.1.tgz#84b7473b630a7b8c21c741f81d8fe4593208b454" + integrity sha512-s3P7pgexgT/HTUSYgxJyn28A+99mmLq4HsJepMPzu0R8ImJc52QNqaFYW1Z2z2uIb1/J3eYgaAWVpaC+v/1aAQ== dependencies: "@discoveryjs/json-ext" "0.5.7" acorn "^8.0.4" acorn-walk "^8.0.0" - chalk "^4.1.0" commander "^7.2.0" + debounce "^1.2.1" + escape-string-regexp "^4.0.0" gzip-size "^6.0.0" - lodash "^4.17.20" + html-escaper "^2.0.2" + is-plain-object "^5.0.0" opener "^1.5.2" - sirv "^1.0.7" + picocolors "^1.0.0" + sirv "^2.0.3" ws "^7.3.1" webpack-dev-middleware@^5.3.1: @@ -8417,9 +8517,9 @@ webpack-dev-middleware@^5.3.1: schema-utils "^4.0.0" webpack-dev-server@^4.9.3: - version "4.11.1" - resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-4.11.1.tgz#ae07f0d71ca0438cf88446f09029b92ce81380b5" - integrity sha512-lILVz9tAUy1zGFwieuaQtYiadImb5M3d+H+L1zDYalYoDl0cksAB1UNyuE5MMWJrG6zR1tXkCP2fitl7yoUJiw== + version "4.15.1" + resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-4.15.1.tgz#8944b29c12760b3a45bdaa70799b17cb91b03df7" + integrity sha512-5hbAst3h3C3L8w6W4P96L5vaV0PxSmJhxZvWKYIdgxOQm8pNZ5dEOmmSLBVpP85ReeyRt6AS1QJNyo/oFFPeVA== dependencies: "@types/bonjour" "^3.5.9" "@types/connect-history-api-fallback" "^1.3.5" @@ -8427,7 +8527,7 @@ webpack-dev-server@^4.9.3: "@types/serve-index" "^1.9.1" "@types/serve-static" "^1.13.10" "@types/sockjs" "^0.3.33" - "@types/ws" "^8.5.1" + "@types/ws" "^8.5.5" ansi-html-community "^0.0.8" bonjour-service "^1.0.11" chokidar "^3.5.3" @@ -8440,6 +8540,7 @@ webpack-dev-server@^4.9.3: html-entities "^2.3.2" http-proxy-middleware "^2.0.3" ipaddr.js "^2.0.1" + launch-editor "^2.6.0" open "^8.0.9" p-retry "^4.5.0" rimraf "^3.0.2" @@ -8449,14 +8550,15 @@ webpack-dev-server@^4.9.3: sockjs "^0.3.24" spdy "^4.0.2" webpack-dev-middleware "^5.3.1" - ws "^8.4.2" + ws "^8.13.0" webpack-merge@^5.8.0: - version "5.8.0" - resolved "https://registry.yarnpkg.com/webpack-merge/-/webpack-merge-5.8.0.tgz#2b39dbf22af87776ad744c390223731d30a68f61" - integrity sha512-/SaI7xY0831XwP6kzuwhKWVKDP9t1QY1h65lAFLbZqMPIuYcD9QAW4u9STIbU9kaJbPBB/geU/gLr1wDjOhQ+Q== + version "5.10.0" + resolved "https://registry.yarnpkg.com/webpack-merge/-/webpack-merge-5.10.0.tgz#a3ad5d773241e9c682803abf628d4cd62b8a4177" + integrity sha512-+4zXKdx7UnO+1jaN4l2lHVD+mFvnlZQP/6ljaJVb4SZiwIKeUnrT5l0gkT8z+n4hKpC+jpOv6O9R+gLtag7pSA== dependencies: clone-deep "^4.0.1" + flat "^5.0.2" wildcard "^2.0.0" webpack-sources@^3.2.2, webpack-sources@^3.2.3: @@ -8465,21 +8567,21 @@ webpack-sources@^3.2.2, webpack-sources@^3.2.3: integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w== webpack@^5.73.0: - version "5.76.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.76.0.tgz#f9fb9fb8c4a7dbdcd0d56a98e56b8a942ee2692c" - integrity sha512-l5sOdYBDunyf72HW8dF23rFtWq/7Zgvt/9ftMof71E/yUb1YLOBmTgA2K4vQthB3kotMrSj609txVE0dnr2fjA== + version "5.89.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.89.0.tgz#56b8bf9a34356e93a6625770006490bf3a7f32dc" + integrity sha512-qyfIC10pOr70V+jkmud8tMfajraGCZMBWJtrmuBymQKCrLTRejBI8STDp1MCyZu/QTdZSeacCQYpYNQVOzX5kw== dependencies: "@types/eslint-scope" "^3.7.3" - "@types/estree" "^0.0.51" - "@webassemblyjs/ast" "1.11.1" - "@webassemblyjs/wasm-edit" "1.11.1" - "@webassemblyjs/wasm-parser" "1.11.1" + "@types/estree" "^1.0.0" + "@webassemblyjs/ast" "^1.11.5" + "@webassemblyjs/wasm-edit" "^1.11.5" + "@webassemblyjs/wasm-parser" "^1.11.5" acorn "^8.7.1" - acorn-import-assertions "^1.7.6" + acorn-import-assertions "^1.9.0" browserslist "^4.14.5" chrome-trace-event "^1.0.2" - enhanced-resolve "^5.10.0" - es-module-lexer "^0.9.0" + enhanced-resolve "^5.15.0" + es-module-lexer "^1.2.1" eslint-scope "5.1.1" events "^3.2.0" glob-to-regexp "^0.4.1" @@ -8488,9 +8590,9 @@ webpack@^5.73.0: loader-runner "^4.2.0" mime-types "^2.1.27" neo-async "^2.6.2" - schema-utils "^3.1.0" + schema-utils "^3.2.0" tapable "^2.1.1" - terser-webpack-plugin "^5.1.3" + terser-webpack-plugin "^5.3.7" watchpack "^2.4.0" webpack-sources "^3.2.3" @@ -8555,9 +8657,9 @@ widest-line@^4.0.1: string-width "^5.0.1" wildcard@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/wildcard/-/wildcard-2.0.0.tgz#a77d20e5200c6faaac979e4b3aadc7b3dd7f8fec" - integrity sha512-JcKqAHLPxcdb9KM49dufGXn2x3ssnfjbcaQdLlfZsL9rH9wgDQjUtDxbo8NE0F6SFvydeu1VhZe7hZuHsB2/pw== + version "2.0.1" + resolved "https://registry.yarnpkg.com/wildcard/-/wildcard-2.0.1.tgz#5ab10d02487198954836b6349f74fff961e10f67" + integrity sha512-CC1bOL87PIWSBhDcTrdeLo6eGT7mCFtrg0uIJtqJUFyK+eJnzl8A1niH56uu7KMa5XFrtiV+AQuHO3n7DsHnLQ== wordwrap@^1.0.0: version "1.0.0" @@ -8602,10 +8704,10 @@ ws@^7.3.1: resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.9.tgz#54fa7db29f4c7cec68b1ddd3a89de099942bb591" integrity sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q== -ws@^8.4.2: - version "8.12.1" - resolved "https://registry.yarnpkg.com/ws/-/ws-8.12.1.tgz#c51e583d79140b5e42e39be48c934131942d4a8f" - integrity sha512-1qo+M9Ba+xNhPB+YTWUlK6M17brTut5EXbcBaMRN5pH5dFrXz7lzz1ChFSUq3bOUl8yEvSenhHmYUNJxFzdJew== +ws@^8.13.0: + version "8.16.0" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.16.0.tgz#d1cd774f36fbc07165066a60e40323eab6446fd4" + integrity sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ== xdg-basedir@^4.0.0: version "4.0.0" diff --git a/l1-contracts/src/core/libraries/ConstantsGen.sol b/l1-contracts/src/core/libraries/ConstantsGen.sol index 4b0aecbc3ce4..e8eb5f3c5c0a 100644 --- a/l1-contracts/src/core/libraries/ConstantsGen.sol +++ b/l1-contracts/src/core/libraries/ConstantsGen.sol @@ -62,7 +62,7 @@ library Constants { uint256 internal constant ARGS_HASH_CHUNK_LENGTH = 32; uint256 internal constant ARGS_HASH_CHUNK_COUNT = 16; uint256 internal constant L1_TO_L2_MESSAGE_LENGTH = 8; - uint256 internal constant L1_TO_L2_MESSAGE_ORACLE_CALL_LENGTH = 26; + uint256 internal constant L1_TO_L2_MESSAGE_ORACLE_CALL_LENGTH = 25; uint256 internal constant MAX_NOTE_FIELDS_LENGTH = 20; uint256 internal constant GET_NOTE_ORACLE_RETURN_LENGTH = 23; uint256 internal constant MAX_NOTES_PER_PAGE = 10; diff --git a/l1-contracts/test/portals/TokenPortal.sol b/l1-contracts/test/portals/TokenPortal.sol index ccd6661ea832..421199522646 100644 --- a/l1-contracts/test/portals/TokenPortal.sol +++ b/l1-contracts/test/portals/TokenPortal.sol @@ -1,4 +1,3 @@ -// docs:start:init pragma solidity >=0.8.18; import {IERC20} from "@oz/token/ERC20/IERC20.sol"; @@ -12,6 +11,7 @@ import {DataStructures} from "../../src/core/libraries/DataStructures.sol"; import {Hash} from "../../src/core/libraries/Hash.sol"; // docs:end:content_hash_sol_import +// docs:start:init contract TokenPortal { using SafeERC20 for IERC20; diff --git a/noir/.github/actions/setup/action.yml b/noir/.github/actions/setup/action.yml index 8e24b6738a9e..b265a63d29ab 100644 --- a/noir/.github/actions/setup/action.yml +++ b/noir/.github/actions/setup/action.yml @@ -4,7 +4,7 @@ description: Installs the workspace's yarn dependencies and caches them runs: using: composite steps: - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 id: node with: node-version: 18.17.1 diff --git a/noir/.github/workflows/docs-dead-links.yml b/noir/.github/workflows/docs-dead-links.yml index ffb18fa0eb28..40e948fe2c17 100644 --- a/noir/.github/workflows/docs-dead-links.yml +++ b/noir/.github/workflows/docs-dead-links.yml @@ -29,7 +29,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} WORKFLOW_NAME: ${{ github.workflow }} - WORKFLOW_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/job/${{ github.job }} + WORKFLOW_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} with: update_existing: true filename: .github/DEAD_LINKS_IN_DOCS.md diff --git a/noir/.github/workflows/docs-pr.yml b/noir/.github/workflows/docs-pr.yml index a16487a49efb..f4a1be826a8d 100644 --- a/noir/.github/workflows/docs-pr.yml +++ b/noir/.github/workflows/docs-pr.yml @@ -11,7 +11,7 @@ jobs: steps: - name: Check if label is present id: check-labels - uses: actions/github-script@v3 + uses: actions/github-script@v7.0.1 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | @@ -21,10 +21,11 @@ jobs: } // Fetch the list of files changed in the PR - const { data: files } = await github.pulls.listFiles({ + const { data: files } = await github.rest.pulls.listFiles({ owner: context.repo.owner, repo: context.repo.repo, - pull_number: context.issue.number + pull_number: context.issue.number, + per_page: 100 }); // Check if any file is within the 'docs' folder @@ -33,13 +34,13 @@ jobs: - name: Add label if not present if: steps.check-labels.outputs.result == 'true' - uses: actions/github-script@v3 + uses: actions/github-script@v7.0.1 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | const labels = context.payload.pull_request.labels.map(label => label.name); if (!labels.includes('documentation')) { - github.issues.addLabels({ + github.rest.issues.addLabels({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, @@ -47,20 +48,14 @@ jobs: }) } - build_and_deploy_preview: + build_preview: runs-on: ubuntu-latest - permissions: - pull-requests: write - needs: add_label - if: needs.add_label.outputs.has_label == 'true' steps: - name: Checkout code uses: actions/checkout@v4 - - name: Setup Node.js - uses: actions/setup-node@v2 - with: - node-version: '18' + - name: Install Yarn dependencies + uses: ./.github/actions/setup - name: Install wasm-bindgen-cli uses: taiki-e/install-action@v2 @@ -71,13 +66,34 @@ jobs: run: | npm i wasm-opt -g - - name: Install Yarn dependencies - uses: ./.github/actions/setup - - name: Build docs run: - yarn workspaces foreach -Rt run build + yarn workspaces foreach -Rpt --from docs run build + + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: docs + path: ./docs/build/ + retention-days: 3 + + deploy_preview: + needs: [build_preview, add_label] + runs-on: ubuntu-latest + permissions: + pull-requests: write + if: needs.add_label.outputs.has_label == 'true' + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Download built docs + uses: actions/download-artifact@v3 + with: + name: docs + path: ./docs/build + - name: Deploy to Netlify uses: nwtgck/actions-netlify@v2.1 with: diff --git a/noir/.github/workflows/publish-docs.yml b/noir/.github/workflows/publish-docs.yml index 07b39d7627cf..231b57550c97 100644 --- a/noir/.github/workflows/publish-docs.yml +++ b/noir/.github/workflows/publish-docs.yml @@ -15,10 +15,8 @@ jobs: - name: Checkout release branch uses: actions/checkout@v4 - - name: Setup Node.js - uses: actions/setup-node@v2 - with: - node-version: '18' + - name: Install Yarn dependencies + uses: ./.github/actions/setup - name: Install wasm-bindgen-cli uses: taiki-e/install-action@v2 @@ -29,9 +27,6 @@ jobs: run: | npm i wasm-opt -g - - name: Install Yarn dependencies - uses: ./.github/actions/setup - - name: Build docs for deploying working-directory: docs run: diff --git a/noir/.github/workflows/release.yml b/noir/.github/workflows/release.yml index f9f6fe2fc540..22a733b38c58 100644 --- a/noir/.github/workflows/release.yml +++ b/noir/.github/workflows/release.yml @@ -44,6 +44,15 @@ jobs: run: | cargo update --workspace + - uses: actions/setup-node@v3 + with: + node-version: 18.17.1 + cache: 'yarn' + cache-dependency-path: 'yarn.lock' + + - name: Update yarn.lock + run: yarn + - name: Configure git run: | git config user.name kevaundray @@ -68,11 +77,6 @@ jobs: ref: ${{ fromJSON(needs.release-please.outputs.release-pr).headBranchName }} token: ${{ secrets.NOIR_RELEASES_TOKEN }} - - name: Setup Node.js - uses: actions/setup-node@v2 - with: - node-version: '18' - - name: Install Yarn dependencies uses: ./.github/actions/setup diff --git a/noir/.gitrepo b/noir/.gitrepo index 5fcea33359ce..9fa4e9ae521a 100644 --- a/noir/.gitrepo +++ b/noir/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/noir-lang/noir branch = aztec-packages - commit = 13f93d523342daf478e08e8ccc0f00962c7fbe05 - parent = 41ae75cdee6285729551965972e8cb039ff3045a + commit = 7dba0a18ad83e74f8114c6ca594ad10e5e334704 + parent = bcab9ceab62bede3bc1c105b3e639e7c64e3217a method = merge cmdver = 0.4.6 diff --git a/noir/.release-please-manifest.json b/noir/.release-please-manifest.json index 01f6fb140b1b..f440a7a2c515 100644 --- a/noir/.release-please-manifest.json +++ b/noir/.release-please-manifest.json @@ -1,4 +1,4 @@ { - ".": "0.22.0", - "acvm-repo": "0.38.0" + ".": "0.23.0", + "acvm-repo": "0.39.0" } \ No newline at end of file diff --git a/noir/CHANGELOG.md b/noir/CHANGELOG.md index 3fc044076a0e..af7eb5b2f19e 100644 --- a/noir/CHANGELOG.md +++ b/noir/CHANGELOG.md @@ -1,5 +1,97 @@ # Changelog +## [0.23.0](https://github.com/noir-lang/noir/compare/v0.22.0...v0.23.0) (2024-01-22) + + +### ⚠ BREAKING CHANGES + +* Ban nested slices ([#4018](https://github.com/noir-lang/noir/issues/4018)) +* Breaking changes from aztec-packages ([#3955](https://github.com/noir-lang/noir/issues/3955)) +* Rename Arithmetic opcode to AssertZero ([#3840](https://github.com/noir-lang/noir/issues/3840)) +* remove circuit methods from noir_wasm ([#3869](https://github.com/noir-lang/noir/issues/3869)) + +### Features + +* Add `assert_max_bit_size` method to `Field` ([#4016](https://github.com/noir-lang/noir/issues/4016)) ([bc9a44f](https://github.com/noir-lang/noir/commit/bc9a44f285e0569825a307b06ee8acd93461c87e)) +* Add `noir-compiler` checks to `aztec_macros` ([#4031](https://github.com/noir-lang/noir/issues/4031)) ([420a5c7](https://github.com/noir-lang/noir/commit/420a5c74a14dcfeede04337a42282093a7b5e63e)) +* Add a `--force` flag to force a full recompile ([#4054](https://github.com/noir-lang/noir/issues/4054)) ([27a8e68](https://github.com/noir-lang/noir/commit/27a8e6864643d81d96e84990e2e26cd16596a695)) +* Add dependency resolver for `noir_wasm` and implement `FileManager` for consistency with native interface ([#3891](https://github.com/noir-lang/noir/issues/3891)) ([c29c7d7](https://github.com/noir-lang/noir/commit/c29c7d7c9615b9f45c696b1bdc1c497d55469dfa)) +* Add foreign call support to `noir_codegen` functions ([#3933](https://github.com/noir-lang/noir/issues/3933)) ([e5e52a8](https://github.com/noir-lang/noir/commit/e5e52a81b31d7735b680e97a9bef89a010a99763)) +* Add MVP `nargo export` command ([#3870](https://github.com/noir-lang/noir/issues/3870)) ([fbb51ed](https://github.com/noir-lang/noir/commit/fbb51ed33e9e4d9105d8946cdfc4ea387c85258e)) +* Add support for codegenning multiple functions which use the same structs in their interface ([#3868](https://github.com/noir-lang/noir/issues/3868)) ([1dcfcc5](https://github.com/noir-lang/noir/commit/1dcfcc5265f618685a783504b1d4be213e4cda2d)) +* Added efficient field comparisons for bn254 ([#4042](https://github.com/noir-lang/noir/issues/4042)) ([1f9cad0](https://github.com/noir-lang/noir/commit/1f9cad00c57ea257f57419d2446a46938beb19f9)) +* Assert maximum bit size when creating a U128 from an integer ([#4024](https://github.com/noir-lang/noir/issues/4024)) ([8f9c7e4](https://github.com/noir-lang/noir/commit/8f9c7e4de9f2ae5b39714d8e0d26b2befcd11c4a)) +* Avoid unnecessary range checks by inspecting instructions for casts ([#4039](https://github.com/noir-lang/noir/issues/4039)) ([378c18e](https://github.com/noir-lang/noir/commit/378c18eb42d75852b97f849d05c9e3f650601339)) +* Breaking changes from aztec-packages ([#3955](https://github.com/noir-lang/noir/issues/3955)) ([5be049e](https://github.com/noir-lang/noir/commit/5be049eee6c342649462282ee04f6411e6ea392c)) +* Bubble up `Instruction::Constrain`s to be applied as early as possible. ([#4065](https://github.com/noir-lang/noir/issues/4065)) ([66f5cdd](https://github.com/noir-lang/noir/commit/66f5cddc133ba0311028eba96c0ff6ec2ecaee59)) +* Cached LSP parsing ([#4083](https://github.com/noir-lang/noir/issues/4083)) ([b4f724e](https://github.com/noir-lang/noir/commit/b4f724e848b291a733e417c394ac3fc7649c08c5)) +* Comparison for signed integers ([#3873](https://github.com/noir-lang/noir/issues/3873)) ([bcbd49b](https://github.com/noir-lang/noir/commit/bcbd49b8b44749e149f83c1240094fa2f0a19087)) +* Decompose `Instruction::Cast` to have an explicit truncation instruction ([#3946](https://github.com/noir-lang/noir/issues/3946)) ([35f18ef](https://github.com/noir-lang/noir/commit/35f18ef4d7c8041e3cf622a5643748d0793c2aa6)) +* Decompose `Instruction::Constrain` into multiple more basic constraints ([#3892](https://github.com/noir-lang/noir/issues/3892)) ([51cf9d3](https://github.com/noir-lang/noir/commit/51cf9d37c8b9fbb14bb54b178d93129a7563e131)) +* Docker testing flow ([#3895](https://github.com/noir-lang/noir/issues/3895)) ([179c90d](https://github.com/noir-lang/noir/commit/179c90dc3263c85de105c57925d9c5894427e8e1)) +* Extract parsing to its own pass and do it in parallel ([#4063](https://github.com/noir-lang/noir/issues/4063)) ([569cbbc](https://github.com/noir-lang/noir/commit/569cbbc231a242c32821cba56f3649f3228a1cc7)) +* Implement `Eq` trait on curve points ([#3944](https://github.com/noir-lang/noir/issues/3944)) ([abf751a](https://github.com/noir-lang/noir/commit/abf751ab7f57f87520be16b2bc6168efdf95a430)) +* Implement DAP protocol in Nargo ([#3627](https://github.com/noir-lang/noir/issues/3627)) ([13834d4](https://github.com/noir-lang/noir/commit/13834d43bd876909cb50494a41b42297f7e6375b)) +* Implement generic traits ([#4000](https://github.com/noir-lang/noir/issues/4000)) ([916fd15](https://github.com/noir-lang/noir/commit/916fd158aa361ac80d32767f575ad896c3462b15)) +* Implement Operator Overloading ([#3931](https://github.com/noir-lang/noir/issues/3931)) ([4b16090](https://github.com/noir-lang/noir/commit/4b16090beecd0fcdd41c9e7b8f615c4625c26a5b)) +* **lsp:** Cache definitions for goto requests ([#3930](https://github.com/noir-lang/noir/issues/3930)) ([4a2140f](https://github.com/noir-lang/noir/commit/4a2140f1f36bbe3afbc006f8db74820308ae27d5)) +* **lsp:** Goto global ([#4043](https://github.com/noir-lang/noir/issues/4043)) ([15237b3](https://github.com/noir-lang/noir/commit/15237b34dbce5ea54973a178449e67cca8ac4f9d)) +* **lsp:** Goto struct member inside Impl method ([#3918](https://github.com/noir-lang/noir/issues/3918)) ([99c2c5a](https://github.com/noir-lang/noir/commit/99c2c5a2c2c0da6bad783b60d9e3de8d9a1f4ee4)) +* **lsp:** Goto trait from trait impl ([#3956](https://github.com/noir-lang/noir/issues/3956)) ([eb566e2](https://github.com/noir-lang/noir/commit/eb566e2125e847a3e3efbd2bc15a88a1c454a7df)) +* **lsp:** Goto trait method declaration ([#3991](https://github.com/noir-lang/noir/issues/3991)) ([eb79166](https://github.com/noir-lang/noir/commit/eb79166f7d2b7aa45c9c6c0aa37db1c0a5dfa00f)) +* **lsp:** Goto type alias ([#4061](https://github.com/noir-lang/noir/issues/4061)) ([dc83385](https://github.com/noir-lang/noir/commit/dc83385e9fe5766cd8218265be38c54243cae76e)) +* **lsp:** Goto type definition ([#4029](https://github.com/noir-lang/noir/issues/4029)) ([8bb4ddf](https://github.com/noir-lang/noir/commit/8bb4ddfdd81d491ff713a056a7eae522f329d173)) +* **lsp:** Re-add code lens feature with improved performance ([#3829](https://github.com/noir-lang/noir/issues/3829)) ([8f5cd6c](https://github.com/noir-lang/noir/commit/8f5cd6c0b641b3970bf626e8910b2a4c7cc8c310)) +* Optimize array ops for arrays of structs ([#4027](https://github.com/noir-lang/noir/issues/4027)) ([c9ec0d8](https://github.com/noir-lang/noir/commit/c9ec0d811ddc8653201ed765b51585a7c1b946fb)) +* Optimize logic gate ACIR-gen ([#3897](https://github.com/noir-lang/noir/issues/3897)) ([926460a](https://github.com/noir-lang/noir/commit/926460a0c70e21e2f4720148cf424e44ab9b0678)) +* Prefer `AcirContext`-native methods for performing logic operations ([#3898](https://github.com/noir-lang/noir/issues/3898)) ([0ec39b8](https://github.com/noir-lang/noir/commit/0ec39b8396084ed1e7f20609c8ad8a5844a86674)) +* Remove range constraints from witnesses which are constrained to be constants ([#3928](https://github.com/noir-lang/noir/issues/3928)) ([afe9c7a](https://github.com/noir-lang/noir/commit/afe9c7a38bb9d4245205d3aa46d4ce23d70a5671)) +* Remove truncation from brillig casts ([#3997](https://github.com/noir-lang/noir/issues/3997)) ([857ff97](https://github.com/noir-lang/noir/commit/857ff97b196174a0999f0fe7e387bfca5c3b7cd3)) +* Remove truncations which can be seen to be noops using type information ([#3953](https://github.com/noir-lang/noir/issues/3953)) ([cc3c2c2](https://github.com/noir-lang/noir/commit/cc3c2c22644f0b5d8369bad2362ea6e9112a0713)) +* Remove unnecessary predicate from `Lt` instruction ([#3922](https://github.com/noir-lang/noir/issues/3922)) ([a63433f](https://github.com/noir-lang/noir/commit/a63433fb8747722ec3cf2c6eb85d34e5b04bc15c)) +* Simplify chains of casts to be all in terms of the original `ValueId` ([#3984](https://github.com/noir-lang/noir/issues/3984)) ([2384d3e](https://github.com/noir-lang/noir/commit/2384d3e97af24a8718fbf57f6b276a5ce1de06fe)) +* Simplify multiplications by `0` or `1` in ACIR gen ([#3924](https://github.com/noir-lang/noir/issues/3924)) ([e58844d](https://github.com/noir-lang/noir/commit/e58844daf9f040626a3a7595f8c4f831e48a4037)) +* Support for u128 ([#3913](https://github.com/noir-lang/noir/issues/3913)) ([b4911dc](https://github.com/noir-lang/noir/commit/b4911dcf676f0925ac631ba6f60fc9c4945b2fee)) +* Support printing more types ([#4071](https://github.com/noir-lang/noir/issues/4071)) ([f5c4632](https://github.com/noir-lang/noir/commit/f5c4632e174beba508e1e31d0e2ae3f6d028ae2c)) +* Sync `aztec-packages` ([#4011](https://github.com/noir-lang/noir/issues/4011)) ([fee2452](https://github.com/noir-lang/noir/commit/fee24523c427c27f0bdaf98ea09a852a2da3e94c)) +* Sync commits from `aztec-packages` ([#4068](https://github.com/noir-lang/noir/issues/4068)) ([7a8f3a3](https://github.com/noir-lang/noir/commit/7a8f3a33b57875e681e3d81e667e3570a1cdbdcc)) +* Use singleton `WasmBlackBoxFunctionSolver` in `noir_js` ([#3966](https://github.com/noir-lang/noir/issues/3966)) ([10b28de](https://github.com/noir-lang/noir/commit/10b28def4d74822b7af2c19a1cc693788272b00b)) + + +### Bug Fixes + +* Acir gen doesn't panic on unsupported BB function ([#3866](https://github.com/noir-lang/noir/issues/3866)) ([34fd978](https://github.com/noir-lang/noir/commit/34fd978d206789a9e9f5167bfd690a34386834d0)) +* Allow abi encoding arrays of structs from JS ([#3867](https://github.com/noir-lang/noir/issues/3867)) ([9b713f8](https://github.com/noir-lang/noir/commit/9b713f8cf599df262a12ec1098136c50b2b46766)) +* Allow abi encoding tuples from JS ([#3894](https://github.com/noir-lang/noir/issues/3894)) ([f7fa181](https://github.com/noir-lang/noir/commit/f7fa1811ad2591020c914976f26e2f11a91cd177)) +* Allow ast when macro errors ([#4005](https://github.com/noir-lang/noir/issues/4005)) ([efccec3](https://github.com/noir-lang/noir/commit/efccec3c24eb093fba99b1c29f01a78aae5776d0)) +* Allow lsp to run inside of a docker container ([#3876](https://github.com/noir-lang/noir/issues/3876)) ([2529977](https://github.com/noir-lang/noir/commit/2529977acd684219f57ef086415557cc07af043b)) +* Bit-shifts for signed integers ([#3890](https://github.com/noir-lang/noir/issues/3890)) ([6ddd98a](https://github.com/noir-lang/noir/commit/6ddd98ab7d3fefde491cf12b785f76bf0585609e)) +* Checks for cyclic dependencies ([#3699](https://github.com/noir-lang/noir/issues/3699)) ([642011a](https://github.com/noir-lang/noir/commit/642011ab6ebbe8f012eda1da1abbf8660500723d)) +* **debugger:** Crash when stepping through locations spanning multiple lines ([#3920](https://github.com/noir-lang/noir/issues/3920)) ([223e860](https://github.com/noir-lang/noir/commit/223e860975c2698bd5043340b937de74552ec15b)) +* Don't fail if no tests and the user didn't provide a pattern ([#3864](https://github.com/noir-lang/noir/issues/3864)) ([decbd0f](https://github.com/noir-lang/noir/commit/decbd0f0c019844cd2b235e7804d2f6ba7b23897)) +* Fix advisory issue in cargo-deny ([#4077](https://github.com/noir-lang/noir/issues/4077)) ([19baea0](https://github.com/noir-lang/noir/commit/19baea0d18e2d26bd04b649f79dd8e681488d1dc)) +* Fixing dark mode background on the CTA button ([#3882](https://github.com/noir-lang/noir/issues/3882)) ([57eae42](https://github.com/noir-lang/noir/commit/57eae42080d6a928e8010c6bc77489964a5777ef)) +* Fixup exports from `noir_wasm` ([#4022](https://github.com/noir-lang/noir/issues/4022)) ([358cdd2](https://github.com/noir-lang/noir/commit/358cdd2725444091b3322c47754e3cbd9b1d3614)) +* Handle multiple imports in the same file ([#3903](https://github.com/noir-lang/noir/issues/3903)) ([219423e](https://github.com/noir-lang/noir/commit/219423eb87fa12bd8cca2a6fd2ce4c06e308783c)) +* Hoist constraints on inputs to top of program ([#4076](https://github.com/noir-lang/noir/issues/4076)) ([447aa34](https://github.com/noir-lang/noir/commit/447aa343555cbd5a7cd735876e08f43271ecdd40)) +* Implement missing codegen for `BlackBoxFunc::EcdsaSecp256r1` in brillig ([#3943](https://github.com/noir-lang/noir/issues/3943)) ([2c5eceb](https://github.com/noir-lang/noir/commit/2c5eceb04ab6bc38e954492642121c7fe3da866f)) +* Improve `nargo test` output ([#3973](https://github.com/noir-lang/noir/issues/3973)) ([3ab5ff4](https://github.com/noir-lang/noir/commit/3ab5ff431145a1f747b698caed15caebaa145f04)) +* Make `constant_to_radix` emit a slice instead of an array ([#4049](https://github.com/noir-lang/noir/issues/4049)) ([5cdb1d0](https://github.com/noir-lang/noir/commit/5cdb1d0dabe2e38a1610f718747cc2fb4263339d)) +* Operator overloading & static trait method references resolving to generic impls ([#3967](https://github.com/noir-lang/noir/issues/3967)) ([f1de8fa](https://github.com/noir-lang/noir/commit/f1de8fa3247bcee624bcd7a0f89fe7c7cd8430f1)) +* Preserve brillig entrypoint functions without arguments ([#3951](https://github.com/noir-lang/noir/issues/3951)) ([1111465](https://github.com/noir-lang/noir/commit/1111465551557ed9e97e4b43d6eccc4b5896a39f)) +* Prevent `Instruction::Constrain`s for non-primitive types ([#3916](https://github.com/noir-lang/noir/issues/3916)) ([467948f](https://github.com/noir-lang/noir/commit/467948f9ee9ae65b4e2badaa1d15835fced3e835)) +* Remove panic for adding an invalid crate name in wasm compiler ([#3977](https://github.com/noir-lang/noir/issues/3977)) ([7a1baa5](https://github.com/noir-lang/noir/commit/7a1baa56faa2deb385ef1b6c9da9073dafd5a376)) +* Return error rather instead of panicking on invalid circuit ([#3976](https://github.com/noir-lang/noir/issues/3976)) ([67201bf](https://github.com/noir-lang/noir/commit/67201bfc21a9c8858aa86be9cd47d463fb78d925)) +* Search all levels of struct nesting before codegenning primitive types ([#3970](https://github.com/noir-lang/noir/issues/3970)) ([13ae014](https://github.com/noir-lang/noir/commit/13ae014ddcbd9eddb401c563b95053f7a1a89f1c)) +* Update generics docs to mention we have traits now ([#3980](https://github.com/noir-lang/noir/issues/3980)) ([c2acdf1](https://github.com/noir-lang/noir/commit/c2acdf1793a67abc9a074457e057a44da3b82c39)) + + +### Miscellaneous Chores + +* Ban nested slices ([#4018](https://github.com/noir-lang/noir/issues/4018)) ([f8a1fb7](https://github.com/noir-lang/noir/commit/f8a1fb7eed1ae4a9779eb16b142a64094aa603c6)) +* Remove circuit methods from noir_wasm ([#3869](https://github.com/noir-lang/noir/issues/3869)) ([12d884e](https://github.com/noir-lang/noir/commit/12d884e2b74efab7257626d8878ea1a7455ecf85)) +* Rename Arithmetic opcode to AssertZero ([#3840](https://github.com/noir-lang/noir/issues/3840)) ([836f171](https://github.com/noir-lang/noir/commit/836f17145c2901060706294461c2d282dd121b3e)) + ## [0.22.0](https://github.com/noir-lang/noir/compare/v0.21.0...v0.22.0) (2023-12-18) diff --git a/noir/Cargo.lock b/noir/Cargo.lock index 79f1934059f5..93f1d25fc76b 100644 --- a/noir/Cargo.lock +++ b/noir/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "acir" -version = "0.38.0" +version = "0.39.0" dependencies = [ "acir_field", "base64 0.21.2", @@ -23,7 +23,7 @@ dependencies = [ [[package]] name = "acir_field" -version = "0.38.0" +version = "0.39.0" dependencies = [ "ark-bls12-381", "ark-bn254", @@ -37,7 +37,7 @@ dependencies = [ [[package]] name = "acvm" -version = "0.38.0" +version = "0.39.0" dependencies = [ "acir", "acvm_blackbox_solver", @@ -53,7 +53,7 @@ dependencies = [ [[package]] name = "acvm_blackbox_solver" -version = "0.38.0" +version = "0.39.0" dependencies = [ "acir", "blake2", @@ -68,7 +68,7 @@ dependencies = [ [[package]] name = "acvm_js" -version = "0.38.0" +version = "0.39.0" dependencies = [ "acvm", "bn254_blackbox_solver", @@ -115,14 +115,15 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" dependencies = [ "cfg-if 1.0.0", "getrandom 0.2.10", "once_cell", "version_check", + "zerocopy", ] [[package]] @@ -211,7 +212,7 @@ checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" [[package]] name = "arena" -version = "0.22.0" +version = "0.23.0" dependencies = [ "generational-arena", ] @@ -415,7 +416,7 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "aztec_macros" -version = "0.22.0" +version = "0.23.0" dependencies = [ "iter-extended", "noirc_frontend", @@ -579,7 +580,7 @@ dependencies = [ [[package]] name = "bn254_blackbox_solver" -version = "0.38.0" +version = "0.39.0" dependencies = [ "acir", "acvm_blackbox_solver", @@ -601,7 +602,7 @@ dependencies = [ [[package]] name = "brillig" -version = "0.38.0" +version = "0.39.0" dependencies = [ "acir_field", "serde", @@ -609,7 +610,7 @@ dependencies = [ [[package]] name = "brillig_vm" -version = "0.38.0" +version = "0.39.0" dependencies = [ "acir", "acvm_blackbox_solver", @@ -845,7 +846,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.32", ] [[package]] @@ -1295,7 +1296,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.26", + "syn 2.0.32", ] [[package]] @@ -1306,7 +1307,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core", "quote", - "syn 2.0.26", + "syn 2.0.32", ] [[package]] @@ -1556,7 +1557,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.32", ] [[package]] @@ -1682,7 +1683,7 @@ dependencies = [ [[package]] name = "fm" -version = "0.22.0" +version = "0.23.0" dependencies = [ "codespan-reporting", "iter-extended", @@ -1774,7 +1775,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.32", ] [[package]] @@ -1944,9 +1945,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.20" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97ec8491ebaf99c8eaa73058b045fe58073cd6be7f596ac993ced0b0a0c01049" +checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" dependencies = [ "bytes", "fnv", @@ -1954,7 +1955,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 1.9.3", + "indexmap 2.0.0", "slab", "tokio", "tokio-util 0.7.8", @@ -1991,7 +1992,7 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.6", ] [[package]] @@ -2254,7 +2255,7 @@ version = "0.11.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fb7c1b80a1dfa604bb4a649a5c5aeef3d913f7c520cb42b40e534e8a61bcdfc" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.6", "indexmap 1.9.3", "is-terminal", "itoa", @@ -2294,7 +2295,7 @@ dependencies = [ [[package]] name = "iter-extended" -version = "0.22.0" +version = "0.23.0" [[package]] name = "itertools" @@ -2647,7 +2648,7 @@ checksum = "7843ec2de400bcbc6a6328c958dc38e5359da6e93e72e37bc5246bf1ae776389" [[package]] name = "nargo" -version = "0.22.0" +version = "0.23.0" dependencies = [ "acvm", "codespan-reporting", @@ -2675,7 +2676,7 @@ dependencies = [ [[package]] name = "nargo_cli" -version = "0.22.0" +version = "0.23.0" dependencies = [ "acvm", "assert_cmd", @@ -2726,7 +2727,7 @@ dependencies = [ [[package]] name = "nargo_fmt" -version = "0.22.0" +version = "0.23.0" dependencies = [ "bytecount", "noirc_frontend", @@ -2738,7 +2739,7 @@ dependencies = [ [[package]] name = "nargo_toml" -version = "0.22.0" +version = "0.23.0" dependencies = [ "dirs", "fm", @@ -2811,7 +2812,7 @@ dependencies = [ [[package]] name = "noir_debugger" -version = "0.22.0" +version = "0.23.0" dependencies = [ "acvm", "assert_cmd", @@ -2834,12 +2835,13 @@ dependencies = [ [[package]] name = "noir_lsp" -version = "0.22.0" +version = "0.23.0" dependencies = [ "acvm", "async-lsp", "codespan-lsp", "fm", + "fxhash", "lsp-types 0.94.1", "nargo", "nargo_fmt", @@ -2847,6 +2849,7 @@ dependencies = [ "noirc_driver", "noirc_errors", "noirc_frontend", + "rayon", "serde", "serde_json", "serde_with", @@ -2858,7 +2861,7 @@ dependencies = [ [[package]] name = "noir_wasm" -version = "0.22.0" +version = "0.23.0" dependencies = [ "acvm", "build-data", @@ -2881,7 +2884,7 @@ dependencies = [ [[package]] name = "noirc_abi" -version = "0.22.0" +version = "0.23.0" dependencies = [ "acvm", "iter-extended", @@ -2898,7 +2901,7 @@ dependencies = [ [[package]] name = "noirc_abi_wasm" -version = "0.22.0" +version = "0.23.0" dependencies = [ "acvm", "build-data", @@ -2915,7 +2918,7 @@ dependencies = [ [[package]] name = "noirc_driver" -version = "0.22.0" +version = "0.23.0" dependencies = [ "acvm", "aztec_macros", @@ -2935,7 +2938,7 @@ dependencies = [ [[package]] name = "noirc_errors" -version = "0.22.0" +version = "0.23.0" dependencies = [ "acvm", "base64 0.21.2", @@ -2952,7 +2955,7 @@ dependencies = [ [[package]] name = "noirc_evaluator" -version = "0.22.0" +version = "0.23.0" dependencies = [ "acvm", "fxhash", @@ -2968,7 +2971,7 @@ dependencies = [ [[package]] name = "noirc_frontend" -version = "0.22.0" +version = "0.23.0" dependencies = [ "acvm", "arena", @@ -2992,7 +2995,7 @@ dependencies = [ [[package]] name = "noirc_printable_type" -version = "0.22.0" +version = "0.23.0" dependencies = [ "acvm", "iter-extended", @@ -3844,7 +3847,7 @@ dependencies = [ "quote", "rust-embed-utils", "shellexpand", - "syn 2.0.26", + "syn 2.0.32", "walkdir", ] @@ -4154,7 +4157,7 @@ checksum = "741e124f5485c7e60c03b043f79f320bff3527f4bbf12cf3831750dc46a0ec2c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.32", ] [[package]] @@ -4176,7 +4179,7 @@ checksum = "1d89a8107374290037607734c0b73a85db7ed80cae314b3c5791f192a496e731" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.32", ] [[package]] @@ -4226,7 +4229,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.32", ] [[package]] @@ -4251,7 +4254,7 @@ checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.32", ] [[package]] @@ -4527,9 +4530,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.26" +version = "2.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45c3457aacde3c65315de5031ec191ce46604304d2446e803d71ade03308d970" +checksum = "239814284fd6f1a4ffe4ca893952cdd93c224b6a1571c9a9eadd670295c0c9e2" dependencies = [ "proc-macro2", "quote", @@ -4600,9 +4603,9 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "test-binary" -version = "3.0.1" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb28771e7854f02e5705f2a1b09451d932a273f5a4ec1c9fa4c65882b8b7b6ca" +checksum = "6c7cb854285c40b61c0fade358bf63a2bb1226688a1ea11432ea65349209e6e3" dependencies = [ "camino", "cargo_metadata", @@ -4649,7 +4652,7 @@ checksum = "463fe12d7993d3b327787537ce8dd4dfa058de32fc2b195ef3cde03dc4771e8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.32", ] [[package]] @@ -4740,7 +4743,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.32", ] [[package]] @@ -4891,7 +4894,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.32", ] [[package]] @@ -5163,7 +5166,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.32", "wasm-bindgen-shared", ] @@ -5197,7 +5200,7 @@ checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.32", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5678,6 +5681,26 @@ dependencies = [ "libc", ] +[[package]] +name = "zerocopy" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.32", +] + [[package]] name = "zeroize" version = "1.6.0" @@ -5695,5 +5718,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.26", + "syn 2.0.32", ] diff --git a/noir/Cargo.toml b/noir/Cargo.toml index f0fc7249efc0..8a827cacfcd2 100644 --- a/noir/Cargo.toml +++ b/noir/Cargo.toml @@ -38,7 +38,7 @@ resolver = "2" [workspace.package] # x-release-please-start-version -version = "0.22.0" +version = "0.23.0" # x-release-please-end authors = ["The Noir Team "] edition = "2021" @@ -49,14 +49,14 @@ repository = "https://github.com/noir-lang/noir/" [workspace.dependencies] # ACVM workspace dependencies -acir_field = { version = "0.38.0", path = "acvm-repo/acir_field", default-features = false } -acir = { version = "0.38.0", path = "acvm-repo/acir", default-features = false } -acvm = { version = "0.38.0", path = "acvm-repo/acvm" } +acir_field = { version = "0.39.0", path = "acvm-repo/acir_field", default-features = false } +acir = { version = "0.39.0", path = "acvm-repo/acir", default-features = false } +acvm = { version = "0.39.0", path = "acvm-repo/acvm" } stdlib = { version = "0.37.1", package = "acvm_stdlib", path = "acvm-repo/stdlib", default-features = false } -brillig = { version = "0.38.0", path = "acvm-repo/brillig", default-features = false } -brillig_vm = { version = "0.38.0", path = "acvm-repo/brillig_vm", default-features = false } -acvm_blackbox_solver = { version = "0.38.0", path = "acvm-repo/blackbox_solver", default-features = false } -bn254_blackbox_solver = { version = "0.38.0", path = "acvm-repo/bn254_blackbox_solver", default-features = false } +brillig = { version = "0.39.0", path = "acvm-repo/brillig", default-features = false } +brillig_vm = { version = "0.39.0", path = "acvm-repo/brillig_vm", default-features = false } +acvm_blackbox_solver = { version = "0.39.0", path = "acvm-repo/blackbox_solver", default-features = false } +bn254_blackbox_solver = { version = "0.39.0", path = "acvm-repo/bn254_blackbox_solver", default-features = false } # Noir compiler workspace dependencies arena = { path = "compiler/utils/arena" } diff --git a/noir/acvm-repo/CHANGELOG.md b/noir/acvm-repo/CHANGELOG.md index d413bd390c40..7f68244a7eb9 100644 --- a/noir/acvm-repo/CHANGELOG.md +++ b/noir/acvm-repo/CHANGELOG.md @@ -5,6 +5,38 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.39.0](https://github.com/noir-lang/noir/compare/v0.38.0...v0.39.0) (2024-01-22) + + +### ⚠ BREAKING CHANGES + +* Breaking changes from aztec-packages ([#3955](https://github.com/noir-lang/noir/issues/3955)) +* Rename Arithmetic opcode to AssertZero ([#3840](https://github.com/noir-lang/noir/issues/3840)) +* Remove unused methods on ACIR opcodes ([#3841](https://github.com/noir-lang/noir/issues/3841)) +* Remove partial backend feature ([#3805](https://github.com/noir-lang/noir/issues/3805)) + +### Features + +* Aztec-packages ([#3754](https://github.com/noir-lang/noir/issues/3754)) ([c043265](https://github.com/noir-lang/noir/commit/c043265e550b59bd4296504826fe15d3ce3e9ad2)) +* Breaking changes from aztec-packages ([#3955](https://github.com/noir-lang/noir/issues/3955)) ([5be049e](https://github.com/noir-lang/noir/commit/5be049eee6c342649462282ee04f6411e6ea392c)) +* Remove range constraints from witnesses which are constrained to be constants ([#3928](https://github.com/noir-lang/noir/issues/3928)) ([afe9c7a](https://github.com/noir-lang/noir/commit/afe9c7a38bb9d4245205d3aa46d4ce23d70a5671)) +* Speed up transformation of debug messages ([#3815](https://github.com/noir-lang/noir/issues/3815)) ([2a8af1e](https://github.com/noir-lang/noir/commit/2a8af1e4141ffff61547ee1c2837a6392bd5db48)) +* Sync `aztec-packages` ([#4011](https://github.com/noir-lang/noir/issues/4011)) ([fee2452](https://github.com/noir-lang/noir/commit/fee24523c427c27f0bdaf98ea09a852a2da3e94c)) +* Sync commits from `aztec-packages` ([#4068](https://github.com/noir-lang/noir/issues/4068)) ([7a8f3a3](https://github.com/noir-lang/noir/commit/7a8f3a33b57875e681e3d81e667e3570a1cdbdcc)) + + +### Bug Fixes + +* Deserialize odd length hex literals ([#3747](https://github.com/noir-lang/noir/issues/3747)) ([4000fb2](https://github.com/noir-lang/noir/commit/4000fb279221eb07187d657bfaa7f1c7b311abf2)) +* Return error rather instead of panicking on invalid circuit ([#3976](https://github.com/noir-lang/noir/issues/3976)) ([67201bf](https://github.com/noir-lang/noir/commit/67201bfc21a9c8858aa86be9cd47d463fb78d925)) + + +### Miscellaneous Chores + +* Remove partial backend feature ([#3805](https://github.com/noir-lang/noir/issues/3805)) ([0383100](https://github.com/noir-lang/noir/commit/0383100853a80a5b28b797cdfeae0d271f1b7805)) +* Remove unused methods on ACIR opcodes ([#3841](https://github.com/noir-lang/noir/issues/3841)) ([9e5d0e8](https://github.com/noir-lang/noir/commit/9e5d0e813d61a0bfb5ee68174ed287c5a20f1579)) +* Rename Arithmetic opcode to AssertZero ([#3840](https://github.com/noir-lang/noir/issues/3840)) ([836f171](https://github.com/noir-lang/noir/commit/836f17145c2901060706294461c2d282dd121b3e)) + ## [0.38.0](https://github.com/noir-lang/noir/compare/v0.37.1...v0.38.0) (2023-12-18) diff --git a/noir/acvm-repo/acir/Cargo.toml b/noir/acvm-repo/acir/Cargo.toml index b44c64dd8383..49b10c57cc8c 100644 --- a/noir/acvm-repo/acir/Cargo.toml +++ b/noir/acvm-repo/acir/Cargo.toml @@ -2,7 +2,7 @@ name = "acir" description = "ACIR is the IR that the VM processes, it is analogous to LLVM IR" # x-release-please-start-version -version = "0.38.0" +version = "0.39.0" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/noir/acvm-repo/acir/codegen/acir.cpp b/noir/acvm-repo/acir/codegen/acir.cpp index 9b74a8ea6310..07bcd5f9f972 100644 --- a/noir/acvm-repo/acir/codegen/acir.cpp +++ b/noir/acvm-repo/acir/codegen/acir.cpp @@ -206,7 +206,66 @@ namespace Circuit { static RecursiveAggregation bincodeDeserialize(std::vector); }; - std::variant value; + struct BigIntAdd { + uint32_t lhs; + uint32_t rhs; + uint32_t output; + + friend bool operator==(const BigIntAdd&, const BigIntAdd&); + std::vector bincodeSerialize() const; + static BigIntAdd bincodeDeserialize(std::vector); + }; + + struct BigIntNeg { + uint32_t lhs; + uint32_t rhs; + uint32_t output; + + friend bool operator==(const BigIntNeg&, const BigIntNeg&); + std::vector bincodeSerialize() const; + static BigIntNeg bincodeDeserialize(std::vector); + }; + + struct BigIntMul { + uint32_t lhs; + uint32_t rhs; + uint32_t output; + + friend bool operator==(const BigIntMul&, const BigIntMul&); + std::vector bincodeSerialize() const; + static BigIntMul bincodeDeserialize(std::vector); + }; + + struct BigIntDiv { + uint32_t lhs; + uint32_t rhs; + uint32_t output; + + friend bool operator==(const BigIntDiv&, const BigIntDiv&); + std::vector bincodeSerialize() const; + static BigIntDiv bincodeDeserialize(std::vector); + }; + + struct BigIntFromLeBytes { + std::vector inputs; + std::vector modulus; + uint32_t output; + + friend bool operator==(const BigIntFromLeBytes&, const BigIntFromLeBytes&); + std::vector bincodeSerialize() const; + static BigIntFromLeBytes bincodeDeserialize(std::vector); + }; + + struct BigIntToLeBytes { + uint32_t input; + std::vector outputs; + + friend bool operator==(const BigIntToLeBytes&, const BigIntToLeBytes&); + std::vector bincodeSerialize() const; + static BigIntToLeBytes bincodeDeserialize(std::vector); + }; + + std::variant value; friend bool operator==(const BlackBoxFuncCall&, const BlackBoxFuncCall&); std::vector bincodeSerialize() const; @@ -543,7 +602,66 @@ namespace Circuit { static EmbeddedCurveDouble bincodeDeserialize(std::vector); }; - std::variant value; + struct BigIntAdd { + Circuit::RegisterIndex lhs; + Circuit::RegisterIndex rhs; + Circuit::RegisterIndex output; + + friend bool operator==(const BigIntAdd&, const BigIntAdd&); + std::vector bincodeSerialize() const; + static BigIntAdd bincodeDeserialize(std::vector); + }; + + struct BigIntNeg { + Circuit::RegisterIndex lhs; + Circuit::RegisterIndex rhs; + Circuit::RegisterIndex output; + + friend bool operator==(const BigIntNeg&, const BigIntNeg&); + std::vector bincodeSerialize() const; + static BigIntNeg bincodeDeserialize(std::vector); + }; + + struct BigIntMul { + Circuit::RegisterIndex lhs; + Circuit::RegisterIndex rhs; + Circuit::RegisterIndex output; + + friend bool operator==(const BigIntMul&, const BigIntMul&); + std::vector bincodeSerialize() const; + static BigIntMul bincodeDeserialize(std::vector); + }; + + struct BigIntDiv { + Circuit::RegisterIndex lhs; + Circuit::RegisterIndex rhs; + Circuit::RegisterIndex output; + + friend bool operator==(const BigIntDiv&, const BigIntDiv&); + std::vector bincodeSerialize() const; + static BigIntDiv bincodeDeserialize(std::vector); + }; + + struct BigIntFromLeBytes { + Circuit::HeapVector inputs; + Circuit::HeapVector modulus; + Circuit::RegisterIndex output; + + friend bool operator==(const BigIntFromLeBytes&, const BigIntFromLeBytes&); + std::vector bincodeSerialize() const; + static BigIntFromLeBytes bincodeDeserialize(std::vector); + }; + + struct BigIntToLeBytes { + Circuit::RegisterIndex input; + Circuit::HeapVector output; + + friend bool operator==(const BigIntToLeBytes&, const BigIntToLeBytes&); + std::vector bincodeSerialize() const; + static BigIntToLeBytes bincodeDeserialize(std::vector); + }; + + std::variant value; friend bool operator==(const BlackBoxOp&, const BlackBoxOp&); std::vector bincodeSerialize() const; @@ -2469,6 +2587,267 @@ Circuit::BlackBoxFuncCall::RecursiveAggregation serde::Deserializable BlackBoxFuncCall::BigIntAdd::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxFuncCall::BigIntAdd BlackBoxFuncCall::BigIntAdd::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxFuncCall::BigIntAdd &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.lhs, serializer); + serde::Serializable::serialize(obj.rhs, serializer); + serde::Serializable::serialize(obj.output, serializer); +} + +template <> +template +Circuit::BlackBoxFuncCall::BigIntAdd serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BlackBoxFuncCall::BigIntAdd obj; + obj.lhs = serde::Deserializable::deserialize(deserializer); + obj.rhs = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxFuncCall::BigIntNeg &lhs, const BlackBoxFuncCall::BigIntNeg &rhs) { + if (!(lhs.lhs == rhs.lhs)) { return false; } + if (!(lhs.rhs == rhs.rhs)) { return false; } + if (!(lhs.output == rhs.output)) { return false; } + return true; + } + + inline std::vector BlackBoxFuncCall::BigIntNeg::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxFuncCall::BigIntNeg BlackBoxFuncCall::BigIntNeg::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxFuncCall::BigIntNeg &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.lhs, serializer); + serde::Serializable::serialize(obj.rhs, serializer); + serde::Serializable::serialize(obj.output, serializer); +} + +template <> +template +Circuit::BlackBoxFuncCall::BigIntNeg serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BlackBoxFuncCall::BigIntNeg obj; + obj.lhs = serde::Deserializable::deserialize(deserializer); + obj.rhs = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxFuncCall::BigIntMul &lhs, const BlackBoxFuncCall::BigIntMul &rhs) { + if (!(lhs.lhs == rhs.lhs)) { return false; } + if (!(lhs.rhs == rhs.rhs)) { return false; } + if (!(lhs.output == rhs.output)) { return false; } + return true; + } + + inline std::vector BlackBoxFuncCall::BigIntMul::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxFuncCall::BigIntMul BlackBoxFuncCall::BigIntMul::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxFuncCall::BigIntMul &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.lhs, serializer); + serde::Serializable::serialize(obj.rhs, serializer); + serde::Serializable::serialize(obj.output, serializer); +} + +template <> +template +Circuit::BlackBoxFuncCall::BigIntMul serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BlackBoxFuncCall::BigIntMul obj; + obj.lhs = serde::Deserializable::deserialize(deserializer); + obj.rhs = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxFuncCall::BigIntDiv &lhs, const BlackBoxFuncCall::BigIntDiv &rhs) { + if (!(lhs.lhs == rhs.lhs)) { return false; } + if (!(lhs.rhs == rhs.rhs)) { return false; } + if (!(lhs.output == rhs.output)) { return false; } + return true; + } + + inline std::vector BlackBoxFuncCall::BigIntDiv::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxFuncCall::BigIntDiv BlackBoxFuncCall::BigIntDiv::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxFuncCall::BigIntDiv &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.lhs, serializer); + serde::Serializable::serialize(obj.rhs, serializer); + serde::Serializable::serialize(obj.output, serializer); +} + +template <> +template +Circuit::BlackBoxFuncCall::BigIntDiv serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BlackBoxFuncCall::BigIntDiv obj; + obj.lhs = serde::Deserializable::deserialize(deserializer); + obj.rhs = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxFuncCall::BigIntFromLeBytes &lhs, const BlackBoxFuncCall::BigIntFromLeBytes &rhs) { + if (!(lhs.inputs == rhs.inputs)) { return false; } + if (!(lhs.modulus == rhs.modulus)) { return false; } + if (!(lhs.output == rhs.output)) { return false; } + return true; + } + + inline std::vector BlackBoxFuncCall::BigIntFromLeBytes::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxFuncCall::BigIntFromLeBytes BlackBoxFuncCall::BigIntFromLeBytes::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxFuncCall::BigIntFromLeBytes &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.inputs, serializer); + serde::Serializable::serialize(obj.modulus, serializer); + serde::Serializable::serialize(obj.output, serializer); +} + +template <> +template +Circuit::BlackBoxFuncCall::BigIntFromLeBytes serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BlackBoxFuncCall::BigIntFromLeBytes obj; + obj.inputs = serde::Deserializable::deserialize(deserializer); + obj.modulus = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxFuncCall::BigIntToLeBytes &lhs, const BlackBoxFuncCall::BigIntToLeBytes &rhs) { + if (!(lhs.input == rhs.input)) { return false; } + if (!(lhs.outputs == rhs.outputs)) { return false; } + return true; + } + + inline std::vector BlackBoxFuncCall::BigIntToLeBytes::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxFuncCall::BigIntToLeBytes BlackBoxFuncCall::BigIntToLeBytes::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxFuncCall::BigIntToLeBytes &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.input, serializer); + serde::Serializable::serialize(obj.outputs, serializer); +} + +template <> +template +Circuit::BlackBoxFuncCall::BigIntToLeBytes serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BlackBoxFuncCall::BigIntToLeBytes obj; + obj.input = serde::Deserializable::deserialize(deserializer); + obj.outputs = serde::Deserializable::deserialize(deserializer); + return obj; +} + namespace Circuit { inline bool operator==(const BlackBoxOp &lhs, const BlackBoxOp &rhs) { @@ -3092,6 +3471,267 @@ Circuit::BlackBoxOp::EmbeddedCurveDouble serde::Deserializable BlackBoxOp::BigIntAdd::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxOp::BigIntAdd BlackBoxOp::BigIntAdd::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxOp::BigIntAdd &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.lhs, serializer); + serde::Serializable::serialize(obj.rhs, serializer); + serde::Serializable::serialize(obj.output, serializer); +} + +template <> +template +Circuit::BlackBoxOp::BigIntAdd serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BlackBoxOp::BigIntAdd obj; + obj.lhs = serde::Deserializable::deserialize(deserializer); + obj.rhs = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxOp::BigIntNeg &lhs, const BlackBoxOp::BigIntNeg &rhs) { + if (!(lhs.lhs == rhs.lhs)) { return false; } + if (!(lhs.rhs == rhs.rhs)) { return false; } + if (!(lhs.output == rhs.output)) { return false; } + return true; + } + + inline std::vector BlackBoxOp::BigIntNeg::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxOp::BigIntNeg BlackBoxOp::BigIntNeg::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxOp::BigIntNeg &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.lhs, serializer); + serde::Serializable::serialize(obj.rhs, serializer); + serde::Serializable::serialize(obj.output, serializer); +} + +template <> +template +Circuit::BlackBoxOp::BigIntNeg serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BlackBoxOp::BigIntNeg obj; + obj.lhs = serde::Deserializable::deserialize(deserializer); + obj.rhs = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxOp::BigIntMul &lhs, const BlackBoxOp::BigIntMul &rhs) { + if (!(lhs.lhs == rhs.lhs)) { return false; } + if (!(lhs.rhs == rhs.rhs)) { return false; } + if (!(lhs.output == rhs.output)) { return false; } + return true; + } + + inline std::vector BlackBoxOp::BigIntMul::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxOp::BigIntMul BlackBoxOp::BigIntMul::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxOp::BigIntMul &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.lhs, serializer); + serde::Serializable::serialize(obj.rhs, serializer); + serde::Serializable::serialize(obj.output, serializer); +} + +template <> +template +Circuit::BlackBoxOp::BigIntMul serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BlackBoxOp::BigIntMul obj; + obj.lhs = serde::Deserializable::deserialize(deserializer); + obj.rhs = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxOp::BigIntDiv &lhs, const BlackBoxOp::BigIntDiv &rhs) { + if (!(lhs.lhs == rhs.lhs)) { return false; } + if (!(lhs.rhs == rhs.rhs)) { return false; } + if (!(lhs.output == rhs.output)) { return false; } + return true; + } + + inline std::vector BlackBoxOp::BigIntDiv::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxOp::BigIntDiv BlackBoxOp::BigIntDiv::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxOp::BigIntDiv &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.lhs, serializer); + serde::Serializable::serialize(obj.rhs, serializer); + serde::Serializable::serialize(obj.output, serializer); +} + +template <> +template +Circuit::BlackBoxOp::BigIntDiv serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BlackBoxOp::BigIntDiv obj; + obj.lhs = serde::Deserializable::deserialize(deserializer); + obj.rhs = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxOp::BigIntFromLeBytes &lhs, const BlackBoxOp::BigIntFromLeBytes &rhs) { + if (!(lhs.inputs == rhs.inputs)) { return false; } + if (!(lhs.modulus == rhs.modulus)) { return false; } + if (!(lhs.output == rhs.output)) { return false; } + return true; + } + + inline std::vector BlackBoxOp::BigIntFromLeBytes::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxOp::BigIntFromLeBytes BlackBoxOp::BigIntFromLeBytes::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxOp::BigIntFromLeBytes &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.inputs, serializer); + serde::Serializable::serialize(obj.modulus, serializer); + serde::Serializable::serialize(obj.output, serializer); +} + +template <> +template +Circuit::BlackBoxOp::BigIntFromLeBytes serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BlackBoxOp::BigIntFromLeBytes obj; + obj.inputs = serde::Deserializable::deserialize(deserializer); + obj.modulus = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); + return obj; +} + +namespace Circuit { + + inline bool operator==(const BlackBoxOp::BigIntToLeBytes &lhs, const BlackBoxOp::BigIntToLeBytes &rhs) { + if (!(lhs.input == rhs.input)) { return false; } + if (!(lhs.output == rhs.output)) { return false; } + return true; + } + + inline std::vector BlackBoxOp::BigIntToLeBytes::bincodeSerialize() const { + auto serializer = serde::BincodeSerializer(); + serde::Serializable::serialize(*this, serializer); + return std::move(serializer).bytes(); + } + + inline BlackBoxOp::BigIntToLeBytes BlackBoxOp::BigIntToLeBytes::bincodeDeserialize(std::vector input) { + auto deserializer = serde::BincodeDeserializer(input); + auto value = serde::Deserializable::deserialize(deserializer); + if (deserializer.get_buffer_offset() < input.size()) { + throw serde::deserialization_error("Some input bytes were not read"); + } + return value; + } + +} // end of namespace Circuit + +template <> +template +void serde::Serializable::serialize(const Circuit::BlackBoxOp::BigIntToLeBytes &obj, Serializer &serializer) { + serde::Serializable::serialize(obj.input, serializer); + serde::Serializable::serialize(obj.output, serializer); +} + +template <> +template +Circuit::BlackBoxOp::BigIntToLeBytes serde::Deserializable::deserialize(Deserializer &deserializer) { + Circuit::BlackBoxOp::BigIntToLeBytes obj; + obj.input = serde::Deserializable::deserialize(deserializer); + obj.output = serde::Deserializable::deserialize(deserializer); + return obj; +} + namespace Circuit { inline bool operator==(const BlockId &lhs, const BlockId &rhs) { diff --git a/noir/acvm-repo/acir/src/circuit/black_box_functions.rs b/noir/acvm-repo/acir/src/circuit/black_box_functions.rs index d1f5560313b4..41b8923a8c9f 100644 --- a/noir/acvm-repo/acir/src/circuit/black_box_functions.rs +++ b/noir/acvm-repo/acir/src/circuit/black_box_functions.rs @@ -49,6 +49,18 @@ pub enum BlackBoxFunc { EmbeddedCurveAdd, /// Point doubling over the embedded curve on which [`FieldElement`][acir_field::FieldElement] is defined. EmbeddedCurveDouble, + /// BigInt addition + BigIntAdd, + /// BigInt subtraction + BigIntNeg, + /// BigInt multiplication + BigIntMul, + /// BigInt division + BigIntDiv, + /// BigInt from le bytes + BigIntFromLeBytes, + /// BigInt to le bytes + BigIntToLeBytes, } impl std::fmt::Display for BlackBoxFunc { @@ -77,8 +89,15 @@ impl BlackBoxFunc { BlackBoxFunc::Keccakf1600 => "keccakf1600", BlackBoxFunc::RecursiveAggregation => "recursive_aggregation", BlackBoxFunc::EcdsaSecp256r1 => "ecdsa_secp256r1", + BlackBoxFunc::BigIntAdd => "bigint_add", + BlackBoxFunc::BigIntNeg => "bigint_neg", + BlackBoxFunc::BigIntMul => "bigint_mul", + BlackBoxFunc::BigIntDiv => "bigint_div", + BlackBoxFunc::BigIntFromLeBytes => "bigint_from_le_bytes", + BlackBoxFunc::BigIntToLeBytes => "bigint_to_le_bytes", } } + pub fn lookup(op_name: &str) -> Option { match op_name { "sha256" => Some(BlackBoxFunc::SHA256), @@ -98,6 +117,12 @@ impl BlackBoxFunc { "keccak256" => Some(BlackBoxFunc::Keccak256), "keccakf1600" => Some(BlackBoxFunc::Keccakf1600), "recursive_aggregation" => Some(BlackBoxFunc::RecursiveAggregation), + "bigint_add" => Some(BlackBoxFunc::BigIntAdd), + "bigint_neg" => Some(BlackBoxFunc::BigIntNeg), + "bigint_mul" => Some(BlackBoxFunc::BigIntMul), + "bigint_div" => Some(BlackBoxFunc::BigIntDiv), + "bigint_from_le_bytes" => Some(BlackBoxFunc::BigIntFromLeBytes), + "bigint_to_le_bytes" => Some(BlackBoxFunc::BigIntToLeBytes), _ => None, } } diff --git a/noir/acvm-repo/acir/src/circuit/opcodes/black_box_function_call.rs b/noir/acvm-repo/acir/src/circuit/opcodes/black_box_function_call.rs index 7ee4e2498a5f..1fdc02653771 100644 --- a/noir/acvm-repo/acir/src/circuit/opcodes/black_box_function_call.rs +++ b/noir/acvm-repo/acir/src/circuit/opcodes/black_box_function_call.rs @@ -120,6 +120,35 @@ pub enum BlackBoxFuncCall { /// key provided to the circuit matches the key produced by the circuit creator key_hash: FunctionInput, }, + BigIntAdd { + lhs: u32, + rhs: u32, + output: u32, + }, + BigIntNeg { + lhs: u32, + rhs: u32, + output: u32, + }, + BigIntMul { + lhs: u32, + rhs: u32, + output: u32, + }, + BigIntDiv { + lhs: u32, + rhs: u32, + output: u32, + }, + BigIntFromLeBytes { + inputs: Vec, + modulus: Vec, + output: u32, + }, + BigIntToLeBytes { + input: u32, + outputs: Vec, + }, } impl BlackBoxFuncCall { @@ -143,6 +172,12 @@ impl BlackBoxFuncCall { BlackBoxFuncCall::Keccak256VariableLength { .. } => BlackBoxFunc::Keccak256, BlackBoxFuncCall::Keccakf1600 { .. } => BlackBoxFunc::Keccakf1600, BlackBoxFuncCall::RecursiveAggregation { .. } => BlackBoxFunc::RecursiveAggregation, + BlackBoxFuncCall::BigIntAdd { .. } => BlackBoxFunc::BigIntAdd, + BlackBoxFuncCall::BigIntNeg { .. } => BlackBoxFunc::BigIntNeg, + BlackBoxFuncCall::BigIntMul { .. } => BlackBoxFunc::BigIntMul, + BlackBoxFuncCall::BigIntDiv { .. } => BlackBoxFunc::BigIntDiv, + BlackBoxFuncCall::BigIntFromLeBytes { .. } => BlackBoxFunc::BigIntFromLeBytes, + &BlackBoxFuncCall::BigIntToLeBytes { .. } => BlackBoxFunc::BigIntToLeBytes, } } @@ -158,10 +193,16 @@ impl BlackBoxFuncCall { | BlackBoxFuncCall::Keccak256 { inputs, .. } | BlackBoxFuncCall::Keccakf1600 { inputs, .. } | BlackBoxFuncCall::PedersenCommitment { inputs, .. } - | BlackBoxFuncCall::PedersenHash { inputs, .. } => inputs.to_vec(), + | BlackBoxFuncCall::PedersenHash { inputs, .. } + | BlackBoxFuncCall::BigIntFromLeBytes { inputs, .. } => inputs.to_vec(), BlackBoxFuncCall::AND { lhs, rhs, .. } | BlackBoxFuncCall::XOR { lhs, rhs, .. } => { vec![*lhs, *rhs] } + BlackBoxFuncCall::BigIntAdd { .. } + | BlackBoxFuncCall::BigIntNeg { .. } + | BlackBoxFuncCall::BigIntMul { .. } + | BlackBoxFuncCall::BigIntDiv { .. } + | BlackBoxFuncCall::BigIntToLeBytes { .. } => Vec::new(), BlackBoxFuncCall::FixedBaseScalarMul { low, high, .. } => vec![*low, *high], BlackBoxFuncCall::EmbeddedCurveAdd { input1_x, input1_y, input2_x, input2_y, .. @@ -249,7 +290,8 @@ impl BlackBoxFuncCall { | BlackBoxFuncCall::Blake2s { outputs, .. } | BlackBoxFuncCall::Blake3 { outputs, .. } | BlackBoxFuncCall::Keccak256 { outputs, .. } - | BlackBoxFuncCall::Keccakf1600 { outputs, .. } => outputs.to_vec(), + | BlackBoxFuncCall::Keccakf1600 { outputs, .. } + | BlackBoxFuncCall::Keccak256VariableLength { outputs, .. } => outputs.to_vec(), BlackBoxFuncCall::AND { output, .. } | BlackBoxFuncCall::XOR { output, .. } | BlackBoxFuncCall::SchnorrVerify { output, .. } @@ -260,10 +302,16 @@ impl BlackBoxFuncCall { | BlackBoxFuncCall::PedersenCommitment { outputs, .. } | BlackBoxFuncCall::EmbeddedCurveAdd { outputs, .. } | BlackBoxFuncCall::EmbeddedCurveDouble { outputs, .. } => vec![outputs.0, outputs.1], - BlackBoxFuncCall::RANGE { .. } | BlackBoxFuncCall::RecursiveAggregation { .. } => { + BlackBoxFuncCall::RANGE { .. } + | BlackBoxFuncCall::RecursiveAggregation { .. } + | BlackBoxFuncCall::BigIntFromLeBytes { .. } + | BlackBoxFuncCall::BigIntAdd { .. } + | BlackBoxFuncCall::BigIntNeg { .. } + | BlackBoxFuncCall::BigIntMul { .. } + | BlackBoxFuncCall::BigIntDiv { .. } => { vec![] } - BlackBoxFuncCall::Keccak256VariableLength { outputs, .. } => outputs.to_vec(), + BlackBoxFuncCall::BigIntToLeBytes { outputs, .. } => outputs.to_vec(), } } } diff --git a/noir/acvm-repo/acir_field/Cargo.toml b/noir/acvm-repo/acir_field/Cargo.toml index cedfc66e7349..dde121f40291 100644 --- a/noir/acvm-repo/acir_field/Cargo.toml +++ b/noir/acvm-repo/acir_field/Cargo.toml @@ -2,7 +2,7 @@ name = "acir_field" description = "The field implementation being used by ACIR." # x-release-please-start-version -version = "0.38.0" +version = "0.39.0" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/noir/acvm-repo/acvm/Cargo.toml b/noir/acvm-repo/acvm/Cargo.toml index be2391a3216f..a40148a01efd 100644 --- a/noir/acvm-repo/acvm/Cargo.toml +++ b/noir/acvm-repo/acvm/Cargo.toml @@ -2,7 +2,7 @@ name = "acvm" description = "The virtual machine that processes ACIR given a backend/proof system." # x-release-please-start-version -version = "0.38.0" +version = "0.39.0" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/noir/acvm-repo/acvm/src/compiler/transformers/mod.rs b/noir/acvm-repo/acvm/src/compiler/transformers/mod.rs index 306ea1b7c126..effe1128d36f 100644 --- a/noir/acvm-repo/acvm/src/compiler/transformers/mod.rs +++ b/noir/acvm-repo/acvm/src/compiler/transformers/mod.rs @@ -105,7 +105,12 @@ pub(super) fn transform_internal( transformer.mark_solvable(*output); } acir::circuit::opcodes::BlackBoxFuncCall::RANGE { .. } - | acir::circuit::opcodes::BlackBoxFuncCall::RecursiveAggregation { .. } => (), + | acir::circuit::opcodes::BlackBoxFuncCall::RecursiveAggregation { .. } + | acir::circuit::opcodes::BlackBoxFuncCall::BigIntFromLeBytes { .. } + | acir::circuit::opcodes::BlackBoxFuncCall::BigIntAdd { .. } + | acir::circuit::opcodes::BlackBoxFuncCall::BigIntNeg { .. } + | acir::circuit::opcodes::BlackBoxFuncCall::BigIntMul { .. } + | acir::circuit::opcodes::BlackBoxFuncCall::BigIntDiv { .. } => (), acir::circuit::opcodes::BlackBoxFuncCall::SHA256 { outputs, .. } | acir::circuit::opcodes::BlackBoxFuncCall::Keccak256 { outputs, .. } | acir::circuit::opcodes::BlackBoxFuncCall::Keccak256VariableLength { @@ -114,7 +119,10 @@ pub(super) fn transform_internal( } | acir::circuit::opcodes::BlackBoxFuncCall::Keccakf1600 { outputs, .. } | acir::circuit::opcodes::BlackBoxFuncCall::Blake2s { outputs, .. } - | acir::circuit::opcodes::BlackBoxFuncCall::Blake3 { outputs, .. } => { + | acir::circuit::opcodes::BlackBoxFuncCall::Blake3 { outputs, .. } + | acir::circuit::opcodes::BlackBoxFuncCall::BigIntToLeBytes { + outputs, .. + } => { for witness in outputs { transformer.mark_solvable(*witness); } diff --git a/noir/acvm-repo/acvm/src/pwg/blackbox/mod.rs b/noir/acvm-repo/acvm/src/pwg/blackbox/mod.rs index 5eea234885c5..a56b24b86f3d 100644 --- a/noir/acvm-repo/acvm/src/pwg/blackbox/mod.rs +++ b/noir/acvm-repo/acvm/src/pwg/blackbox/mod.rs @@ -185,5 +185,11 @@ pub(crate) fn solve( } // Recursive aggregation will be entirely handled by the backend and is not solved by the ACVM BlackBoxFuncCall::RecursiveAggregation { .. } => Ok(()), + BlackBoxFuncCall::BigIntAdd { .. } => todo!(), + BlackBoxFuncCall::BigIntNeg { .. } => todo!(), + BlackBoxFuncCall::BigIntMul { .. } => todo!(), + BlackBoxFuncCall::BigIntDiv { .. } => todo!(), + BlackBoxFuncCall::BigIntFromLeBytes { .. } => todo!(), + BlackBoxFuncCall::BigIntToLeBytes { .. } => todo!(), } } diff --git a/noir/acvm-repo/acvm_js/Cargo.toml b/noir/acvm-repo/acvm_js/Cargo.toml index e8d46b9717e1..226e273c3064 100644 --- a/noir/acvm-repo/acvm_js/Cargo.toml +++ b/noir/acvm-repo/acvm_js/Cargo.toml @@ -2,7 +2,7 @@ name = "acvm_js" description = "Typescript wrapper around the ACVM allowing execution of ACIR code" # x-release-please-start-version -version = "0.38.0" +version = "0.39.0" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/noir/acvm-repo/acvm_js/package.json b/noir/acvm-repo/acvm_js/package.json index 2d878e961da9..4ec9b1a2da38 100644 --- a/noir/acvm-repo/acvm_js/package.json +++ b/noir/acvm-repo/acvm_js/package.json @@ -1,6 +1,6 @@ { "name": "@noir-lang/acvm_js", - "version": "0.38.0", + "version": "0.39.0", "publishConfig": { "access": "public" }, diff --git a/noir/acvm-repo/blackbox_solver/Cargo.toml b/noir/acvm-repo/blackbox_solver/Cargo.toml index 749ef8f289a3..7359cf307e4b 100644 --- a/noir/acvm-repo/blackbox_solver/Cargo.toml +++ b/noir/acvm-repo/blackbox_solver/Cargo.toml @@ -2,7 +2,7 @@ name = "acvm_blackbox_solver" description = "A solver for the blackbox functions found in ACIR and Brillig" # x-release-please-start-version -version = "0.38.0" +version = "0.39.0" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/noir/acvm-repo/bn254_blackbox_solver/Cargo.toml b/noir/acvm-repo/bn254_blackbox_solver/Cargo.toml index b98bb370f748..a73aded231f2 100644 --- a/noir/acvm-repo/bn254_blackbox_solver/Cargo.toml +++ b/noir/acvm-repo/bn254_blackbox_solver/Cargo.toml @@ -2,7 +2,7 @@ name = "bn254_blackbox_solver" description = "Solvers for black box functions which are specific for the bn254 curve" # x-release-please-start-version -version = "0.38.0" +version = "0.39.0" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/noir/acvm-repo/brillig/Cargo.toml b/noir/acvm-repo/brillig/Cargo.toml index ee8651faeece..b9cedfe8d603 100644 --- a/noir/acvm-repo/brillig/Cargo.toml +++ b/noir/acvm-repo/brillig/Cargo.toml @@ -2,7 +2,7 @@ name = "brillig" description = "Brillig is the bytecode ACIR uses for non-determinism." # x-release-please-start-version -version = "0.38.0" +version = "0.39.0" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/noir/acvm-repo/brillig/src/black_box.rs b/noir/acvm-repo/brillig/src/black_box.rs index c007e78b785d..5893758ce9ec 100644 --- a/noir/acvm-repo/brillig/src/black_box.rs +++ b/noir/acvm-repo/brillig/src/black_box.rs @@ -6,15 +6,30 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] pub enum BlackBoxOp { /// Calculates the SHA256 hash of the inputs. - Sha256 { message: HeapVector, output: HeapArray }, + Sha256 { + message: HeapVector, + output: HeapArray, + }, /// Calculates the Blake2s hash of the inputs. - Blake2s { message: HeapVector, output: HeapArray }, + Blake2s { + message: HeapVector, + output: HeapArray, + }, /// Calculates the Blake3 hash of the inputs. - Blake3 { message: HeapVector, output: HeapArray }, + Blake3 { + message: HeapVector, + output: HeapArray, + }, /// Calculates the Keccak256 hash of the inputs. - Keccak256 { message: HeapVector, output: HeapArray }, + Keccak256 { + message: HeapVector, + output: HeapArray, + }, /// Keccak Permutation function of 1600 width - Keccakf1600 { message: HeapVector, output: HeapArray }, + Keccakf1600 { + message: HeapVector, + output: HeapArray, + }, /// Verifies a ECDSA signature over the secp256k1 curve. EcdsaSecp256k1 { hashed_msg: HeapVector, @@ -40,11 +55,23 @@ pub enum BlackBoxOp { result: RegisterIndex, }, /// Calculates a Pedersen commitment to the inputs. - PedersenCommitment { inputs: HeapVector, domain_separator: RegisterIndex, output: HeapArray }, + PedersenCommitment { + inputs: HeapVector, + domain_separator: RegisterIndex, + output: HeapArray, + }, /// Calculates a Pedersen hash to the inputs. - PedersenHash { inputs: HeapVector, domain_separator: RegisterIndex, output: RegisterIndex }, + PedersenHash { + inputs: HeapVector, + domain_separator: RegisterIndex, + output: RegisterIndex, + }, /// Performs scalar multiplication over the embedded curve. - FixedBaseScalarMul { low: RegisterIndex, high: RegisterIndex, result: HeapArray }, + FixedBaseScalarMul { + low: RegisterIndex, + high: RegisterIndex, + result: HeapArray, + }, /// Performs addition over the embedded curve. EmbeddedCurveAdd { input1_x: RegisterIndex, @@ -54,5 +81,39 @@ pub enum BlackBoxOp { result: HeapArray, }, /// Performs point doubling over the embedded curve. - EmbeddedCurveDouble { input1_x: RegisterIndex, input1_y: RegisterIndex, result: HeapArray }, + EmbeddedCurveDouble { + input1_x: RegisterIndex, + input1_y: RegisterIndex, + result: HeapArray, + }, + + BigIntAdd { + lhs: RegisterIndex, + rhs: RegisterIndex, + output: RegisterIndex, + }, + BigIntNeg { + lhs: RegisterIndex, + rhs: RegisterIndex, + output: RegisterIndex, + }, + BigIntMul { + lhs: RegisterIndex, + rhs: RegisterIndex, + output: RegisterIndex, + }, + BigIntDiv { + lhs: RegisterIndex, + rhs: RegisterIndex, + output: RegisterIndex, + }, + BigIntFromLeBytes { + inputs: HeapVector, + modulus: HeapVector, + output: RegisterIndex, + }, + BigIntToLeBytes { + input: RegisterIndex, + output: HeapVector, + }, } diff --git a/noir/acvm-repo/brillig_vm/Cargo.toml b/noir/acvm-repo/brillig_vm/Cargo.toml index 91bef2572bb3..5a8a34be881c 100644 --- a/noir/acvm-repo/brillig_vm/Cargo.toml +++ b/noir/acvm-repo/brillig_vm/Cargo.toml @@ -2,7 +2,7 @@ name = "brillig_vm" description = "The virtual machine that processes Brillig bytecode, used to introduce non-determinism to the ACVM" # x-release-please-start-version -version = "0.38.0" +version = "0.39.0" # x-release-please-end authors.workspace = true edition.workspace = true diff --git a/noir/acvm-repo/brillig_vm/src/black_box.rs b/noir/acvm-repo/brillig_vm/src/black_box.rs index 463038509e13..edbebb61eced 100644 --- a/noir/acvm-repo/brillig_vm/src/black_box.rs +++ b/noir/acvm-repo/brillig_vm/src/black_box.rs @@ -200,6 +200,12 @@ pub(crate) fn evaluate_black_box( registers.set(*output, hash.into()); Ok(()) } + BlackBoxOp::BigIntAdd { .. } => todo!(), + BlackBoxOp::BigIntNeg { .. } => todo!(), + BlackBoxOp::BigIntMul { .. } => todo!(), + BlackBoxOp::BigIntDiv { .. } => todo!(), + BlackBoxOp::BigIntFromLeBytes { .. } => todo!(), + BlackBoxOp::BigIntToLeBytes { .. } => todo!(), } } @@ -218,6 +224,12 @@ fn black_box_function_from_op(op: &BlackBoxOp) -> BlackBoxFunc { BlackBoxOp::FixedBaseScalarMul { .. } => BlackBoxFunc::FixedBaseScalarMul, BlackBoxOp::EmbeddedCurveAdd { .. } => BlackBoxFunc::EmbeddedCurveAdd, BlackBoxOp::EmbeddedCurveDouble { .. } => BlackBoxFunc::EmbeddedCurveDouble, + BlackBoxOp::BigIntAdd { .. } => BlackBoxFunc::BigIntAdd, + BlackBoxOp::BigIntNeg { .. } => BlackBoxFunc::BigIntNeg, + BlackBoxOp::BigIntMul { .. } => BlackBoxFunc::BigIntMul, + BlackBoxOp::BigIntDiv { .. } => BlackBoxFunc::BigIntDiv, + BlackBoxOp::BigIntFromLeBytes { .. } => BlackBoxFunc::BigIntFromLeBytes, + BlackBoxOp::BigIntToLeBytes { .. } => BlackBoxFunc::BigIntToLeBytes, } } diff --git a/noir/aztec_macros/src/lib.rs b/noir/aztec_macros/src/lib.rs index c985bbc367a2..7c62f8f81692 100644 --- a/noir/aztec_macros/src/lib.rs +++ b/noir/aztec_macros/src/lib.rs @@ -40,6 +40,7 @@ pub enum AztecMacroError { AztecComputeNoteHashAndNullifierNotFound { span: Span }, AztecContractHasTooManyFunctions { span: Span }, AztecContractConstructorMissing { span: Span }, + UnsupportedFunctionArgumentType { span: Span, typ: UnresolvedTypeData }, } impl From for MacroError { @@ -65,6 +66,11 @@ impl From for MacroError { secondary_message: None, span: Some(span), }, + AztecMacroError::UnsupportedFunctionArgumentType { span, typ } => MacroError { + primary_message: format!("Provided parameter type `{typ:?}` is not supported in Aztec contract interface"), + secondary_message: None, + span: Some(span), + }, } } } @@ -341,11 +347,14 @@ fn transform_module( for func in module.functions.iter_mut() { for secondary_attribute in func.def.attributes.secondary.clone() { + let crate_graph = &context.crate_graph[crate_id]; if is_custom_attribute(&secondary_attribute, "aztec(private)") { - transform_function("Private", func, storage_defined); + transform_function("Private", func, storage_defined) + .map_err(|err| (err.into(), crate_graph.root_file_id))?; has_transformed_module = true; } else if is_custom_attribute(&secondary_attribute, "aztec(public)") { - transform_function("Public", func, storage_defined); + transform_function("Public", func, storage_defined) + .map_err(|err| (err.into(), crate_graph.root_file_id))?; has_transformed_module = true; } } @@ -384,7 +393,11 @@ fn transform_module( /// - A new Input that is provided for a kernel app circuit, named: {Public/Private}ContextInputs /// - Hashes all of the function input variables /// - This instantiates a helper function -fn transform_function(ty: &str, func: &mut NoirFunction, storage_defined: bool) { +fn transform_function( + ty: &str, + func: &mut NoirFunction, + storage_defined: bool, +) -> Result<(), AztecMacroError> { let context_name = format!("{}Context", ty); let inputs_name = format!("{}ContextInputs", ty); let return_type_name = format!("{}CircuitPublicInputs", ty); @@ -396,7 +409,7 @@ fn transform_function(ty: &str, func: &mut NoirFunction, storage_defined: bool) } // Insert the context creation as the first action - let create_context = create_context(&context_name, &func.def.parameters); + let create_context = create_context(&context_name, &func.def.parameters)?; func.def.body.0.splice(0..0, (create_context).iter().cloned()); // Add the inputs to the params @@ -423,6 +436,8 @@ fn transform_function(ty: &str, func: &mut NoirFunction, storage_defined: bool) "Public" => func.def.is_open = true, _ => (), } + + Ok(()) } /// Transform Unconstrained @@ -621,7 +636,7 @@ fn create_inputs(ty: &str) -> Param { /// let mut context = PrivateContext::new(inputs, hasher.hash()); /// } /// ``` -fn create_context(ty: &str, params: &[Param]) -> Vec { +fn create_context(ty: &str, params: &[Param]) -> Result, AztecMacroError> { let mut injected_expressions: Vec = vec![]; // `let mut hasher = Hasher::new();` @@ -637,7 +652,7 @@ fn create_context(ty: &str, params: &[Param]) -> Vec { injected_expressions.push(let_hasher); // Iterate over each of the function parameters, adding to them to the hasher - params.iter().for_each(|Param { pattern, typ, span: _, visibility: _ }| { + for Param { pattern, typ, span, .. } in params { match pattern { Pattern::Identifier(identifier) => { // Match the type to determine the padding to do @@ -666,16 +681,18 @@ fn create_context(ty: &str, params: &[Param]) -> Vec { }, ) } - _ => panic!( - "[Aztec Noir] Provided parameter type: {:?} is not supported", - unresolved_type - ), + _ => { + return Err(AztecMacroError::UnsupportedFunctionArgumentType { + typ: unresolved_type.clone(), + span: *span, + }) + } }; injected_expressions.push(expression); } _ => todo!(), // Maybe unreachable? } - }); + } // Create the inputs to the context let inputs_expression = variable("inputs"); @@ -697,7 +714,7 @@ fn create_context(ty: &str, params: &[Param]) -> Vec { injected_expressions.push(let_context); // Return all expressions that will be injected by the hasher - injected_expressions + Ok(injected_expressions) } /// Abstract Return Type diff --git a/noir/bootstrap_cache.sh b/noir/bootstrap_cache.sh index ac919f3ca658..672702416bd4 100755 --- a/noir/bootstrap_cache.sh +++ b/noir/bootstrap_cache.sh @@ -8,3 +8,4 @@ echo -e "\033[1mRetrieving noir packages from remote cache...\033[0m" extract_repo noir-packages /usr/src/noir/packages ./ echo -e "\033[1mRetrieving nargo from remote cache...\033[0m" extract_repo noir /usr/src/noir/target/release ./target/ + diff --git a/noir/compiler/fm/src/file_map.rs b/noir/compiler/fm/src/file_map.rs index c4d7002a0820..50412d352ec4 100644 --- a/noir/compiler/fm/src/file_map.rs +++ b/noir/compiler/fm/src/file_map.rs @@ -75,6 +75,10 @@ impl FileMap { pub fn get_file_id(&self, file_name: &PathString) -> Option { self.name_to_id.get(file_name).cloned() } + + pub fn all_file_ids(&self) -> impl Iterator { + self.name_to_id.values() + } } impl Default for FileMap { fn default() -> Self { diff --git a/noir/compiler/noirc_driver/tests/stdlib_warnings.rs b/noir/compiler/noirc_driver/tests/stdlib_warnings.rs index e9153ec2f99f..6f4376211237 100644 --- a/noir/compiler/noirc_driver/tests/stdlib_warnings.rs +++ b/noir/compiler/noirc_driver/tests/stdlib_warnings.rs @@ -1,7 +1,7 @@ use std::path::Path; use noirc_driver::{file_manager_with_stdlib, prepare_crate, ErrorsAndWarnings}; -use noirc_frontend::hir::Context; +use noirc_frontend::hir::{def_map::parse_file, Context}; #[test] fn stdlib_does_not_produce_constant_warnings() -> Result<(), ErrorsAndWarnings> { @@ -15,8 +15,13 @@ fn stdlib_does_not_produce_constant_warnings() -> Result<(), ErrorsAndWarnings> file_manager.add_file_with_source(file_name, source.to_owned()).expect( "Adding source buffer to file manager should never fail when file manager is empty", ); + let parsed_files = file_manager + .as_file_map() + .all_file_ids() + .map(|&file_id| (file_id, parse_file(&file_manager, file_id))) + .collect(); - let mut context = Context::new(file_manager); + let mut context = Context::new(file_manager, parsed_files); let root_crate_id = prepare_crate(&mut context, file_name); let ((), warnings) = noirc_driver::check_crate(&mut context, root_crate_id, false, false)?; diff --git a/noir/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_black_box.rs b/noir/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_black_box.rs index c081806f4a73..c7b6f39279ba 100644 --- a/noir/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_black_box.rs +++ b/noir/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_black_box.rs @@ -244,6 +244,107 @@ pub(crate) fn convert_black_box_call( BlackBoxFunc::RecursiveAggregation => unimplemented!( "ICE: `BlackBoxFunc::RecursiveAggregation` is not implemented by the Brillig VM" ), + BlackBoxFunc::BigIntAdd => { + if let ( + [BrilligVariable::Simple(lhs), BrilligVariable::Simple(rhs)], + [BrilligVariable::Simple(output)], + ) = (function_arguments, function_results) + { + brillig_context.black_box_op_instruction(BlackBoxOp::BigIntAdd { + lhs: *lhs, + rhs: *rhs, + output: *output, + }); + } else { + unreachable!( + "ICE: EmbeddedCurveAdd expects two register arguments and one array result" + ) + } + } + BlackBoxFunc::BigIntNeg => { + if let ( + [BrilligVariable::Simple(lhs), BrilligVariable::Simple(rhs)], + [BrilligVariable::Simple(output)], + ) = (function_arguments, function_results) + { + brillig_context.black_box_op_instruction(BlackBoxOp::BigIntNeg { + lhs: *lhs, + rhs: *rhs, + output: *output, + }); + } else { + unreachable!( + "ICE: EmbeddedCurveAdd expects two register arguments and one array result" + ) + } + } + BlackBoxFunc::BigIntMul => { + if let ( + [BrilligVariable::Simple(lhs), BrilligVariable::Simple(rhs)], + [BrilligVariable::Simple(output)], + ) = (function_arguments, function_results) + { + brillig_context.black_box_op_instruction(BlackBoxOp::BigIntMul { + lhs: *lhs, + rhs: *rhs, + output: *output, + }); + } else { + unreachable!( + "ICE: EmbeddedCurveAdd expects two register arguments and one array result" + ) + } + } + BlackBoxFunc::BigIntDiv => { + if let ( + [BrilligVariable::Simple(lhs), BrilligVariable::Simple(rhs)], + [BrilligVariable::Simple(output)], + ) = (function_arguments, function_results) + { + brillig_context.black_box_op_instruction(BlackBoxOp::BigIntDiv { + lhs: *lhs, + rhs: *rhs, + output: *output, + }); + } else { + unreachable!( + "ICE: EmbeddedCurveAdd expects two register arguments and one array result" + ) + } + } + BlackBoxFunc::BigIntFromLeBytes => { + if let ([inputs, modulus], [BrilligVariable::Simple(output)]) = + (function_arguments, function_results) + { + let inputs_vector = convert_array_or_vector(brillig_context, inputs, bb_func); + let modulus_vector = convert_array_or_vector(brillig_context, modulus, bb_func); + brillig_context.black_box_op_instruction(BlackBoxOp::BigIntFromLeBytes { + inputs: inputs_vector.to_heap_vector(), + modulus: modulus_vector.to_heap_vector(), + output: *output, + }); + } else { + unreachable!( + "ICE: EmbeddedCurveAdd expects two register arguments and one array result" + ) + } + } + BlackBoxFunc::BigIntToLeBytes => { + if let ( + [BrilligVariable::Simple(input)], + [BrilligVariable::BrilligVector(result_vector)], + ) = (function_arguments, function_results) + { + brillig_context.black_box_op_instruction(BlackBoxOp::BigIntToLeBytes { + input: *input, + output: result_vector.to_heap_vector(), + }); + } else { + unreachable!( + "ICE: EmbeddedCurveAdd expects two register arguments and one array result" + ) + } + } } } diff --git a/noir/compiler/noirc_evaluator/src/brillig/brillig_ir/debug_show.rs b/noir/compiler/noirc_evaluator/src/brillig/brillig_ir/debug_show.rs index dc8c6b6694cf..5709b0a1aa25 100644 --- a/noir/compiler/noirc_evaluator/src/brillig/brillig_ir/debug_show.rs +++ b/noir/compiler/noirc_evaluator/src/brillig/brillig_ir/debug_show.rs @@ -457,6 +457,59 @@ impl DebugShow { result ); } + BlackBoxOp::BigIntAdd { lhs, rhs, output } => { + debug_println!( + self.enable_debug_trace, + " BIGINT_ADD {} {} -> {}", + lhs, + rhs, + output + ); + } + BlackBoxOp::BigIntNeg { lhs, rhs, output } => { + debug_println!( + self.enable_debug_trace, + " BIGINT_NEG {} {} -> {}", + lhs, + rhs, + output + ); + } + BlackBoxOp::BigIntMul { lhs, rhs, output } => { + debug_println!( + self.enable_debug_trace, + " BIGINT_MUL {} {} -> {}", + lhs, + rhs, + output + ); + } + BlackBoxOp::BigIntDiv { lhs, rhs, output } => { + debug_println!( + self.enable_debug_trace, + " BIGINT_DIV {} {} -> {}", + lhs, + rhs, + output + ); + } + BlackBoxOp::BigIntFromLeBytes { inputs, modulus, output } => { + debug_println!( + self.enable_debug_trace, + " BIGINT_FROM_LE_BYTES {} {} -> {}", + inputs, + modulus, + output + ); + } + BlackBoxOp::BigIntToLeBytes { input, output } => { + debug_println!( + self.enable_debug_trace, + " BIGINT_TO_LE_BYTES {} -> {}", + input, + output + ); + } } } diff --git a/noir/compiler/noirc_evaluator/src/ssa.rs b/noir/compiler/noirc_evaluator/src/ssa.rs index f11c077d49a5..e2da5652faf6 100644 --- a/noir/compiler/noirc_evaluator/src/ssa.rs +++ b/noir/compiler/noirc_evaluator/src/ssa.rs @@ -45,7 +45,7 @@ pub(crate) fn optimize_into_acir( let ssa_gen_span = span!(Level::TRACE, "ssa_generation"); let ssa_gen_span_guard = ssa_gen_span.enter(); - let ssa_builder = SsaBuilder::new(program, print_ssa_passes)? + let ssa = SsaBuilder::new(program, print_ssa_passes)? .run_pass(Ssa::defunctionalize, "After Defunctionalization:") .run_pass(Ssa::inline_functions, "After Inlining:") // Run mem2reg with the CFG separated into blocks @@ -62,16 +62,12 @@ pub(crate) fn optimize_into_acir( // Run mem2reg once more with the flattened CFG to catch any remaining loads/stores .run_pass(Ssa::mem2reg, "After Mem2Reg:") .run_pass(Ssa::fold_constants, "After Constant Folding:") - .run_pass(Ssa::dead_instruction_elimination, "After Dead Instruction Elimination:"); + .run_pass(Ssa::dead_instruction_elimination, "After Dead Instruction Elimination:") + .run_pass(Ssa::bubble_up_constrains, "After Constraint Bubbling:") + .finish(); - let brillig = ssa_builder.to_brillig(print_brillig_trace); + let brillig = ssa.to_brillig(print_brillig_trace); - // Split off any passes the are not necessary for Brillig generation but are necessary for ACIR generation. - // We only need to fill out nested slices as we need to have a known length when dealing with memory operations - // in ACIR gen while this is not necessary in the Brillig IR. - let ssa = ssa_builder - .run_pass(Ssa::fill_internal_slices, "After Fill Internal Slice Dummy Data:") - .finish(); drop(ssa_gen_span_guard); let last_array_uses = ssa.find_last_array_uses(); diff --git a/noir/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/generated_acir.rs b/noir/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/generated_acir.rs index efc64c5286e3..4572cf1dd083 100644 --- a/noir/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/generated_acir.rs +++ b/noir/compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/generated_acir.rs @@ -251,6 +251,34 @@ impl GeneratedAcir { public_inputs: inputs[2].clone(), key_hash: inputs[3][0], }, + BlackBoxFunc::BigIntAdd => BlackBoxFuncCall::BigIntAdd { + lhs: constants[0].to_u128() as u32, + rhs: constants[1].to_u128() as u32, + output: constants[2].to_u128() as u32, + }, + BlackBoxFunc::BigIntNeg => BlackBoxFuncCall::BigIntNeg { + lhs: constants[0].to_u128() as u32, + rhs: constants[1].to_u128() as u32, + output: constants[2].to_u128() as u32, + }, + BlackBoxFunc::BigIntMul => BlackBoxFuncCall::BigIntMul { + lhs: constants[0].to_u128() as u32, + rhs: constants[1].to_u128() as u32, + output: constants[2].to_u128() as u32, + }, + BlackBoxFunc::BigIntDiv => BlackBoxFuncCall::BigIntDiv { + lhs: constants[0].to_u128() as u32, + rhs: constants[1].to_u128() as u32, + output: constants[2].to_u128() as u32, + }, + BlackBoxFunc::BigIntFromLeBytes => BlackBoxFuncCall::BigIntFromLeBytes { + inputs: inputs[0].clone(), + modulus: vecmap(constants, |c| c.to_u128() as u8), + output: todo!(), + }, + BlackBoxFunc::BigIntToLeBytes => { + BlackBoxFuncCall::BigIntToLeBytes { input: constants[0].to_u128() as u32, outputs } + } }; self.push_opcode(AcirOpcode::BlackBoxFuncCall(black_box_func_call)); @@ -573,6 +601,7 @@ fn black_box_func_expected_input_size(name: BlackBoxFunc) -> Option { match name { // Bitwise opcodes will take in 2 parameters BlackBoxFunc::AND | BlackBoxFunc::XOR => Some(2), + // All of the hash/cipher methods will take in a // variable number of inputs. BlackBoxFunc::Keccak256 @@ -593,15 +622,30 @@ fn black_box_func_expected_input_size(name: BlackBoxFunc) -> Option { BlackBoxFunc::SchnorrVerify | BlackBoxFunc::EcdsaSecp256k1 | BlackBoxFunc::EcdsaSecp256r1 => None, + // Inputs for fixed based scalar multiplication // is the low and high limbs of the scalar BlackBoxFunc::FixedBaseScalarMul => Some(2), + // Recursive aggregation has a variable number of inputs BlackBoxFunc::RecursiveAggregation => None, + // Addition over the embedded curve: input are coordinates (x1,y1) and (x2,y2) of the Grumpkin points BlackBoxFunc::EmbeddedCurveAdd => Some(4), + // Doubling over the embedded curve: input is (x,y) coordinate of the point. BlackBoxFunc::EmbeddedCurveDouble => Some(2), + + // Big integer operations take in 2 inputs + BlackBoxFunc::BigIntAdd + | BlackBoxFunc::BigIntNeg + | BlackBoxFunc::BigIntMul + | BlackBoxFunc::BigIntDiv => Some(2), + + // FromLeBytes takes a variable array of bytes as input + BlackBoxFunc::BigIntFromLeBytes => None, + // ToLeBytes takes a single big integer as input + BlackBoxFunc::BigIntToLeBytes => Some(1), } } @@ -612,28 +656,46 @@ fn black_box_expected_output_size(name: BlackBoxFunc) -> Option { // Bitwise opcodes will return 1 parameter which is the output // or the operation. BlackBoxFunc::AND | BlackBoxFunc::XOR => Some(1), + // 32 byte hash algorithms BlackBoxFunc::Keccak256 | BlackBoxFunc::SHA256 | BlackBoxFunc::Blake2s | BlackBoxFunc::Blake3 => Some(32), + BlackBoxFunc::Keccakf1600 => Some(25), + // Pedersen commitment returns a point BlackBoxFunc::PedersenCommitment => Some(2), + // Pedersen hash returns a field BlackBoxFunc::PedersenHash => Some(1), + // Can only apply a range constraint to one // witness at a time. BlackBoxFunc::RANGE => Some(0), + // Signature verification algorithms will return a boolean BlackBoxFunc::SchnorrVerify | BlackBoxFunc::EcdsaSecp256k1 | BlackBoxFunc::EcdsaSecp256r1 => Some(1), + // Output of operations over the embedded curve // will be 2 field elements representing the point. BlackBoxFunc::FixedBaseScalarMul | BlackBoxFunc::EmbeddedCurveAdd | BlackBoxFunc::EmbeddedCurveDouble => Some(2), + + // Big integer operations return a big integer + BlackBoxFunc::BigIntAdd + | BlackBoxFunc::BigIntNeg + | BlackBoxFunc::BigIntMul + | BlackBoxFunc::BigIntDiv + | BlackBoxFunc::BigIntFromLeBytes => Some(1), + + // ToLeBytes returns a variable array of bytes + BlackBoxFunc::BigIntToLeBytes => None, + // Recursive aggregation has a variable number of outputs BlackBoxFunc::RecursiveAggregation => None, } diff --git a/noir/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs b/noir/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs index c0e3ed1ff661..d832b8d0fbb6 100644 --- a/noir/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs +++ b/noir/compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs @@ -88,10 +88,6 @@ struct Context { /// a new BlockId max_block_id: u32, - /// Maps SSA array values to their slice size and any nested slices internal to the parent slice. - /// This enables us to maintain the slice structure of a slice when performing an array get. - slice_sizes: HashMap, Vec>, - data_bus: DataBus, } @@ -202,7 +198,6 @@ impl Context { internal_memory_blocks: HashMap::default(), internal_mem_block_lengths: HashMap::default(), max_block_id: 0, - slice_sizes: HashMap::default(), data_bus: DataBus::default(), } } @@ -415,62 +410,10 @@ impl Context { self.define_result_var(dfg, instruction_id, result_acir_var); } Instruction::Constrain(lhs, rhs, assert_message) => { - let lhs = self.convert_value(*lhs, dfg); - let rhs = self.convert_value(*rhs, dfg); - - fn get_var_equality_assertions( - lhs: AcirValue, - rhs: AcirValue, - read_from_index: &mut impl FnMut(BlockId, usize) -> Result, - ) -> Result, InternalError> { - match (lhs, rhs) { - (AcirValue::Var(lhs, _), AcirValue::Var(rhs, _)) => Ok(vec![(lhs, rhs)]), - (AcirValue::Array(lhs_values), AcirValue::Array(rhs_values)) => { - let var_equality_assertions = lhs_values - .into_iter() - .zip(rhs_values) - .map(|(lhs, rhs)| { - get_var_equality_assertions(lhs, rhs, read_from_index) - }) - .collect::, _>>()? - .into_iter() - .flatten() - .collect(); - Ok(var_equality_assertions) - } - ( - AcirValue::DynamicArray(AcirDynamicArray { - block_id: lhs_block_id, - len, - .. - }), - AcirValue::DynamicArray(AcirDynamicArray { - block_id: rhs_block_id, - .. - }), - ) => try_vecmap(0..len, |i| { - let lhs_var = read_from_index(lhs_block_id, i)?; - let rhs_var = read_from_index(rhs_block_id, i)?; - Ok((lhs_var, rhs_var)) - }), - _ => { - unreachable!("ICE: lhs and rhs should be of the same type") - } - } - } - - let mut read_dynamic_array_index = - |block_id: BlockId, array_index: usize| -> Result { - let index_var = self.acir_context.add_constant(array_index); + let lhs = self.convert_numeric_value(*lhs, dfg)?; + let rhs = self.convert_numeric_value(*rhs, dfg)?; - self.acir_context.read_from_memory(block_id, &index_var) - }; - - for (lhs, rhs) in - get_var_equality_assertions(lhs, rhs, &mut read_dynamic_array_index)? - { - self.acir_context.assert_eq_var(lhs, rhs, assert_message.clone())?; - } + self.acir_context.assert_eq_var(lhs, rhs, assert_message.clone())?; } Instruction::Cast(value_id, _) => { let acir_var = self.convert_numeric_value(*value_id, dfg)?; @@ -683,21 +626,15 @@ impl Context { ) -> Result { let index_const = dfg.get_numeric_constant(index); let value_type = dfg.type_of_value(array); - let (Type::Array(element_types, _) | Type::Slice(element_types)) = &value_type else { + // Compiler sanity checks + assert!( + !value_type.is_nested_slice(), + "ICE: Nested slice type has reached ACIR generation" + ); + let (Type::Array(_, _) | Type::Slice(_)) = &value_type else { unreachable!("ICE: expected array or slice type"); - }; - // TODO(#3188): Need to be able to handle constant index for slices to seriously reduce - // constraint sizes of nested slices - // This can only be done if we accurately flatten nested slices as otherwise we will reach - // index out of bounds errors. If the slice is already flat then we can treat them similarly to arrays. - if matches!(value_type, Type::Slice(_)) - && element_types.iter().any(|element| element.contains_slice_element()) - { - return Ok(false); - } - match self.convert_value(array, dfg) { AcirValue::Var(acir_var, _) => { return Err(RuntimeError::InternalError(InternalError::Unexpected { @@ -788,24 +725,8 @@ impl Context { let mut dummy_predicate_index = predicate_index; // We must setup the dummy value to match the type of the value we wish to store - let slice_sizes = if store_type.contains_slice_element() { - self.compute_slice_sizes(store, None, dfg); - self.slice_sizes.get(&store).cloned().ok_or_else(|| { - InternalError::Unexpected { - expected: "Store value should have slice sizes computed".to_owned(), - found: "Missing key in slice sizes map".to_owned(), - call_stack: self.acir_context.get_call_stack(), - } - })? - } else { - vec![] - }; - let dummy = self.array_get_value( - &store_type, - block_id, - &mut dummy_predicate_index, - &slice_sizes, - )?; + let dummy = + self.array_get_value(&store_type, block_id, &mut dummy_predicate_index)?; Some(self.convert_array_set_store_value(&store_value, &dummy)?) } @@ -922,26 +843,12 @@ impl Context { } } - let value = if !res_typ.contains_slice_element() { - self.array_get_value(&res_typ, block_id, &mut var_index, &[])? - } else { - let slice_sizes = self - .slice_sizes - .get(&array_id) - .expect("ICE: Array with slices should have associated slice sizes"); - - // The first max size is going to be the length of the parent slice - // As we are fetching from the parent slice we just want its internal - // slice sizes. - let slice_sizes = slice_sizes[1..].to_vec(); - - let value = self.array_get_value(&res_typ, block_id, &mut var_index, &slice_sizes)?; - - // Insert the resulting slice sizes - self.slice_sizes.insert(results[0], slice_sizes); - - value - }; + // Compiler sanity check + assert!( + !res_typ.contains_slice_element(), + "ICE: Nested slice result found during ACIR generation" + ); + let value = self.array_get_value(&res_typ, block_id, &mut var_index)?; self.define_result(dfg, instruction, value.clone()); @@ -953,7 +860,6 @@ impl Context { ssa_type: &Type, block_id: BlockId, var_index: &mut AcirVar, - slice_sizes: &[usize], ) -> Result { let one = self.acir_context.add_constant(FieldElement::one()); match ssa_type.clone() { @@ -971,33 +877,12 @@ impl Context { let mut values = Vector::new(); for _ in 0..len { for typ in element_types.as_ref() { - values.push_back(self.array_get_value( - typ, - block_id, - var_index, - slice_sizes, - )?); + values.push_back(self.array_get_value(typ, block_id, var_index)?); } } Ok(AcirValue::Array(values)) } - Type::Slice(element_types) => { - // It is not enough to execute this loop and simply pass the size from the parent definition. - // We need the internal sizes of each type in case of a nested slice. - let mut values = Vector::new(); - - let (current_size, new_sizes) = - slice_sizes.split_first().expect("should be able to split"); - - for _ in 0..*current_size { - for typ in element_types.as_ref() { - values - .push_back(self.array_get_value(typ, block_id, var_index, new_sizes)?); - } - } - Ok(AcirValue::Array(values)) - } - _ => unreachable!("ICE - expected an array or slice"), + _ => unreachable!("ICE: Expected an array or numeric but got {ssa_type:?}"), } } @@ -1059,23 +944,6 @@ impl Context { self.array_set_value(&store_value, result_block_id, &mut var_index)?; - // Set new resulting array to have the same slice sizes as the instruction input - if let Type::Slice(element_types) = &array_typ { - let has_internal_slices = - element_types.as_ref().iter().any(|typ| typ.contains_slice_element()); - if has_internal_slices { - let slice_sizes = self - .slice_sizes - .get(&array_id) - .expect( - "ICE: Expected array with internal slices to have associated slice sizes", - ) - .clone(); - let results = dfg.instruction_results(instruction); - self.slice_sizes.insert(results[0], slice_sizes); - } - } - let element_type_sizes = if !can_omit_element_sizes_array(&array_typ) { Some(self.init_element_type_sizes_array(&array_typ, array_id, None, dfg)?) } else { @@ -1184,8 +1052,6 @@ impl Context { Type::Array(_, _) | Type::Slice(_) => { match &dfg[array_id] { Value::Array { array, .. } => { - self.compute_slice_sizes(array_id, None, dfg); - for (i, value) in array.iter().enumerate() { flat_elem_type_sizes.push( self.flattened_slice_size(*value, dfg) + flat_elem_type_sizes[i], @@ -1285,41 +1151,6 @@ impl Context { Ok(element_type_sizes) } - fn compute_slice_sizes( - &mut self, - current_array_id: ValueId, - parent_array: Option, - dfg: &DataFlowGraph, - ) { - let (array, typ) = match &dfg[current_array_id] { - Value::Array { array, typ } => (array, typ.clone()), - _ => return, - }; - - if !matches!(typ, Type::Slice(_)) { - return; - } - - let element_size = typ.element_size(); - let true_len = array.len() / element_size; - if let Some(parent_array) = parent_array { - let sizes_list = - self.slice_sizes.get_mut(&parent_array).expect("ICE: expected size list"); - sizes_list.push(true_len); - for value in array { - self.compute_slice_sizes(*value, Some(parent_array), dfg); - } - } else { - // This means the current_array_id is the parent array - // The slice sizes should follow the parent array's type structure - // thus we start our sizes list with the parent array size. - self.slice_sizes.insert(current_array_id, vec![true_len]); - for value in array { - self.compute_slice_sizes(*value, Some(current_array_id), dfg); - } - } - } - fn copy_dynamic_array( &mut self, source: BlockId, @@ -1772,23 +1603,21 @@ impl Context { let slice_length = self.convert_value(arguments[0], dfg).into_var()?; let (slice_contents, slice_typ, _) = self.check_array_is_initialized(arguments[1], dfg)?; - let slice = self.convert_value(slice_contents, dfg); + assert!(!slice_typ.is_nested_slice(), "ICE: Nested slice used in ACIR generation"); + let slice = self.convert_value(slice_contents, dfg); let mut new_elem_size = Self::flattened_value_size(&slice); let mut new_slice = Vector::new(); self.slice_intrinsic_input(&mut new_slice, slice)?; let elements_to_push = &arguments[2..]; - // We only fill internal slices for nested slices (a slice inside of a slice). - // So we must directly push back elements for slices which are not a nested slice. - if !slice_typ.is_nested_slice() { - for elem in elements_to_push { - let element = self.convert_value(*elem, dfg); - - new_elem_size += Self::flattened_value_size(&element); - new_slice.push_back(element); - } + // We must directly push back elements for non-nested slices + for elem in elements_to_push { + let element = self.convert_value(*elem, dfg); + + new_elem_size += Self::flattened_value_size(&element); + new_slice.push_back(element); } // Increase the slice length by one to enable accessing more elements in the slice. @@ -1800,20 +1629,6 @@ impl Context { self.initialize_array(result_block_id, new_elem_size, Some(new_slice_val.clone()))?; // The previous slice length represents the index we want to write into. let mut var_index = slice_length; - // Dynamic arrays are represented as flat memory. We must flatten the user facing index - // to a flattened index that matches the complex slice structure. - if slice_typ.is_nested_slice() { - let element_size = slice_typ.element_size(); - - // Multiply the element size against the var index before fetching the flattened index - // This operation makes sure our user-facing slice index matches the strategy for indexing in SSA, - // which is how `get_flattened_index` expects its index input. - let element_size_var = self.acir_context.add_constant(element_size); - var_index = self.acir_context.mul_var(slice_length, element_size_var)?; - var_index = - self.get_flattened_index(&slice_typ, slice_contents, var_index, dfg)?; - } - // Write the elements we wish to push back directly. // The slice's underlying array value should already be filled with dummy data // to enable this write to be within bounds. @@ -1847,8 +1662,9 @@ impl Context { let (slice_contents, slice_typ, _) = self.check_array_is_initialized(arguments[1], dfg)?; - let slice: AcirValue = self.convert_value(slice_contents, dfg); + assert!(!slice_typ.is_nested_slice(), "ICE: Nested slice used in ACIR generation"); + let slice: AcirValue = self.convert_value(slice_contents, dfg); let mut new_slice_size = Self::flattened_value_size(&slice); // Increase the slice length by one to enable accessing more elements in the slice. @@ -1860,33 +1676,14 @@ impl Context { let elements_to_push = &arguments[2..]; let mut elem_size = 0; - // We only fill internal slices for nested slices (a slice inside of a slice). - // So we must directly push front elements for slices which are not a nested slice. - if !slice_typ.is_nested_slice() { - for elem in elements_to_push.iter().rev() { - let element = self.convert_value(*elem, dfg); - - elem_size += Self::flattened_value_size(&element); - new_slice.push_front(element); - } - new_slice_size += elem_size; - } else { - // We have already filled the appropriate dummy values for nested slice during SSA gen. - // We need to account for that we do not go out of bounds by removing dummy data as we - // push elements to the front of our slice. - // Using this strategy we are able to avoid dynamic writes like we do for a SlicePushBack. - for elem in elements_to_push.iter().rev() { - let element = self.convert_value(*elem, dfg); - - let elem_size = Self::flattened_value_size(&element); - // Have to pop based off of the flattened value size as we read the - // slice intrinsic as a flat list of AcirValue::Var - for _ in 0..elem_size { - new_slice.pop_back(); - } - new_slice.push_front(element); - } + // We must directly push front elements for non-nested slices + for elem in elements_to_push.iter().rev() { + let element = self.convert_value(*elem, dfg); + + elem_size += Self::flattened_value_size(&element); + new_slice.push_front(element); } + new_slice_size += elem_size; let new_slice_val = AcirValue::Array(new_slice.clone()); @@ -1928,55 +1725,16 @@ impl Context { let (slice_contents, slice_typ, block_id) = self.check_array_is_initialized(arguments[1], dfg)?; - let slice = self.convert_value(slice_contents, dfg); - - let element_size = slice_typ.element_size(); + assert!(!slice_typ.is_nested_slice(), "ICE: Nested slice used in ACIR generation"); let mut popped_elements = Vec::new(); - // Fetch the values we are popping off of the slice. - // In the case of non-nested slice the logic is simple as we do not - // need to account for the internal slice sizes or flattening the index. - // - // The pop back operation results are of the format [slice length, slice contents, popped elements]. - // Thus, we look at the result ids at index 2 and onwards to determine the type of each popped element. - if !slice_typ.is_nested_slice() { - for res in &result_ids[2..] { - let elem = self.array_get_value( - &dfg.type_of_value(*res), - block_id, - &mut var_index, - &[], - )?; - popped_elements.push(elem); - } - } else { - // Fetch the slice sizes of the nested slice. - let slice_sizes = self.slice_sizes.get(&slice_contents); - let mut slice_sizes = - slice_sizes.expect("ICE: should have slice sizes").clone(); - // We want to remove the parent size as we are fetching the child - slice_sizes.remove(0); - - // Multiply the element size against the var index before fetching the flattened index - // This operation makes sure our user-facing slice index matches the strategy for indexing in SSA, - // which is how `get_flattened_index` expects its index input. - let element_size_var = self.acir_context.add_constant(element_size); - // We want to use an index one less than the slice length - var_index = self.acir_context.mul_var(var_index, element_size_var)?; - var_index = - self.get_flattened_index(&slice_typ, slice_contents, var_index, dfg)?; - - for res in &result_ids[2..] { - let elem = self.array_get_value( - &dfg.type_of_value(*res), - block_id, - &mut var_index, - &slice_sizes, - )?; - popped_elements.push(elem); - } + for res in &result_ids[2..] { + let elem = + self.array_get_value(&dfg.type_of_value(*res), block_id, &mut var_index)?; + popped_elements.push(elem); } + let slice = self.convert_value(slice_contents, dfg); let mut new_slice = Vector::new(); self.slice_intrinsic_input(&mut new_slice, slice)?; @@ -1994,11 +1752,13 @@ impl Context { let (slice_contents, slice_typ, block_id) = self.check_array_is_initialized(arguments[1], dfg)?; - let slice = self.convert_value(slice_contents, dfg); + assert!(!slice_typ.is_nested_slice(), "ICE: Nested slice used in ACIR generation"); let one = self.acir_context.add_constant(FieldElement::one()); let new_slice_length = self.acir_context.sub_var(slice_length, one)?; + let slice = self.convert_value(slice_contents, dfg); + let mut new_slice = Vector::new(); self.slice_intrinsic_input(&mut new_slice, slice)?; @@ -2010,40 +1770,14 @@ impl Context { // Fetch the values we are popping off of the slice. // In the case of non-nested slice the logic is simple as we do not // need to account for the internal slice sizes or flattening the index. - // - // The pop front operation results are of the format [popped elements, slice length, slice contents]. - // Thus, we look at the result ids up to the element size to determine the type of each popped element. - if !slice_typ.is_nested_slice() { - for res in &result_ids[..element_size] { - let element = self.array_get_value( - &dfg.type_of_value(*res), - block_id, - &mut var_index, - &[], - )?; - let elem_size = Self::flattened_value_size(&element); - popped_elements_size += elem_size; - popped_elements.push(element); - } - } else { - let slice_sizes = self.slice_sizes.get(&slice_contents); - let mut slice_sizes = - slice_sizes.expect("ICE: should have slice sizes").clone(); - // We want to remove the parent size as we are fetching the child - slice_sizes.remove(0); - - for res in &result_ids[..element_size] { - let element = self.array_get_value( - &dfg.type_of_value(*res), - block_id, - &mut var_index, - &slice_sizes, - )?; - let elem_size = Self::flattened_value_size(&element); - popped_elements_size += elem_size; - popped_elements.push(element); - } + for res in &result_ids[..element_size] { + let element = + self.array_get_value(&dfg.type_of_value(*res), block_id, &mut var_index)?; + let elem_size = Self::flattened_value_size(&element); + popped_elements_size += elem_size; + popped_elements.push(element); } + // It is expected that the `popped_elements_size` is the flattened size of the elements, // as the input slice should be a dynamic array which is represented by flat memory. new_slice = new_slice.slice(popped_elements_size..); @@ -2059,6 +1793,7 @@ impl Context { let (slice_contents, slice_typ, block_id) = self.check_array_is_initialized(arguments[1], dfg)?; + assert!(!slice_typ.is_nested_slice(), "ICE: Nested slice used in ACIR generation"); let slice = self.convert_value(slice_contents, dfg); let insert_index = self.convert_value(arguments[2], dfg).into_var()?; @@ -2164,7 +1899,6 @@ impl Context { } } - // let new_slice_val = AcirValue::Array(new_slice); let element_type_sizes = if !can_omit_element_sizes_array(&slice_typ) { Some(self.init_element_type_sizes_array( &slice_typ, @@ -2189,6 +1923,7 @@ impl Context { let (slice_contents, slice_typ, block_id) = self.check_array_is_initialized(arguments[1], dfg)?; + assert!(!slice_typ.is_nested_slice(), "ICE: Nested slice used in ACIR generation"); let slice = self.convert_value(slice_contents, dfg); let remove_index = self.convert_value(arguments[2], dfg).into_var()?; @@ -2217,8 +1952,6 @@ impl Context { self.get_flattened_index(&slice_typ, slice_contents, flat_remove_index, dfg)?; // Fetch the values we are remove from the slice. - // In the case of non-nested slice the logic is simple as we do not - // need to account for the internal slice sizes or flattening the index. // As we fetch the values we can determine the size of the removed values // which we will later use for writing the correct resulting slice. let mut popped_elements = Vec::new(); @@ -2226,36 +1959,12 @@ impl Context { // Set a temp index just for fetching from the original slice as `array_get_value` mutates // the index internally. let mut temp_index = flat_user_index; - if !slice_typ.is_nested_slice() { - for res in &result_ids[2..(2 + element_size)] { - let element = self.array_get_value( - &dfg.type_of_value(*res), - block_id, - &mut temp_index, - &[], - )?; - let elem_size = Self::flattened_value_size(&element); - popped_elements_size += elem_size; - popped_elements.push(element); - } - } else { - let slice_sizes = self.slice_sizes.get(&slice_contents); - let mut slice_sizes = - slice_sizes.expect("ICE: should have slice sizes").clone(); - // We want to remove the parent size as we are fetching the child - slice_sizes.remove(0); - - for res in &result_ids[2..(2 + element_size)] { - let element = self.array_get_value( - &dfg.type_of_value(*res), - block_id, - &mut temp_index, - &slice_sizes, - )?; - let elem_size = Self::flattened_value_size(&element); - popped_elements_size += elem_size; - popped_elements.push(element); - } + for res in &result_ids[2..(2 + element_size)] { + let element = + self.array_get_value(&dfg.type_of_value(*res), block_id, &mut temp_index)?; + let elem_size = Self::flattened_value_size(&element); + popped_elements_size += elem_size; + popped_elements.push(element); } // Go through the entire slice argument and determine what value should be written to the new slice. diff --git a/noir/compiler/noirc_evaluator/src/ssa/function_builder/mod.rs b/noir/compiler/noirc_evaluator/src/ssa/function_builder/mod.rs index 852848afb81e..44be423be101 100644 --- a/noir/compiler/noirc_evaluator/src/ssa/function_builder/mod.rs +++ b/noir/compiler/noirc_evaluator/src/ssa/function_builder/mod.rs @@ -367,10 +367,12 @@ impl FunctionBuilder { let r_squared = self.insert_binary(r, BinaryOp::Mul, r); let a = self.insert_binary(r_squared, BinaryOp::Mul, lhs); let idx = self.field_constant(FieldElement::from((bit_size - i) as i128)); - let b = self.insert_array_get(rhs_bits, idx, Type::field()); + let b = self.insert_array_get(rhs_bits, idx, Type::bool()); + let not_b = self.insert_not(b); + let b = self.insert_cast(b, Type::field()); + let not_b = self.insert_cast(not_b, Type::field()); let r1 = self.insert_binary(a, BinaryOp::Mul, b); - let c = self.insert_binary(one, BinaryOp::Sub, b); - let r2 = self.insert_binary(c, BinaryOp::Mul, r_squared); + let r2 = self.insert_binary(r_squared, BinaryOp::Mul, not_b); r = self.insert_binary(r1, BinaryOp::Add, r2); } r diff --git a/noir/compiler/noirc_evaluator/src/ssa/ir/instruction/call.rs b/noir/compiler/noirc_evaluator/src/ssa/ir/instruction/call.rs index d1991abab377..ff9dc4f345ec 100644 --- a/noir/compiler/noirc_evaluator/src/ssa/ir/instruction/call.rs +++ b/noir/compiler/noirc_evaluator/src/ssa/ir/instruction/call.rs @@ -434,8 +434,13 @@ fn simplify_black_box_func( // Currently unsolvable here as we rely on an implementation in the backend. SimplifyResult::None } - - BlackBoxFunc::RecursiveAggregation => SimplifyResult::None, + BlackBoxFunc::BigIntAdd + | BlackBoxFunc::BigIntNeg + | BlackBoxFunc::BigIntMul + | BlackBoxFunc::BigIntDiv + | BlackBoxFunc::RecursiveAggregation + | BlackBoxFunc::BigIntFromLeBytes + | BlackBoxFunc::BigIntToLeBytes => SimplifyResult::None, BlackBoxFunc::AND => { unreachable!("ICE: `BlackBoxFunc::AND` calls should be transformed into a `BinaryOp`") diff --git a/noir/compiler/noirc_evaluator/src/ssa/ir/types.rs b/noir/compiler/noirc_evaluator/src/ssa/ir/types.rs index ae53c7705c25..f412def1e760 100644 --- a/noir/compiler/noirc_evaluator/src/ssa/ir/types.rs +++ b/noir/compiler/noirc_evaluator/src/ssa/ir/types.rs @@ -139,7 +139,7 @@ impl Type { } pub(crate) fn is_nested_slice(&self) -> bool { - if let Type::Slice(element_types) = self { + if let Type::Slice(element_types) | Type::Array(element_types, _) = self { element_types.as_ref().iter().any(|typ| typ.contains_slice_element()) } else { false diff --git a/noir/compiler/noirc_evaluator/src/ssa/opt/bubble_up_constrains.rs b/noir/compiler/noirc_evaluator/src/ssa/opt/bubble_up_constrains.rs new file mode 100644 index 000000000000..8a903cbd87b3 --- /dev/null +++ b/noir/compiler/noirc_evaluator/src/ssa/opt/bubble_up_constrains.rs @@ -0,0 +1,153 @@ +use std::collections::HashMap; + +use crate::ssa::{ + ir::instruction::{Instruction, InstructionId}, + ssa_gen::Ssa, +}; + +impl Ssa { + /// A simple SSA pass to go through each instruction and move every `Instruction::Constrain` to immediately + /// after when all of its inputs are available. + #[tracing::instrument(level = "trace", skip(self))] + pub(crate) fn bubble_up_constrains(mut self) -> Ssa { + for function in self.functions.values_mut() { + for block in function.reachable_blocks() { + let instructions = function.dfg[block].take_instructions(); + let mut filtered_instructions = Vec::with_capacity(instructions.len()); + + // Multiple constrains can bubble up to sit under a single instruction. We want to maintain the ordering of these constraints, + // so we need to keep track of how many constraints are attached to a given instruction. + // Some assertions don't operate on instruction results, so we use Option so we also track the None case + let mut inserted_at_instruction: HashMap, usize> = + HashMap::with_capacity(instructions.len()); + + let dfg = &function.dfg; + for instruction in instructions { + let (lhs, rhs) = match dfg[instruction] { + Instruction::Constrain(lhs, rhs, ..) => (lhs, rhs), + _ => { + filtered_instructions.push(instruction); + continue; + } + }; + + let last_instruction_that_creates_inputs = filtered_instructions + .iter() + .rev() + .position(|&instruction_id| { + let results = dfg.instruction_results(instruction_id).to_vec(); + results.contains(&lhs) || results.contains(&rhs) + }) + // We iterate through the previous instructions in reverse order so the index is from the + // back of the vector + .map(|reversed_index| filtered_instructions.len() - reversed_index - 1); + + let insertion_index = last_instruction_that_creates_inputs + .map(|index| { + // We want to insert just after the last instruction that creates the inputs + index + 1 + }) + // If it doesn't depend from the previous instructions, then we insert at the start + .unwrap_or_default(); + + let already_inserted_for_this_instruction = inserted_at_instruction + .entry( + last_instruction_that_creates_inputs + .map(|index| filtered_instructions[index]), + ) + .or_default(); + + filtered_instructions.insert( + insertion_index + *already_inserted_for_this_instruction, + instruction, + ); + + *already_inserted_for_this_instruction += 1; + } + + *function.dfg[block].instructions_mut() = filtered_instructions; + } + } + self + } +} + +#[cfg(test)] +mod test { + use crate::ssa::{ + function_builder::FunctionBuilder, + ir::{ + function::RuntimeType, + instruction::{Binary, BinaryOp, Instruction}, + map::Id, + types::Type, + }, + }; + + #[test] + fn check_bubble_up_constrains() { + // fn main f0 { + // b0(v0: Field): + // v1 = add v0, Field 1 + // v2 = add v1, Field 1 + // constrain v0 == Field 1 'With message' + // constrain v2 == Field 3 + // constrain v0 == Field 1 + // constrain v1 == Field 2 + // constrain v1 == Field 2 'With message' + // } + // + let main_id = Id::test_new(0); + + // Compiling main + let mut builder = FunctionBuilder::new("main".into(), main_id, RuntimeType::Acir); + let v0 = builder.add_parameter(Type::field()); + + let one = builder.field_constant(1u128); + let two = builder.field_constant(2u128); + let three = builder.field_constant(3u128); + + let v1 = builder.insert_binary(v0, BinaryOp::Add, one); + let v2 = builder.insert_binary(v1, BinaryOp::Add, one); + builder.insert_constrain(v0, one, Some("With message".to_string())); + builder.insert_constrain(v2, three, None); + builder.insert_constrain(v0, one, None); + builder.insert_constrain(v1, two, None); + builder.insert_constrain(v1, two, Some("With message".to_string())); + builder.terminate_with_return(vec![]); + + let ssa = builder.finish(); + + // Expected output: + // + // fn main f0 { + // b0(v0: Field): + // constrain v0 == Field 1 'With message' + // constrain v0 == Field 1 + // v1 = add v0, Field 1 + // constrain v1 == Field 2 + // constrain v1 == Field 2 'With message' + // v2 = add v1, Field 1 + // constrain v2 == Field 3 + // } + // + let ssa = ssa.bubble_up_constrains(); + let main = ssa.main(); + let block = &main.dfg[main.entry_block()]; + assert_eq!(block.instructions().len(), 7); + + let expected_instructions = vec![ + Instruction::Constrain(v0, one, Some("With message".to_string())), + Instruction::Constrain(v0, one, None), + Instruction::Binary(Binary { lhs: v0, rhs: one, operator: BinaryOp::Add }), + Instruction::Constrain(v1, two, None), + Instruction::Constrain(v1, two, Some("With message".to_string())), + Instruction::Binary(Binary { lhs: v1, rhs: one, operator: BinaryOp::Add }), + Instruction::Constrain(v2, three, None), + ]; + + for (index, instruction) in block.instructions().iter().enumerate() { + assert_eq!(&main.dfg[*instruction], &expected_instructions[index]); + } + } +} diff --git a/noir/compiler/noirc_evaluator/src/ssa/opt/fill_internal_slices.rs b/noir/compiler/noirc_evaluator/src/ssa/opt/fill_internal_slices.rs deleted file mode 100644 index 5ee8e42fe3ac..000000000000 --- a/noir/compiler/noirc_evaluator/src/ssa/opt/fill_internal_slices.rs +++ /dev/null @@ -1,765 +0,0 @@ -//! This module defines the internal slices data fill pass. -//! The purpose of this pass is to fill out nested slice values represented by SSA array values. -//! "Filling out" a nested slice specifically refers to making a nested slice's internal slice types -//! match up in their size. This pass is necessary for dynamic array operations to work in ACIR gen -//! as we need to have a known size for any memory operations. As slice types do not carry a size we -//! need to make sure all nested internal slices have the same size in order to accurately -//! read from or write to a nested slice. This pass ultimately attaches dummy data to any smaller internal slice types. -//! -//! A simple example: -//! If we have a slice of the type [[Field]] which is of length 2. The internal slices themselves -//! could be of different sizes, such as 3 and 4. An array operation on this nested slice would look -//! something like below: -//! array_get [Field 3, [Field 1, Field 1, Field 1], Field 4, [Field 2, Field 2, Field 2, Field 2]], index Field v0 -//! Will get translated into a new instruction like such: -//! array_get [Field 3, [Field 1, Field 1, Field 1, Field 0], Field 4, [Field 2, Field 2, Field 2, Field 2]], index Field v0 -//! -//! -//! TODO(#3188): Currently the pass only works on a single flattened block. This should be updated in followup work. -//! The steps of the pass are as follows: -//! - Process each instruction of the block to collect relevant slice size information. We want to find the maximum size that a nested slice -//! potentially could be. Slices can potentially be set to larger array values or used in intrinsics that increase or shorten their size. -//! - Track all array constants and compute an initial map of their nested slice sizes. The slice sizes map is simply a map of an SSA array value -//! to its array size and then any child slice values that may exist. -//! - We also track a map to resolve a starting array constant to its final possible array value. This map is updated on the appropriate instructions -//! such as ArraySet or any slice intrinsics. -//! - On an ArrayGet operation add the resulting value as a possible child of the original slice. In SSA we will reuse the same memory block -//! for the nested slice and must account for an internal slice being fetched and set to a larger value, otherwise we may have an out of bounds error. -//! Also set the resulting fetched value to have the same internal slice size map as the children of the original array used in the operation. -//! - On an ArraySet operation we set the resulting value to have the same slice sizes map as the original array used in the operation. Like the result of -//! an ArrayGet we need to also add the `value` for an ArraySet as a possible child slice of the original array. -//! - For slice intrinsics we set the resulting value to have the same slice sizes map as the original array the same way as we do in an ArraySet. -//! However, with a slice intrinsic we also increase the size for the respective slice intrinsics. -//! We do not decrement the size on intrinsics that could remove values from a slice. This is because we could potentially go back to the smaller slice size, -//! not fill in the appropriate dummies and then get an out of bounds error later when executing the ACIR. We always want to compute -//! what a slice maximum size could be. -//! - Now we need to add each instruction back except with the updated original array values. -//! - Resolve the original slice value to what its final value would be using the previously computed map. -//! - Find the max size as each layer of the recursive nested slice type. -//! For instance in the example above we have a slice of depth 2 with the max sizes of [2, 4]. -//! - Follow the slice type to check whether the SSA value is under the specified max size. If a slice value -//! is under the max size we then attach dummy data. -//! - Construct a final nested slice with the now attached dummy data and replace the original array in the previously -//! saved ArrayGet and ArraySet instructions. - -use crate::ssa::{ - ir::{ - basic_block::BasicBlockId, - dfg::CallStack, - function::{Function, RuntimeType}, - function_inserter::FunctionInserter, - instruction::{Instruction, InstructionId, Intrinsic}, - post_order::PostOrder, - types::Type, - value::{Value, ValueId}, - }, - ssa_gen::Ssa, -}; - -use acvm::FieldElement; -use fxhash::FxHashMap as HashMap; - -impl Ssa { - #[tracing::instrument(level = "trace", skip(self))] - pub(crate) fn fill_internal_slices(mut self) -> Ssa { - for function in self.functions.values_mut() { - // This pass is only necessary for generating ACIR and thus we should not - // process Brillig functions. - // The pass is also currently only setup to handle a function with a single flattened block. - // For complex Brillig functions we can expect this pass to panic. - if function.runtime() == RuntimeType::Acir { - let databus = function.dfg.data_bus.clone(); - let mut context = Context::new(function); - context.process_blocks(); - // update the databus with the new array instructions - function.dfg.data_bus = databus.map_values(|t| context.inserter.resolve(t)); - } - } - self - } -} - -struct Context<'f> { - post_order: PostOrder, - inserter: FunctionInserter<'f>, - - /// Maps SSA array values representing a slice's contents to its updated array value - /// after an array set or a slice intrinsic operation. - /// Maps original value -> result - mapped_slice_values: HashMap, - - /// Maps an updated array value following an array operation to its previous value. - /// When used in conjunction with `mapped_slice_values` we form a two way map of all array - /// values being used in array operations. - /// Maps result -> original value - slice_parents: HashMap, -} - -impl<'f> Context<'f> { - fn new(function: &'f mut Function) -> Self { - let post_order = PostOrder::with_function(function); - let inserter = FunctionInserter::new(function); - - Context { - post_order, - inserter, - mapped_slice_values: HashMap::default(), - slice_parents: HashMap::default(), - } - } - - fn process_blocks(&mut self) { - let mut block_order = PostOrder::with_function(self.inserter.function).into_vec(); - block_order.reverse(); - for block in block_order { - self.process_block(block); - } - } - - fn process_block(&mut self, block: BasicBlockId) { - // Fetch SSA values potentially with internal slices - let instructions = self.inserter.function.dfg[block].take_instructions(); - - // Values containing nested slices to be replaced - let mut slice_values = Vec::new(); - // Maps SSA array ID representing slice contents to its length and a list of its potential internal slices - // This map is constructed once for an array constant and is then updated - // according to the rules in `collect_slice_information`. - let mut slice_sizes: HashMap)> = HashMap::default(); - - // Update the slice sizes map to help find the potential max size of each nested slice. - for instruction in instructions.iter() { - self.collect_slice_information(*instruction, &mut slice_values, &mut slice_sizes); - } - - // Add back every instruction with the updated nested slices. - for instruction in instructions { - self.push_updated_instruction(instruction, &slice_values, &slice_sizes, block); - } - - self.inserter.map_terminator_in_place(block); - } - - /// Determine how the slice sizes map needs to be updated according to the provided instruction. - fn collect_slice_information( - &mut self, - instruction: InstructionId, - slice_values: &mut Vec, - slice_sizes: &mut HashMap)>, - ) { - let results = self.inserter.function.dfg.instruction_results(instruction); - match &self.inserter.function.dfg[instruction] { - Instruction::ArrayGet { array, .. } => { - let array_typ = self.inserter.function.dfg.type_of_value(*array); - let array_value = &self.inserter.function.dfg[*array]; - // If we have an SSA value containing nested slices we should mark it - // as a slice that potentially requires to be filled with dummy data. - if matches!(array_value, Value::Array { .. }) && array_typ.contains_slice_element() - { - slice_values.push(*array); - // Initial insertion into the slice sizes map - // Any other insertions should only occur if the value is already - // a part of the map. - self.compute_slice_sizes(*array, slice_sizes); - } - - let res_typ = self.inserter.function.dfg.type_of_value(results[0]); - if res_typ.contains_slice_element() { - if let Some(inner_sizes) = slice_sizes.get_mut(array) { - // Include the result in the parent array potential children - // If the result has internal slices and is called in an array set - // we could potentially have a new larger slice which we need to account for - inner_sizes.1.push(results[0]); - self.slice_parents.insert(results[0], *array); - - let inner_sizes_iter = inner_sizes.1.clone(); - for slice_value in inner_sizes_iter { - let inner_slice = slice_sizes.get(&slice_value).unwrap_or_else(|| { - panic!("ICE: should have inner slice set for {slice_value}") - }); - slice_sizes.insert(results[0], inner_slice.clone()); - if slice_value != results[0] { - self.mapped_slice_values.insert(slice_value, results[0]); - } - } - } - } - } - Instruction::ArraySet { array, value, .. } => { - let array_typ = self.inserter.function.dfg.type_of_value(*array); - let array_value = &self.inserter.function.dfg[*array]; - // If we have an SSA value containing nested slices we should mark it - // as a slice that potentially requires to be filled with dummy data. - if matches!(array_value, Value::Array { .. }) && array_typ.contains_slice_element() - { - slice_values.push(*array); - // Initial insertion into the slice sizes map - // Any other insertions should only occur if the value is already - // a part of the map. - self.compute_slice_sizes(*array, slice_sizes); - } - - let value_typ = self.inserter.function.dfg.type_of_value(*value); - if value_typ.contains_slice_element() { - self.compute_slice_sizes(*value, slice_sizes); - - let inner_sizes = slice_sizes.get_mut(array).expect("ICE expected slice sizes"); - inner_sizes.1.push(*value); - } - - if let Some(inner_sizes) = slice_sizes.get_mut(array) { - let inner_sizes = inner_sizes.clone(); - - slice_sizes.insert(results[0], inner_sizes); - - self.mapped_slice_values.insert(*array, results[0]); - self.slice_parents.insert(results[0], *array); - } - } - Instruction::Call { func, arguments } => { - let func = &self.inserter.function.dfg[*func]; - if let Value::Intrinsic(intrinsic) = func { - let (argument_index, result_index) = match intrinsic { - Intrinsic::SlicePushBack - | Intrinsic::SlicePushFront - | Intrinsic::SlicePopBack - | Intrinsic::SliceInsert - | Intrinsic::SliceRemove => (1, 1), - // `pop_front` returns the popped element, and then the respective slice. - // This means in the case of a slice with structs, the result index of the popped slice - // will change depending on the number of elements in the struct. - // For example, a slice with four elements will look as such in SSA: - // v3, v4, v5, v6, v7, v8 = call slice_pop_front(v1, v2) - // where v7 is the slice length and v8 is the popped slice itself. - Intrinsic::SlicePopFront => (1, results.len() - 1), - _ => return, - }; - let slice_contents = arguments[argument_index]; - match intrinsic { - Intrinsic::SlicePushBack - | Intrinsic::SlicePushFront - | Intrinsic::SliceInsert => { - for arg in &arguments[(argument_index + 1)..] { - let element_typ = self.inserter.function.dfg.type_of_value(*arg); - if element_typ.contains_slice_element() { - slice_values.push(*arg); - self.compute_slice_sizes(*arg, slice_sizes); - } - } - if let Some(inner_sizes) = slice_sizes.get_mut(&slice_contents) { - inner_sizes.0 += 1; - - let inner_sizes = inner_sizes.clone(); - slice_sizes.insert(results[result_index], inner_sizes); - - self.mapped_slice_values - .insert(slice_contents, results[result_index]); - self.slice_parents.insert(results[result_index], slice_contents); - } - } - Intrinsic::SlicePopBack - | Intrinsic::SliceRemove - | Intrinsic::SlicePopFront => { - // We do not decrement the size on intrinsics that could remove values from a slice. - // This is because we could potentially go back to the smaller slice and not fill in dummies. - // This pass should be tracking the potential max that a slice ***could be*** - if let Some(inner_sizes) = slice_sizes.get(&slice_contents) { - let inner_sizes = inner_sizes.clone(); - slice_sizes.insert(results[result_index], inner_sizes); - - self.mapped_slice_values - .insert(slice_contents, results[result_index]); - self.slice_parents.insert(results[result_index], slice_contents); - } - } - _ => {} - } - } - } - _ => {} - } - } - - fn push_updated_instruction( - &mut self, - instruction: InstructionId, - slice_values: &[ValueId], - slice_sizes: &HashMap)>, - block: BasicBlockId, - ) { - match &self.inserter.function.dfg[instruction] { - Instruction::ArrayGet { array, .. } | Instruction::ArraySet { array, .. } => { - if slice_values.contains(array) { - let (new_array_op_instr, call_stack) = - self.get_updated_array_op_instr(*array, slice_sizes, instruction); - self.inserter.push_instruction_value( - new_array_op_instr, - instruction, - block, - call_stack, - ); - } else { - self.inserter.push_instruction(instruction, block); - } - } - Instruction::Call { func: _, arguments } => { - let mut args_to_replace = Vec::new(); - for (i, arg) in arguments.iter().enumerate() { - let element_typ = self.inserter.function.dfg.type_of_value(*arg); - if slice_values.contains(arg) && element_typ.contains_slice_element() { - args_to_replace.push((i, *arg)); - } - } - if args_to_replace.is_empty() { - self.inserter.push_instruction(instruction, block); - } else { - // Using the original slice is ok to do as during collection of slice information - // we guarantee that only the arguments to slice intrinsic calls can be replaced. - let slice_contents = arguments[1]; - - let element_typ = self.inserter.function.dfg.type_of_value(arguments[1]); - let elem_depth = Self::compute_nested_slice_depth(&element_typ); - - let mut max_sizes = Vec::new(); - max_sizes.resize(elem_depth, 0); - // We want the max for the parent of the argument - let parent = self.resolve_slice_parent(slice_contents); - self.compute_slice_max_sizes(parent, slice_sizes, &mut max_sizes, 0); - - for (index, arg) in args_to_replace { - let element_typ = self.inserter.function.dfg.type_of_value(arg); - max_sizes.remove(0); - let new_array = - self.attach_slice_dummies(&element_typ, Some(arg), false, &max_sizes); - - let instruction_id = instruction; - let (instruction, call_stack) = - self.inserter.map_instruction(instruction_id); - let new_call_instr = match instruction { - Instruction::Call { func, mut arguments } => { - arguments[index] = new_array; - Instruction::Call { func, arguments } - } - _ => panic!("Expected call instruction"), - }; - self.inserter.push_instruction_value( - new_call_instr, - instruction_id, - block, - call_stack, - ); - } - } - } - _ => { - self.inserter.push_instruction(instruction, block); - } - } - } - - /// Construct an updated ArrayGet or ArraySet instruction where the array value - /// has been replaced by a newly filled in array according to the max internal - /// slice sizes. - fn get_updated_array_op_instr( - &mut self, - array_id: ValueId, - slice_sizes: &HashMap)>, - instruction: InstructionId, - ) -> (Instruction, CallStack) { - let mapped_slice_value = self.resolve_slice_value(array_id); - - let (current_size, _) = slice_sizes - .get(&mapped_slice_value) - .unwrap_or_else(|| panic!("should have slice sizes: {mapped_slice_value}")); - - let mut max_sizes = Vec::new(); - - let typ = self.inserter.function.dfg.type_of_value(array_id); - let depth = Self::compute_nested_slice_depth(&typ); - max_sizes.resize(depth, 0); - - max_sizes[0] = *current_size; - self.compute_slice_max_sizes(array_id, slice_sizes, &mut max_sizes, 1); - - let new_array = self.attach_slice_dummies(&typ, Some(array_id), true, &max_sizes); - - let instruction_id = instruction; - let (instruction, call_stack) = self.inserter.map_instruction(instruction_id); - let new_array_op_instr = match instruction { - Instruction::ArrayGet { index, .. } => { - Instruction::ArrayGet { array: new_array, index } - } - Instruction::ArraySet { index, value, .. } => { - Instruction::ArraySet { array: new_array, index, value } - } - _ => panic!("Expected array set"), - }; - - (new_array_op_instr, call_stack) - } - - fn attach_slice_dummies( - &mut self, - typ: &Type, - value: Option, - is_parent_slice: bool, - max_sizes: &[usize], - ) -> ValueId { - match typ { - Type::Numeric(_) => { - if let Some(value) = value { - self.inserter.resolve(value) - } else { - let zero = FieldElement::zero(); - self.inserter.function.dfg.make_constant(zero, Type::field()) - } - } - Type::Array(element_types, len) => { - if let Some(value) = value { - self.inserter.resolve(value) - } else { - let mut array = im::Vector::new(); - for _ in 0..*len { - for typ in element_types.iter() { - array.push_back(self.attach_slice_dummies(typ, None, false, max_sizes)); - } - } - self.inserter.function.dfg.make_array(array, typ.clone()) - } - } - Type::Slice(element_types) => { - let (current_size, max_sizes) = - max_sizes.split_first().expect("ICE: Missing internal slice max size"); - let mut max_size = *current_size; - if let Some(value) = value { - let mut slice = im::Vector::new(); - - let value = self.inserter.function.dfg[value].clone(); - let array = match value { - Value::Array { array, .. } => array, - _ => { - panic!("Expected an array value"); - } - }; - - if is_parent_slice { - max_size = array.len() / element_types.len(); - } - for i in 0..max_size { - for (element_index, element_type) in element_types.iter().enumerate() { - let index_usize = i * element_types.len() + element_index; - let valid_index = index_usize < array.len(); - let maybe_value = - if valid_index { Some(array[index_usize]) } else { None }; - slice.push_back(self.attach_slice_dummies( - element_type, - maybe_value, - false, - max_sizes, - )); - } - } - - self.inserter.function.dfg.make_array(slice, typ.clone()) - } else { - let mut slice = im::Vector::new(); - for _ in 0..max_size { - for typ in element_types.iter() { - slice.push_back(self.attach_slice_dummies(typ, None, false, max_sizes)); - } - } - self.inserter.function.dfg.make_array(slice, typ.clone()) - } - } - Type::Reference(_) => { - unreachable!("ICE: Generating dummy data for references is unsupported") - } - Type::Function => { - unreachable!("ICE: Generating dummy data for functions is unsupported") - } - } - } - - // This methods computes a map representing a nested slice. - // The method also automatically computes the given max slice size - // at each depth of the recursive type. - // For example if we had a next slice - fn compute_slice_sizes( - &self, - array_id: ValueId, - slice_sizes: &mut HashMap)>, - ) { - if let Value::Array { array, typ } = &self.inserter.function.dfg[array_id].clone() { - if let Type::Slice(_) = typ { - let element_size = typ.element_size(); - let len = array.len() / element_size; - let mut slice_value = (len, vec![]); - for value in array { - let typ = self.inserter.function.dfg.type_of_value(*value); - if let Type::Slice(_) = typ { - slice_value.1.push(*value); - self.compute_slice_sizes(*value, slice_sizes); - } - } - // Mark the correct max size based upon an array values internal structure - let mut max_size = 0; - for inner_value in slice_value.1.iter() { - let inner_slice = - slice_sizes.get(inner_value).expect("ICE: should have inner slice set"); - if inner_slice.0 > max_size { - max_size = inner_slice.0; - } - } - for inner_value in slice_value.1.iter() { - let inner_slice = - slice_sizes.get_mut(inner_value).expect("ICE: should have inner slice set"); - if inner_slice.0 < max_size { - inner_slice.0 = max_size; - } - } - slice_sizes.insert(array_id, slice_value); - } - } - } - - /// Determine the maximum possible size of an internal slice at each - /// layer of a nested slice. - /// - /// If the slice map is incorrectly formed the function will exceed - /// the type's nested slice depth and panic. - fn compute_slice_max_sizes( - &self, - array_id: ValueId, - slice_sizes: &HashMap)>, - max_sizes: &mut Vec, - depth: usize, - ) { - let array_id = self.resolve_slice_value(array_id); - let (current_size, inner_slices) = slice_sizes - .get(&array_id) - .unwrap_or_else(|| panic!("should have slice sizes: {array_id}")); - - if inner_slices.is_empty() { - return; - } - - let mut max = *current_size; - for inner_slice in inner_slices.iter() { - let inner_slice = &self.resolve_slice_value(*inner_slice); - - let (inner_size, _) = slice_sizes[inner_slice]; - if inner_size > max { - max = inner_size; - } - self.compute_slice_max_sizes(*inner_slice, slice_sizes, max_sizes, depth + 1); - } - - if max > max_sizes[depth] { - max_sizes[depth] = max; - } - } - - /// Compute the depth of nested slices in a given Type. - /// The depth follows the recursive type structure of a slice. - fn compute_nested_slice_depth(typ: &Type) -> usize { - let mut depth = 0; - if let Type::Slice(element_types) = typ { - depth += 1; - for typ in element_types.as_ref() { - depth += Self::compute_nested_slice_depth(typ); - } - } - depth - } - - /// Resolves a ValueId representing a slice's contents to its updated value. - /// If there is no resolved value for the supplied value, the value which - /// was passed to the method is returned. - fn resolve_slice_value(&self, array_id: ValueId) -> ValueId { - match self.mapped_slice_values.get(&array_id) { - Some(value) => self.resolve_slice_value(*value), - None => array_id, - } - } - - /// Resolves a ValueId representing a slice's contents to its previous value. - /// If there is no resolved parent value it means we have the original slice value - /// and the value which was passed to the method is returned. - fn resolve_slice_parent(&self, array_id: ValueId) -> ValueId { - match self.slice_parents.get(&array_id) { - Some(value) => self.resolve_slice_parent(*value), - None => array_id, - } - } -} - -#[cfg(test)] -mod tests { - - use std::rc::Rc; - - use acvm::FieldElement; - use im::vector; - - use crate::ssa::{ - function_builder::FunctionBuilder, - ir::{ - dfg::DataFlowGraph, - function::RuntimeType, - instruction::{BinaryOp, Instruction}, - map::Id, - types::Type, - value::ValueId, - }, - }; - - #[test] - fn test_simple_nested_slice() { - // We want to test that a nested slice with two internal slices of primitive types - // fills the smaller internal slice with dummy data to match the length of the - // larger internal slice. - - // Note that slices are a represented by a tuple of (length, contents). - // The type of the nested slice in this test is [[Field]]. - // - // This is the original SSA: - // acir fn main f0 { - // b0(v0: Field): - // v2 = lt v0, Field 2 - // constrain v2 == Field 1 'Index out of bounds' - // v11 = array_get [[Field 3, [Field 1, Field 1, Field 1]], [Field 4, [Field 2, Field 2, Field 2, Field 2]]], index Field v0 - // constrain v11 == Field 4 - // return - // } - - let main_id = Id::test_new(0); - let mut builder = FunctionBuilder::new("main".into(), main_id, RuntimeType::Acir); - - let main_v0 = builder.add_parameter(Type::field()); - - let two = builder.field_constant(2_u128); - // Every slice access checks against the dynamic slice length - let slice_access_check = builder.insert_binary(main_v0, BinaryOp::Lt, two); - let one = builder.field_constant(1_u128); - builder.insert_constrain(slice_access_check, one, Some("Index out of bounds".to_owned())); - - let field_element_type = Rc::new(vec![Type::field()]); - let inner_slice_contents_type = Type::Slice(field_element_type); - - let inner_slice_small_len = builder.field_constant(3_u128); - let inner_slice_small_contents = - builder.array_constant(vector![one, one, one], inner_slice_contents_type.clone()); - - let inner_slice_big_len = builder.field_constant(4_u128); - let inner_slice_big_contents = - builder.array_constant(vector![two, two, two, two], inner_slice_contents_type.clone()); - - let outer_slice_element_type = Rc::new(vec![Type::field(), inner_slice_contents_type]); - let outer_slice_type = Type::Slice(outer_slice_element_type); - - let outer_slice_contents = builder.array_constant( - vector![ - inner_slice_small_len, - inner_slice_small_contents, - inner_slice_big_len, - inner_slice_big_contents - ], - outer_slice_type, - ); - // Fetching the length of the second nested slice - // We must use a parameter to main as we do not want the array operation to be simplified out during SSA gen. The filling of internal slices - // is necessary for dynamic nested slices and thus we want to generate the SSA that ACIR gen would be converting. - let array_get_res = builder.insert_array_get(outer_slice_contents, main_v0, Type::field()); - - let four = builder.field_constant(4_u128); - builder.insert_constrain(array_get_res, four, None); - builder.terminate_with_return(vec![]); - - // Note that now the smaller internal slice should have extra dummy data that matches the larger internal slice's size. - // - // Expected SSA: - // acir fn main f0 { - // b0(v0: Field): - // v10 = lt v0, Field 2 - // constrain v10 == Field 1 'Index out of bounds' - // v18 = array_get [Field 3, [Field 1, Field 1, Field 1, Field 0], Field 4, [Field 2, Field 2, Field 2, Field 2]], index v0 - // constrain v18 == Field 4 - // return - // } - - let ssa = builder.finish().fill_internal_slices(); - - let func = ssa.main(); - let block_id = func.entry_block(); - - // Check the array get expression has replaced its nested slice with a new slice - // where the internal slice has dummy data attached to it. - let instructions = func.dfg[block_id].instructions(); - let array_id = instructions - .iter() - .find_map(|instruction| { - if let Instruction::ArrayGet { array, .. } = func.dfg[*instruction] { - Some(array) - } else { - None - } - }) - .expect("Should find array_get instruction"); - - let (array_constant, _) = - func.dfg.get_array_constant(array_id).expect("should have an array constant"); - - let inner_slice_small_len = func - .dfg - .get_numeric_constant(array_constant[0]) - .expect("should have a numeric constant"); - assert_eq!( - inner_slice_small_len, - FieldElement::from(3u128), - "The length of the smaller internal slice should be unchanged" - ); - - let (inner_slice_small_contents, _) = - func.dfg.get_array_constant(array_constant[1]).expect("should have an array constant"); - let small_capacity = inner_slice_small_contents.len(); - assert_eq!(small_capacity, 4, "The inner slice contents should contain dummy element"); - - compare_array_constants(&inner_slice_small_contents, &[1, 1, 1, 0], &func.dfg); - - let inner_slice_big_len = func - .dfg - .get_numeric_constant(array_constant[2]) - .expect("should have a numeric constant"); - assert_eq!( - inner_slice_big_len, - FieldElement::from(4u128), - "The length of the larger internal slice should be unchanged" - ); - - let (inner_slice_big_contents, _) = - func.dfg.get_array_constant(array_constant[3]).expect("should have an array constant"); - let big_capacity = inner_slice_big_contents.len(); - assert_eq!( - small_capacity, big_capacity, - "The length of both internal slice contents should be the same" - ); - - compare_array_constants(&inner_slice_big_contents, &[2u128; 4], &func.dfg); - } - - fn compare_array_constants( - got_list: &im::Vector, - expected_list: &[u128], - dfg: &DataFlowGraph, - ) { - for i in 0..got_list.len() { - let got_value = - dfg.get_numeric_constant(got_list[i]).expect("should have a numeric constant"); - assert_eq!( - got_value, - FieldElement::from(expected_list[i]), - "Value is different than expected" - ); - } - } -} diff --git a/noir/compiler/noirc_evaluator/src/ssa/opt/mod.rs b/noir/compiler/noirc_evaluator/src/ssa/opt/mod.rs index 95784194d284..71725422a7a9 100644 --- a/noir/compiler/noirc_evaluator/src/ssa/opt/mod.rs +++ b/noir/compiler/noirc_evaluator/src/ssa/opt/mod.rs @@ -5,10 +5,10 @@ //! Generally, these passes are also expected to minimize the final amount of instructions. mod array_use; mod assert_constant; +mod bubble_up_constrains; mod constant_folding; mod defunctionalize; mod die; -mod fill_internal_slices; pub(crate) mod flatten_cfg; mod inlining; mod mem2reg; diff --git a/noir/compiler/noirc_evaluator/src/ssa/ssa_gen/context.rs b/noir/compiler/noirc_evaluator/src/ssa/ssa_gen/context.rs index f1a2154d3a89..0e155776545e 100644 --- a/noir/compiler/noirc_evaluator/src/ssa/ssa_gen/context.rs +++ b/noir/compiler/noirc_evaluator/src/ssa/ssa_gen/context.rs @@ -270,11 +270,12 @@ impl<'a> FunctionContext<'a> { /// helper function which add instructions to the block computing the absolute value of the /// given signed integer input. When the input is negative, we return its two complement, and itself when it is positive. fn absolute_value_helper(&mut self, input: ValueId, sign: ValueId, bit_size: u32) -> ValueId { + assert_eq!(self.builder.type_of_value(sign), Type::bool()); + // We compute the absolute value of lhs - let one = self.builder.numeric_constant(FieldElement::one(), Type::bool()); let bit_width = self.builder.numeric_constant(FieldElement::from(2_i128.pow(bit_size)), Type::field()); - let sign_not = self.builder.insert_binary(one, BinaryOp::Sub, sign); + let sign_not = self.builder.insert_not(sign); // We use unsafe casts here, this is fine as we're casting to a `field` type. let as_field = self.builder.insert_cast(input, Type::field()); @@ -472,7 +473,6 @@ impl<'a> FunctionContext<'a> { location: Location, ) { let is_sub = operator == BinaryOpKind::Subtract; - let one = self.builder.numeric_constant(FieldElement::one(), Type::bool()); let half_width = self.builder.numeric_constant( FieldElement::from(2_i128.pow(bit_size - 1)), Type::unsigned(bit_size), @@ -484,7 +484,7 @@ impl<'a> FunctionContext<'a> { let mut rhs_sign = self.builder.insert_binary(rhs_as_unsigned, BinaryOp::Lt, half_width); let message = if is_sub { // lhs - rhs = lhs + (-rhs) - rhs_sign = self.builder.insert_binary(one, BinaryOp::Sub, rhs_sign); + rhs_sign = self.builder.insert_not(rhs_sign); "attempt to subtract with overflow".to_string() } else { "attempt to add with overflow".to_string() @@ -518,13 +518,15 @@ impl<'a> FunctionContext<'a> { let product = self.builder.insert_cast(product_field, Type::unsigned(bit_size)); // Then we check the signed product fits in a signed integer of bit_size-bits - let not_same = self.builder.insert_binary(one, BinaryOp::Sub, same_sign); + let not_same = self.builder.insert_not(same_sign); let not_same_sign_field = self.insert_safe_cast(not_same, Type::unsigned(bit_size), location); let positive_maximum_with_offset = self.builder.insert_binary(half_width, BinaryOp::Add, not_same_sign_field); let product_overflow_check = self.builder.insert_binary(product, BinaryOp::Lt, positive_maximum_with_offset); + + let one = self.builder.numeric_constant(FieldElement::one(), Type::bool()); self.builder.set_location(location).insert_constrain( product_overflow_check, one, diff --git a/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs b/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs index f0fc482cae0c..c768ea96f8f3 100644 --- a/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs +++ b/noir/compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs @@ -491,7 +491,7 @@ pub(crate) fn check_methods_signatures( } // We also need to bind the traits generics to the trait's generics on the impl - for ((_, generic), binding) in the_trait.generics.iter().zip(trait_generics) { + for (generic, binding) in the_trait.generics.iter().zip(trait_generics) { generic.bind(binding); } @@ -599,7 +599,7 @@ pub(crate) fn check_methods_signatures( the_trait.set_methods(trait_methods); the_trait.self_type_typevar.unbind(the_trait.self_type_typevar_id); - for (old_id, generic) in &the_trait.generics { - generic.unbind(*old_id); + for generic in &the_trait.generics { + generic.unbind(generic.id()); } } diff --git a/noir/compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs b/noir/compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs index 2e6eb3992ff4..3cd60c33b8b0 100644 --- a/noir/compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs +++ b/noir/compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs @@ -20,7 +20,7 @@ use super::{ }, errors::{DefCollectorErrorKind, DuplicateType}, }; -use crate::hir::def_map::{parse_file, LocalModuleId, ModuleData, ModuleId}; +use crate::hir::def_map::{LocalModuleId, ModuleData, ModuleId}; use crate::hir::resolution::import::ImportDirective; use crate::hir::Context; @@ -555,7 +555,7 @@ impl<'a> ModCollector<'a> { context.visited_files.insert(child_file_id, location); // Parse the AST for the module we just found and then recursively look for it's defs - let (ast, parsing_errors) = parse_file(&context.file_manager, child_file_id); + let (ast, parsing_errors) = context.parsed_file_results(child_file_id); let ast = ast.into_sorted(); errors.extend( diff --git a/noir/compiler/noirc_frontend/src/hir/def_map/mod.rs b/noir/compiler/noirc_frontend/src/hir/def_map/mod.rs index d60ceffa9af0..8c985e88e0b5 100644 --- a/noir/compiler/noirc_frontend/src/hir/def_map/mod.rs +++ b/noir/compiler/noirc_frontend/src/hir/def_map/mod.rs @@ -87,7 +87,7 @@ impl CrateDefMap { // First parse the root file. let root_file_id = context.crate_graph[crate_id].root_file_id; - let (ast, parsing_errors) = parse_file(&context.file_manager, root_file_id); + let (ast, parsing_errors) = context.parsed_file_results(root_file_id); let mut ast = ast.into_sorted(); for macro_processor in ¯o_processors { diff --git a/noir/compiler/noirc_frontend/src/hir/mod.rs b/noir/compiler/noirc_frontend/src/hir/mod.rs index c62f357167f0..2124b5281f4f 100644 --- a/noir/compiler/noirc_frontend/src/hir/mod.rs +++ b/noir/compiler/noirc_frontend/src/hir/mod.rs @@ -7,18 +7,22 @@ pub mod type_check; use crate::graph::{CrateGraph, CrateId}; use crate::hir_def::function::FuncMeta; use crate::node_interner::{FuncId, NodeInterner, StructId}; +use crate::parser::ParserError; +use crate::ParsedModule; use def_map::{Contract, CrateDefMap}; use fm::FileManager; use noirc_errors::Location; use std::borrow::Cow; -use std::collections::BTreeMap; +use std::collections::{BTreeMap, HashMap}; use self::def_map::TestFunction; +pub type ParsedFiles = HashMap)>; + /// Helper object which groups together several useful context objects used /// during name resolution. Once name resolution is finished, only the /// def_interner is required for type inference and monomorphization. -pub struct Context<'file_manager> { +pub struct Context<'file_manager, 'parsed_files> { pub def_interner: NodeInterner, pub crate_graph: CrateGraph, pub(crate) def_maps: BTreeMap, @@ -30,6 +34,11 @@ pub struct Context<'file_manager> { /// A map of each file that already has been visited from a prior `mod foo;` declaration. /// This is used to issue an error if a second `mod foo;` is declared to the same file. pub visited_files: BTreeMap, + + // A map of all parsed files. + // Same as the file manager, we take ownership of the parsed files in the WASM context. + // Parsed files is also read only. + pub parsed_files: Cow<'parsed_files, ParsedFiles>, } #[derive(Debug, Copy, Clone)] @@ -39,27 +48,36 @@ pub enum FunctionNameMatch<'a> { Contains(&'a str), } -impl Context<'_> { - pub fn new(file_manager: FileManager) -> Context<'static> { +impl Context<'_, '_> { + pub fn new(file_manager: FileManager, parsed_files: ParsedFiles) -> Context<'static, 'static> { Context { def_interner: NodeInterner::default(), def_maps: BTreeMap::new(), visited_files: BTreeMap::new(), crate_graph: CrateGraph::default(), file_manager: Cow::Owned(file_manager), + parsed_files: Cow::Owned(parsed_files), } } - pub fn from_ref_file_manager(file_manager: &FileManager) -> Context<'_> { + pub fn from_ref_file_manager<'file_manager, 'parsed_files>( + file_manager: &'file_manager FileManager, + parsed_files: &'parsed_files ParsedFiles, + ) -> Context<'file_manager, 'parsed_files> { Context { def_interner: NodeInterner::default(), def_maps: BTreeMap::new(), visited_files: BTreeMap::new(), crate_graph: CrateGraph::default(), file_manager: Cow::Borrowed(file_manager), + parsed_files: Cow::Borrowed(parsed_files), } } + pub fn parsed_file_results(&self, file_id: fm::FileId) -> (ParsedModule, Vec) { + self.parsed_files.get(&file_id).expect("noir file wasn't parsed").clone() + } + /// Returns the CrateDefMap for a given CrateId. /// It is perfectly valid for the compiler to look /// up a CrateDefMap and it is not available. diff --git a/noir/compiler/noirc_frontend/src/hir/resolution/resolver.rs b/noir/compiler/noirc_frontend/src/hir/resolution/resolver.rs index bb7acf1037b1..1d4f60ffd516 100644 --- a/noir/compiler/noirc_frontend/src/hir/resolution/resolver.rs +++ b/noir/compiler/noirc_frontend/src/hir/resolution/resolver.rs @@ -39,7 +39,7 @@ use crate::{ use crate::{ ArrayLiteral, ContractFunctionType, Distinctness, ForRange, FunctionDefinition, FunctionReturnType, FunctionVisibility, Generics, LValue, NoirStruct, NoirTypeAlias, Param, - Path, PathKind, Pattern, Shared, StructType, Type, TypeAliasType, TypeBinding, TypeVariable, + Path, PathKind, Pattern, Shared, StructType, Type, TypeAliasType, TypeVariable, TypeVariableKind, UnaryOp, UnresolvedGenerics, UnresolvedTraitConstraint, UnresolvedType, UnresolvedTypeData, UnresolvedTypeExpression, Visibility, ERROR_IDENT, }; @@ -558,6 +558,10 @@ impl<'a> Resolver<'a> { let result = self.interner.get_type_alias(id).get_type(&args); + // Collecting Type Alias references [Location]s to be used by LSP in order + // to resolve the definition of the type alias + self.interner.add_type_alias_ref(id, Location::new(span, self.file)); + // Because there is no ordering to when type aliases (and other globals) are resolved, // it is possible for one to refer to an Error type and issue no error if it is set // equal to another type alias. Fixing this fully requires an analysis to create a DFG @@ -643,7 +647,7 @@ impl<'a> Resolver<'a> { None => { let id = self.interner.next_type_variable_id(); let typevar = TypeVariable::unbound(id); - new_variables.push((id, typevar.clone())); + new_variables.push(typevar.clone()); // 'Named'Generic is a bit of a misnomer here, we want a type variable that // wont be bound over but this one has no name since we do not currently @@ -773,7 +777,7 @@ impl<'a> Resolver<'a> { self.generics.push((name, typevar.clone(), span)); } - (id, typevar) + typevar }) } @@ -783,7 +787,7 @@ impl<'a> Resolver<'a> { pub fn add_existing_generics(&mut self, names: &UnresolvedGenerics, generics: &Generics) { assert_eq!(names.len(), generics.len()); - for (name, (_id, typevar)) in names.iter().zip(generics) { + for (name, typevar) in names.iter().zip(generics) { self.add_existing_generic(&name.0.contents, name.0.span(), typevar.clone()); } } @@ -851,14 +855,7 @@ impl<'a> Resolver<'a> { let attributes = func.attributes().clone(); - let mut generics = - vecmap(self.generics.clone(), |(name, typevar, _)| match &*typevar.borrow() { - TypeBinding::Unbound(id) => (*id, typevar.clone()), - TypeBinding::Bound(binding) => { - unreachable!("Expected {} to be unbound, but it is bound to {}", name, binding) - } - }); - + let mut generics = vecmap(&self.generics, |(_, typevar, _)| typevar.clone()); let mut parameters = vec![]; let mut parameter_types = vec![]; diff --git a/noir/compiler/noirc_frontend/src/hir/resolution/traits.rs b/noir/compiler/noirc_frontend/src/hir/resolution/traits.rs index f08d9c50c847..8f966be312ba 100644 --- a/noir/compiler/noirc_frontend/src/hir/resolution/traits.rs +++ b/noir/compiler/noirc_frontend/src/hir/resolution/traits.rs @@ -18,7 +18,7 @@ use crate::{ }, hir_def::traits::{TraitConstant, TraitFunction, TraitImpl, TraitType}, node_interner::{FuncId, NodeInterner, TraitId}, - Generics, Path, Shared, TraitItem, Type, TypeBinding, TypeVariable, TypeVariableKind, + Generics, Path, Shared, TraitItem, Type, TypeVariable, TypeVariableKind, }; use super::{ @@ -42,8 +42,7 @@ pub(crate) fn resolve_traits( for (trait_id, unresolved_trait) in traits { let generics = vecmap(&unresolved_trait.trait_def.generics, |_| { - let id = context.def_interner.next_type_variable_id(); - (id, TypeVariable::unbound(id)) + TypeVariable::unbound(context.def_interner.next_type_variable_id()) }); // Resolve order @@ -142,17 +141,7 @@ fn resolve_trait_methods( let arguments = vecmap(parameters, |param| resolver.resolve_type(param.1.clone())); let return_type = resolver.resolve_type(return_type.get_type().into_owned()); - let generics = - vecmap(resolver.get_generics(), |(_, type_var, _)| match &*type_var.borrow() { - TypeBinding::Unbound(id) => (*id, type_var.clone()), - TypeBinding::Bound(binding) => { - unreachable!("Trait generic was bound to {binding}") - } - }); - - // Ensure the trait is generic over the Self type as well - // let the_trait = resolver.interner.get_trait(trait_id); - // generics.push((the_trait.self_type_typevar_id, the_trait.self_type_typevar.clone())); + let generics = vecmap(resolver.get_generics(), |(_, type_var, _)| type_var.clone()); let default_impl_list: Vec<_> = unresolved_trait .fns_with_default_impl @@ -465,8 +454,7 @@ pub(crate) fn resolve_trait_impls( methods: vecmap(&impl_methods, |(_, func_id)| *func_id), }); - let impl_generics = - vecmap(impl_generics, |(_, type_variable, _)| (type_variable.id(), type_variable)); + let impl_generics = vecmap(impl_generics, |(_, type_variable, _)| type_variable); if let Err((prev_span, prev_file)) = interner.add_trait_implementation( self_type.clone(), diff --git a/noir/compiler/noirc_frontend/src/hir/type_check/expr.rs b/noir/compiler/noirc_frontend/src/hir/type_check/expr.rs index b583959bfb1a..58cf4e7b289f 100644 --- a/noir/compiler/noirc_frontend/src/hir/type_check/expr.rs +++ b/noir/compiler/noirc_frontend/src/hir/type_check/expr.rs @@ -595,7 +595,7 @@ impl<'interner> TypeChecker<'interner> { .generics .iter() .zip(generics) - .map(|((id, var), arg)| (*id, (var.clone(), arg))) + .map(|(var, arg)| (var.id(), (var.clone(), arg))) .collect(); (method.typ.clone(), method.arguments().len(), generic_bindings) diff --git a/noir/compiler/noirc_frontend/src/hir_def/traits.rs b/noir/compiler/noirc_frontend/src/hir_def/traits.rs index 85c292ac5f3b..16b9899039f9 100644 --- a/noir/compiler/noirc_frontend/src/hir_def/traits.rs +++ b/noir/compiler/noirc_frontend/src/hir_def/traits.rs @@ -147,7 +147,7 @@ impl TraitFunction { } } - pub fn generics(&self) -> &[(TypeVariableId, TypeVariable)] { + pub fn generics(&self) -> &[TypeVariable] { match &self.typ { Type::Function(..) => &[], Type::Forall(generics, _) => generics, diff --git a/noir/compiler/noirc_frontend/src/hir_def/types.rs b/noir/compiler/noirc_frontend/src/hir_def/types.rs index f59341e5b1ca..8979d60c0055 100644 --- a/noir/compiler/noirc_frontend/src/hir_def/types.rs +++ b/noir/compiler/noirc_frontend/src/hir_def/types.rs @@ -207,11 +207,8 @@ pub struct StructType { pub location: Location, } -/// Corresponds to generic lists such as `` in the source -/// program. The `TypeVariableId` portion is used to match two -/// type variables to check for equality, while the `TypeVariable` is -/// the actual part that can be mutated to bind it to another type. -pub type Generics = Vec<(TypeVariableId, TypeVariable)>; +/// Corresponds to generic lists such as `` in the source program. +pub type Generics = Vec; impl std::hash::Hash for StructType { fn hash(&self, state: &mut H) { @@ -260,7 +257,7 @@ impl StructType { .generics .iter() .zip(generic_args) - .map(|((old_id, old_var), new)| (*old_id, (old_var.clone(), new.clone()))) + .map(|(old, new)| (old.id(), (old.clone(), new.clone()))) .collect(); (typ.substitute(&substitutions), i) @@ -276,7 +273,7 @@ impl StructType { .generics .iter() .zip(generic_args) - .map(|((old_id, old_var), new)| (*old_id, (old_var.clone(), new.clone()))) + .map(|(old, new)| (old.id(), (old.clone(), new.clone()))) .collect(); vecmap(&self.fields, |(name, typ)| { @@ -317,7 +314,7 @@ pub struct TypeAliasType { pub id: TypeAliasId, pub typ: Type, pub generics: Generics, - pub span: Span, + pub location: Location, } impl std::hash::Hash for TypeAliasType { @@ -337,7 +334,7 @@ impl std::fmt::Display for TypeAliasType { write!(f, "{}", self.name)?; if !self.generics.is_empty() { - let generics = vecmap(&self.generics, |(_, binding)| binding.borrow().to_string()); + let generics = vecmap(&self.generics, |binding| binding.borrow().to_string()); write!(f, "{}", generics.join(", "))?; } @@ -349,11 +346,11 @@ impl TypeAliasType { pub fn new( id: TypeAliasId, name: Ident, - span: Span, + location: Location, typ: Type, generics: Generics, ) -> TypeAliasType { - TypeAliasType { id, typ, name, span, generics } + TypeAliasType { id, typ, name, location, generics } } pub fn set_type_and_generics(&mut self, new_typ: Type, new_generics: Generics) { @@ -369,7 +366,7 @@ impl TypeAliasType { .generics .iter() .zip(generic_args) - .map(|((old_id, old_var), new)| (*old_id, (old_var.clone(), new.clone()))) + .map(|(old, new)| (old.id(), (old.clone(), new.clone()))) .collect(); self.typ.substitute(&substitutions) @@ -707,7 +704,7 @@ impl Type { /// Takes a monomorphic type and generalizes it over each of the type variables in the /// given type bindings, ignoring what each type variable is bound to in the TypeBindings. pub(crate) fn generalize_from_substitutions(self, type_bindings: TypeBindings) -> Type { - let polymorphic_type_vars = vecmap(type_bindings, |(id, (type_var, _))| (id, type_var)); + let polymorphic_type_vars = vecmap(type_bindings, |(_, (type_var, _))| type_var); Type::Forall(polymorphic_type_vars, Box::new(self)) } @@ -801,7 +798,7 @@ impl std::fmt::Display for Type { }, Type::Constant(x) => x.fmt(f), Type::Forall(typevars, typ) => { - let typevars = vecmap(typevars, |(var, _)| var.to_string()); + let typevars = vecmap(typevars, |var| var.id().to_string()); write!(f, "forall {}. {}", typevars.join(" "), typ) } Type::Function(args, ret, env) => { @@ -1307,9 +1304,9 @@ impl Type { ) -> (Type, TypeBindings) { match self { Type::Forall(typevars, typ) => { - for (id, var) in typevars { + for var in typevars { bindings - .entry(*id) + .entry(var.id()) .or_insert_with(|| (var.clone(), interner.next_type_variable())); } @@ -1328,9 +1325,9 @@ impl Type { Type::Forall(typevars, typ) => { let replacements = typevars .iter() - .map(|(id, var)| { + .map(|var| { let new = interner.next_type_variable(); - (*id, (var.clone(), new)) + (var.id(), (var.clone(), new)) }) .collect(); @@ -1428,8 +1425,8 @@ impl Type { Type::Forall(typevars, typ) => { // Trying to substitute_helper a variable de, substitute_bound_typevarsfined within a nested Forall // is usually impossible and indicative of an error in the type checker somewhere. - for (var, _) in typevars { - assert!(!type_bindings.contains_key(var)); + for var in typevars { + assert!(!type_bindings.contains_key(&var.id())); } let typ = Box::new(typ.substitute_helper(type_bindings, substitute_bound_typevars)); Type::Forall(typevars.clone(), typ) @@ -1476,7 +1473,7 @@ impl Type { } } Type::Forall(typevars, typ) => { - !typevars.iter().any(|(id, _)| *id == target_id) && typ.occurs(target_id) + !typevars.iter().any(|var| var.id() == target_id) && typ.occurs(target_id) } Type::Function(args, ret, env) => { args.iter().any(|arg| arg.occurs(target_id)) @@ -1549,7 +1546,7 @@ impl Type { } pub fn from_generics(generics: &Generics) -> Vec { - vecmap(generics, |(_, var)| Type::TypeVariable(var.clone(), TypeVariableKind::Normal)) + vecmap(generics, |var| Type::TypeVariable(var.clone(), TypeVariableKind::Normal)) } } @@ -1620,7 +1617,7 @@ impl From<&Type> for PrintableType { match value { Type::FieldElement => PrintableType::Field, Type::Array(size, typ) => { - let length = size.evaluate_to_u64().expect("Cannot print variable sized arrays"); + let length = size.evaluate_to_u64(); let typ = typ.as_ref(); PrintableType::Array { length, typ: Box::new(typ.into()) } } @@ -1641,7 +1638,7 @@ impl From<&Type> for PrintableType { } Type::FmtString(_, _) => unreachable!("format strings cannot be printed"), Type::Error => unreachable!(), - Type::Unit => unreachable!(), + Type::Unit => PrintableType::Unit, Type::Constant(_) => unreachable!(), Type::Struct(def, ref args) => { let struct_type = def.borrow(); @@ -1649,13 +1646,17 @@ impl From<&Type> for PrintableType { let fields = vecmap(fields, |(name, typ)| (name, typ.into())); PrintableType::Struct { fields, name: struct_type.name.to_string() } } - Type::TraitAsType(..) => unreachable!(), - Type::Tuple(_) => todo!("printing tuple types is not yet implemented"), + Type::TraitAsType(_, _, _) => unreachable!(), + Type::Tuple(types) => PrintableType::Tuple { types: vecmap(types, |typ| typ.into()) }, Type::TypeVariable(_, _) => unreachable!(), Type::NamedGeneric(..) => unreachable!(), Type::Forall(..) => unreachable!(), - Type::Function(_, _, _) => unreachable!(), - Type::MutableReference(_) => unreachable!("cannot print &mut"), + Type::Function(_, _, env) => { + PrintableType::Function { env: Box::new(env.as_ref().into()) } + } + Type::MutableReference(typ) => { + PrintableType::MutableReference { typ: Box::new(typ.as_ref().into()) } + } Type::NotConstant => unreachable!(), } } diff --git a/noir/compiler/noirc_frontend/src/monomorphization/mod.rs b/noir/compiler/noirc_frontend/src/monomorphization/mod.rs index ac11e00ad201..67b246a02ce0 100644 --- a/noir/compiler/noirc_frontend/src/monomorphization/mod.rs +++ b/noir/compiler/noirc_frontend/src/monomorphization/mod.rs @@ -27,7 +27,7 @@ use crate::{ node_interner::{self, DefinitionKind, NodeInterner, StmtId, TraitImplKind, TraitMethodId}, token::FunctionAttribute, ContractFunctionType, FunctionKind, Type, TypeBinding, TypeBindings, TypeVariable, - TypeVariableId, TypeVariableKind, UnaryOp, Visibility, + TypeVariableKind, UnaryOp, Visibility, }; use self::ast::{Definition, FuncId, Function, LocalId, Program}; @@ -1029,11 +1029,16 @@ impl<'interner> Monomorphizer<'interner> { } fn append_printable_type_info_inner(typ: &Type, arguments: &mut Vec) { + // Disallow printing slices and mutable references for consistency, + // since they cannot be passed from ACIR into Brillig if let HirType::Array(size, _) = typ { if let HirType::NotConstant = **size { unreachable!("println does not support slices. Convert the slice to an array before passing it to println"); } + } else if matches!(typ, HirType::MutableReference(_)) { + unreachable!("println does not support mutable references."); } + let printable_type: PrintableType = typ.into(); let abi_as_string = serde_json::to_string(&printable_type) .expect("ICE: expected PrintableType to serialize"); @@ -1533,8 +1538,8 @@ impl<'interner> Monomorphizer<'interner> { let (generics, impl_method_type) = self.interner.function_meta(&impl_method).typ.unwrap_forall(); - let replace_type_variable = |(id, var): &(TypeVariableId, TypeVariable)| { - (*id, (var.clone(), Type::TypeVariable(var.clone(), TypeVariableKind::Normal))) + let replace_type_variable = |var: &TypeVariable| { + (var.id(), (var.clone(), Type::TypeVariable(var.clone(), TypeVariableKind::Normal))) }; // Replace each NamedGeneric with a TypeVariable containing the same internal type variable diff --git a/noir/compiler/noirc_frontend/src/node_interner.rs b/noir/compiler/noirc_frontend/src/node_interner.rs index 173bac958771..e734161e360e 100644 --- a/noir/compiler/noirc_frontend/src/node_interner.rs +++ b/noir/compiler/noirc_frontend/src/node_interner.rs @@ -78,7 +78,7 @@ pub struct NodeInterner { // // Map type aliases to the actual type. // When resolving types, check against this map to see if a type alias is defined. - type_aliases: Vec, + pub(crate) type_aliases: Vec, // Trait map. // @@ -142,6 +142,10 @@ pub struct NodeInterner { // For trait implementation functions, this is their self type and trait they belong to func_id_to_trait: HashMap, + + /// A list of all type aliases that are referenced in the program. + /// Searched by LSP to resolve [Location]s of [TypeAliasType]s + pub(crate) type_alias_ref: Vec<(TypeAliasId, Location)>, } /// A trait implementation is either a normal implementation that is present in the source @@ -450,6 +454,7 @@ impl Default for NodeInterner { globals: HashMap::new(), struct_methods: HashMap::new(), primitive_methods: HashMap::new(), + type_alias_ref: Vec::new(), }; // An empty block expression is used often, we add this into the `node` on startup @@ -499,8 +504,7 @@ impl NodeInterner { // This lets us record how many arguments the type expects so that other types // can refer to it with generic arguments before the generic parameters themselves // are resolved. - let id = TypeVariableId(0); - (id, TypeVariable::unbound(id)) + TypeVariable::unbound(TypeVariableId(0)) }), self_type_typevar_id, self_type_typevar: TypeVariable::unbound(self_type_typevar_id), @@ -530,8 +534,7 @@ impl NodeInterner { // This lets us record how many arguments the type expects so that other types // can refer to it with generic arguments before the generic parameters themselves // are resolved. - let id = TypeVariableId(0); - (id, TypeVariable::unbound(id)) + TypeVariable::unbound(TypeVariableId(0)) }); let location = Location::new(typ.struct_def.span, file_id); @@ -547,17 +550,19 @@ impl NodeInterner { self.type_aliases.push(TypeAliasType::new( type_id, typ.type_alias_def.name.clone(), - typ.type_alias_def.span, + Location::new(typ.type_alias_def.span, typ.file_id), Type::Error, - vecmap(&typ.type_alias_def.generics, |_| { - let id = TypeVariableId(0); - (id, TypeVariable::unbound(id)) - }), + vecmap(&typ.type_alias_def.generics, |_| TypeVariable::unbound(TypeVariableId(0))), )); type_id } + /// Adds [TypeLiasId] and [Location] to the type_alias_ref vector + /// So that we can later resolve [Location]s type aliases from the LSP requests + pub fn add_type_alias_ref(&mut self, type_id: TypeAliasId, location: Location) { + self.type_alias_ref.push((type_id, location)); + } pub fn update_struct(&mut self, type_id: StructId, f: impl FnOnce(&mut StructType)) { let mut value = self.structs.get_mut(&type_id).unwrap().borrow_mut(); f(&mut value); @@ -1195,19 +1200,18 @@ impl NodeInterner { self.trait_implementations.push(trait_impl.clone()); - // Ignoring overlapping TraitImplKind::Assumed impls here is perfectly fine. - // It should never happen since impls are defined at global scope, but even - // if they were, we should never prevent defining a new impl because a where - // clause already assumes it exists. - // Replace each generic with a fresh type variable let substitutions = impl_generics .into_iter() - .map(|(id, typevar)| (id, (typevar, self.next_type_variable()))) + .map(|typevar| (typevar.id(), (typevar, self.next_type_variable()))) .collect(); let instantiated_object_type = object_type.substitute(&substitutions); + // Ignoring overlapping `TraitImplKind::Assumed` impls here is perfectly fine. + // It should never happen since impls are defined at global scope, but even + // if they were, we should never prevent defining a new impl because a 'where' + // clause already assumes it exists. if let Ok((TraitImplKind::Normal(existing), _)) = self.try_lookup_trait_implementation( &instantiated_object_type, trait_id, diff --git a/noir/compiler/noirc_frontend/src/resolve_locations.rs b/noir/compiler/noirc_frontend/src/resolve_locations.rs index 95ced906984e..02325de4da82 100644 --- a/noir/compiler/noirc_frontend/src/resolve_locations.rs +++ b/noir/compiler/noirc_frontend/src/resolve_locations.rs @@ -33,17 +33,22 @@ impl NodeInterner { /// Returns the [Location] of the definition of the given Ident found at [Span] of the given [FileId]. /// Returns [None] when definition is not found. - pub fn get_definition_location_from(&self, location: Location) -> Option { + pub fn get_definition_location_from( + &self, + location: Location, + return_type_location_instead: bool, + ) -> Option { self.find_location_index(location) - .and_then(|index| self.resolve_location(index)) + .and_then(|index| self.resolve_location(index, return_type_location_instead)) .or_else(|| self.try_resolve_trait_impl_location(location)) .or_else(|| self.try_resolve_trait_method_declaration(location)) + .or_else(|| self.try_resolve_type_alias(location)) } pub fn get_declaration_location_from(&self, location: Location) -> Option { self.try_resolve_trait_method_declaration(location).or_else(|| { self.find_location_index(location) - .and_then(|index| self.resolve_location(index)) + .and_then(|index| self.resolve_location(index, false)) .and_then(|found_impl_location| { self.try_resolve_trait_method_declaration(found_impl_location) }) @@ -53,12 +58,31 @@ impl NodeInterner { /// For a given [Index] we return [Location] to which we resolved to /// We currently return None for features not yet implemented /// TODO(#3659): LSP goto def should error when Ident at Location could not resolve - fn resolve_location(&self, index: impl Into) -> Option { + fn resolve_location( + &self, + index: impl Into, + return_type_location_instead: bool, + ) -> Option { + if return_type_location_instead { + return self.get_type_location_from_index(index); + } + let node = self.nodes.get(index.into())?; match node { - Node::Function(func) => self.resolve_location(func.as_expr()), - Node::Expression(expression) => self.resolve_expression_location(expression), + Node::Function(func) => { + self.resolve_location(func.as_expr(), return_type_location_instead) + } + Node::Expression(expression) => { + self.resolve_expression_location(expression, return_type_location_instead) + } + _ => None, + } + } + + fn get_type_location_from_index(&self, index: impl Into) -> Option { + match self.id_type(index.into()) { + Type::Struct(struct_type, _) => Some(struct_type.borrow().location), _ => None, } } @@ -66,7 +90,11 @@ impl NodeInterner { /// Resolves the [Location] of the definition for a given [HirExpression] /// /// Note: current the code returns None because some expressions are not yet implemented. - fn resolve_expression_location(&self, expression: &HirExpression) -> Option { + fn resolve_expression_location( + &self, + expression: &HirExpression, + return_type_location_instead: bool, + ) -> Option { match expression { HirExpression::Ident(ident) => { let definition_info = self.definition(ident.id); @@ -88,7 +116,7 @@ impl NodeInterner { } HirExpression::Call(expr_call) => { let func = expr_call.func; - self.resolve_location(func) + self.resolve_location(func, return_type_location_instead) } _ => None, @@ -167,4 +195,12 @@ impl NodeInterner { method.map(|method| method.location) }) } + + #[tracing::instrument(skip(self), ret)] + fn try_resolve_type_alias(&self, location: Location) -> Option { + self.type_alias_ref + .iter() + .find(|(_, named_type_location)| named_type_location.span.contains(&location.span)) + .map(|(type_alias_id, _found_location)| self.get_type_alias(*type_alias_id).location) + } } diff --git a/noir/compiler/noirc_frontend/src/tests.rs b/noir/compiler/noirc_frontend/src/tests.rs index a56c3a7755f6..9ccbddab9eca 100644 --- a/noir/compiler/noirc_frontend/src/tests.rs +++ b/noir/compiler/noirc_frontend/src/tests.rs @@ -52,7 +52,7 @@ mod test { ) -> (ParsedModule, Context, Vec<(CompilationError, FileId)>) { let root = std::path::Path::new("/"); let fm = FileManager::new(root); - let mut context = Context::new(fm); + let mut context = Context::new(fm, Default::default()); context.def_interner.populate_dummy_operator_traits(); let root_file_id = FileId::dummy(); let root_crate_id = context.crate_graph.add_crate_root(root_file_id); diff --git a/noir/compiler/noirc_printable_type/src/lib.rs b/noir/compiler/noirc_printable_type/src/lib.rs index 273e2d512ea8..18f2fe0a873e 100644 --- a/noir/compiler/noirc_printable_type/src/lib.rs +++ b/noir/compiler/noirc_printable_type/src/lib.rs @@ -11,10 +11,13 @@ use thiserror::Error; pub enum PrintableType { Field, Array { - length: u64, + length: Option, #[serde(rename = "type")] typ: Box, }, + Tuple { + types: Vec, + }, SignedInteger { width: u32, }, @@ -29,23 +32,13 @@ pub enum PrintableType { String { length: u64, }, -} - -impl PrintableType { - /// Returns the number of field elements required to represent the type once encoded. - fn field_count(&self) -> u32 { - match self { - Self::Field - | Self::SignedInteger { .. } - | Self::UnsignedInteger { .. } - | Self::Boolean => 1, - Self::Array { length, typ } => typ.field_count() * (*length as u32), - Self::Struct { fields, .. } => { - fields.iter().fold(0, |acc, (_, field_type)| acc + field_type.field_count()) - } - Self::String { length } => *length as u32, - } - } + Function { + env: Box, + }, + MutableReference { + typ: Box, + }, + Unit, } /// This is what all formats eventually transform into @@ -114,43 +107,26 @@ fn convert_string_inputs( fn convert_fmt_string_inputs( foreign_call_inputs: &[ForeignCallParam], ) -> Result { - let (message, input_and_printable_values) = + let (message, input_and_printable_types) = foreign_call_inputs.split_first().ok_or(ForeignCallError::MissingForeignCallInputs)?; let message_as_fields = vecmap(message.values(), |value| value.to_field()); let message_as_string = decode_string_value(&message_as_fields); - let (num_values, input_and_printable_values) = input_and_printable_values + let (num_values, input_and_printable_types) = input_and_printable_types .split_first() .ok_or(ForeignCallError::MissingForeignCallInputs)?; let mut output = Vec::new(); let num_values = num_values.unwrap_value().to_field().to_u128() as usize; - for (i, printable_value) in input_and_printable_values + let types_start_at = input_and_printable_types.len() - num_values; + let mut input_iter = input_and_printable_types[0..types_start_at] .iter() - .skip(input_and_printable_values.len() - num_values) - .enumerate() - { - let printable_type = fetch_printable_type(printable_value)?; - let type_size = printable_type.field_count() as usize; - let value = match printable_type { - PrintableType::Array { .. } | PrintableType::String { .. } => { - // Arrays and strings are represented in a single value vector rather than multiple separate input values - let mut input_values_as_fields = input_and_printable_values[i] - .values() - .into_iter() - .map(|value| value.to_field()); - decode_value(&mut input_values_as_fields, &printable_type) - } - _ => { - // We must use a flat map here as each value in a struct will be in a separate input value - let mut input_values_as_fields = input_and_printable_values[i..(i + type_size)] - .iter() - .flat_map(|param| vecmap(param.values(), |value| value.to_field())); - decode_value(&mut input_values_as_fields, &printable_type) - } - }; + .flat_map(|param| vecmap(param.values(), |value| value.to_field())); + for printable_type in input_and_printable_types.iter().skip(types_start_at) { + let printable_type = fetch_printable_type(printable_type)?; + let value = decode_value(&mut input_iter, &printable_type); output.push((value, printable_type)); } @@ -196,6 +172,12 @@ fn to_string(value: &PrintableValue, typ: &PrintableType) -> Option { output.push_str("false"); } } + (PrintableValue::Field(_), PrintableType::Function { .. }) => { + output.push_str("<>"); + } + (_, PrintableType::MutableReference { .. }) => { + output.push_str("<>"); + } (PrintableValue::Vec(vector), PrintableType::Array { typ, .. }) => { output.push('['); let mut values = vector.iter().peekable(); @@ -233,6 +215,22 @@ fn to_string(value: &PrintableValue, typ: &PrintableType) -> Option { output.push_str(" }"); } + (PrintableValue::Vec(values), PrintableType::Tuple { types }) => { + output.push('('); + let mut elems = values.iter().zip(types).peekable(); + while let Some((value, typ)) = elems.next() { + output.push_str( + &PrintableValueDisplay::Plain(value.clone(), typ.clone()).to_string(), + ); + if elems.peek().is_some() { + output.push_str(", "); + } + } + output.push(')'); + } + + (_, PrintableType::Unit) => output.push_str("()"), + _ => return None, }; @@ -308,7 +306,19 @@ fn decode_value( PrintableValue::Field(field_element) } - PrintableType::Array { length, typ } => { + PrintableType::Array { length: None, typ } => { + let length = field_iterator + .next() + .expect("not enough data to decode variable array length") + .to_u128() as usize; + let mut array_elements = Vec::with_capacity(length); + for _ in 0..length { + array_elements.push(decode_value(field_iterator, typ)); + } + + PrintableValue::Vec(array_elements) + } + PrintableType::Array { length: Some(length), typ } => { let length = *length as usize; let mut array_elements = Vec::with_capacity(length); for _ in 0..length { @@ -317,6 +327,9 @@ fn decode_value( PrintableValue::Vec(array_elements) } + PrintableType::Tuple { types } => { + PrintableValue::Vec(vecmap(types, |typ| decode_value(field_iterator, typ))) + } PrintableType::String { length } => { let field_elements: Vec = field_iterator.take(*length as usize).collect(); @@ -333,6 +346,18 @@ fn decode_value( PrintableValue::Struct(struct_map) } + PrintableType::Function { env } => { + let field_element = field_iterator.next().unwrap(); + let func_ref = PrintableValue::Field(field_element); + // we want to consume the fields from the environment, but for now they are not actually printed + decode_value(field_iterator, env); + func_ref + } + PrintableType::MutableReference { typ } => { + // we decode the reference, but it's not really used for printing + decode_value(field_iterator, typ) + } + PrintableType::Unit => PrintableValue::Field(FieldElement::zero()), } } diff --git a/noir/compiler/wasm/package.json b/noir/compiler/wasm/package.json index 412e9c82f9a5..2aaf4a494df6 100644 --- a/noir/compiler/wasm/package.json +++ b/noir/compiler/wasm/package.json @@ -3,7 +3,7 @@ "contributors": [ "The Noir Team " ], - "version": "0.22.0", + "version": "0.23.0", "license": "(MIT OR Apache-2.0)", "main": "dist/main.js", "types": "./dist/types/src/index.d.cts", diff --git a/noir/compiler/wasm/src/compile.rs b/noir/compiler/wasm/src/compile.rs index 351f9ae8a86c..498ffe447cef 100644 --- a/noir/compiler/wasm/src/compile.rs +++ b/noir/compiler/wasm/src/compile.rs @@ -13,7 +13,7 @@ use noirc_driver::{ use noirc_evaluator::errors::SsaReport; use noirc_frontend::{ graph::{CrateId, CrateName}, - hir::Context, + hir::{def_map::parse_file, Context, ParsedFiles}, }; use serde::Deserialize; use std::{collections::HashMap, path::Path}; @@ -140,6 +140,10 @@ impl PathToFileSourceMap { } } +pub(crate) fn parse_all(fm: &FileManager) -> ParsedFiles { + fm.as_file_map().all_file_ids().map(|&file_id| (file_id, parse_file(fm, file_id))).collect() +} + pub enum CompileResult { Contract { contract: ContractArtifact, warnings: Vec }, Program { program: ProgramArtifact, warnings: Vec }, @@ -162,8 +166,8 @@ pub fn compile( }; let fm = file_manager_with_source_map(file_source_map); - - let mut context = Context::new(fm); + let parsed_files = parse_all(&fm); + let mut context = Context::new(fm, parsed_files); let path = Path::new(&entry_point); let crate_id = prepare_crate(&mut context, path); @@ -291,15 +295,18 @@ mod test { use crate::compile::PathToFileSourceMap; - use super::{file_manager_with_source_map, process_dependency_graph, DependencyGraph}; + use super::{ + file_manager_with_source_map, parse_all, process_dependency_graph, DependencyGraph, + }; use std::{collections::HashMap, path::Path}; - fn setup_test_context(source_map: PathToFileSourceMap) -> Context<'static> { + fn setup_test_context(source_map: PathToFileSourceMap) -> Context<'static, 'static> { let mut fm = file_manager_with_source_map(source_map); // Add this due to us calling prepare_crate on "/main.nr" below fm.add_file_with_source(Path::new("/main.nr"), "fn foo() {}".to_string()); + let parsed_files = parse_all(&fm); - let mut context = Context::new(fm); + let mut context = Context::new(fm, parsed_files); prepare_crate(&mut context, Path::new("/main.nr")); context diff --git a/noir/compiler/wasm/src/compile_new.rs b/noir/compiler/wasm/src/compile_new.rs index 3cb20bd0b5c9..6476f6d29bc9 100644 --- a/noir/compiler/wasm/src/compile_new.rs +++ b/noir/compiler/wasm/src/compile_new.rs @@ -1,5 +1,5 @@ use crate::compile::{ - file_manager_with_source_map, generate_contract_artifact, generate_program_artifact, + file_manager_with_source_map, generate_contract_artifact, generate_program_artifact, parse_all, JsCompileResult, PathToFileSourceMap, }; use crate::errors::{CompileError, JsCompileError}; @@ -20,7 +20,7 @@ use wasm_bindgen::prelude::wasm_bindgen; pub struct CompilerContext { // `wasm_bindgen` currently doesn't allow lifetime parameters on structs so we must use a `'static` lifetime. // `Context` must then own the `FileManager` to satisfy this lifetime. - context: Context<'static>, + context: Context<'static, 'static>, } #[wasm_bindgen(js_name = "CrateId")] @@ -34,7 +34,9 @@ impl CompilerContext { console_error_panic_hook::set_once(); let fm = file_manager_with_source_map(source_map); - CompilerContext { context: Context::new(fm) } + let parsed_files = parse_all(&fm); + + CompilerContext { context: Context::new(fm, parsed_files) } } #[cfg(test)] @@ -231,7 +233,7 @@ mod test { use noirc_driver::prepare_crate; use noirc_frontend::hir::Context; - use crate::compile::{file_manager_with_source_map, PathToFileSourceMap}; + use crate::compile::{file_manager_with_source_map, parse_all, PathToFileSourceMap}; use std::path::Path; @@ -241,8 +243,9 @@ mod test { let mut fm = file_manager_with_source_map(source_map); // Add this due to us calling prepare_crate on "/main.nr" below fm.add_file_with_source(Path::new("/main.nr"), "fn foo() {}".to_string()); + let parsed_files = parse_all(&fm); - let mut context = Context::new(fm); + let mut context = Context::new(fm, parsed_files); prepare_crate(&mut context, Path::new("/main.nr")); CompilerContext { context } diff --git a/noir/docs/versioned_docs/version-v0.22.0/explainers/explainer-oracle.md b/noir/docs/versioned_docs/version-v0.22.0/explainers/explainer-oracle.md deleted file mode 100644 index 76dd0e36d6c8..000000000000 --- a/noir/docs/versioned_docs/version-v0.22.0/explainers/explainer-oracle.md +++ /dev/null @@ -1,57 +0,0 @@ ---- -title: Oracles -description: This guide provides an in-depth understanding of how Oracles work in Noir programming. Learn how to use outside calculations in your programs, constrain oracles, and understand their uses and limitations. -keywords: - - Noir Programming - - Oracles - - JSON-RPC - - Foreign Call Handlers - - Constrained Functions - - Blockchain Programming -sidebar_position: 1 ---- - -If you've seen "The Matrix" you may recall "The Oracle" as Gloria Foster smoking cigarettes and baking cookies. While she appears to "know things", she is actually providing a calculation of a pre-determined future. Noir Oracles are similar, in a way. They don't calculate the future (yet), but they allow you to use outside calculations in your programs. - -![matrix oracle prediction](@site/static/img/memes/matrix_oracle.jpeg) - -A Noir program is usually self-contained. You can pass certain inputs to it, and it will generate a deterministic output for those inputs. But what if you wanted to defer some calculation to an outside process or source? - -Oracles are functions that provide this feature. - -## Use cases - -An example usage for Oracles is proving something on-chain. For example, proving that the ETH-USDC quote was below a certain target at a certain block time. Or even making more complex proofs like proving the ownership of an NFT as an anonymous login method. - -Another interesting use case is to defer expensive calculations to be made outside of the Noir program, and then constraining the result; similar to the use of [unconstrained functions](../noir/syntax/unconstrained.md). - -In short, anything that can be constrained in a Noir program but needs to be fetched from an external source is a great candidate to be used in oracles. - -## Constraining oracles - -Just like in The Matrix, Oracles are powerful. But with great power, comes great responsibility. Just because you're using them in a Noir program doesn't mean they're true. Noir has no superpowers. If you want to prove that Portugal won the Euro Cup 2016, you're still relying on potentially untrusted information. - -To give a concrete example, Alice wants to login to the [NounsDAO](https://nouns.wtf/) forum with her username "noir_nouner" by proving she owns a noun without revealing her ethereum address. Her Noir program could have a oracle call like this: - -```rust -#[oracle(getNoun)] -unconstrained fn get_noun(address: Field) -> Field -``` - -This oracle could naively resolve with the number of Nouns she possesses. However, it is useless as a trusted source, as the oracle could resolve to anything Alice wants. In order to make this oracle call actually useful, Alice would need to constrain the response from the oracle, by proving her address and the noun count belongs to the state tree of the contract. - -In short, **Oracles don't prove anything. Your Noir program does.** - -:::danger - -If you don't constrain the return of your oracle, you could be clearly opening an attack vector on your Noir program. Make double-triple sure that the return of an oracle call is constrained! - -::: - -## How to use Oracles - -On CLI, Nargo resolves oracles by making JSON RPC calls, which means it would require an RPC node to be running. - -In JavaScript, NoirJS accepts and resolves arbitrary call handlers (that is, not limited to JSON) as long as they matches the expected types the developer defines. Refer to [Foreign Call Handler](../reference/NoirJS/noir_js/type-aliases/ForeignCallHandler.md) to learn more about NoirJS's call handling. - -If you want to build using oracles, follow through to the [oracle guide](../how_to/how-to-oracles.md) for a simple example on how to do that. diff --git a/noir/docs/versioned_docs/version-v0.22.0/how_to/how-to-oracles.md b/noir/docs/versioned_docs/version-v0.22.0/how_to/how-to-oracles.md deleted file mode 100644 index 61cabe586e6b..000000000000 --- a/noir/docs/versioned_docs/version-v0.22.0/how_to/how-to-oracles.md +++ /dev/null @@ -1,280 +0,0 @@ ---- -title: How to use Oracles -description: Learn how to use oracles in your Noir program with examples in both Nargo and NoirJS. This guide also covers writing a JSON RPC server and providing custom foreign call handlers for NoirJS. -keywords: - - Noir Programming - - Oracles - - Nargo - - NoirJS - - JSON RPC Server - - Foreign Call Handlers -sidebar_position: 1 ---- - -This guide shows you how to use oracles in your Noir program. For the sake of clarity, it assumes that: - -- You have read the [explainer on Oracles](../explainers/explainer-oracle.md) and are comfortable with the concept. -- You have a Noir program to add oracles to. You can create one using the [vite-hardhat starter](https://github.com/noir-lang/noir-starter/tree/main/vite-hardhat) as a boilerplate. -- You understand the concept of a JSON-RPC server. Visit the [JSON-RPC website](https://www.jsonrpc.org/) if you need a refresher. -- You are comfortable with server-side JavaScript (e.g. Node.js, managing packages, etc.). - -For reference, you can find the snippets used in this tutorial on the [Aztec DevRel Repository](https://github.com/AztecProtocol/dev-rel/tree/main/how_to_oracles/code-snippets/how-to-oracles). - -## Rundown - -This guide has 3 major steps: - -1. How to modify our Noir program to make use of oracle calls as unconstrained functions -2. How to write a JSON RPC Server to resolve these oracle calls with Nargo -3. How to use them in Nargo and how to provide a custom resolver in NoirJS - -## Step 1 - Modify your Noir program - -An oracle is defined in a Noir program by defining two methods: - -- An unconstrained method - This tells the compiler that it is executing an [unconstrained functions](../noir/syntax/unconstrained.md). -- A decorated oracle method - This tells the compiler that this method is an RPC call. - -An example of an oracle that returns a `Field` would be: - -```rust -#[oracle(getSqrt)] -unconstrained fn sqrt(number: Field) -> Field { } - -unconstrained fn get_sqrt(number: Field) -> Field { - sqrt(number) -} -``` - -In this example, we're wrapping our oracle function in a unconstrained method, and decorating it with `oracle(getSqrt)`. We can then call the unconstrained function as we would call any other function: - -```rust -fn main(input: Field) { - let sqrt = get_sqrt(input); -} -``` - -In the next section, we will make this `getSqrt` (defined on the `sqrt` decorator) be a method of the RPC server Noir will use. - -:::danger - -As explained in the [Oracle Explainer](../explainers/explainer-oracle.md), this `main` function is unsafe unless you constrain its return value. For example: - -```rust -fn main(input: Field) { - let sqrt = get_sqrt(input); - assert(sqrt[0].pow_32(2) as u64 == input as u64); // <---- constrain the return of an oracle! -} -``` - -::: - -:::info - -Currently, oracles only work with single params or array params. For example: - -```rust -#[oracle(getSqrt)] -unconstrained fn sqrt([Field; 2]) -> [Field; 2] { } -``` - -::: - -## Step 2 - Write an RPC server - -Brillig will call *one* RPC server. Most likely you will have to write your own, and you can do it in whatever language you prefer. In this guide, we will do it in Javascript. - -Let's use the above example of an oracle that consumes an array with two `Field` and returns their square roots: - -```rust -#[oracle(getSqrt)] -unconstrained fn sqrt(input: [Field; 2]) -> [Field; 2] { } - -unconstrained fn get_sqrt(input: [Field; 2]) -> [Field; 2] { - sqrt(input) -} - -fn main(input: [Field; 2]) { - let sqrt = get_sqrt(input); - assert(sqrt[0].pow_32(2) as u64 == input[0] as u64); - assert(sqrt[1].pow_32(2) as u64 == input[1] as u64); -} -``` - -:::info - -Why square root? - -In general, computing square roots is computationally more expensive than multiplications, which takes a toll when speaking about ZK applications. In this case, instead of calculating the square root in Noir, we are using our oracle to offload that computation to be made in plain. In our circuit we can simply multiply the two values. - -::: - -Now, we should write the correspondent RPC server, starting with the [default JSON-RPC 2.0 boilerplate](https://www.npmjs.com/package/json-rpc-2.0#example): - -```js -import { JSONRPCServer } from "json-rpc-2.0"; -import express from "express"; -import bodyParser from "body-parser"; - -const app = express(); -app.use(bodyParser.json()); - -const server = new JSONRPCServer(); -app.post("/", (req, res) => { - const jsonRPCRequest = req.body; - server.receive(jsonRPCRequest).then((jsonRPCResponse) => { - if (jsonRPCResponse) { - res.json(jsonRPCResponse); - } else { - res.sendStatus(204); - } - }); -}); - -app.listen(5555); -``` - -Now, we will add our `getSqrt` method, as expected by the `#[oracle(getSqrt)]` decorator in our Noir code. It maps through the params array and returns their square roots: - -```js -server.addMethod("getSqrt", async (params) => { - const values = params[0].Array.map(({ inner }) => { - return { inner: `${Math.sqrt(parseInt(inner, 16))}` }; - }); - return { values: [{ Array: values }] }; -}); -``` - -:::tip - -Brillig expects an object with an array of values. Each value is an object declaring to be `Single` or `Array` and returning a `inner` property *as a string*. For example: - -```json -{ "values": [{ "Array": [{ "inner": "1" }, { "inner": "2"}]}]} -{ "values": [{ "Single": { "inner": "1" }}]} -{ "values": [{ "Single": { "inner": "1" }}, { "Array": [{ "inner": "1", { "inner": "2" }}]}]} -``` - -If you're using Typescript, the following types may be helpful in understanding the expected return value and making sure they're easy to follow: - -```js -interface Value { - inner: string, -} - -interface SingleForeignCallParam { - Single: Value, -} - -interface ArrayForeignCallParam { - Array: Value[], -} - -type ForeignCallParam = SingleForeignCallParam | ArrayForeignCallParam; - -interface ForeignCallResult { - values: ForeignCallParam[], -} -``` - -::: - -## Step 3 - Usage with Nargo - -Using the [`nargo` CLI tool](../getting_started/installation/index.md), you can use oracles in the `nargo test`, `nargo execute` and `nargo prove` commands by passing a value to `--oracle-resolver`. For example: - -```bash -nargo test --oracle-resolver http://localhost:5555 -``` - -This tells `nargo` to use your RPC Server URL whenever it finds an oracle decorator. - -## Step 4 - Usage with NoirJS - -In a JS environment, an RPC server is not strictly necessary, as you may want to resolve your oracles without needing any JSON call at all. NoirJS simply expects that you pass a callback function when you generate proofs, and that callback function can be anything. - -For example, if your Noir program expects the host machine to provide CPU pseudo-randomness, you could simply pass it as the `foreignCallHandler`. You don't strictly need to create an RPC server to serve pseudo-randomness, as you may as well get it directly in your app: - -```js -const foreignCallHandler = (name, inputs) => crypto.randomBytes(16) // etc - -await noir.generateFinalProof(inputs, foreignCallHandler) -``` - -As one can see, in NoirJS, the [`foreignCallHandler`](../reference/NoirJS/noir_js/type-aliases/ForeignCallHandler.md) function simply means "a callback function that returns a value of type [`ForeignCallOutput`](../reference/NoirJS/noir_js/type-aliases/ForeignCallOutput.md). It doesn't have to be an RPC call like in the case for Nargo. - -:::tip - -Does this mean you don't have to write an RPC server like in [Step #2](#step-2---write-an-rpc-server)? - -You don't technically have to, but then how would you run `nargo test` or `nargo prove`? To use both `Nargo` and `NoirJS` in your development flow, you will have to write a JSON RPC server. - -::: - -In this case, let's make `foreignCallHandler` call the JSON RPC Server we created in [Step #2](#step-2---write-an-rpc-server), by making it a JSON RPC Client. - -For example, using the same `getSqrt` program in [Step #1](#step-1---modify-your-noir-program) (comments in the code): - -```js -import { JSONRPCClient } from "json-rpc-2.0"; - -// declaring the JSONRPCClient -const client = new JSONRPCClient((jsonRPCRequest) => { -// hitting the same JSON RPC Server we coded above - return fetch("http://localhost:5555", { - method: "POST", - headers: { - "content-type": "application/json", - }, - body: JSON.stringify(jsonRPCRequest), - }).then((response) => { - if (response.status === 200) { - return response - .json() - .then((jsonRPCResponse) => client.receive(jsonRPCResponse)); - } else if (jsonRPCRequest.id !== undefined) { - return Promise.reject(new Error(response.statusText)); - } - }); -}); - -// declaring a function that takes the name of the foreign call (getSqrt) and the inputs -const foreignCallHandler = async (name, input) => { - // notice that the "inputs" parameter contains *all* the inputs - // in this case we to make the RPC request with the first parameter "numbers", which would be input[0] - const oracleReturn = await client.request(name, [ - { Array: input[0].map((i) => ({ inner: i.toString("hex") })) }, - ]); - return [oracleReturn.values[0].Array.map((x) => x.inner)]; -}; - -// the rest of your NoirJS code -const input = { input: [4, 16] }; -const { witness } = await noir.execute(numbers, foreignCallHandler); -``` - -:::tip - -If you're in a NoirJS environment running your RPC server together with a frontend app, you'll probably hit a familiar problem in full-stack development: requests being blocked by [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) policy. For development only, you can simply install and use the [`cors` npm package](https://www.npmjs.com/package/cors) to get around the problem: - -```bash -yarn add cors -``` - -and use it as a middleware: - -```js -import cors from "cors"; - -const app = express(); -app.use(cors()) -``` - -::: - -## Conclusion - -Hopefully by the end of this guide, you should be able to: - -- Write your own logic around Oracles and how to write a JSON RPC server to make them work with your Nargo commands. -- Provide custom foreign call handlers for NoirJS. diff --git a/noir/docs/versioned_docs/version-v0.22.0/noir/syntax/oracles.md b/noir/docs/versioned_docs/version-v0.22.0/noir/syntax/oracles.md deleted file mode 100644 index 2e6a6818d48c..000000000000 --- a/noir/docs/versioned_docs/version-v0.22.0/noir/syntax/oracles.md +++ /dev/null @@ -1,23 +0,0 @@ ---- -title: Oracles -description: Dive into how Noir supports Oracles via RPC calls, and learn how to declare an Oracle in Noir with our comprehensive guide. -keywords: - - Noir - - Oracles - - RPC Calls - - Unconstrained Functions - - Programming - - Blockchain -sidebar_position: 6 ---- - -Noir has support for Oracles via RPC calls. This means Noir will make an RPC call and use the return value for proof generation. - -Since Oracles are not resolved by Noir, they are [`unconstrained` functions](./unconstrained.md) - -You can declare an Oracle through the `#[oracle()]` flag. Example: - -```rust -#[oracle(get_number_sequence)] -unconstrained fn get_number_sequence(_size: Field) -> [Field] {} -``` diff --git a/noir/flake.nix b/noir/flake.nix index 2300d0091147..6849dc0a0ada 100644 --- a/noir/flake.nix +++ b/noir/flake.nix @@ -73,7 +73,7 @@ # Configuration shared between builds config = { # x-release-please-start-version - version = "0.22.0"; + version = "0.23.0"; # x-release-please-end src = pkgs.lib.cleanSourceWith { diff --git a/noir/test_programs/execution_success/bit_and/Prover.toml b/noir/test_programs/execution_success/bit_and/Prover.toml index 40ce2b0bc273..34a5b63e5b16 100644 --- a/noir/test_programs/execution_success/bit_and/Prover.toml +++ b/noir/test_programs/execution_success/bit_and/Prover.toml @@ -1,2 +1,4 @@ x = "0x00" y = "0x10" +a = "0x00" +b = "0x10" diff --git a/noir/test_programs/execution_success/bit_and/src/main.nr b/noir/test_programs/execution_success/bit_and/src/main.nr index 0bc1d9a49bde..5a0aa17e3ede 100644 --- a/noir/test_programs/execution_success/bit_and/src/main.nr +++ b/noir/test_programs/execution_success/bit_and/src/main.nr @@ -1,6 +1,6 @@ // You can only do bit operations with integers. // (Kobi/Daira/Circom/#37) https://github.com/iden3/circom/issues/37 -fn main(x: Field, y: Field) { +fn main(x: Field, y: Field, a: Field, b: Field) { let x_as_u8 = x as u8; let y_as_u8 = y as u8; @@ -9,8 +9,8 @@ fn main(x: Field, y: Field) { let flag = (x == 0) & (y == 16); assert(flag); //bitwise and with odd bits: - let x_as_u11 = x as u11; - let y_as_u11 = y as u11; - assert((x_as_u11 & y_as_u11) == x_as_u11); + let a_as_u8 = a as u8; + let b_as_u8 = b as u8; + assert((a_as_u8 & b_as_u8) == a_as_u8); } diff --git a/noir/test_programs/execution_success/debug_logs/src/main.nr b/noir/test_programs/execution_success/debug_logs/src/main.nr index 6accdf725d92..52c910065c17 100644 --- a/noir/test_programs/execution_success/debug_logs/src/main.nr +++ b/noir/test_programs/execution_success/debug_logs/src/main.nr @@ -39,7 +39,26 @@ fn main(x: Field, y: pub Field) { let struct_string = if x != 5 { f"{foo}" } else { f"{bar}" }; std::println(struct_string); + let one_tuple = (1, 2, 3); + let another_tuple = (4, 5, 6); + std::println(f"one_tuple: {one_tuple}, another_tuple: {another_tuple}"); + std::println(one_tuple); + + let tuples_nested = (one_tuple, another_tuple); + std::println(f"tuples_nested: {tuples_nested}"); + std::println(tuples_nested); + regression_2906(); + + let free_lambda = |x| x + 1; + let sentinel: u32 = 8888; + std::println(f"free_lambda: {free_lambda}, sentinel: {sentinel}"); + std::println(free_lambda); + + let one = 1; + let closured_lambda = |x| x + one; + std::println(f"closured_lambda: {closured_lambda}, sentinel: {sentinel}"); + std::println(closured_lambda); } fn string_identity(string: fmtstr<14, (Field, Field)>) -> fmtstr<14, (Field, Field)> { @@ -79,3 +98,4 @@ fn regression_2906() { dep::std::println(f"array_five_vals: {array_five_vals}, label_five_vals: {label_five_vals}"); } + diff --git a/noir/test_programs/execution_success/nested_slice_dynamic/Nargo.toml b/noir/test_programs/execution_success/nested_array_in_slice/Nargo.toml similarity index 62% rename from noir/test_programs/execution_success/nested_slice_dynamic/Nargo.toml rename to noir/test_programs/execution_success/nested_array_in_slice/Nargo.toml index c8925ed97b4d..4f0748f79be3 100644 --- a/noir/test_programs/execution_success/nested_slice_dynamic/Nargo.toml +++ b/noir/test_programs/execution_success/nested_array_in_slice/Nargo.toml @@ -1,5 +1,5 @@ [package] -name = "nested_slice_dynamic" +name = "nested_array_in_slice" type = "bin" authors = [""] [dependencies] \ No newline at end of file diff --git a/noir/test_programs/execution_success/nested_slice_dynamic/Prover.toml b/noir/test_programs/execution_success/nested_array_in_slice/Prover.toml similarity index 100% rename from noir/test_programs/execution_success/nested_slice_dynamic/Prover.toml rename to noir/test_programs/execution_success/nested_array_in_slice/Prover.toml diff --git a/noir/test_programs/execution_success/nested_slice_dynamic/src/main.nr b/noir/test_programs/execution_success/nested_array_in_slice/src/main.nr similarity index 100% rename from noir/test_programs/execution_success/nested_slice_dynamic/src/main.nr rename to noir/test_programs/execution_success/nested_array_in_slice/src/main.nr diff --git a/noir/tooling/backend_interface/test-binaries/mock_backend/Cargo.lock b/noir/tooling/backend_interface/test-binaries/mock_backend/Cargo.lock index c43d1b849153..3c14a9369070 100644 --- a/noir/tooling/backend_interface/test-binaries/mock_backend/Cargo.lock +++ b/noir/tooling/backend_interface/test-binaries/mock_backend/Cargo.lock @@ -4,81 +4,67 @@ version = 3 [[package]] name = "anstream" -version = "0.3.2" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +checksum = "6e2e1ebcb11de5c03c67de28a7df593d32191b44939c482e97702baaaa6ab6a5" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", - "is-terminal", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.1" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" +checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" [[package]] name = "anstyle-parse" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" dependencies = [ "windows-sys", ] [[package]] name = "anstyle-wincon" -version = "1.0.1" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" dependencies = [ "anstyle", "windows-sys", ] -[[package]] -name = "bitflags" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" - -[[package]] -name = "cc" -version = "1.0.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" - [[package]] name = "clap" -version = "4.3.19" +version = "4.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fd304a20bff958a57f04c4e96a2e7594cc4490a0e809cbd48bb6437edaa452d" +checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c" dependencies = [ "clap_builder", "clap_derive", - "once_cell", ] [[package]] name = "clap_builder" -version = "4.3.19" +version = "4.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01c6a3f08f1fe5662a35cfe393aec09c4df95f60ee93b7556505260f75eee9e1" +checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7" dependencies = [ "anstream", "anstyle", @@ -88,9 +74,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.3.12" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54a9bb5758fc5dfe728d1019941681eccaf0cf8a4189b692a0ee2f2ecf90a050" +checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" dependencies = [ "heck", "proc-macro2", @@ -100,9 +86,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" +checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" [[package]] name = "colorchoice" @@ -110,62 +96,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" -[[package]] -name = "errno" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" -dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "heck" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" -[[package]] -name = "hermit-abi" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" - -[[package]] -name = "is-terminal" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" -dependencies = [ - "hermit-abi", - "rustix", - "windows-sys", -] - -[[package]] -name = "libc" -version = "0.2.147" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" - -[[package]] -name = "linux-raw-sys" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09fc20d2ca12cb9f044c93e3bd6d32d523e6e2ec3db4f7b2939cd99026ecd3f0" - [[package]] name = "mock_backend" version = "0.1.0" @@ -173,43 +109,24 @@ dependencies = [ "clap", ] -[[package]] -name = "once_cell" -version = "1.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" - [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.31" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fe8a65d69dd0808184ebb5f836ab526bb259db23c657efa38711b1072ee47f0" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] -[[package]] -name = "rustix" -version = "0.38.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a962918ea88d644592894bc6dc55acc6c0956488adcebbfb6e273506b7fd6e5" -dependencies = [ - "bitflags", - "errno", - "libc", - "linux-raw-sys", - "windows-sys", -] - [[package]] name = "strsim" version = "0.10.0" @@ -218,9 +135,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "2.0.26" +version = "2.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45c3457aacde3c65315de5031ec191ce46604304d2446e803d71ade03308d970" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" dependencies = [ "proc-macro2", "quote", @@ -229,9 +146,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "utf8parse" @@ -241,18 +158,18 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "windows-sys" -version = "0.48.0" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ "windows-targets", ] [[package]] name = "windows-targets" -version = "0.48.1" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -265,42 +182,42 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.0" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" [[package]] name = "windows_i686_gnu" -version = "0.48.0" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" [[package]] name = "windows_i686_msvc" -version = "0.48.0" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" [[package]] name = "windows_x86_64_gnu" -version = "0.48.0" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" diff --git a/noir/tooling/lsp/Cargo.toml b/noir/tooling/lsp/Cargo.toml index 6371bcbac192..750e85694e2d 100644 --- a/noir/tooling/lsp/Cargo.toml +++ b/noir/tooling/lsp/Cargo.toml @@ -25,6 +25,8 @@ async-lsp = { workspace = true, features = ["omni-trait"] } serde_with = "3.2.0" thiserror.workspace = true fm.workspace = true +rayon = "1.8.0" +fxhash.workspace = true [target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi")))'.dependencies] wasm-bindgen.workspace = true diff --git a/noir/tooling/lsp/src/lib.rs b/noir/tooling/lsp/src/lib.rs index 1099ad602699..b64fc474b0b4 100644 --- a/noir/tooling/lsp/src/lib.rs +++ b/noir/tooling/lsp/src/lib.rs @@ -17,16 +17,20 @@ use async_lsp::{ router::Router, AnyEvent, AnyNotification, AnyRequest, ClientSocket, Error, LspService, ResponseError, }; -use fm::codespan_files as files; +use fm::{codespan_files as files, FileManager}; +use fxhash::FxHashSet; use lsp_types::CodeLens; -use nargo::workspace::Workspace; +use nargo::{parse_all, workspace::Workspace}; use nargo_toml::{find_file_manifest, resolve_workspace_from_toml, PackageSelection}; use noirc_driver::{file_manager_with_stdlib, prepare_crate, NOIR_ARTIFACT_VERSION_STRING}; use noirc_frontend::{ graph::{CrateId, CrateName}, - hir::{Context, FunctionNameMatch}, + hir::{def_map::parse_file, Context, FunctionNameMatch, ParsedFiles}, node_interner::NodeInterner, + parser::ParserError, + ParsedModule, }; +use rayon::prelude::*; use notifications::{ on_did_change_configuration, on_did_change_text_document, on_did_close_text_document, @@ -34,7 +38,8 @@ use notifications::{ }; use requests::{ on_code_lens_request, on_formatting, on_goto_declaration_request, on_goto_definition_request, - on_initialize, on_profile_run_request, on_shutdown, on_test_run_request, on_tests_request, + on_goto_type_definition_request, on_initialize, on_profile_run_request, on_shutdown, + on_test_run_request, on_tests_request, }; use serde_json::Value as JsonValue; use thiserror::Error; @@ -64,6 +69,8 @@ pub struct LspState { input_files: HashMap, cached_lenses: HashMap>, cached_definitions: HashMap, + cached_parsed_files: HashMap))>, + parsing_cache_enabled: bool, } impl LspState { @@ -76,6 +83,8 @@ impl LspState { cached_lenses: HashMap::new(), cached_definitions: HashMap::new(), open_documents_count: 0, + cached_parsed_files: HashMap::new(), + parsing_cache_enabled: true, } } } @@ -98,6 +107,7 @@ impl NargoLspService { .request::(on_profile_run_request) .request::(on_goto_definition_request) .request::(on_goto_declaration_request) + .request::(on_goto_type_definition_request) .notification::(on_initialized) .notification::(on_did_change_configuration) .notification::(on_did_open_text_document) @@ -225,20 +235,78 @@ pub(crate) fn resolve_workspace_for_source_path(file_path: &Path) -> Result (Context<'static>, CrateId) { +fn prepare_source(source: String, state: &mut LspState) -> (Context<'static, 'static>, CrateId) { let root = Path::new(""); let file_name = Path::new("main.nr"); let mut file_manager = file_manager_with_stdlib(root); file_manager.add_file_with_source(file_name, source).expect( "Adding source buffer to file manager should never fail when file manager is empty", ); + let parsed_files = parse_diff(&file_manager, state); - let mut context = Context::new(file_manager); + let mut context = Context::new(file_manager, parsed_files); let root_crate_id = prepare_crate(&mut context, file_name); (context, root_crate_id) } +fn parse_diff(file_manager: &FileManager, state: &mut LspState) -> ParsedFiles { + if state.parsing_cache_enabled { + let noir_file_hashes: Vec<_> = file_manager + .as_file_map() + .all_file_ids() + .par_bridge() + .filter_map(|&file_id| { + let file_path = file_manager.path(file_id).expect("expected file to exist"); + let file_extension = + file_path.extension().expect("expected all file paths to have an extension"); + if file_extension == "nr" { + Some(( + file_id, + file_path.to_path_buf(), + fxhash::hash(file_manager.fetch_file(file_id).expect("file must exist")), + )) + } else { + None + } + }) + .collect(); + + let cache_hits: Vec<_> = noir_file_hashes + .par_iter() + .filter_map(|(file_id, file_path, current_hash)| { + let cached_version = state.cached_parsed_files.get(file_path); + if let Some((hash, cached_parsing)) = cached_version { + if hash == current_hash { + return Some((*file_id, cached_parsing.clone())); + } + } + None + }) + .collect(); + + let cache_hits_ids: FxHashSet<_> = cache_hits.iter().map(|(file_id, _)| *file_id).collect(); + + let cache_misses: Vec<_> = noir_file_hashes + .into_par_iter() + .filter(|(id, _, _)| !cache_hits_ids.contains(id)) + .map(|(file_id, path, hash)| (file_id, path, hash, parse_file(file_manager, file_id))) + .collect(); + + cache_misses.iter().for_each(|(_, path, hash, parse_results)| { + state.cached_parsed_files.insert(path.clone(), (*hash, parse_results.clone())); + }); + + cache_misses + .into_iter() + .map(|(id, _, _, parse_results)| (id, parse_results)) + .chain(cache_hits.into_iter()) + .collect() + } else { + parse_all(file_manager) + } +} + #[test] fn prepare_package_from_source_string() { let source = r#" @@ -249,7 +317,10 @@ fn prepare_package_from_source_string() { } "#; - let (mut context, crate_id) = crate::prepare_source(source.to_string()); + let client = ClientSocket::new_closed(); + let mut state = LspState::new(&client, acvm::blackbox_solver::StubbedBlackBoxSolver); + + let (mut context, crate_id) = crate::prepare_source(source.to_string(), &mut state); let _check_result = noirc_driver::check_crate(&mut context, crate_id, false, false); let main_func_id = context.get_main_function(&crate_id); assert!(main_func_id.is_some()); diff --git a/noir/tooling/lsp/src/notifications/mod.rs b/noir/tooling/lsp/src/notifications/mod.rs index 0cd86803efad..355bb7832c4f 100644 --- a/noir/tooling/lsp/src/notifications/mod.rs +++ b/noir/tooling/lsp/src/notifications/mod.rs @@ -13,7 +13,7 @@ use crate::types::{ }; use crate::{ - byte_span_to_range, get_package_tests_in_crate, prepare_source, + byte_span_to_range, get_package_tests_in_crate, parse_diff, prepare_source, resolve_workspace_for_source_path, LspState, }; @@ -55,7 +55,7 @@ pub(super) fn on_did_change_text_document( let text = params.content_changes.into_iter().next().unwrap().text; state.input_files.insert(params.text_document.uri.to_string(), text.clone()); - let (mut context, crate_id) = prepare_source(text); + let (mut context, crate_id) = prepare_source(text, state); let _ = check_crate(&mut context, crate_id, false, false); let workspace = match resolve_workspace_for_source_path( @@ -131,10 +131,13 @@ fn process_noir_document( let mut workspace_file_manager = file_manager_with_stdlib(&workspace.root_dir); insert_all_files_for_workspace_into_file_manager(&workspace, &mut workspace_file_manager); + let parsed_files = parse_diff(&workspace_file_manager, state); + let diagnostics: Vec<_> = workspace .into_iter() .flat_map(|package| -> Vec { - let (mut context, crate_id) = prepare_package(&workspace_file_manager, package); + let (mut context, crate_id) = + prepare_package(&workspace_file_manager, &parsed_files, package); let file_diagnostics = match check_crate(&mut context, crate_id, false, false) { Ok(((), warnings)) => warnings, diff --git a/noir/tooling/lsp/src/requests/code_lens_request.rs b/noir/tooling/lsp/src/requests/code_lens_request.rs index b16c19457f0e..893ba33d8456 100644 --- a/noir/tooling/lsp/src/requests/code_lens_request.rs +++ b/noir/tooling/lsp/src/requests/code_lens_request.rs @@ -64,7 +64,7 @@ fn on_code_lens_request_inner( let workspace = resolve_workspace_for_source_path(file_path.as_path()).unwrap(); let package = workspace.members.first().unwrap(); - let (mut context, crate_id) = prepare_source(source_string); + let (mut context, crate_id) = prepare_source(source_string, state); // We ignore the warnings and errors produced by compilation for producing code lenses // because we can still get the test functions even if compilation fails let _ = check_crate(&mut context, crate_id, false, false); diff --git a/noir/tooling/lsp/src/requests/goto_declaration.rs b/noir/tooling/lsp/src/requests/goto_declaration.rs index 6e3664804f6a..8e6d519b8959 100644 --- a/noir/tooling/lsp/src/requests/goto_declaration.rs +++ b/noir/tooling/lsp/src/requests/goto_declaration.rs @@ -1,8 +1,8 @@ use std::future::{self, Future}; -use crate::resolve_workspace_for_source_path; use crate::types::GotoDeclarationResult; use crate::LspState; +use crate::{parse_diff, resolve_workspace_for_source_path}; use async_lsp::{ErrorCode, ResponseError}; use lsp_types::request::{GotoDeclarationParams, GotoDeclarationResponse}; @@ -21,7 +21,7 @@ pub(crate) fn on_goto_declaration_request( } fn on_goto_definition_inner( - _state: &mut LspState, + state: &mut LspState, params: GotoDeclarationParams, ) -> Result { let file_path = @@ -36,11 +36,13 @@ fn on_goto_definition_inner( let mut workspace_file_manager = file_manager_with_stdlib(&workspace.root_dir); insert_all_files_for_workspace_into_file_manager(&workspace, &mut workspace_file_manager); + let parsed_files = parse_diff(&workspace_file_manager, state); - let (mut context, crate_id) = nargo::prepare_package(&workspace_file_manager, package); + let (mut context, crate_id) = + nargo::prepare_package(&workspace_file_manager, &parsed_files, package); let interner; - if let Some(def_interner) = _state.cached_definitions.get(&package_root_path) { + if let Some(def_interner) = state.cached_definitions.get(&package_root_path) { interner = def_interner; } else { // We ignore the warnings and errors produced by compilation while resolving the definition diff --git a/noir/tooling/lsp/src/requests/goto_definition.rs b/noir/tooling/lsp/src/requests/goto_definition.rs index 277bbf013f97..88bb667f2e8b 100644 --- a/noir/tooling/lsp/src/requests/goto_definition.rs +++ b/noir/tooling/lsp/src/requests/goto_definition.rs @@ -1,9 +1,10 @@ use std::future::{self, Future}; -use crate::resolve_workspace_for_source_path; +use crate::{parse_diff, resolve_workspace_for_source_path}; use crate::{types::GotoDefinitionResult, LspState}; use async_lsp::{ErrorCode, ResponseError}; +use lsp_types::request::GotoTypeDefinitionParams; use lsp_types::{GotoDefinitionParams, GotoDefinitionResponse}; use nargo::insert_all_files_for_workspace_into_file_manager; use noirc_driver::file_manager_with_stdlib; @@ -14,13 +15,22 @@ pub(crate) fn on_goto_definition_request( state: &mut LspState, params: GotoDefinitionParams, ) -> impl Future> { - let result = on_goto_definition_inner(state, params); + let result = on_goto_definition_inner(state, params, false); + future::ready(result) +} + +pub(crate) fn on_goto_type_definition_request( + state: &mut LspState, + params: GotoTypeDefinitionParams, +) -> impl Future> { + let result = on_goto_definition_inner(state, params, true); future::ready(result) } fn on_goto_definition_inner( - _state: &mut LspState, + state: &mut LspState, params: GotoDefinitionParams, + return_type_location_instead: bool, ) -> Result { let file_path = params.text_document_position_params.text_document.uri.to_file_path().map_err(|_| { @@ -34,11 +44,13 @@ fn on_goto_definition_inner( let mut workspace_file_manager = file_manager_with_stdlib(&workspace.root_dir); insert_all_files_for_workspace_into_file_manager(&workspace, &mut workspace_file_manager); + let parsed_files = parse_diff(&workspace_file_manager, state); - let (mut context, crate_id) = nargo::prepare_package(&workspace_file_manager, package); + let (mut context, crate_id) = + nargo::prepare_package(&workspace_file_manager, &parsed_files, package); let interner; - if let Some(def_interner) = _state.cached_definitions.get(&package_root_path) { + if let Some(def_interner) = state.cached_definitions.get(&package_root_path) { interner = def_interner; } else { // We ignore the warnings and errors produced by compilation while resolving the definition @@ -65,8 +77,9 @@ fn on_goto_definition_inner( span: noirc_errors::Span::single_char(byte_index as u32), }; - let goto_definition_response = - interner.get_definition_location_from(search_for_location).and_then(|found_location| { + let goto_definition_response = interner + .get_definition_location_from(search_for_location, return_type_location_instead) + .and_then(|found_location| { let file_id = found_location.file; let definition_position = to_lsp_location(files, file_id, found_location.span)?; let response: GotoDefinitionResponse = diff --git a/noir/tooling/lsp/src/requests/mod.rs b/noir/tooling/lsp/src/requests/mod.rs index 9a4738e1985c..ec56cf5045a7 100644 --- a/noir/tooling/lsp/src/requests/mod.rs +++ b/noir/tooling/lsp/src/requests/mod.rs @@ -5,7 +5,7 @@ use async_lsp::ResponseError; use fm::codespan_files::Error; use lsp_types::{ DeclarationCapability, Location, Position, TextDocumentSyncCapability, TextDocumentSyncKind, - Url, + TypeDefinitionProviderCapability, Url, }; use nargo_fmt::Config; use serde::{Deserialize, Serialize}; @@ -35,7 +35,8 @@ mod tests; pub(crate) use { code_lens_request::collect_lenses_for_package, code_lens_request::on_code_lens_request, goto_declaration::on_goto_declaration_request, goto_definition::on_goto_definition_request, - profile_run::on_profile_run_request, test_run::on_test_run_request, tests::on_tests_request, + goto_definition::on_goto_type_definition_request, profile_run::on_profile_run_request, + test_run::on_test_run_request, tests::on_tests_request, }; /// LSP client will send initialization request after the server has started. @@ -46,15 +47,25 @@ struct LspInitializationOptions { /// By default this will be set to true (enabled). #[serde(rename = "enableCodeLens", default = "default_enable_code_lens")] enable_code_lens: bool, + + #[serde(rename = "enableParsingCache", default = "default_enable_parsing_cache")] + enable_parsing_cache: bool, } fn default_enable_code_lens() -> bool { true } +fn default_enable_parsing_cache() -> bool { + true +} + impl Default for LspInitializationOptions { fn default() -> Self { - Self { enable_code_lens: default_enable_code_lens() } + Self { + enable_code_lens: default_enable_code_lens(), + enable_parsing_cache: default_enable_parsing_cache(), + } } } @@ -63,11 +74,11 @@ pub(crate) fn on_initialize( params: InitializeParams, ) -> impl Future> { state.root_path = params.root_uri.and_then(|root_uri| root_uri.to_file_path().ok()); - let initialization_options: LspInitializationOptions = params .initialization_options .and_then(|value| serde_json::from_value(value).ok()) .unwrap_or_default(); + state.parsing_cache_enabled = initialization_options.enable_parsing_cache; async move { let text_document_sync = TextDocumentSyncCapability::Kind(TextDocumentSyncKind::FULL); @@ -94,6 +105,7 @@ pub(crate) fn on_initialize( nargo: Some(nargo), definition_provider: Some(lsp_types::OneOf::Left(true)), declaration_provider: Some(DeclarationCapability::Simple(true)), + type_definition_provider: Some(TypeDefinitionProviderCapability::Simple(true)), }, server_info: None, }) diff --git a/noir/tooling/lsp/src/requests/profile_run.rs b/noir/tooling/lsp/src/requests/profile_run.rs index 6664475a68c4..8ba91338f557 100644 --- a/noir/tooling/lsp/src/requests/profile_run.rs +++ b/noir/tooling/lsp/src/requests/profile_run.rs @@ -13,6 +13,7 @@ use noirc_driver::{ use noirc_errors::{debug_info::OpCodesCount, Location}; use crate::{ + parse_diff, types::{NargoProfileRunParams, NargoProfileRunResult}, LspState, }; @@ -26,7 +27,7 @@ pub(crate) fn on_profile_run_request( } fn on_profile_run_request_inner( - state: &LspState, + state: &mut LspState, params: NargoProfileRunParams, ) -> Result { let root_path = state.root_path.as_deref().ok_or_else(|| { @@ -52,23 +53,17 @@ fn on_profile_run_request_inner( let mut workspace_file_manager = file_manager_with_stdlib(&workspace.root_dir); insert_all_files_for_workspace_into_file_manager(&workspace, &mut workspace_file_manager); + let parsed_files = parse_diff(&workspace_file_manager, state); // Since we filtered on crate name, this should be the only item in the iterator match workspace.into_iter().next() { Some(_package) => { - let (binary_packages, contract_packages): (Vec<_>, Vec<_>) = workspace - .into_iter() - .filter(|package| !package.is_library()) - .cloned() - .partition(|package| package.is_binary()); - let expression_width = ExpressionWidth::Bounded { width: 3 }; let (compiled_programs, compiled_contracts) = nargo::ops::compile_workspace( &workspace_file_manager, + &parsed_files, &workspace, - &binary_packages, - &contract_packages, expression_width, &CompileOptions::default(), ) diff --git a/noir/tooling/lsp/src/requests/test_run.rs b/noir/tooling/lsp/src/requests/test_run.rs index c2181d7839d0..135090d7ed98 100644 --- a/noir/tooling/lsp/src/requests/test_run.rs +++ b/noir/tooling/lsp/src/requests/test_run.rs @@ -13,6 +13,7 @@ use noirc_driver::{ use noirc_frontend::hir::FunctionNameMatch; use crate::{ + parse_diff, types::{NargoTestRunParams, NargoTestRunResult}, LspState, }; @@ -25,7 +26,7 @@ pub(crate) fn on_test_run_request( } fn on_test_run_request_inner( - state: &LspState, + state: &mut LspState, params: NargoTestRunParams, ) -> Result { let root_path = state.root_path.as_deref().ok_or_else(|| { @@ -52,11 +53,13 @@ fn on_test_run_request_inner( let mut workspace_file_manager = file_manager_with_stdlib(&workspace.root_dir); insert_all_files_for_workspace_into_file_manager(&workspace, &mut workspace_file_manager); + let parsed_files = parse_diff(&workspace_file_manager, state); // Since we filtered on crate name, this should be the only item in the iterator match workspace.into_iter().next() { Some(package) => { - let (mut context, crate_id) = prepare_package(&workspace_file_manager, package); + let (mut context, crate_id) = + prepare_package(&workspace_file_manager, &parsed_files, package); if check_crate(&mut context, crate_id, false, false).is_err() { let result = NargoTestRunResult { id: params.id.clone(), diff --git a/noir/tooling/lsp/src/requests/tests.rs b/noir/tooling/lsp/src/requests/tests.rs index 0f717b9fb9ee..5b78fcc65c33 100644 --- a/noir/tooling/lsp/src/requests/tests.rs +++ b/noir/tooling/lsp/src/requests/tests.rs @@ -7,7 +7,7 @@ use nargo_toml::{find_package_manifest, resolve_workspace_from_toml, PackageSele use noirc_driver::{check_crate, file_manager_with_stdlib, NOIR_ARTIFACT_VERSION_STRING}; use crate::{ - get_package_tests_in_crate, + get_package_tests_in_crate, parse_diff, types::{NargoPackageTests, NargoTestsParams, NargoTestsResult}, LspState, }; @@ -52,11 +52,13 @@ fn on_tests_request_inner( let mut workspace_file_manager = file_manager_with_stdlib(&workspace.root_dir); insert_all_files_for_workspace_into_file_manager(&workspace, &mut workspace_file_manager); + let parsed_files = parse_diff(&workspace_file_manager, state); let package_tests: Vec<_> = workspace .into_iter() .filter_map(|package| { - let (mut context, crate_id) = prepare_package(&workspace_file_manager, package); + let (mut context, crate_id) = + prepare_package(&workspace_file_manager, &parsed_files, package); // We ignore the warnings and errors produced by compilation for producing tests // because we can still get the test functions even if compilation fails let _ = check_crate(&mut context, crate_id, false, false); diff --git a/noir/tooling/lsp/src/types.rs b/noir/tooling/lsp/src/types.rs index 8dbc51ec83c5..e3492f21346d 100644 --- a/noir/tooling/lsp/src/types.rs +++ b/noir/tooling/lsp/src/types.rs @@ -1,5 +1,7 @@ use fm::FileId; -use lsp_types::{DeclarationCapability, DefinitionOptions, OneOf}; +use lsp_types::{ + DeclarationCapability, DefinitionOptions, OneOf, TypeDefinitionProviderCapability, +}; use noirc_driver::DebugFile; use noirc_errors::{debug_info::OpCodesCount, Location}; use noirc_frontend::graph::CrateName; @@ -25,7 +27,8 @@ pub(crate) mod request { // Re-providing lsp_types that we don't need to override pub(crate) use lsp_types::request::{ - CodeLensRequest as CodeLens, Formatting, GotoDeclaration, GotoDefinition, Shutdown, + CodeLensRequest as CodeLens, Formatting, GotoDeclaration, GotoDefinition, + GotoTypeDefinition, Shutdown, }; #[derive(Debug)] @@ -118,6 +121,10 @@ pub(crate) struct ServerCapabilities { #[serde(skip_serializing_if = "Option::is_none")] pub(crate) definition_provider: Option>, + /// The server provides goto type definition support. + #[serde(skip_serializing_if = "Option::is_none")] + pub(crate) type_definition_provider: Option, + /// The server provides code lens. #[serde(skip_serializing_if = "Option::is_none")] pub(crate) code_lens_provider: Option, diff --git a/noir/tooling/nargo/src/lib.rs b/noir/tooling/nargo/src/lib.rs index 62ff4325a230..0fdff8b202f8 100644 --- a/noir/tooling/nargo/src/lib.rs +++ b/noir/tooling/nargo/src/lib.rs @@ -20,9 +20,10 @@ use fm::FileManager; use noirc_driver::{add_dep, prepare_crate, prepare_dependency}; use noirc_frontend::{ graph::{CrateId, CrateName}, - hir::Context, + hir::{def_map::parse_file, Context, ParsedFiles}, }; use package::{Dependency, Package}; +use rayon::prelude::*; pub use self::errors::NargoError; @@ -95,11 +96,27 @@ fn insert_all_files_for_packages_dependencies_into_file_manager( } } -pub fn prepare_package<'file_manager>( +pub fn parse_all(file_manager: &FileManager) -> ParsedFiles { + file_manager + .as_file_map() + .all_file_ids() + .par_bridge() + .filter(|&&file_id| { + let file_path = file_manager.path(file_id).expect("expected file to exist"); + let file_extension = + file_path.extension().expect("expected all file paths to have an extension"); + file_extension == "nr" + }) + .map(|&file_id| (file_id, parse_file(file_manager, file_id))) + .collect() +} + +pub fn prepare_package<'file_manager, 'parsed_files>( file_manager: &'file_manager FileManager, + parsed_files: &'parsed_files ParsedFiles, package: &Package, -) -> (Context<'file_manager>, CrateId) { - let mut context = Context::from_ref_file_manager(file_manager); +) -> (Context<'file_manager, 'parsed_files>, CrateId) { + let mut context = Context::from_ref_file_manager(file_manager, parsed_files); let crate_id = prepare_crate(&mut context, &package.entry_path); diff --git a/noir/tooling/nargo/src/ops/compile.rs b/noir/tooling/nargo/src/ops/compile.rs index 043e2a367a5b..866bfe39d7b8 100644 --- a/noir/tooling/nargo/src/ops/compile.rs +++ b/noir/tooling/nargo/src/ops/compile.rs @@ -1,6 +1,7 @@ use acvm::ExpressionWidth; use fm::FileManager; use noirc_driver::{CompilationResult, CompileOptions, CompiledContract, CompiledProgram}; +use noirc_frontend::hir::ParsedFiles; use crate::errors::CompileError; use crate::prepare_package; @@ -15,22 +16,36 @@ use rayon::prelude::*; /// This function will return an error if there are any compilations errors reported. pub fn compile_workspace( file_manager: &FileManager, + parsed_files: &ParsedFiles, workspace: &Workspace, - binary_packages: &[Package], - contract_packages: &[Package], expression_width: ExpressionWidth, compile_options: &CompileOptions, ) -> Result<(Vec, Vec), CompileError> { + let (binary_packages, contract_packages): (Vec<_>, Vec<_>) = workspace + .into_iter() + .filter(|package| !package.is_library()) + .cloned() + .partition(|package| package.is_binary()); + // Compile all of the packages in parallel. let program_results: Vec> = binary_packages .par_iter() .map(|package| { - compile_program(file_manager, workspace, package, compile_options, expression_width) + compile_program( + file_manager, + parsed_files, + package, + compile_options, + expression_width, + None, + ) }) .collect(); let contract_results: Vec> = contract_packages .par_iter() - .map(|package| compile_contract(file_manager, package, compile_options, expression_width)) + .map(|package| { + compile_contract(file_manager, parsed_files, package, compile_options, expression_width) + }) .collect(); // Report any warnings/errors which were encountered during compilation. @@ -62,19 +77,16 @@ pub fn compile_workspace( pub fn compile_program( file_manager: &FileManager, - workspace: &Workspace, + parsed_files: &ParsedFiles, package: &Package, compile_options: &CompileOptions, expression_width: ExpressionWidth, + cached_program: Option, ) -> CompilationResult { - let (mut context, crate_id) = prepare_package(file_manager, package); - - let program_artifact_path = workspace.package_build_path(package); - let mut debug_artifact_path = program_artifact_path.clone(); - debug_artifact_path.set_file_name(format!("debug_{}.json", package.name)); + let (mut context, crate_id) = prepare_package(file_manager, parsed_files, package); let (program, warnings) = - noirc_driver::compile_main(&mut context, crate_id, compile_options, None)?; + noirc_driver::compile_main(&mut context, crate_id, compile_options, cached_program)?; // Apply backend specific optimizations. let optimized_program = crate::ops::optimize_program(program, expression_width); @@ -82,20 +94,16 @@ pub fn compile_program( Ok((optimized_program, warnings)) } -fn compile_contract( +pub fn compile_contract( file_manager: &FileManager, + parsed_files: &ParsedFiles, package: &Package, compile_options: &CompileOptions, expression_width: ExpressionWidth, ) -> CompilationResult { - let (mut context, crate_id) = prepare_package(file_manager, package); + let (mut context, crate_id) = prepare_package(file_manager, parsed_files, package); let (contract, warnings) = - match noirc_driver::compile_contract(&mut context, crate_id, compile_options) { - Ok(contracts_and_warnings) => contracts_and_warnings, - Err(errors) => { - return Err(errors); - } - }; + noirc_driver::compile_contract(&mut context, crate_id, compile_options)?; let optimized_contract = crate::ops::optimize_contract(contract, expression_width); diff --git a/noir/tooling/nargo/src/ops/mod.rs b/noir/tooling/nargo/src/ops/mod.rs index 34487ed97703..4912c84839e8 100644 --- a/noir/tooling/nargo/src/ops/mod.rs +++ b/noir/tooling/nargo/src/ops/mod.rs @@ -1,4 +1,4 @@ -pub use self::compile::{compile_program, compile_workspace}; +pub use self::compile::{compile_contract, compile_program, compile_workspace}; pub use self::execute::execute_circuit; pub use self::foreign_calls::{DefaultForeignCallExecutor, ForeignCallExecutor}; pub use self::optimize::{optimize_contract, optimize_program}; diff --git a/noir/tooling/nargo_cli/Cargo.toml b/noir/tooling/nargo_cli/Cargo.toml index 2652adaf3277..6e022f090f09 100644 --- a/noir/tooling/nargo_cli/Cargo.toml +++ b/noir/tooling/nargo_cli/Cargo.toml @@ -74,7 +74,7 @@ pprof = { version = "0.12", features = [ "criterion", ] } iai = "0.1.1" -test-binary = "3.0.1" +test-binary = "3.0.2" [[bench]] name = "criterion" diff --git a/noir/tooling/nargo_cli/build.rs b/noir/tooling/nargo_cli/build.rs index 9a0492c99adb..57aa487f66af 100644 --- a/noir/tooling/nargo_cli/build.rs +++ b/noir/tooling/nargo_cli/build.rs @@ -75,7 +75,7 @@ fn execution_success_{test_name}() {{ let mut cmd = Command::cargo_bin("nargo").unwrap(); cmd.env("NARGO_BACKEND_PATH", path_to_mock_backend()); cmd.arg("--program-dir").arg(test_program_dir); - cmd.arg("execute"); + cmd.arg("execute").arg("--force"); cmd.assert().success(); }} @@ -194,11 +194,12 @@ fn compile_success_empty_{test_name}() {{ cmd.arg("--program-dir").arg(test_program_dir); cmd.arg("info"); cmd.arg("--json"); + cmd.arg("--force"); let output = cmd.output().expect("Failed to execute command"); if !output.status.success() {{ - panic!("`nargo info` failed with: {{}}", String::from_utf8(output.stderr).unwrap()); + panic!("`nargo info` failed with: {{}}", String::from_utf8(output.stderr).unwrap_or_default()); }} // `compile_success_empty` tests should be able to compile down to an empty circuit. @@ -206,7 +207,7 @@ fn compile_success_empty_{test_name}() {{ panic!("JSON was not well-formatted {{:?}}",output.stdout) }}); let num_opcodes = &json["programs"][0]["acir_opcodes"]; - assert_eq!(num_opcodes.as_u64().unwrap(), 0); + assert_eq!(num_opcodes.as_u64().expect("number of opcodes should fit in a u64"), 0); }} "#, test_dir = test_dir.display(), @@ -242,7 +243,7 @@ fn compile_success_contract_{test_name}() {{ let mut cmd = Command::cargo_bin("nargo").unwrap(); cmd.env("NARGO_BACKEND_PATH", path_to_mock_backend()); cmd.arg("--program-dir").arg(test_program_dir); - cmd.arg("compile"); + cmd.arg("compile").arg("--force"); cmd.assert().success(); }} @@ -280,7 +281,7 @@ fn compile_failure_{test_name}() {{ let mut cmd = Command::cargo_bin("nargo").unwrap(); cmd.env("NARGO_BACKEND_PATH", path_to_mock_backend()); cmd.arg("--program-dir").arg(test_program_dir); - cmd.arg("execute"); + cmd.arg("execute").arg("--force"); cmd.assert().failure().stderr(predicate::str::contains("The application panicked (crashed).").not()); }} diff --git a/noir/tooling/nargo_cli/src/cli/check_cmd.rs b/noir/tooling/nargo_cli/src/cli/check_cmd.rs index e2db492fe9c1..a8b9dbdeeb26 100644 --- a/noir/tooling/nargo_cli/src/cli/check_cmd.rs +++ b/noir/tooling/nargo_cli/src/cli/check_cmd.rs @@ -6,7 +6,7 @@ use fm::FileManager; use iter_extended::btree_map; use nargo::{ errors::CompileError, insert_all_files_for_workspace_into_file_manager, package::Package, - prepare_package, + parse_all, prepare_package, }; use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection}; use noirc_abi::{AbiParameter, AbiType, MAIN_RETURN_NAME}; @@ -16,7 +16,7 @@ use noirc_driver::{ }; use noirc_frontend::{ graph::{CrateId, CrateName}, - hir::Context, + hir::{Context, ParsedFiles}, }; use super::fs::write_to_file; @@ -54,9 +54,10 @@ pub(crate) fn run( let mut workspace_file_manager = file_manager_with_stdlib(&workspace.root_dir); insert_all_files_for_workspace_into_file_manager(&workspace, &mut workspace_file_manager); + let parsed_files = parse_all(&workspace_file_manager); for package in &workspace { - check_package(&workspace_file_manager, package, &args.compile_options)?; + check_package(&workspace_file_manager, &parsed_files, package, &args.compile_options)?; println!("[{}] Constraint system successfully built!", package.name); } Ok(()) @@ -64,10 +65,11 @@ pub(crate) fn run( fn check_package( file_manager: &FileManager, + parsed_files: &ParsedFiles, package: &Package, compile_options: &CompileOptions, ) -> Result<(), CompileError> { - let (mut context, crate_id) = prepare_package(file_manager, package); + let (mut context, crate_id) = prepare_package(file_manager, parsed_files, package); check_crate_and_report_errors( &mut context, crate_id, diff --git a/noir/tooling/nargo_cli/src/cli/codegen_verifier_cmd.rs b/noir/tooling/nargo_cli/src/cli/codegen_verifier_cmd.rs index 1eb8153ce9bb..8bf12ee4100b 100644 --- a/noir/tooling/nargo_cli/src/cli/codegen_verifier_cmd.rs +++ b/noir/tooling/nargo_cli/src/cli/codegen_verifier_cmd.rs @@ -6,12 +6,8 @@ use super::{ use crate::backends::Backend; use crate::errors::CliError; -use acvm::ExpressionWidth; use clap::Args; -use fm::FileManager; -use nargo::insert_all_files_for_workspace_into_file_manager; -use nargo::package::Package; -use nargo::workspace::Workspace; +use nargo::{insert_all_files_for_workspace_into_file_manager, parse_all}; use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection}; use noirc_driver::{file_manager_with_stdlib, CompileOptions, NOIR_ARTIFACT_VERSION_STRING}; use noirc_frontend::graph::CrateName; @@ -48,18 +44,20 @@ pub(crate) fn run( let mut workspace_file_manager = file_manager_with_stdlib(&workspace.root_dir); insert_all_files_for_workspace_into_file_manager(&workspace, &mut workspace_file_manager); + let parsed_files = parse_all(&workspace_file_manager); let expression_width = backend.get_backend_info()?; for package in &workspace { - let smart_contract_string = smart_contract_for_package( + let program = compile_bin_package( &workspace_file_manager, - &workspace, - backend, + &parsed_files, package, &args.compile_options, expression_width, )?; + let smart_contract_string = backend.eth_contract(&program.circuit)?; + let contract_dir = workspace.contracts_directory_path(package); create_named_dir(&contract_dir, "contract"); let contract_path = contract_dir.join("plonk_vk").with_extension("sol"); @@ -70,17 +68,3 @@ pub(crate) fn run( Ok(()) } - -fn smart_contract_for_package( - file_manager: &FileManager, - workspace: &Workspace, - backend: &Backend, - package: &Package, - compile_options: &CompileOptions, - expression_width: ExpressionWidth, -) -> Result { - let program = - compile_bin_package(file_manager, workspace, package, compile_options, expression_width)?; - - Ok(backend.eth_contract(&program.circuit)?) -} diff --git a/noir/tooling/nargo_cli/src/cli/compile_cmd.rs b/noir/tooling/nargo_cli/src/cli/compile_cmd.rs index 9e739f5c818c..aa9a46f39ef5 100644 --- a/noir/tooling/nargo_cli/src/cli/compile_cmd.rs +++ b/noir/tooling/nargo_cli/src/cli/compile_cmd.rs @@ -5,10 +5,10 @@ use acvm::ExpressionWidth; use fm::FileManager; use nargo::artifacts::program::ProgramArtifact; use nargo::errors::CompileError; -use nargo::insert_all_files_for_workspace_into_file_manager; +use nargo::ops::{compile_contract, compile_program}; use nargo::package::Package; -use nargo::prepare_package; use nargo::workspace::Workspace; +use nargo::{insert_all_files_for_workspace_into_file_manager, parse_all}; use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection}; use noirc_driver::file_manager_with_stdlib; use noirc_driver::NOIR_ARTIFACT_VERSION_STRING; @@ -17,6 +17,7 @@ use noirc_driver::{CompilationResult, CompileOptions, CompiledContract, Compiled use noirc_frontend::graph::CrateName; use clap::Args; +use noirc_frontend::hir::ParsedFiles; use crate::backends::Backend; use crate::errors::CliError; @@ -60,24 +61,28 @@ pub(crate) fn run( let mut workspace_file_manager = file_manager_with_stdlib(&workspace.root_dir); insert_all_files_for_workspace_into_file_manager(&workspace, &mut workspace_file_manager); - - let (binary_packages, contract_packages): (Vec<_>, Vec<_>) = workspace - .into_iter() - .filter(|package| !package.is_library()) - .cloned() - .partition(|package| package.is_binary()); + let parsed_files = parse_all(&workspace_file_manager); let expression_width = backend.get_backend_info_or_default(); - let (_, compiled_contracts) = compile_workspace( + let (compiled_program, compiled_contracts) = compile_workspace( &workspace_file_manager, + &parsed_files, &workspace, - &binary_packages, - &contract_packages, expression_width, &args.compile_options, )?; + let (binary_packages, contract_packages): (Vec<_>, Vec<_>) = workspace + .into_iter() + .filter(|package| !package.is_library()) + .cloned() + .partition(|package| package.is_binary()); + // Save build artifacts to disk. + let only_acir = args.compile_options.only_acir; + for (package, program) in binary_packages.into_iter().zip(compiled_program) { + save_program(program.clone(), &package, &workspace.target_directory_path(), only_acir); + } for (package, contract) in contract_packages.into_iter().zip(compiled_contracts) { save_contract(contract, &package, &circuit_dir); } @@ -87,22 +92,43 @@ pub(crate) fn run( pub(super) fn compile_workspace( file_manager: &FileManager, + parsed_files: &ParsedFiles, workspace: &Workspace, - binary_packages: &[Package], - contract_packages: &[Package], expression_width: ExpressionWidth, compile_options: &CompileOptions, ) -> Result<(Vec, Vec), CliError> { + let (binary_packages, contract_packages): (Vec<_>, Vec<_>) = workspace + .into_iter() + .filter(|package| !package.is_library()) + .cloned() + .partition(|package| package.is_binary()); + // Compile all of the packages in parallel. let program_results: Vec> = binary_packages .par_iter() .map(|package| { - compile_program(file_manager, workspace, package, compile_options, expression_width) + let program_artifact_path = workspace.package_build_path(package); + let cached_program: Option = + read_program_from_file(program_artifact_path) + .ok() + .filter(|p| p.noir_version == NOIR_ARTIFACT_VERSION_STRING) + .map(|p| p.into()); + + compile_program( + file_manager, + parsed_files, + package, + compile_options, + expression_width, + cached_program, + ) }) .collect(); let contract_results: Vec> = contract_packages .par_iter() - .map(|package| compile_contract(file_manager, package, compile_options, expression_width)) + .map(|package| { + compile_contract(file_manager, parsed_files, package, compile_options, expression_width) + }) .collect(); // Report any warnings/errors which were encountered during compilation. @@ -134,7 +160,7 @@ pub(super) fn compile_workspace( pub(crate) fn compile_bin_package( file_manager: &FileManager, - workspace: &Workspace, + parsed_files: &ParsedFiles, package: &Package, compile_options: &CompileOptions, expression_width: ExpressionWidth, @@ -143,8 +169,14 @@ pub(crate) fn compile_bin_package( return Err(CompileError::LibraryCrate(package.name.clone()).into()); } - let compilation_result = - compile_program(file_manager, workspace, package, compile_options, expression_width); + let compilation_result = compile_program( + file_manager, + parsed_files, + package, + compile_options, + expression_width, + None, + ); let program = report_errors( compilation_result, @@ -156,53 +188,6 @@ pub(crate) fn compile_bin_package( Ok(program) } -fn compile_program( - file_manager: &FileManager, - workspace: &Workspace, - package: &Package, - compile_options: &CompileOptions, - expression_width: ExpressionWidth, -) -> CompilationResult { - let (mut context, crate_id) = prepare_package(file_manager, package); - - let program_artifact_path = workspace.package_build_path(package); - let cached_program: Option = - read_program_from_file(program_artifact_path) - .ok() - .filter(|p| p.noir_version == NOIR_ARTIFACT_VERSION_STRING) - .map(|p| p.into()); - - let (program, warnings) = - noirc_driver::compile_main(&mut context, crate_id, compile_options, cached_program)?; - - // Apply backend specific optimizations. - let optimized_program = nargo::ops::optimize_program(program, expression_width); - let only_acir = compile_options.only_acir; - save_program(optimized_program.clone(), package, &workspace.target_directory_path(), only_acir); - - Ok((optimized_program, warnings)) -} - -fn compile_contract( - file_manager: &FileManager, - package: &Package, - compile_options: &CompileOptions, - expression_width: ExpressionWidth, -) -> CompilationResult { - let (mut context, crate_id) = prepare_package(file_manager, package); - let (contract, warnings) = - match noirc_driver::compile_contract(&mut context, crate_id, compile_options) { - Ok(contracts_and_warnings) => contracts_and_warnings, - Err(errors) => { - return Err(errors); - } - }; - - let optimized_contract = nargo::ops::optimize_contract(contract, expression_width); - - Ok((optimized_contract, warnings)) -} - pub(super) fn save_program( program: CompiledProgram, package: &Package, diff --git a/noir/tooling/nargo_cli/src/cli/dap_cmd.rs b/noir/tooling/nargo_cli/src/cli/dap_cmd.rs index 29e696ea6086..9798cbedfeb1 100644 --- a/noir/tooling/nargo_cli/src/cli/dap_cmd.rs +++ b/noir/tooling/nargo_cli/src/cli/dap_cmd.rs @@ -2,8 +2,8 @@ use acvm::acir::native_types::WitnessMap; use backend_interface::Backend; use clap::Args; use nargo::constants::PROVER_INPUT_FILE; -use nargo::insert_all_files_for_workspace_into_file_manager; use nargo::workspace::Workspace; +use nargo::{insert_all_files_for_workspace_into_file_manager, parse_all}; use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection}; use noirc_abi::input_parser::Format; use noirc_driver::{ @@ -70,10 +70,11 @@ fn load_and_compile_project( let mut workspace_file_manager = file_manager_with_stdlib(std::path::Path::new("")); insert_all_files_for_workspace_into_file_manager(&workspace, &mut workspace_file_manager); + let parsed_files = parse_all(&workspace_file_manager); let compiled_program = compile_bin_package( &workspace_file_manager, - &workspace, + &parsed_files, package, &CompileOptions::default(), expression_width, diff --git a/noir/tooling/nargo_cli/src/cli/debug_cmd.rs b/noir/tooling/nargo_cli/src/cli/debug_cmd.rs index f78a683aa8f9..e62cbc11ec87 100644 --- a/noir/tooling/nargo_cli/src/cli/debug_cmd.rs +++ b/noir/tooling/nargo_cli/src/cli/debug_cmd.rs @@ -6,8 +6,8 @@ use clap::Args; use nargo::artifacts::debug::DebugArtifact; use nargo::constants::PROVER_INPUT_FILE; -use nargo::insert_all_files_for_workspace_into_file_manager; use nargo::package::Package; +use nargo::{insert_all_files_for_workspace_into_file_manager, parse_all}; use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection}; use noirc_abi::input_parser::{Format, InputValue}; use noirc_abi::InputMap; @@ -57,6 +57,7 @@ pub(crate) fn run( let mut workspace_file_manager = file_manager_with_stdlib(std::path::Path::new("")); insert_all_files_for_workspace_into_file_manager(&workspace, &mut workspace_file_manager); + let parsed_files = parse_all(&workspace_file_manager); let Some(package) = workspace.into_iter().find(|p| p.is_binary()) else { println!( @@ -67,7 +68,7 @@ pub(crate) fn run( let compiled_program = compile_bin_package( &workspace_file_manager, - &workspace, + &parsed_files, package, &args.compile_options, expression_width, diff --git a/noir/tooling/nargo_cli/src/cli/execute_cmd.rs b/noir/tooling/nargo_cli/src/cli/execute_cmd.rs index 7f695c42fa4c..cf0d46a0718b 100644 --- a/noir/tooling/nargo_cli/src/cli/execute_cmd.rs +++ b/noir/tooling/nargo_cli/src/cli/execute_cmd.rs @@ -5,9 +5,9 @@ use clap::Args; use nargo::artifacts::debug::DebugArtifact; use nargo::constants::PROVER_INPUT_FILE; use nargo::errors::try_to_diagnose_runtime_error; -use nargo::insert_all_files_for_workspace_into_file_manager; use nargo::ops::DefaultForeignCallExecutor; use nargo::package::Package; +use nargo::{insert_all_files_for_workspace_into_file_manager, parse_all}; use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection}; use noirc_abi::input_parser::{Format, InputValue}; use noirc_abi::InputMap; @@ -66,12 +66,13 @@ pub(crate) fn run( let mut workspace_file_manager = file_manager_with_stdlib(&workspace.root_dir); insert_all_files_for_workspace_into_file_manager(&workspace, &mut workspace_file_manager); + let parsed_files = parse_all(&workspace_file_manager); let expression_width = backend.get_backend_info_or_default(); for package in &workspace { let compiled_program = compile_bin_package( &workspace_file_manager, - &workspace, + &parsed_files, package, &args.compile_options, expression_width, diff --git a/noir/tooling/nargo_cli/src/cli/export_cmd.rs b/noir/tooling/nargo_cli/src/cli/export_cmd.rs index ac3e93e09b7f..feaa55857e56 100644 --- a/noir/tooling/nargo_cli/src/cli/export_cmd.rs +++ b/noir/tooling/nargo_cli/src/cli/export_cmd.rs @@ -1,13 +1,14 @@ use nargo::errors::CompileError; use noirc_errors::FileDiagnostic; +use noirc_frontend::hir::ParsedFiles; use rayon::prelude::*; use fm::FileManager; use iter_extended::try_vecmap; -use nargo::insert_all_files_for_workspace_into_file_manager; use nargo::package::Package; use nargo::prepare_package; use nargo::workspace::Workspace; +use nargo::{insert_all_files_for_workspace_into_file_manager, parse_all}; use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection}; use noirc_driver::{ compile_no_check, file_manager_with_stdlib, CompileOptions, CompiledProgram, @@ -60,6 +61,7 @@ pub(crate) fn run( let mut workspace_file_manager = file_manager_with_stdlib(&workspace.root_dir); insert_all_files_for_workspace_into_file_manager(&workspace, &mut workspace_file_manager); + let parsed_files = parse_all(&workspace_file_manager); let library_packages: Vec<_> = workspace.into_iter().filter(|package| package.is_library()).collect(); @@ -69,6 +71,7 @@ pub(crate) fn run( .map(|package| { compile_exported_functions( &workspace_file_manager, + &parsed_files, &workspace, package, &args.compile_options, @@ -79,11 +82,12 @@ pub(crate) fn run( fn compile_exported_functions( file_manager: &FileManager, + parsed_files: &ParsedFiles, workspace: &Workspace, package: &Package, compile_options: &CompileOptions, ) -> Result<(), CliError> { - let (mut context, crate_id) = prepare_package(file_manager, package); + let (mut context, crate_id) = prepare_package(file_manager, parsed_files, package); check_crate_and_report_errors( &mut context, crate_id, diff --git a/noir/tooling/nargo_cli/src/cli/info_cmd.rs b/noir/tooling/nargo_cli/src/cli/info_cmd.rs index f983a19c0fdb..8dfff67b47fd 100644 --- a/noir/tooling/nargo_cli/src/cli/info_cmd.rs +++ b/noir/tooling/nargo_cli/src/cli/info_cmd.rs @@ -6,7 +6,7 @@ use clap::Args; use iter_extended::vecmap; use nargo::{ artifacts::debug::DebugArtifact, insert_all_files_for_workspace_into_file_manager, - package::Package, + package::Package, parse_all, }; use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection}; use noirc_driver::{ @@ -67,19 +67,13 @@ pub(crate) fn run( let mut workspace_file_manager = file_manager_with_stdlib(&workspace.root_dir); insert_all_files_for_workspace_into_file_manager(&workspace, &mut workspace_file_manager); - - let (binary_packages, contract_packages): (Vec<_>, Vec<_>) = workspace - .into_iter() - .filter(|package| !package.is_library()) - .cloned() - .partition(|package| package.is_binary()); + let parsed_files = parse_all(&workspace_file_manager); let expression_width = backend.get_backend_info_or_default(); let (compiled_programs, compiled_contracts) = compile_workspace( &workspace_file_manager, + &parsed_files, &workspace, - &binary_packages, - &contract_packages, expression_width, &args.compile_options, )?; @@ -101,11 +95,12 @@ pub(crate) fn run( } } + let binary_packages = + workspace.into_iter().filter(|package| package.is_binary()).zip(compiled_programs); let program_info = binary_packages - .into_par_iter() - .zip(compiled_programs) + .par_bridge() .map(|(package, program)| { - count_opcodes_and_gates_in_program(backend, program, &package, expression_width) + count_opcodes_and_gates_in_program(backend, program, package, expression_width) }) .collect::>()?; diff --git a/noir/tooling/nargo_cli/src/cli/prove_cmd.rs b/noir/tooling/nargo_cli/src/cli/prove_cmd.rs index 167ab541bc5f..d02464fd6dfb 100644 --- a/noir/tooling/nargo_cli/src/cli/prove_cmd.rs +++ b/noir/tooling/nargo_cli/src/cli/prove_cmd.rs @@ -1,8 +1,8 @@ use clap::Args; use nargo::constants::{PROVER_INPUT_FILE, VERIFIER_INPUT_FILE}; -use nargo::insert_all_files_for_workspace_into_file_manager; use nargo::package::Package; use nargo::workspace::Workspace; +use nargo::{insert_all_files_for_workspace_into_file_manager, parse_all}; use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection}; use noirc_abi::input_parser::Format; use noirc_driver::{ @@ -66,12 +66,13 @@ pub(crate) fn run( let mut workspace_file_manager = file_manager_with_stdlib(&workspace.root_dir); insert_all_files_for_workspace_into_file_manager(&workspace, &mut workspace_file_manager); + let parsed_files = parse_all(&workspace_file_manager); let expression_width = backend.get_backend_info()?; for package in &workspace { let program = compile_bin_package( &workspace_file_manager, - &workspace, + &parsed_files, package, &args.compile_options, expression_width, diff --git a/noir/tooling/nargo_cli/src/cli/test_cmd.rs b/noir/tooling/nargo_cli/src/cli/test_cmd.rs index 69f03b49cbde..5db842609e58 100644 --- a/noir/tooling/nargo_cli/src/cli/test_cmd.rs +++ b/noir/tooling/nargo_cli/src/cli/test_cmd.rs @@ -8,11 +8,14 @@ use nargo::{ insert_all_files_for_workspace_into_file_manager, ops::{run_test, TestStatus}, package::Package, - prepare_package, + parse_all, prepare_package, }; use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection}; use noirc_driver::{file_manager_with_stdlib, CompileOptions, NOIR_ARTIFACT_VERSION_STRING}; -use noirc_frontend::{graph::CrateName, hir::FunctionNameMatch}; +use noirc_frontend::{ + graph::CrateName, + hir::{FunctionNameMatch, ParsedFiles}, +}; use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor}; use crate::{backends::Backend, cli::check_cmd::check_crate_and_report_errors, errors::CliError}; @@ -66,6 +69,7 @@ pub(crate) fn run( let mut workspace_file_manager = file_manager_with_stdlib(&workspace.root_dir); insert_all_files_for_workspace_into_file_manager(&workspace, &mut workspace_file_manager); + let parsed_files = parse_all(&workspace_file_manager); let pattern = match &args.test_name { Some(name) => { @@ -84,6 +88,7 @@ pub(crate) fn run( // TODO: We should run the whole suite even if there are failures in a package run_tests( &workspace_file_manager, + &parsed_files, &blackbox_solver, package, pattern, @@ -96,8 +101,10 @@ pub(crate) fn run( Ok(()) } +#[allow(clippy::too_many_arguments)] fn run_tests( file_manager: &FileManager, + parsed_files: &ParsedFiles, blackbox_solver: &S, package: &Package, fn_name: FunctionNameMatch, @@ -105,7 +112,7 @@ fn run_tests( foreign_call_resolver_url: Option<&str>, compile_options: &CompileOptions, ) -> Result<(), CliError> { - let (mut context, crate_id) = prepare_package(file_manager, package); + let (mut context, crate_id) = prepare_package(file_manager, parsed_files, package); check_crate_and_report_errors( &mut context, crate_id, diff --git a/noir/tooling/nargo_cli/src/cli/verify_cmd.rs b/noir/tooling/nargo_cli/src/cli/verify_cmd.rs index 86d5e774cbe9..1701b9e063c8 100644 --- a/noir/tooling/nargo_cli/src/cli/verify_cmd.rs +++ b/noir/tooling/nargo_cli/src/cli/verify_cmd.rs @@ -7,9 +7,9 @@ use crate::{backends::Backend, errors::CliError}; use clap::Args; use nargo::constants::{PROOF_EXT, VERIFIER_INPUT_FILE}; -use nargo::insert_all_files_for_workspace_into_file_manager; use nargo::package::Package; use nargo::workspace::Workspace; +use nargo::{insert_all_files_for_workspace_into_file_manager, parse_all}; use nargo_toml::{get_package_manifest, resolve_workspace_from_toml, PackageSelection}; use noirc_abi::input_parser::Format; use noirc_driver::{ @@ -53,12 +53,13 @@ pub(crate) fn run( let mut workspace_file_manager = file_manager_with_stdlib(&workspace.root_dir); insert_all_files_for_workspace_into_file_manager(&workspace, &mut workspace_file_manager); + let parsed_files = parse_all(&workspace_file_manager); let expression_width = backend.get_backend_info()?; for package in &workspace { let program = compile_bin_package( &workspace_file_manager, - &workspace, + &parsed_files, package, &args.compile_options, expression_width, diff --git a/noir/tooling/noir_codegen/package.json b/noir/tooling/noir_codegen/package.json index 7d76b1a91381..60ccf5ec2a5b 100644 --- a/noir/tooling/noir_codegen/package.json +++ b/noir/tooling/noir_codegen/package.json @@ -3,7 +3,7 @@ "contributors": [ "The Noir Team " ], - "version": "0.22.0", + "version": "0.23.0", "packageManager": "yarn@3.5.1", "license": "(MIT OR Apache-2.0)", "type": "module", diff --git a/noir/tooling/noir_js/package.json b/noir/tooling/noir_js/package.json index ed2fd2258100..356909a1e35b 100644 --- a/noir/tooling/noir_js/package.json +++ b/noir/tooling/noir_js/package.json @@ -3,7 +3,7 @@ "contributors": [ "The Noir Team " ], - "version": "0.22.0", + "version": "0.23.0", "packageManager": "yarn@3.5.1", "license": "(MIT OR Apache-2.0)", "type": "module", diff --git a/noir/tooling/noir_js_backend_barretenberg/package.json b/noir/tooling/noir_js_backend_barretenberg/package.json index e22ea2ff49d5..cd2a6354ac4b 100644 --- a/noir/tooling/noir_js_backend_barretenberg/package.json +++ b/noir/tooling/noir_js_backend_barretenberg/package.json @@ -3,7 +3,7 @@ "contributors": [ "The Noir Team " ], - "version": "0.22.0", + "version": "0.23.0", "packageManager": "yarn@3.5.1", "license": "(MIT OR Apache-2.0)", "type": "module", diff --git a/noir/tooling/noir_js_types/package.json b/noir/tooling/noir_js_types/package.json index 0276b8d087cd..ef75f3d2fb38 100644 --- a/noir/tooling/noir_js_types/package.json +++ b/noir/tooling/noir_js_types/package.json @@ -4,7 +4,7 @@ "The Noir Team " ], "packageManager": "yarn@3.5.1", - "version": "0.22.0", + "version": "0.23.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://noir-lang.org/", "repository": { diff --git a/noir/tooling/noirc_abi_wasm/package.json b/noir/tooling/noirc_abi_wasm/package.json index d023e1e43910..db0f6c291530 100644 --- a/noir/tooling/noirc_abi_wasm/package.json +++ b/noir/tooling/noirc_abi_wasm/package.json @@ -3,7 +3,7 @@ "contributors": [ "The Noir Team " ], - "version": "0.22.0", + "version": "0.23.0", "license": "(MIT OR Apache-2.0)", "homepage": "https://noir-lang.org/", "repository": { diff --git a/noir/yarn.lock b/noir/yarn.lock index e7822f59bdc3..db3f493bc62d 100644 --- a/noir/yarn.lock +++ b/noir/yarn.lock @@ -221,6 +221,20 @@ __metadata: languageName: node linkType: hard +"@aztec/bb.js@npm:0.16.0": + version: 0.16.0 + resolution: "@aztec/bb.js@npm:0.16.0" + dependencies: + comlink: ^4.4.1 + commander: ^10.0.1 + debug: ^4.3.4 + tslib: ^2.4.0 + bin: + bb.js: dest/node/main.js + checksum: 5f68b4ad16284a3a871e0ad21fea05aed670383bc639c9d07ab3bf9b7a9d15cc8a4e5cda404a9290775ad5023924739543a8aac37d602892dd1fb5087521970b + languageName: node + linkType: hard + "@aztec/bb.js@npm:0.19.0": version: 0.19.0 resolution: "@aztec/bb.js@npm:0.19.0" @@ -4381,6 +4395,13 @@ __metadata: languageName: node linkType: hard +"@noir-lang/acvm_js@npm:0.38.0": + version: 0.38.0 + resolution: "@noir-lang/acvm_js@npm:0.38.0" + checksum: 42a5bba45135d1df0d0eb3f7b65439733e016580bad610e859e140638d42200d6b856ff11c4b30417b74ce011da7c39861aafb1c5b8c7211de2172aea449c635 + languageName: node + linkType: hard + "@noir-lang/acvm_js@workspace:*, @noir-lang/acvm_js@workspace:acvm-repo/acvm_js": version: 0.0.0-use.local resolution: "@noir-lang/acvm_js@workspace:acvm-repo/acvm_js" @@ -4399,7 +4420,18 @@ __metadata: languageName: unknown linkType: soft -"@noir-lang/backend_barretenberg@^0.22.0, @noir-lang/backend_barretenberg@workspace:*, @noir-lang/backend_barretenberg@workspace:tooling/noir_js_backend_barretenberg": +"@noir-lang/backend_barretenberg@npm:^0.22.0": + version: 0.22.0 + resolution: "@noir-lang/backend_barretenberg@npm:0.22.0" + dependencies: + "@aztec/bb.js": 0.16.0 + "@noir-lang/types": 0.22.0 + fflate: ^0.8.0 + checksum: ead456218ba61d925e0fc5b47d1b94272e980b44a220f1262fb6cdc73cff7cd4232ddc69dd67bb21e50f0b43e7696d4a96fde15e3eadc0bf223ec6d59e014e23 + languageName: node + linkType: hard + +"@noir-lang/backend_barretenberg@workspace:*, @noir-lang/backend_barretenberg@workspace:tooling/noir_js_backend_barretenberg": version: 0.0.0-use.local resolution: "@noir-lang/backend_barretenberg@workspace:tooling/noir_js_backend_barretenberg" dependencies: @@ -4443,7 +4475,18 @@ __metadata: languageName: unknown linkType: soft -"@noir-lang/noir_js@^0.22.0, @noir-lang/noir_js@workspace:*, @noir-lang/noir_js@workspace:tooling/noir_js": +"@noir-lang/noir_js@npm:^0.22.0": + version: 0.22.0 + resolution: "@noir-lang/noir_js@npm:0.22.0" + dependencies: + "@noir-lang/acvm_js": 0.38.0 + "@noir-lang/noirc_abi": 0.22.0 + "@noir-lang/types": 0.22.0 + checksum: 3b0873ad87521415af11208bebe5690191d03fa06dcd515789f0a63f7641146cdcb01d292b208452856ea3967e196c8332cb2618e013f9e7e5ce7d6e09de043d + languageName: node + linkType: hard + +"@noir-lang/noir_js@workspace:*, @noir-lang/noir_js@workspace:tooling/noir_js": version: 0.0.0-use.local resolution: "@noir-lang/noir_js@workspace:tooling/noir_js" dependencies: @@ -4466,7 +4509,14 @@ __metadata: languageName: unknown linkType: soft -"@noir-lang/noir_wasm@^0.22.0, @noir-lang/noir_wasm@workspace:*, @noir-lang/noir_wasm@workspace:compiler/wasm": +"@noir-lang/noir_wasm@npm:^0.22.0": + version: 0.22.0 + resolution: "@noir-lang/noir_wasm@npm:0.22.0" + checksum: 7ac0ca170bf312df761d7ccfd32a67a27f88f15ad4eed1807864295d761d3b2176ffb82f4c6931e1bc06b225d6f738519962c79ffbce9a33d5ef8a6a2bdea82c + languageName: node + linkType: hard + +"@noir-lang/noir_wasm@workspace:*, @noir-lang/noir_wasm@workspace:compiler/wasm": version: 0.0.0-use.local resolution: "@noir-lang/noir_wasm@workspace:compiler/wasm" dependencies: @@ -4510,6 +4560,13 @@ __metadata: languageName: unknown linkType: soft +"@noir-lang/noirc_abi@npm:0.22.0": + version: 0.22.0 + resolution: "@noir-lang/noirc_abi@npm:0.22.0" + checksum: a250c6cc5ca37fcf02663f8d6b027776f0e58920fb8f8a84efcf74f079f235bb11bbad682ba332211d9b9a79b6a3eb7faede7701cd88582b682971a41ca6212d + languageName: node + linkType: hard + "@noir-lang/noirc_abi@workspace:*, @noir-lang/noirc_abi@workspace:tooling/noirc_abi_wasm": version: 0.0.0-use.local resolution: "@noir-lang/noirc_abi@workspace:tooling/noirc_abi_wasm" @@ -4540,7 +4597,16 @@ __metadata: languageName: unknown linkType: soft -"@noir-lang/types@^0.22.0, @noir-lang/types@workspace:*, @noir-lang/types@workspace:tooling/noir_js_types": +"@noir-lang/types@npm:0.22.0, @noir-lang/types@npm:^0.22.0": + version: 0.22.0 + resolution: "@noir-lang/types@npm:0.22.0" + dependencies: + "@noir-lang/noirc_abi": 0.22.0 + checksum: 5dd1badf0449c518e755172de1d2f2c1b95bfaf7b7328b7de00b8ce9ba68bd447ca65e827185da7d737e7e88dcaf296b29687ffe2e1f5b4d5cc31ce3e3b4f208 + languageName: node + linkType: hard + +"@noir-lang/types@workspace:*, @noir-lang/types@workspace:tooling/noir_js_types": version: 0.0.0-use.local resolution: "@noir-lang/types@workspace:tooling/noir_js_types" dependencies: diff --git a/yarn-project/accounts/.eslintrc.cjs b/yarn-project/accounts/.eslintrc.cjs index e659927475c0..ec1dd3e14de0 100644 --- a/yarn-project/accounts/.eslintrc.cjs +++ b/yarn-project/accounts/.eslintrc.cjs @@ -1 +1 @@ -module.exports = require('@aztec/foundation/eslint'); +module.exports = require('@aztec/foundation/eslint.docs'); diff --git a/yarn-project/acir-simulator/src/acvm/oracle/oracle.ts b/yarn-project/acir-simulator/src/acvm/oracle/oracle.ts index 49449ffcbcb8..020e1738776b 100644 --- a/yarn-project/acir-simulator/src/acvm/oracle/oracle.ts +++ b/yarn-project/acir-simulator/src/acvm/oracle/oracle.ts @@ -33,10 +33,14 @@ export class Oracle { return toACVMField(packed); } - async getSecretKey([publicKeyX]: ACVMField[], [publicKeyY]: ACVMField[]): Promise { - const publicKey = new Point(fromACVMField(publicKeyX), fromACVMField(publicKeyY)); - const secretKey = await this.typedOracle.getSecretKey(publicKey); - return [toACVMField(secretKey.low), toACVMField(secretKey.high)]; + async getNullifierKeyPair([accountAddress]: ACVMField[]): Promise { + const { publicKey, secretKey } = await this.typedOracle.getNullifierKeyPair(fromACVMField(accountAddress)); + return [ + toACVMField(publicKey.x), + toACVMField(publicKey.y), + toACVMField(secretKey.high), + toACVMField(secretKey.low), + ]; } async getPublicKeyAndPartialAddress([address]: ACVMField[]) { @@ -228,8 +232,8 @@ export class Oracle { } async getL1ToL2Message([msgKey]: ACVMField[]): Promise { - const { root, ...message } = await this.typedOracle.getL1ToL2Message(fromACVMField(msgKey)); - return toAcvmL1ToL2MessageLoadOracleInputs(message, root); + const { ...message } = await this.typedOracle.getL1ToL2Message(fromACVMField(msgKey)); + return toAcvmL1ToL2MessageLoadOracleInputs(message); } async getPortalContractAddress([aztecAddress]: ACVMField[]): Promise { diff --git a/yarn-project/acir-simulator/src/acvm/oracle/typed_oracle.ts b/yarn-project/acir-simulator/src/acvm/oracle/typed_oracle.ts index 995a285b7b1a..27d9f8d5f307 100644 --- a/yarn-project/acir-simulator/src/acvm/oracle/typed_oracle.ts +++ b/yarn-project/acir-simulator/src/acvm/oracle/typed_oracle.ts @@ -7,11 +7,25 @@ import { PublicKey, UnencryptedL2Log, } from '@aztec/circuit-types'; -import { BlockHeader, PrivateCallStackItem, PublicCallRequest } from '@aztec/circuits.js'; +import { BlockHeader, GrumpkinPrivateKey, PrivateCallStackItem, PublicCallRequest } from '@aztec/circuits.js'; import { FunctionSelector } from '@aztec/foundation/abi'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { EthAddress } from '@aztec/foundation/eth-address'; -import { Fr, GrumpkinScalar } from '@aztec/foundation/fields'; +import { Fr } from '@aztec/foundation/fields'; + +/** + * A pair of public key and secret key. + */ +export interface KeyPair { + /** + * Public key. + */ + publicKey: PublicKey; + /** + * Secret Key. + */ + secretKey: GrumpkinPrivateKey; +} /** * Information about a note needed during execution. @@ -34,7 +48,7 @@ export interface NoteData { } /** - * The partial data for L1 to L2 Messages provided by other data sources. + * The data for L1 to L2 Messages provided by other data sources. */ export interface MessageLoadOracleInputs { /** @@ -52,16 +66,6 @@ export interface MessageLoadOracleInputs { index: bigint; } -/** - * The data required by Aztec.nr to validate L1 to L2 Messages. - */ -export interface L1ToL2MessageOracleReturnData extends MessageLoadOracleInputs { - /** - * The current root of the l1 to l2 message tree. - */ - root: Fr; -} - /** * Oracle with typed parameters and typed return values. * Methods that require read and/or write will have to be implemented based on the context (public, private, or view) @@ -76,7 +80,7 @@ export abstract class TypedOracle { throw new Error('Not available.'); } - getSecretKey(_owner: PublicKey): Promise { + getNullifierKeyPair(_accountAddress: AztecAddress): Promise { throw new Error('Not available.'); } @@ -153,7 +157,7 @@ export abstract class TypedOracle { throw new Error('Not available.'); } - getL1ToL2Message(_msgKey: Fr): Promise { + getL1ToL2Message(_msgKey: Fr): Promise { throw new Error('Not available.'); } diff --git a/yarn-project/acir-simulator/src/acvm/serialize.ts b/yarn-project/acir-simulator/src/acvm/serialize.ts index 1877bf264d98..5e844ff8a7cd 100644 --- a/yarn-project/acir-simulator/src/acvm/serialize.ts +++ b/yarn-project/acir-simulator/src/acvm/serialize.ts @@ -199,18 +199,13 @@ export function toAcvmEnqueuePublicFunctionResult(item: PublicCallRequest): ACVM /** * Converts the result of loading messages to ACVM fields. * @param messageLoadOracleInputs - The result of loading messages to convert. - * @param l1ToL2MessageTreeRoot - The L1 to L2 message tree root * @returns The Message Oracle Fields. */ -export function toAcvmL1ToL2MessageLoadOracleInputs( - messageLoadOracleInputs: MessageLoadOracleInputs, - l1ToL2MessageTreeRoot: Fr, -): ACVMField[] { +export function toAcvmL1ToL2MessageLoadOracleInputs(messageLoadOracleInputs: MessageLoadOracleInputs): ACVMField[] { return [ ...messageLoadOracleInputs.message.map(f => toACVMField(f)), toACVMField(messageLoadOracleInputs.index), ...messageLoadOracleInputs.siblingPath.map(f => toACVMField(f)), - toACVMField(l1ToL2MessageTreeRoot), ]; } diff --git a/yarn-project/acir-simulator/src/avm/avm_message_call_result.ts b/yarn-project/acir-simulator/src/avm/avm_message_call_result.ts index ec258dff1126..e2290e4fa6d1 100644 --- a/yarn-project/acir-simulator/src/avm/avm_message_call_result.ts +++ b/yarn-project/acir-simulator/src/avm/avm_message_call_result.ts @@ -6,12 +6,15 @@ import { Fr } from '@aztec/foundation/fields'; export class AvmMessageCallResult { /** - */ public readonly reverted: boolean; + /** - */ + public readonly revertReason: Error | undefined; /** .- */ public readonly output: Fr[]; - constructor(reverted: boolean, output: Fr[]) { + private constructor(reverted: boolean, output: Fr[], revertReason?: Error) { this.reverted = reverted; this.output = output; + this.revertReason = revertReason; } /** @@ -26,9 +29,10 @@ export class AvmMessageCallResult { /** * Terminate a call as a revert * @param output - Return data ( revert message ) + * @param reason - Optional reason for revert * @returns instance of AvmMessageCallResult */ - public static revert(output: Fr[]): AvmMessageCallResult { - return new AvmMessageCallResult(true, output); + public static revert(output: Fr[], reason?: Error): AvmMessageCallResult { + return new AvmMessageCallResult(true, output, reason); } } diff --git a/yarn-project/acir-simulator/src/avm/interpreter/interpreter.test.ts b/yarn-project/acir-simulator/src/avm/interpreter/interpreter.test.ts index a52a2c13222e..7f252ec739c8 100644 --- a/yarn-project/acir-simulator/src/avm/interpreter/interpreter.test.ts +++ b/yarn-project/acir-simulator/src/avm/interpreter/interpreter.test.ts @@ -8,7 +8,7 @@ import { Add } from '../opcodes/arithmetic.js'; import { Jump, Return } from '../opcodes/control_flow.js'; import { Instruction } from '../opcodes/instruction.js'; import { CalldataCopy } from '../opcodes/memory.js'; -import { AvmInterpreter } from './interpreter.js'; +import { AvmInterpreter, InvalidProgramCounterError } from './interpreter.js'; describe('interpreter', () => { it('Should execute a series of instructions', () => { @@ -16,12 +16,9 @@ describe('interpreter', () => { const stateManager = mock(); const instructions: Instruction[] = [ - // Copy the first two elements of the calldata to memory regions 0 and 1 - new CalldataCopy(0, 2, 0), - // Add the two together and store the result in memory region 2 - new Add(0, 1, 2), // 1 + 2 - // Return the result - new Return(2, 1), // [3] + new CalldataCopy(/*cdOffset=*/ 0, /*copySize=*/ 2, /*destOffset=*/ 0), + new Add(/*aOffset=*/ 0, /*bOffset=*/ 1, /*destOffset=*/ 2), + new Return(/*returnOffset=*/ 2, /*copySize=*/ 1), ]; const context = new AvmMachineState(calldata); @@ -29,10 +26,8 @@ describe('interpreter', () => { const avmReturnData = interpreter.run(); expect(avmReturnData.reverted).toBe(false); - - const returnData = avmReturnData.output; - expect(returnData.length).toBe(1); - expect(returnData).toEqual([new Fr(3)]); + expect(avmReturnData.revertReason).toBeUndefined(); + expect(avmReturnData.output).toEqual([new Fr(3)]); }); it('Should revert with an invalid jump', () => { @@ -49,5 +44,7 @@ describe('interpreter', () => { const avmReturnData = interpreter.run(); expect(avmReturnData.reverted).toBe(true); + expect(avmReturnData.revertReason).toBeInstanceOf(InvalidProgramCounterError); + expect(avmReturnData.output).toHaveLength(0); }); }); diff --git a/yarn-project/acir-simulator/src/avm/interpreter/interpreter.ts b/yarn-project/acir-simulator/src/avm/interpreter/interpreter.ts index 9bbd511c2d37..f3970ade43f6 100644 --- a/yarn-project/acir-simulator/src/avm/interpreter/interpreter.ts +++ b/yarn-project/acir-simulator/src/avm/interpreter/interpreter.ts @@ -1,6 +1,7 @@ -// import { AvmContext } from "../avm_machineState.js"; import { Fr } from '@aztec/foundation/fields'; +import { strict as assert } from 'assert'; + import { AvmMachineState } from '../avm_machine_state.js'; import { AvmMessageCallResult } from '../avm_message_call_result.js'; import { AvmStateManager } from '../avm_state_manager.js'; @@ -16,10 +17,10 @@ export class AvmInterpreter { private machineState: AvmMachineState; private stateManager: AvmStateManager; - constructor(machineState: AvmMachineState, stateManager: AvmStateManager, bytecode: Instruction[]) { + constructor(machineState: AvmMachineState, stateManager: AvmStateManager, instructions: Instruction[]) { this.machineState = machineState; this.stateManager = stateManager; - this.instructions = bytecode; + this.instructions = instructions; } /** @@ -29,27 +30,30 @@ export class AvmInterpreter { * - any other panic will throw */ run(): AvmMessageCallResult { + assert(this.instructions.length > 0); + try { - while (!this.machineState.halted && this.machineState.pc < this.instructions.length) { + while (!this.machineState.halted) { const instruction = this.instructions[this.machineState.pc]; - - if (!instruction) { - throw new InvalidInstructionError(this.machineState.pc); - } + assert(!!instruction); // This should never happen instruction.execute(this.machineState, this.stateManager); if (this.machineState.pc >= this.instructions.length) { - throw new InvalidProgramCounterError(this.machineState.pc, this.instructions.length); + throw new InvalidProgramCounterError(this.machineState.pc, /*max=*/ this.instructions.length); } } const returnData = this.machineState.getReturnData(); return AvmMessageCallResult.success(returnData); - } catch (e) { - // TODO: This should only accept AVM defined errors, anything else SHOULD be thrown upstream + } catch (_e) { + if (!(_e instanceof AvmInterpreterError)) { + throw _e; + } + + const revertReason: AvmInterpreterError = _e; const revertData = this.machineState.getReturnData(); - return AvmMessageCallResult.revert(revertData); + return AvmMessageCallResult.revert(revertData, revertReason); } } @@ -64,20 +68,22 @@ export class AvmInterpreter { } /** - * Error is thrown when the program counter goes to an invalid location. - * There is no instruction at the provided pc + * Avm-specific errors should derive from this */ -class InvalidProgramCounterError extends Error { - constructor(pc: number, max: number) { - super(`Invalid program counter ${pc}, max is ${max}`); +export abstract class AvmInterpreterError extends Error { + constructor(message: string) { + super(message); + this.name = 'AvmInterpreterError'; } } /** - * This assertion should never be hit - there should always be a valid instruction + * Error is thrown when the program counter goes to an invalid location. + * There is no instruction at the provided pc */ -class InvalidInstructionError extends Error { - constructor(pc: number) { - super(`Invalid instruction at ${pc}`); +export class InvalidProgramCounterError extends AvmInterpreterError { + constructor(pc: number, max: number) { + super(`Invalid program counter ${pc}, max is ${max}`); + this.name = 'InvalidProgramCounterError'; } } diff --git a/yarn-project/acir-simulator/src/avm/opcodes/bitwise.test.ts b/yarn-project/acir-simulator/src/avm/opcodes/bitwise.test.ts new file mode 100644 index 000000000000..e1de73560412 --- /dev/null +++ b/yarn-project/acir-simulator/src/avm/opcodes/bitwise.test.ts @@ -0,0 +1,166 @@ +import { Fr } from '@aztec/foundation/fields'; + +import { mock } from 'jest-mock-extended'; + +import { AvmMachineState } from '../avm_machine_state.js'; +import { AvmStateManager } from '../avm_state_manager.js'; +import { + And, + /*Not,*/ + Or, + Shl, + Shr, + Xor, +} from './bitwise.js'; + +describe('Bitwise instructions', () => { + let machineState: AvmMachineState; + let stateManager = mock(); + + beforeEach(() => { + machineState = new AvmMachineState([]); + stateManager = mock(); + }); + + it('Should AND correctly over Fr type', () => { + const a = new Fr(0b11111110010011100100n); + const b = new Fr(0b11100100111001001111n); + + machineState.writeMemory(0, a); + machineState.writeMemory(1, b); + + new And(0, 1, 2).execute(machineState, stateManager); + + const expected = new Fr(0b11100100010001000100n); + const actual = machineState.readMemory(2); + expect(actual).toEqual(expected); + }); + + it('Should OR correctly over Fr type', () => { + const a = new Fr(0b11111110010011100100n); + const b = new Fr(0b11100100111001001111n); + + machineState.writeMemory(0, a); + machineState.writeMemory(1, b); + + new Or(0, 1, 2).execute(machineState, stateManager); + + const expected = new Fr(0b11111110111011101111n); + const actual = machineState.readMemory(2); + expect(actual).toEqual(expected); + }); + + it('Should XOR correctly over Fr type', () => { + const a = new Fr(0b11111110010011100100n); + const b = new Fr(0b11100100111001001111n); + + machineState.writeMemory(0, a); + machineState.writeMemory(1, b); + + new Xor(0, 1, 2).execute(machineState, stateManager); + + const expected = new Fr(0b00011010101010101011n); + const actual = machineState.readMemory(2); + expect(actual).toEqual(expected); + }); + + describe('SHR', () => { + it('Should shift correctly 0 positions over Fr type', () => { + const a = new Fr(0b11111110010011100100n); + const b = new Fr(0n); + + machineState.writeMemory(0, a); + machineState.writeMemory(1, b); + + new Shr(0, 1, 2).execute(machineState, stateManager); + + const expected = a; + const actual = machineState.readMemory(2); + expect(actual).toEqual(expected); + }); + + it('Should shift correctly 2 positions over Fr type', () => { + const a = new Fr(0b11111110010011100100n); + const b = new Fr(2n); + + machineState.writeMemory(0, a); + machineState.writeMemory(1, b); + + new Shr(0, 1, 2).execute(machineState, stateManager); + + const expected = new Fr(0b00111111100100111001n); + const actual = machineState.readMemory(2); + expect(actual).toEqual(expected); + }); + + it('Should shift correctly 19 positions over Fr type', () => { + const a = new Fr(0b11111110010011100100n); + const b = new Fr(19n); + + machineState.writeMemory(0, a); + machineState.writeMemory(1, b); + + new Shr(0, 1, 2).execute(machineState, stateManager); + + const expected = new Fr(0b01n); + const actual = machineState.readMemory(2); + expect(actual).toEqual(expected); + }); + }); + + describe('SHL', () => { + it('Should shift correctly 0 positions over Fr type', () => { + const a = new Fr(0b11111110010011100100n); + const b = new Fr(0n); + + machineState.writeMemory(0, a); + machineState.writeMemory(1, b); + + new Shl(0, 1, 2).execute(machineState, stateManager); + + const expected = a; + const actual = machineState.readMemory(2); + expect(actual).toEqual(expected); + }); + + it('Should shift correctly 2 positions over Fr type', () => { + const a = new Fr(0b11111110010011100100n); + const b = new Fr(2n); + + machineState.writeMemory(0, a); + machineState.writeMemory(1, b); + + new Shl(0, 1, 2).execute(machineState, stateManager); + + const expected = new Fr(0b1111111001001110010000n); + const actual = machineState.readMemory(2); + expect(actual).toEqual(expected); + }); + + // it('Should shift correctly over bit limit over Fr type', () => { + // const a = new Fr(0b11111110010011100100n); + // const b = new Fr(19n); + + // machineState.writeMemory(0, a); + // machineState.writeMemory(1, b); + + // new Shl(0, 1, 2).execute(machineState, stateManager); + + // const expected = new Fr(0b01n); + // const actual = machineState.readMemory(2); + // expect(actual).toEqual(expected); + // }); + }); + + // it('Should NOT correctly over Fr type', () => { + // const a = new Fr(0b11111110010011100100n); + + // machineState.writeMemory(0, a); + + // new Not(0, 1).execute(machineState, stateManager); + + // const expected = new Fr(0b00000001101100011011n); // high bits! + // const actual = machineState.readMemory(1); + // expect(actual).toEqual(expected); + // }); +}); diff --git a/yarn-project/acir-simulator/src/avm/opcodes/bitwise.ts b/yarn-project/acir-simulator/src/avm/opcodes/bitwise.ts index 4950c771f7c6..ff7802aac614 100644 --- a/yarn-project/acir-simulator/src/avm/opcodes/bitwise.ts +++ b/yarn-project/acir-simulator/src/avm/opcodes/bitwise.ts @@ -120,6 +120,9 @@ export class Shr extends Instruction { const a: Fr = machineState.readMemory(this.aOffset); const b: Fr = machineState.readMemory(this.bOffset); + // Here we are assuming that the field element maps to a positive number. + // The >> operator is *signed* in JS (and it sign extends). + // E.g.: -1n >> 3n == -1n. const dest = new Fr(a.toBigInt() >> b.toBigInt()); machineState.writeMemory(this.destOffset, dest); diff --git a/yarn-project/acir-simulator/src/avm/opcodes/control_flow.test.ts b/yarn-project/acir-simulator/src/avm/opcodes/control_flow.test.ts index 864ee0d0b425..906584b3493d 100644 --- a/yarn-project/acir-simulator/src/avm/opcodes/control_flow.test.ts +++ b/yarn-project/acir-simulator/src/avm/opcodes/control_flow.test.ts @@ -8,7 +8,7 @@ import { Add, Mul, Sub } from './arithmetic.js'; import { And, Not, Or, Shl, Shr, Xor } from './bitwise.js'; import { Eq, Lt, Lte } from './comparators.js'; import { InternalCall, InternalCallStackEmptyError, InternalReturn, Jump, JumpI } from './control_flow.js'; -import { CalldataCopy, Cast, Mov, Set } from './memory.js'; +import { CMov, CalldataCopy, Cast, Mov, Set } from './memory.js'; describe('Control Flow Opcodes', () => { let stateManager = mock(); @@ -132,6 +132,7 @@ describe('Control Flow Opcodes', () => { new CalldataCopy(0, 1, 2), new Set(0n, 1), new Mov(0, 1), + new CMov(0, 1, 2, 3), new Cast(0, 1), ]; diff --git a/yarn-project/acir-simulator/src/avm/opcodes/instruction_set.ts b/yarn-project/acir-simulator/src/avm/opcodes/instruction_set.ts index 4395ba46d534..664467f887dd 100644 --- a/yarn-project/acir-simulator/src/avm/opcodes/instruction_set.ts +++ b/yarn-project/acir-simulator/src/avm/opcodes/instruction_set.ts @@ -1,12 +1,9 @@ import { Add, Div, Mul, Sub } from './arithmetic.js'; -//import { And, Not, Or, Shl, Shr, Xor } from './bitwise.js'; +import { And, Not, Or, Shl, Shr, Xor } from './bitwise.js'; //import { Eq, Lt, Lte } from './comparators.js'; import { InternalCall, InternalReturn, Jump, JumpI, Return } from './control_flow.js'; import { Instruction } from './instruction.js'; -import { - CalldataCopy, - /*Cast, Mov*/ -} from './memory.js'; +import { CMov, CalldataCopy, Cast, Mov, Set } from './memory.js'; import { Opcode } from './opcodes.js'; /** - */ @@ -30,14 +27,14 @@ export const INSTRUCTION_SET: Map = ne //[Opcode.LT, Lt], //[Opcode.LTE, Lte], //// Compute - Bitwise - //[Opcode.AND, And], - //[Opcode.OR, Or], - //[Opcode.XOR, Xor], - //[Opcode.NOT, Not], - //[Opcode.SHL, Shl], - //[Opcode.SHR, Shr], + [Opcode.AND, And], + [Opcode.OR, Or], + [Opcode.XOR, Xor], + [Opcode.NOT, Not], + [Opcode.SHL, Shl], + [Opcode.SHR, Shr], //// Compute - Type Conversions - //[Opcode.CAST, Cast], + [Opcode.CAST, Cast], //// Execution Environment //[Opcode.ADDRESS, Address], @@ -72,9 +69,9 @@ export const INSTRUCTION_SET: Map = ne [Opcode.INTERNALCALL, InternalCall], [Opcode.INTERNALRETURN, InternalReturn], //// Machine State - Memory - //[Opcode.SET, Set], - //[Opcode.MOV, Mov], - //[Opcode.CMOV, CMov], + [Opcode.SET, Set], + [Opcode.MOV, Mov], + [Opcode.CMOV, CMov], //// World State //[Opcode.BLOCKHEADERBYNUMBER, Blockheaderbynumber], diff --git a/yarn-project/acir-simulator/src/avm/opcodes/memory.test.ts b/yarn-project/acir-simulator/src/avm/opcodes/memory.test.ts new file mode 100644 index 000000000000..3b02ef36c32c --- /dev/null +++ b/yarn-project/acir-simulator/src/avm/opcodes/memory.test.ts @@ -0,0 +1,182 @@ +import { Fr } from '@aztec/foundation/fields'; + +import { mock } from 'jest-mock-extended'; + +import { AvmMachineState } from '../avm_machine_state.js'; +import { AvmStateManager } from '../avm_state_manager.js'; +import { CMov, CalldataCopy, Cast, Mov, Set } from './memory.js'; + +describe('Memory instructions', () => { + let machineState: AvmMachineState; + let stateManager = mock(); + + beforeEach(() => { + machineState = new AvmMachineState([]); + stateManager = mock(); + }); + + it('Should SET memory correctly', () => { + const value = 123456n; + + new Set(value, 1).execute(machineState, stateManager); + + const expected = new Fr(value); + const actual = machineState.readMemory(1); + expect(actual).toEqual(expected); + }); + + // TODO(https://github.com/AztecProtocol/aztec-packages/issues/3987): tags are not implemented yet - this will behave as a mov + describe('CAST', () => { + it('Should work correctly on different memory cells', () => { + const value = new Fr(123456n); + + machineState.writeMemory(0, value); + + new Cast(/*aOffset=*/ 0, /*dstOffset=*/ 1).execute(machineState, stateManager); + + const actual = machineState.readMemory(1); + expect(actual).toEqual(value); + }); + + it('Should work correctly on same memory cell', () => { + const value = new Fr(123456n); + + machineState.writeMemory(0, value); + + new Cast(/*aOffset=*/ 0, /*dstOffset=*/ 0).execute(machineState, stateManager); + + const actual = machineState.readMemory(0); + expect(actual).toEqual(value); + }); + }); + + describe('MOV', () => { + it('Should work correctly on different memory cells', () => { + const value = new Fr(123456n); + + machineState.writeMemory(0, value); + + new Mov(/*aOffset=*/ 0, /*dstOffset=*/ 1).execute(machineState, stateManager); + + const actual = machineState.readMemory(1); + expect(actual).toEqual(value); + }); + + it('Should work correctly on same memory cell', () => { + const value = new Fr(123456n); + + machineState.writeMemory(0, value); + + new Mov(/*aOffset=*/ 0, /*dstOffset=*/ 0).execute(machineState, stateManager); + + const actual = machineState.readMemory(0); + expect(actual).toEqual(value); + }); + }); + + describe('MOV', () => { + it('Should move A if COND is true, on different memory cells', () => { + const valueA = new Fr(123456n); + const valueB = new Fr(80n); + const valueCondition = new Fr(22n); + + machineState.writeMemory(0, valueA); + machineState.writeMemory(1, valueB); + machineState.writeMemory(2, valueCondition); + + new CMov(/*aOffset=*/ 0, /*bOffset=*/ 1, /*condOffset=*/ 2, /*dstOffset=*/ 3).execute(machineState, stateManager); + + const actual = machineState.readMemory(3); + expect(actual).toEqual(valueA); + }); + + it('Should move B if COND is false, on different memory cells', () => { + const valueA = new Fr(123456n); + const valueB = new Fr(80n); + const valueCondition = new Fr(0n); + + machineState.writeMemory(0, valueA); + machineState.writeMemory(1, valueB); + machineState.writeMemory(2, valueCondition); + + new CMov(/*aOffset=*/ 0, /*bOffset=*/ 1, /*condOffset=*/ 2, /*dstOffset=*/ 3).execute(machineState, stateManager); + + const actual = machineState.readMemory(3); + expect(actual).toEqual(valueB); + }); + + it('Should move A if COND is true, on overlapping memory cells', () => { + const valueA = new Fr(123456n); + const valueB = new Fr(80n); + const valueCondition = new Fr(22n); + + machineState.writeMemory(0, valueA); + machineState.writeMemory(1, valueB); + machineState.writeMemory(2, valueCondition); + + new CMov(/*aOffset=*/ 0, /*bOffset=*/ 1, /*condOffset=*/ 2, /*dstOffset=*/ 2).execute(machineState, stateManager); + + const actual = machineState.readMemory(2); + expect(actual).toEqual(valueA); + }); + + it('Should move B if COND is false, on overlapping memory cells', () => { + const valueA = new Fr(123456n); + const valueB = new Fr(80n); + const valueCondition = new Fr(0n); + + machineState.writeMemory(0, valueA); + machineState.writeMemory(1, valueB); + machineState.writeMemory(2, valueCondition); + + new CMov(/*aOffset=*/ 0, /*bOffset=*/ 1, /*condOffset=*/ 2, /*dstOffset=*/ 2).execute(machineState, stateManager); + + const actual = machineState.readMemory(2); + expect(actual).toEqual(valueB); + }); + }); + + describe('CALLDATA', () => { + it('Writes nothing if size is 0', () => { + const previousValue = new Fr(123456n); + const calldata = [new Fr(1n), new Fr(2n), new Fr(3n)]; + + machineState = new AvmMachineState(calldata); + machineState.writeMemory(0, previousValue); + + new CalldataCopy(/*cdOffset=*/ 2, /*copySize=*/ 0, /*dstOffset=*/ 0).execute(machineState, stateManager); + + const actual = machineState.readMemory(0); + expect(actual).toEqual(previousValue); + }); + + it('Copies all calldata', () => { + const previousValue = new Fr(123456n); + const calldata = [new Fr(1n), new Fr(2n), new Fr(3n)]; + + machineState = new AvmMachineState(calldata); + machineState.writeMemory(0, previousValue); + + new CalldataCopy(/*cdOffset=*/ 0, /*copySize=*/ 3, /*dstOffset=*/ 0).execute(machineState, stateManager); + + const actual = machineState.readMemoryChunk(/*offset=*/ 0, /*size=*/ 3); + expect(actual).toEqual(calldata); + }); + + it('Copies slice of calldata', () => { + const previousValue = new Fr(123456n); + const calldata = [new Fr(1n), new Fr(2n), new Fr(3n)]; + + machineState = new AvmMachineState(calldata); + machineState.writeMemory(0, previousValue); + + new CalldataCopy(/*cdOffset=*/ 1, /*copySize=*/ 2, /*dstOffset=*/ 0).execute(machineState, stateManager); + + const expected = calldata.slice(1); + const actual = machineState.readMemoryChunk(/*offset=*/ 0, /*size=*/ 2); + expect(actual).toEqual(expected); + }); + + // TODO: check bad cases (i.e., out of bounds) + }); +}); diff --git a/yarn-project/acir-simulator/src/avm/opcodes/memory.ts b/yarn-project/acir-simulator/src/avm/opcodes/memory.ts index c856645eef9b..3e6bbc62afdd 100644 --- a/yarn-project/acir-simulator/src/avm/opcodes/memory.ts +++ b/yarn-project/acir-simulator/src/avm/opcodes/memory.ts @@ -9,13 +9,12 @@ export class Set extends Instruction { static type: string = 'SET'; static numberOfOperands = 2; - constructor(private constt: bigint, private destOffset: number) { + constructor(private value: bigint, private destOffset: number) { super(); } execute(machineState: AvmMachineState, _stateManager: AvmStateManager): void { - const dest = new Fr(this.constt); - machineState.writeMemory(this.destOffset, dest); + machineState.writeMemory(this.destOffset, new Fr(this.value)); this.incrementPc(machineState); } @@ -58,6 +57,31 @@ export class Mov extends Instruction { } } +/** - */ +export class CMov extends Instruction { + static type: string = 'MOV'; + static numberOfOperands = 4; + + constructor( + private aOffset: number, + private bOffset: number, + private condOffset: number, + private destOffset: number, + ) { + super(); + } + + execute(machineState: AvmMachineState, _stateManager: AvmStateManager): void { + const a = machineState.readMemory(this.aOffset); + const b = machineState.readMemory(this.bOffset); + const cond = machineState.readMemory(this.condOffset); + + machineState.writeMemory(this.destOffset, cond.toBigInt() ? a : b); + + this.incrementPc(machineState); + } +} + /** - */ export class CalldataCopy extends Instruction { static type: string = 'CALLDATACOPY'; diff --git a/yarn-project/acir-simulator/src/avm/opcodes/opcodes.ts b/yarn-project/acir-simulator/src/avm/opcodes/opcodes.ts index e0760e102132..6f3f37090078 100644 --- a/yarn-project/acir-simulator/src/avm/opcodes/opcodes.ts +++ b/yarn-project/acir-simulator/src/avm/opcodes/opcodes.ts @@ -1,83 +1,87 @@ /** - * All AVM opcodes + * All AVM opcodes. + * Source: https://yp-aztec.netlify.app/docs/public-vm/instruction-set */ export enum Opcode { // Compute // Compute - Arithmetic - ADD, - SUB, - MUL, - DIV, + ADD = 0x00, + SUB = 0x01, + MUL = 0x02, + DIV = 0x03, // Compute - Comparators - EQ, - LT, - LTE, + EQ = 0x04, + LT = 0x05, + LTE = 0x06, // Compute - Bitwise - AND, - OR, - XOR, - NOT, - SHL, - SHR, + AND = 0x07, + OR = 0x08, + XOR = 0x09, + NOT = 0x0a, + SHL = 0x0b, + SHR = 0x0c, // Compute - Type Conversions - CAST, + CAST = 0x0d, // Execution Environment - ADDRESS, - STORAGEADDRESS, - ORIGIN, - SENDER, - PORTAL, - FEEPERL1GAS, - FEEPERL2GAS, - FEEPERDAGAS, - CONTRACTCALLDEPTH, + ADDRESS = 0x0e, + STORAGEADDRESS = 0x0f, + ORIGIN = 0x10, + SENDER = 0x11, + PORTAL = 0x12, + FEEPERL1GAS = 0x13, + FEEPERL2GAS = 0x14, + FEEPERDAGAS = 0x15, + CONTRACTCALLDEPTH = 0x16, // Execution Environment - Globals - CHAINID, - VERSION, - BLOCKNUMBER, - TIMESTAMP, - COINBASE, - BLOCKL1GASLIMIT, - BLOCKL2GASLIMIT, - BLOCKDAGASLIMIT, + CHAINID = 0x17, + VERSION = 0x18, + BLOCKNUMBER = 0x19, + TIMESTAMP = 0x1a, + COINBASE = 0x1b, + BLOCKL1GASLIMIT = 0x1c, + BLOCKL2GASLIMIT = 0x1d, + BLOCKDAGASLIMIT = 0x1e, // Execution Environment - Calldata - CALLDATACOPY, + CALLDATACOPY = 0x1f, // Machine State // Machine State - Gas - L1GASLEFT, - L2GASLEFT, - DAGASLEFT, + L1GASLEFT = 0x20, + L2GASLEFT = 0x21, + DAGASLEFT = 0x22, // Machine State - Internal Control Flow - JUMP, - JUMPI, - INTERNALCALL, - INTERNALRETURN, + JUMP = 0x23, + JUMPI = 0x24, + INTERNALCALL = 0x25, + INTERNALRETURN = 0x26, // Machine State - Memory - SET, - MOV, - CMOV, + SET = 0x27, + MOV = 0x28, + CMOV = 0x29, // World State - BLOCKHEADERBYNUMBER, - SLOAD, // Public Storage - SSTORE, // Public Storage - READL1TOL2MSG, // Messages - SENDL2TOL1MSG, // Messages - EMITNOTEHASH, // Notes & Nullifiers - EMITNULLIFIER, // Notes & Nullifiers + BLOCKHEADERBYNUMBER = 0x2a, + SLOAD = 0x2b, // Public Storage + SSTORE = 0x2c, // Public Storage + READL1TOL2MSG = 0x2d, // Messages + SENDL2TOL1MSG = 0x2e, // Messages + EMITNOTEHASH = 0x2f, // Notes & Nullifiers + EMITNULLIFIER = 0x30, // Notes & Nullifiers // Accrued Substate - EMITUNENCRYPTEDLOG, + EMITUNENCRYPTEDLOG = 0x31, // Control Flow - Contract Calls - CALL, - STATICCALL, - RETURN, - REVERT, + CALL = 0x32, + STATICCALL = 0x33, + RETURN = 0x34, + REVERT = 0x35, // Gadgets - KECCAK, - POSEIDON, + KECCAK = 0x36, + POSEIDON = 0x37, + + // Add new opcodes before this + TOTAL_OPCODES_NUMBER, } diff --git a/yarn-project/acir-simulator/src/client/db_oracle.ts b/yarn-project/acir-simulator/src/client/db_oracle.ts index eb4f59fae84e..7090aa52300f 100644 --- a/yarn-project/acir-simulator/src/client/db_oracle.ts +++ b/yarn-project/acir-simulator/src/client/db_oracle.ts @@ -1,11 +1,11 @@ import { L2Block, MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@aztec/circuit-types'; -import { BlockHeader, CompleteAddress, GrumpkinPrivateKey, PublicKey } from '@aztec/circuits.js'; +import { BlockHeader, CompleteAddress } from '@aztec/circuits.js'; import { FunctionArtifactWithDebugMetadata, FunctionSelector } from '@aztec/foundation/abi'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { EthAddress } from '@aztec/foundation/eth-address'; import { Fr } from '@aztec/foundation/fields'; -import { NoteData } from '../acvm/index.js'; +import { KeyPair, NoteData } from '../acvm/index.js'; import { CommitmentsDB } from '../public/db.js'; /** @@ -43,16 +43,16 @@ export interface DBOracle extends CommitmentsDB { popCapsule(): Promise; /** - * Retrieve the secret key associated with a specific public key. + * Retrieve the nullifier key pair associated with a specific account. * The function only allows access to the secret keys of the transaction creator, - * and throws an error if the address does not match the public key address of the key pair. + * and throws an error if the address does not match the account address of the key pair. * - * @param contractAddress - The contract address. Ignored here. But we might want to return different keys for different contracts. - * @param pubKey - The public key of an account. - * @returns A Promise that resolves to the secret key. - * @throws An Error if the input address does not match the public key address of the key pair. + * @param accountAddress - The account address. + * @param contractAddress - The contract address. + * @returns A Promise that resolves to the nullifier key pair. + * @throws An Error if the input address does not match the account address of the key pair. */ - getSecretKey(contractAddress: AztecAddress, pubKey: PublicKey): Promise; + getNullifierKeyPair(accountAddress: AztecAddress, contractAddress: AztecAddress): Promise; /** * Retrieves a set of notes stored in the database for a given contract address and storage slot. diff --git a/yarn-project/acir-simulator/src/client/private_execution.test.ts b/yarn-project/acir-simulator/src/client/private_execution.test.ts index becd6a0f73c6..775433dbeb86 100644 --- a/yarn-project/acir-simulator/src/client/private_execution.test.ts +++ b/yarn-project/acir-simulator/src/client/private_execution.test.ts @@ -1,4 +1,4 @@ -import { Note, PackedArguments, TxExecutionRequest } from '@aztec/circuit-types'; +import { L1ToL2Message, Note, PackedArguments, TxExecutionRequest } from '@aztec/circuit-types'; import { BlockHeader, CallContext, @@ -9,8 +9,10 @@ import { MAX_NEW_COMMITMENTS_PER_CALL, NOTE_HASH_TREE_HEIGHT, PublicCallRequest, - PublicKey, TxContext, + computeNullifierSecretKey, + computeSiloedNullifierSecretKey, + derivePublicKey, nonEmptySideEffects, sideEffectArrayToValueArray, } from '@aztec/circuits.js'; @@ -52,6 +54,7 @@ import { default as levelup } from 'levelup'; import { type MemDown, default as memdown } from 'memdown'; import { getFunctionSelector } from 'viem'; +import { KeyPair } from '../acvm/index.js'; import { buildL1ToL2Message } from '../test/utils.js'; import { computeSlotForMapping } from '../utils.js'; import { DBOracle } from './db_oracle.js'; @@ -75,13 +78,15 @@ describe('Private Execution test suite', () => { let recipient: AztecAddress; let ownerCompleteAddress: CompleteAddress; let recipientCompleteAddress: CompleteAddress; + let ownerNullifierKeyPair: KeyPair; + let recipientNullifierKeyPair: KeyPair; const treeHeights: { [name: string]: number } = { noteHash: NOTE_HASH_TREE_HEIGHT, l1ToL2Messages: L1_TO_L2_MSG_TREE_HEIGHT, }; - const trees: { [name: keyof typeof treeHeights]: AppendOnlyTree } = {}; + let trees: { [name: keyof typeof treeHeights]: AppendOnlyTree } = {}; const txContextFields: FieldsOf = { isContractDeploymentTx: false, isFeePaymentTx: false, @@ -138,7 +143,7 @@ describe('Private Execution test suite', () => { await trees[name].appendLeaves(leaves.map(l => l.toBuffer())); // Update root. - const newRoot = trees[name].getRoot(false); + const newRoot = trees[name].getRoot(true); const prevRoots = blockHeader.toBuffer(); const rootIndex = name === 'noteHash' ? 0 : 32 * 3; const newRoots = Buffer.concat([prevRoots.subarray(0, rootIndex), newRoot, prevRoots.subarray(rootIndex + 32)]); @@ -157,18 +162,37 @@ describe('Private Execution test suite', () => { owner = ownerCompleteAddress.address; recipient = recipientCompleteAddress.address; + + const ownerNullifierSecretKey = computeNullifierSecretKey(ownerPk); + ownerNullifierKeyPair = { + secretKey: ownerNullifierSecretKey, + publicKey: derivePublicKey(ownerNullifierSecretKey), + }; + + const recipientNullifierSecretKey = computeNullifierSecretKey(recipientPk); + recipientNullifierKeyPair = { + secretKey: recipientNullifierSecretKey, + publicKey: derivePublicKey(recipientNullifierSecretKey), + }; }); beforeEach(() => { + trees = {}; oracle = mock(); - oracle.getSecretKey.mockImplementation((contractAddress: AztecAddress, pubKey: PublicKey) => { - if (pubKey.equals(ownerCompleteAddress.publicKey)) { - return Promise.resolve(ownerPk); + oracle.getNullifierKeyPair.mockImplementation((accountAddress: AztecAddress, contractAddress: AztecAddress) => { + if (accountAddress.equals(ownerCompleteAddress.address)) { + return Promise.resolve({ + publicKey: ownerNullifierKeyPair.publicKey, + secretKey: computeSiloedNullifierSecretKey(ownerNullifierKeyPair.secretKey, contractAddress), + }); } - if (pubKey.equals(recipientCompleteAddress.publicKey)) { - return Promise.resolve(recipientPk); + if (accountAddress.equals(recipientCompleteAddress.address)) { + return Promise.resolve({ + publicKey: recipientNullifierKeyPair.publicKey, + secretKey: computeSiloedNullifierSecretKey(recipientNullifierKeyPair.secretKey, contractAddress), + }); } - throw new Error(`Unknown address ${pubKey}`); + throw new Error(`Unknown address ${accountAddress}`); }); oracle.getBlockHeader.mockResolvedValue(blockHeader); @@ -453,53 +477,248 @@ describe('Private Execution test suite', () => { }); }); - it('Should be able to consume a dummy cross chain message', async () => { - const bridgedAmount = 100n; + describe('L1 to L2', () => { const artifact = getFunctionArtifact(TestContractArtifact, 'consume_mint_private_message'); + const canceller = EthAddress.random(); + let bridgedAmount = 100n; - const secretForL1ToL2MessageConsumption = new Fr(1n); const secretHashForRedeemingNotes = new Fr(2n); - const canceller = EthAddress.random(); - const preimage = buildL1ToL2Message( - getFunctionSelector('mint_private(bytes32,uint256,address)').substring(2), - [secretHashForRedeemingNotes, new Fr(bridgedAmount), canceller.toField()], - contractAddress, - secretForL1ToL2MessageConsumption, - ); + let secretForL1ToL2MessageConsumption = new Fr(1n); - // stub message key - const messageKey = Fr.random(); - const tree = await insertLeaves([messageKey], 'l1ToL2Messages'); + let crossChainMsgRecipient: AztecAddress | undefined; + let crossChainMsgSender: EthAddress | undefined; + let messageKey: Fr | undefined; - oracle.getL1ToL2Message.mockImplementation(async () => { - return Promise.resolve({ - message: preimage.toFieldArray(), - index: 0n, - siblingPath: (await tree.getSiblingPath(0n, false)).toFieldArray(), + let preimage: L1ToL2Message; + + let args: Fr[]; + + beforeEach(() => { + bridgedAmount = 100n; + secretForL1ToL2MessageConsumption = new Fr(2n); + + crossChainMsgRecipient = undefined; + crossChainMsgSender = undefined; + messageKey = undefined; + }); + + const computePreimage = () => + buildL1ToL2Message( + getFunctionSelector('mint_private(bytes32,uint256,address)').substring(2), + [secretHashForRedeemingNotes, new Fr(bridgedAmount), canceller.toField()], + crossChainMsgRecipient ?? contractAddress, + secretForL1ToL2MessageConsumption, + ); + + const computeArgs = () => + encodeArguments(artifact, [ + secretHashForRedeemingNotes, + bridgedAmount, + canceller.toField(), + messageKey ?? preimage.hash(), + secretForL1ToL2MessageConsumption, + ]); + + const mockOracles = async () => { + const tree = await insertLeaves([messageKey ?? preimage.hash()], 'l1ToL2Messages'); + oracle.getL1ToL2Message.mockImplementation(async () => { + return Promise.resolve({ + message: preimage.toFieldArray(), + index: 0n, + siblingPath: (await tree.getSiblingPath(0n, false)).toFieldArray(), + }); }); + }; + + it('Should be able to consume a dummy cross chain message', async () => { + preimage = computePreimage(); + + args = computeArgs(); + + await mockOracles(); + // Update state + oracle.getBlockHeader.mockResolvedValue(blockHeader); + + const result = await runSimulator({ + contractAddress, + artifact, + args, + portalContractAddress: crossChainMsgSender ?? preimage.sender.sender, + txContext: { version: new Fr(1n), chainId: new Fr(1n) }, + }); + + // Check a nullifier has been inserted + const newNullifiers = sideEffectArrayToValueArray( + nonEmptySideEffects(result.callStackItem.publicInputs.newNullifiers), + ); + + expect(newNullifiers).toHaveLength(1); }); - const args = [ - secretHashForRedeemingNotes, - bridgedAmount, - canceller.toField(), - messageKey, - secretForL1ToL2MessageConsumption, - ]; - const result = await runSimulator({ - contractAddress, - artifact, - args, - portalContractAddress: preimage.sender.sender, - txContext: { version: new Fr(1n), chainId: new Fr(1n) }, + it('Message not matching requested key', async () => { + messageKey = Fr.random(); + + preimage = computePreimage(); + + args = computeArgs(); + + await mockOracles(); + // Update state + oracle.getBlockHeader.mockResolvedValue(blockHeader); + + await expect( + runSimulator({ + contractAddress, + artifact, + args, + portalContractAddress: crossChainMsgSender ?? preimage.sender.sender, + txContext: { version: new Fr(1n), chainId: new Fr(1n) }, + }), + ).rejects.toThrowError('Message not matching requested key'); }); - // Check a nullifier has been inserted - const newNullifiers = sideEffectArrayToValueArray( - nonEmptySideEffects(result.callStackItem.publicInputs.newNullifiers), - ); + it('Invalid membership proof', async () => { + preimage = computePreimage(); - expect(newNullifiers).toHaveLength(1); + args = computeArgs(); + + await mockOracles(); + + await expect( + runSimulator({ + contractAddress, + artifact, + args, + portalContractAddress: crossChainMsgSender ?? preimage.sender.sender, + txContext: { version: new Fr(1n), chainId: new Fr(1n) }, + }), + ).rejects.toThrowError('Message not in state'); + }); + + it('Invalid recipient', async () => { + crossChainMsgRecipient = AztecAddress.random(); + + preimage = computePreimage(); + + args = computeArgs(); + + await mockOracles(); + // Update state + oracle.getBlockHeader.mockResolvedValue(blockHeader); + + await expect( + runSimulator({ + contractAddress, + artifact, + args, + portalContractAddress: crossChainMsgSender ?? preimage.sender.sender, + txContext: { version: new Fr(1n), chainId: new Fr(1n) }, + }), + ).rejects.toThrowError('Invalid recipient'); + }); + + it('Invalid sender', async () => { + crossChainMsgSender = EthAddress.random(); + preimage = computePreimage(); + + args = computeArgs(); + + await mockOracles(); + // Update state + oracle.getBlockHeader.mockResolvedValue(blockHeader); + + await expect( + runSimulator({ + contractAddress, + artifact, + args, + portalContractAddress: crossChainMsgSender ?? preimage.sender.sender, + txContext: { version: new Fr(1n), chainId: new Fr(1n) }, + }), + ).rejects.toThrowError('Invalid sender'); + }); + + it('Invalid chainid', async () => { + preimage = computePreimage(); + + args = computeArgs(); + + await mockOracles(); + // Update state + oracle.getBlockHeader.mockResolvedValue(blockHeader); + + await expect( + runSimulator({ + contractAddress, + artifact, + args, + portalContractAddress: crossChainMsgSender ?? preimage.sender.sender, + txContext: { version: new Fr(1n), chainId: new Fr(2n) }, + }), + ).rejects.toThrowError('Invalid Chainid'); + }); + + it('Invalid version', async () => { + preimage = computePreimage(); + + args = computeArgs(); + + await mockOracles(); + // Update state + oracle.getBlockHeader.mockResolvedValue(blockHeader); + + await expect( + runSimulator({ + contractAddress, + artifact, + args, + portalContractAddress: crossChainMsgSender ?? preimage.sender.sender, + txContext: { version: new Fr(2n), chainId: new Fr(1n) }, + }), + ).rejects.toThrowError('Invalid Version'); + }); + + it('Invalid content', async () => { + preimage = computePreimage(); + + bridgedAmount = bridgedAmount + 1n; // Invalid amount + args = computeArgs(); + + await mockOracles(); + // Update state + oracle.getBlockHeader.mockResolvedValue(blockHeader); + + await expect( + runSimulator({ + contractAddress, + artifact, + args, + portalContractAddress: crossChainMsgSender ?? preimage.sender.sender, + txContext: { version: new Fr(1n), chainId: new Fr(1n) }, + }), + ).rejects.toThrowError('Invalid Content'); + }); + + it('Invalid Secret', async () => { + preimage = computePreimage(); + + secretForL1ToL2MessageConsumption = Fr.random(); + args = computeArgs(); + + await mockOracles(); + // Update state + oracle.getBlockHeader.mockResolvedValue(blockHeader); + + await expect( + runSimulator({ + contractAddress, + artifact, + args, + portalContractAddress: crossChainMsgSender ?? preimage.sender.sender, + txContext: { version: new Fr(1n), chainId: new Fr(1n) }, + }), + ).rejects.toThrowError('Invalid message secret'); + }); }); it('Should be able to consume a dummy public to private message', async () => { @@ -659,7 +878,15 @@ describe('Private Execution test suite', () => { expect(gotNoteValue).toEqual(amountToTransfer); const nullifier = result.callStackItem.publicInputs.newNullifiers[0]; - const expectedNullifier = hashFields([innerNoteHash, ownerPk.low, ownerPk.high]); + const siloedNullifierSecretKey = computeSiloedNullifierSecretKey( + ownerNullifierKeyPair.secretKey, + contractAddress, + ); + const expectedNullifier = hashFields([ + innerNoteHash, + siloedNullifierSecretKey.low, + siloedNullifierSecretKey.high, + ]); expect(nullifier.value).toEqual(expectedNullifier); }); @@ -732,7 +959,15 @@ describe('Private Execution test suite', () => { expect(gotNoteValue).toEqual(amountToTransfer); const nullifier = execGetThenNullify.callStackItem.publicInputs.newNullifiers[0]; - const expectedNullifier = hashFields([innerNoteHash, ownerPk.low, ownerPk.high]); + const siloedNullifierSecretKey = computeSiloedNullifierSecretKey( + ownerNullifierKeyPair.secretKey, + contractAddress, + ); + const expectedNullifier = hashFields([ + innerNoteHash, + siloedNullifierSecretKey.low, + siloedNullifierSecretKey.high, + ]); expect(nullifier.value).toEqual(expectedNullifier); // check that the last get_notes call return no note diff --git a/yarn-project/acir-simulator/src/client/simulator.test.ts b/yarn-project/acir-simulator/src/client/simulator.test.ts index b1e0d95a4bcc..7c5a3e830e28 100644 --- a/yarn-project/acir-simulator/src/client/simulator.test.ts +++ b/yarn-project/acir-simulator/src/client/simulator.test.ts @@ -4,7 +4,7 @@ import { computeUniqueCommitment, siloCommitment } from '@aztec/circuits.js/abis import { ABIParameterVisibility, FunctionArtifactWithDebugMetadata, getFunctionArtifact } from '@aztec/foundation/abi'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { pedersenHash } from '@aztec/foundation/crypto'; -import { Fr, GrumpkinScalar } from '@aztec/foundation/fields'; +import { Fr, GrumpkinScalar, Point } from '@aztec/foundation/fields'; import { TokenContractArtifact } from '@aztec/noir-contracts/Token'; import { MockProxy, mock } from 'jest-mock-extended'; @@ -15,20 +15,20 @@ import { AcirSimulator } from './simulator.js'; describe('Simulator', () => { let oracle: MockProxy; let simulator: AcirSimulator; - let ownerCompleteAddress: CompleteAddress; - let owner: AztecAddress; const ownerPk = GrumpkinScalar.fromString('2dcc5485a58316776299be08c78fa3788a1a7961ae30dc747fb1be17692a8d32'); + const ownerCompleteAddress = CompleteAddress.fromPrivateKeyAndPartialAddress(ownerPk, Fr.random()); + const owner = ownerCompleteAddress.address; + const ownerNullifierSecretKey = GrumpkinScalar.random(); + const ownerNullifierPublicKey = Point.random(); const hashFields = (data: Fr[]) => Fr.fromBuffer(pedersenHash(data.map(f => f.toBuffer()))); - beforeAll(() => { - ownerCompleteAddress = CompleteAddress.fromPrivateKeyAndPartialAddress(ownerPk, Fr.random()); - owner = ownerCompleteAddress.address; - }); - beforeEach(() => { oracle = mock(); - oracle.getSecretKey.mockResolvedValue(ownerPk); + oracle.getNullifierKeyPair.mockResolvedValue({ + secretKey: ownerNullifierSecretKey, + publicKey: ownerNullifierPublicKey, + }); oracle.getCompleteAddress.mockResolvedValue(ownerCompleteAddress); simulator = new AcirSimulator(oracle); @@ -50,7 +50,11 @@ describe('Simulator', () => { const innerNoteHash = hashFields([storageSlot, valueNoteHash]); const siloedNoteHash = siloCommitment(contractAddress, innerNoteHash); const uniqueSiloedNoteHash = computeUniqueCommitment(nonce, siloedNoteHash); - const innerNullifier = hashFields([uniqueSiloedNoteHash, ownerPk.low, ownerPk.high]); + const innerNullifier = hashFields([ + uniqueSiloedNoteHash, + ownerNullifierSecretKey.low, + ownerNullifierSecretKey.high, + ]); const result = await simulator.computeNoteHashAndNullifier(contractAddress, nonce, storageSlot, note); diff --git a/yarn-project/acir-simulator/src/client/simulator.ts b/yarn-project/acir-simulator/src/client/simulator.ts index 92430a19969a..74e6c1ae4eed 100644 --- a/yarn-project/acir-simulator/src/client/simulator.ts +++ b/yarn-project/acir-simulator/src/client/simulator.ts @@ -184,7 +184,7 @@ export class AcirSimulator { const extendedNoteItems = note.items.concat(Array(maxNoteFields - note.items.length).fill(Fr.ZERO)); const execRequest: FunctionCall = { - to: AztecAddress.ZERO, + to: contractAddress, functionData: FunctionData.empty(), args: encodeArguments(artifact, [contractAddress, nonce, storageSlot, extendedNoteItems]), }; @@ -192,7 +192,7 @@ export class AcirSimulator { const [innerNoteHash, siloedNoteHash, uniqueSiloedNoteHash, innerNullifier] = (await this.runUnconstrained( execRequest, artifact, - AztecAddress.ZERO, + contractAddress, )) as bigint[]; return { diff --git a/yarn-project/acir-simulator/src/client/view_data_oracle.ts b/yarn-project/acir-simulator/src/client/view_data_oracle.ts index b029833f2ea3..3fb79b16b6fd 100644 --- a/yarn-project/acir-simulator/src/client/view_data_oracle.ts +++ b/yarn-project/acir-simulator/src/client/view_data_oracle.ts @@ -7,7 +7,7 @@ import { NullifierMembershipWitness, PublicDataWitness, } from '@aztec/circuit-types'; -import { BlockHeader, PublicKey } from '@aztec/circuits.js'; +import { BlockHeader } from '@aztec/circuits.js'; import { computeGlobalsHash, siloNullifier } from '@aztec/circuits.js/abis'; import { AztecAddress } from '@aztec/foundation/aztec-address'; import { Fr } from '@aztec/foundation/fields'; @@ -36,11 +36,11 @@ export class ViewDataOracle extends TypedOracle { } /** - * Return the secret key of a owner to use in a specific contract. - * @param owner - The owner of the secret key. + * Return the nullifier key pair of an account to use in a specific contract. + * @param account - The account address of the nullifier key. */ - public getSecretKey(owner: PublicKey) { - return this.db.getSecretKey(this.contractAddress, owner); + public getNullifierKeyPair(account: AztecAddress) { + return this.db.getNullifierKeyPair(account, this.contractAddress); } /** @@ -240,8 +240,7 @@ export class ViewDataOracle extends TypedOracle { * @returns The l1 to l2 message data */ public async getL1ToL2Message(msgKey: Fr) { - const message = await this.db.getL1ToL2Message(msgKey); - return { ...message, root: this.blockHeader.l1ToL2MessageTreeRoot }; + return await this.db.getL1ToL2Message(msgKey); } /** diff --git a/yarn-project/acir-simulator/src/public/index.test.ts b/yarn-project/acir-simulator/src/public/index.test.ts index 05d9654ae476..739a4bfcd3e0 100644 --- a/yarn-project/acir-simulator/src/public/index.test.ts +++ b/yarn-project/acir-simulator/src/public/index.test.ts @@ -1,3 +1,4 @@ +import { L1ToL2Message } from '@aztec/circuit-types'; import { BlockHeader, CallContext, FunctionData, GlobalVariables, L1_TO_L2_MSG_TREE_HEIGHT } from '@aztec/circuits.js'; import { FunctionArtifact, FunctionSelector, encodeArguments } from '@aztec/foundation/abi'; import { AztecAddress } from '@aztec/foundation/aztec-address'; @@ -353,69 +354,6 @@ describe('ACIR public execution simulator', () => { expect(result.newL2ToL1Messages[0].toBuffer()).toEqual(expectedNewMessageValue); }); - it('Should be able to consume an L1 to L2 message in the public context', async () => { - const mintPublicArtifact = TestContractArtifact.functions.find(f => f.name === 'consume_mint_public_message')!; - - // Set up cross chain message - const canceller = EthAddress.random(); - - const bridgedAmount = 20n; - const secret = new Fr(1n); - const recipient = AztecAddress.random(); - - const preimage = buildL1ToL2Message( - getFunctionSelector('mint_public(bytes32,uint256,address)').substring(2), - [recipient.toField(), new Fr(bridgedAmount), canceller.toField()], - contractAddress, - secret, - ); - - // Stub message key - const messageKey = Fr.random(); - const args = encodeArguments(mintPublicArtifact, [ - recipient.toField(), - bridgedAmount, - canceller.toField(), - messageKey, - secret, - ]); - - const callContext = CallContext.from({ - msgSender: AztecAddress.random(), - storageContractAddress: contractAddress, - portalContractAddress: preimage.sender.sender, - functionSelector: FunctionSelector.empty(), - isContractDeployment: false, - isDelegateCall: false, - isStaticCall: false, - startSideEffectCounter: 0, - }); - - publicContracts.getBytecode.mockResolvedValue(Buffer.from(mintPublicArtifact.bytecode, 'base64')); - publicState.storageRead.mockResolvedValue(Fr.ZERO); - - // Mock response - commitmentsDb.getL1ToL2Message.mockImplementation(async () => { - return await Promise.resolve({ - message: preimage.toFieldArray(), - index: 0n, - siblingPath: Array(L1_TO_L2_MSG_TREE_HEIGHT).fill(Fr.random()), - }); - }); - - const execution: PublicExecution = { contractAddress, functionData, args, callContext }; - - const gv = new GlobalVariables( - new Fr(preimage.sender.chainId), - new Fr(preimage.recipient.version), - Fr.ZERO, - Fr.ZERO, - ); - const result = await executor.simulate(execution, gv); - - expect(result.newNullifiers.length).toEqual(1); - }); - it('Should be able to create a nullifier from the public context', async () => { const createNullifierPublicArtifact = TestContractArtifact.functions.find( f => f.name === 'create_nullifier_public', @@ -445,5 +383,228 @@ describe('ACIR public execution simulator', () => { const expectedNewMessageValue = pedersenHash(params.map(a => a.toBuffer())); expect(result.newNullifiers[0].value.toBuffer()).toEqual(expectedNewMessageValue); }); + + describe('L1 to L2 messages', () => { + const mintPublicArtifact = TestContractArtifact.functions.find(f => f.name === 'consume_mint_public_message')!; + + const canceller = EthAddress.random(); + const tokenRecipient = AztecAddress.random(); + let bridgedAmount = 20n; + let secret = new Fr(1); + + let crossChainMsgRecipient: AztecAddress | undefined; + let crossChainMsgSender: EthAddress | undefined; + let messageKey: Fr | undefined; + + let preimage: L1ToL2Message; + let globalVariables: GlobalVariables; + + let args: Fr[]; + let callContext: CallContext; + + beforeEach(() => { + bridgedAmount = 20n; + secret = new Fr(1); + + crossChainMsgRecipient = undefined; + crossChainMsgSender = undefined; + messageKey = undefined; + }); + + const computePreImage = () => + buildL1ToL2Message( + getFunctionSelector('mint_public(bytes32,uint256,address)').substring(2), + [tokenRecipient.toField(), new Fr(bridgedAmount), canceller.toField()], + crossChainMsgRecipient ?? contractAddress, + secret, + ); + + const computeArgs = () => + encodeArguments(mintPublicArtifact, [ + tokenRecipient.toField(), + bridgedAmount, + canceller.toField(), + messageKey ?? preimage.hash(), + secret, + ]); + + const computeCallContext = () => + CallContext.from({ + msgSender: AztecAddress.random(), + storageContractAddress: contractAddress, + portalContractAddress: crossChainMsgSender ?? preimage.sender.sender, + functionSelector: FunctionSelector.empty(), + isContractDeployment: false, + isDelegateCall: false, + isStaticCall: false, + startSideEffectCounter: 0, + }); + + const computeGlobalVariables = () => + new GlobalVariables(new Fr(preimage.sender.chainId), new Fr(preimage.recipient.version), Fr.ZERO, Fr.ZERO); + + const mockOracles = () => { + publicContracts.getBytecode.mockResolvedValue(Buffer.from(mintPublicArtifact.bytecode, 'base64')); + publicState.storageRead.mockResolvedValue(Fr.ZERO); + + const siblingPath = Array(L1_TO_L2_MSG_TREE_HEIGHT).fill(Fr.random()); + let root = messageKey ?? preimage.hash(); + for (const sibling of siblingPath) { + root = Fr.fromBuffer(pedersenHash([root.toBuffer(), sibling.toBuffer()])); + } + commitmentsDb.getL1ToL2Message.mockImplementation(async () => { + return await Promise.resolve({ + message: preimage.toFieldArray(), + index: 0n, + siblingPath, + }); + }); + + return root; + }; + + it('Should be able to consume an L1 to L2 message in the public context', async () => { + preimage = computePreImage(); + + args = computeArgs(); + callContext = computeCallContext(); + + // Prepare the state + blockHeader.l1ToL2MessageTreeRoot = mockOracles(); + globalVariables = computeGlobalVariables(); + + const execution: PublicExecution = { contractAddress, functionData, args, callContext }; + executor = new PublicExecutor(publicState, publicContracts, commitmentsDb, blockHeader); + const result = await executor.simulate(execution, globalVariables); + expect(result.newNullifiers.length).toEqual(1); + }); + + it('Message not matching requested key', async () => { + // Using a random value for the message key + messageKey = Fr.random(); + + preimage = computePreImage(); + args = computeArgs(); + callContext = computeCallContext(); + + // Prepare the state + blockHeader.l1ToL2MessageTreeRoot = mockOracles(); + globalVariables = computeGlobalVariables(); + + const execution: PublicExecution = { contractAddress, functionData, args, callContext }; + executor = new PublicExecutor(publicState, publicContracts, commitmentsDb, blockHeader); + await expect(executor.simulate(execution, globalVariables)).rejects.toThrowError( + 'Message not matching requested key', + ); + }); + + it('Invalid membership proof', async () => { + preimage = computePreImage(); + args = computeArgs(); + callContext = computeCallContext(); + + // Mock oracles but don't update state + mockOracles(); + + // Prepare the state + globalVariables = computeGlobalVariables(); + + const execution: PublicExecution = { contractAddress, functionData, args, callContext }; + executor = new PublicExecutor(publicState, publicContracts, commitmentsDb, blockHeader); + await expect(executor.simulate(execution, globalVariables)).rejects.toThrowError('Message not in state'); + }); + + it('Invalid recipient', async () => { + crossChainMsgRecipient = AztecAddress.random(); + preimage = computePreImage(); + args = computeArgs(); + callContext = computeCallContext(); + + // Prepare the state + blockHeader.l1ToL2MessageTreeRoot = mockOracles(); + globalVariables = computeGlobalVariables(); + + const execution: PublicExecution = { contractAddress, functionData, args, callContext }; + executor = new PublicExecutor(publicState, publicContracts, commitmentsDb, blockHeader); + await expect(executor.simulate(execution, globalVariables)).rejects.toThrowError('Invalid recipient'); + }); + + it('Invalid sender', async () => { + crossChainMsgSender = EthAddress.random(); + preimage = computePreImage(); + args = computeArgs(); + callContext = computeCallContext(); + + // Prepare the state + blockHeader.l1ToL2MessageTreeRoot = mockOracles(); + globalVariables = computeGlobalVariables(); + + const execution: PublicExecution = { contractAddress, functionData, args, callContext }; + executor = new PublicExecutor(publicState, publicContracts, commitmentsDb, blockHeader); + await expect(executor.simulate(execution, globalVariables)).rejects.toThrowError('Invalid sender'); + }); + + it('Invalid chainid', async () => { + preimage = computePreImage(); + args = computeArgs(); + callContext = computeCallContext(); + + // Prepare the state + blockHeader.l1ToL2MessageTreeRoot = mockOracles(); + globalVariables = computeGlobalVariables(); + globalVariables.chainId = Fr.random(); + + const execution: PublicExecution = { contractAddress, functionData, args, callContext }; + executor = new PublicExecutor(publicState, publicContracts, commitmentsDb, blockHeader); + await expect(executor.simulate(execution, globalVariables)).rejects.toThrowError('Invalid Chainid'); + }); + + it('Invalid version', async () => { + preimage = computePreImage(); + args = computeArgs(); + callContext = computeCallContext(); + + // Prepare the state + blockHeader.l1ToL2MessageTreeRoot = mockOracles(); + globalVariables = computeGlobalVariables(); + globalVariables.version = Fr.random(); + + const execution: PublicExecution = { contractAddress, functionData, args, callContext }; + executor = new PublicExecutor(publicState, publicContracts, commitmentsDb, blockHeader); + await expect(executor.simulate(execution, globalVariables)).rejects.toThrowError('Invalid Version'); + }); + + it('Invalid Content', async () => { + preimage = computePreImage(); + + bridgedAmount = bridgedAmount + 1n; // Invalid amount + args = computeArgs(); + callContext = computeCallContext(); + + // Prepare the state + blockHeader.l1ToL2MessageTreeRoot = mockOracles(); + globalVariables = computeGlobalVariables(); + + const execution: PublicExecution = { contractAddress, functionData, args, callContext }; + executor = new PublicExecutor(publicState, publicContracts, commitmentsDb, blockHeader); + await expect(executor.simulate(execution, globalVariables)).rejects.toThrowError('Invalid Content'); + }); + + it('Invalid secret', async () => { + preimage = computePreImage(); + + secret = Fr.random(); // Invalid secret + args = computeArgs(); + callContext = computeCallContext(); + + // Prepare the state + blockHeader.l1ToL2MessageTreeRoot = mockOracles(); + globalVariables = computeGlobalVariables(); + + const execution: PublicExecution = { contractAddress, functionData, args, callContext }; + executor = new PublicExecutor(publicState, publicContracts, commitmentsDb, blockHeader); + await expect(executor.simulate(execution, globalVariables)).rejects.toThrowError('Invalid message secret'); + }); + }); }); }); diff --git a/yarn-project/acir-simulator/src/public/public_execution_context.ts b/yarn-project/acir-simulator/src/public/public_execution_context.ts index 886c0c40434b..6b2674886c86 100644 --- a/yarn-project/acir-simulator/src/public/public_execution_context.ts +++ b/yarn-project/acir-simulator/src/public/public_execution_context.ts @@ -102,9 +102,7 @@ export class PublicExecutionContext extends TypedOracle { * @returns The l1 to l2 message data */ public async getL1ToL2Message(msgKey: Fr) { - // l1 to l2 messages in public contexts TODO: https://github.com/AztecProtocol/aztec-packages/issues/616 - const message = await this.commitmentsDb.getL1ToL2Message(msgKey); - return { ...message, root: this.blockHeader.l1ToL2MessageTreeRoot }; + return await this.commitmentsDb.getL1ToL2Message(msgKey); } /** diff --git a/yarn-project/aztec-nr/.gitrepo b/yarn-project/aztec-nr/.gitrepo index 5374705e2dfd..f79bcdda7ec8 100644 --- a/yarn-project/aztec-nr/.gitrepo +++ b/yarn-project/aztec-nr/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/AztecProtocol/aztec-nr branch = master - commit = ecbd4b0a4bf02c8221499b700b7da72363d561fc + commit = b92262c1babe98cea0251398d4bc658eeb212080 method = merge cmdver = 0.4.6 - parent = eb0c17382c5ae5f97b4a796b42bfe59edc24699c + parent = af3e038a85585aa1957fe2c00e3bd9d58efcda46 diff --git a/yarn-project/aztec-nr/address-note/src/address_note.nr b/yarn-project/aztec-nr/address-note/src/address_note.nr index dc5e0fa47d6e..199cbd7b078a 100644 --- a/yarn-project/aztec-nr/address-note/src/address_note.nr +++ b/yarn-project/aztec-nr/address-note/src/address_note.nr @@ -10,7 +10,7 @@ use dep::aztec::{ }, oracle::{ rand::rand, - get_secret_key::get_secret_key, + nullifier_key::get_nullifier_secret_key, get_public_key::get_public_key, }, hash::pedersen_hash, @@ -59,9 +59,20 @@ impl AddressNote { pedersen_hash(self.serialize(), 0) } - pub fn compute_nullifier(self) -> Field { + pub fn compute_nullifier(self, context: &mut PrivateContext) -> Field { let note_hash_for_nullify = compute_note_hash_for_read_or_nullify(AddressNoteMethods, self); - let secret = get_secret_key(self.owner); + let secret = context.request_nullifier_secret_key(self.owner); + // TODO(#1205) Should use a non-zero generator index. + pedersen_hash([ + note_hash_for_nullify, + secret.low, + secret.high, + ],0) + } + + pub fn compute_nullifier_without_context(self) -> Field { + let note_hash_for_nullify = compute_note_hash_for_read_or_nullify(AddressNoteMethods, self); + let secret = get_nullifier_secret_key(self.owner); // TODO(#1205) Should use a non-zero generator index. pedersen_hash([ note_hash_for_nullify, @@ -101,8 +112,12 @@ fn compute_note_hash(note: AddressNote) -> Field { note.compute_note_hash() } -fn compute_nullifier(note: AddressNote) -> Field { - note.compute_nullifier() +fn compute_nullifier(note: AddressNote, context: &mut PrivateContext) -> Field { + note.compute_nullifier(context) +} + +fn compute_nullifier_without_context(note: AddressNote) -> Field { + note.compute_nullifier_without_context() } fn get_header(note: AddressNote) -> NoteHeader { @@ -123,6 +138,7 @@ global AddressNoteMethods = NoteInterface { serialize, compute_note_hash, compute_nullifier, + compute_nullifier_without_context, get_header, set_header, broadcast, diff --git a/yarn-project/aztec-nr/aztec/src/context.nr b/yarn-project/aztec-nr/aztec/src/context.nr index b89e570f53fd..6329a9d541f1 100644 --- a/yarn-project/aztec-nr/aztec/src/context.nr +++ b/yarn-project/aztec-nr/aztec/src/context.nr @@ -1,3 +1,22 @@ +use crate::{ + abi::{ + PrivateContextInputs, + PublicContextInputs, + }, + key::nullifier_key::validate_nullifier_key_against_address, + messaging::process_l1_to_l2_message, + oracle::{ + arguments, + call_private_function::call_private_function_internal, + public_call::call_public_function_internal, + enqueue_public_function_call::enqueue_public_function_call_internal, + context::get_portal_address, + get_block_header::get_block_header, + nullifier_key::get_nullifier_key_pair, + }, + types::vec::BoundedVec, + utils::Reader, +}; use dep::protocol_types::{ abis::{ block_header::BlockHeader, @@ -34,35 +53,14 @@ use dep::protocol_types::{ hash::hash_args, grumpkin_point::GrumpkinPoint, }; +use dep::std::{ + grumpkin_scalar::GrumpkinScalar, + option::Option, +}; // TODO(https://github.com/AztecProtocol/aztec-packages/issues/1165) // use dep::std::collections::vec::Vec; -use crate::abi::{ - PrivateContextInputs, - PublicContextInputs, -}; - -// l1 to l2 messaging -use crate::messaging::process_l1_to_l2_message; - -use crate::types::{ - vec::BoundedVec, -}; - -use crate::utils::Reader; - -use crate::oracle::{ - arguments, - call_private_function::call_private_function_internal, - public_call::call_public_function_internal, - enqueue_public_function_call::enqueue_public_function_call_internal, - context::get_portal_address, - get_block_header::get_block_header, -}; - -use dep::std::option::Option; - // When finished, one can call .finish() to convert back to the abi struct PrivateContext { // docs:start:private-context @@ -201,6 +199,14 @@ impl PrivateContext { self.side_effect_counter = self.side_effect_counter + 1; } + pub fn request_nullifier_secret_key(&mut self, account: AztecAddress) -> GrumpkinScalar { + let key_pair = get_nullifier_key_pair(account); + validate_nullifier_key_against_address(account, key_pair.public_key, key_pair.secret_key); + // TODO: Add request to context. + // self.context.push_nullifier_key_validation_request(public_key, secret_key); + key_pair.secret_key + } + // docs:start:context_message_portal pub fn message_portal(&mut self, content: Field) // docs:end:context_message_portal diff --git a/yarn-project/aztec-nr/aztec/src/history/note_validity.nr b/yarn-project/aztec-nr/aztec/src/history/note_validity.nr index d98a9e878318..30abac51c749 100644 --- a/yarn-project/aztec-nr/aztec/src/history/note_validity.nr +++ b/yarn-project/aztec-nr/aztec/src/history/note_validity.nr @@ -12,8 +12,8 @@ pub fn prove_note_validity( note_interface: NoteInterface, note_with_header: Note, block_number: u32, // The block at which we'll prove that the note exists - context: PrivateContext + context: &mut PrivateContext ) { - prove_note_inclusion(note_interface, note_with_header, block_number, context); + prove_note_inclusion(note_interface, note_with_header, block_number, *context); prove_note_not_nullified(note_interface, note_with_header, block_number, context); } diff --git a/yarn-project/aztec-nr/aztec/src/history/nullifier_non_inclusion.nr b/yarn-project/aztec-nr/aztec/src/history/nullifier_non_inclusion.nr index 47036d2f9f3e..f4cb297d17ad 100644 --- a/yarn-project/aztec-nr/aztec/src/history/nullifier_non_inclusion.nr +++ b/yarn-project/aztec-nr/aztec/src/history/nullifier_non_inclusion.nr @@ -53,9 +53,9 @@ pub fn prove_note_not_nullified( note_interface: NoteInterface, note_with_header: Note, block_number: u32, // The block at which we'll prove that the note was not nullified - context: PrivateContext + context: &mut PrivateContext ) { - let nullifier = compute_siloed_nullifier(note_interface, note_with_header); + let nullifier = compute_siloed_nullifier(note_interface, note_with_header, context); - prove_nullifier_non_inclusion(nullifier, block_number, context); + prove_nullifier_non_inclusion(nullifier, block_number, *context); } diff --git a/yarn-project/aztec-nr/aztec/src/key.nr b/yarn-project/aztec-nr/aztec/src/key.nr new file mode 100644 index 000000000000..3ea8deca7544 --- /dev/null +++ b/yarn-project/aztec-nr/aztec/src/key.nr @@ -0,0 +1 @@ +mod nullifier_key; diff --git a/yarn-project/aztec-nr/aztec/src/key/nullifier_key.nr b/yarn-project/aztec-nr/aztec/src/key/nullifier_key.nr new file mode 100644 index 000000000000..3f07dba4b2ce --- /dev/null +++ b/yarn-project/aztec-nr/aztec/src/key/nullifier_key.nr @@ -0,0 +1,24 @@ +use crate::oracle::get_public_key::get_public_key; +use dep::protocol_types::{ + address::AztecAddress, + grumpkin_point::GrumpkinPoint, +}; +use dep::std::{ + grumpkin_scalar::GrumpkinScalar, + grumpkin_scalar_mul::grumpkin_fixed_base, +}; + +pub fn validate_nullifier_key_against_address( + address: AztecAddress, + nullifier_public_key: GrumpkinPoint, + nullifier_secret_key: GrumpkinScalar +) { + // TODO: Nullifier public key should be part of the address. + // Validation of the secret key should happen in the kernel circuit. + let owner_public_key = get_public_key(address); + assert(owner_public_key.x == nullifier_public_key.x); + assert(owner_public_key.y == nullifier_public_key.y); + let computed_public_key = grumpkin_fixed_base(nullifier_secret_key); + assert(owner_public_key.x == computed_public_key[0]); + assert(owner_public_key.y == computed_public_key[1]); +} diff --git a/yarn-project/aztec-nr/aztec/src/lib.nr b/yarn-project/aztec-nr/aztec/src/lib.nr index 39c5b6c290ed..9bf7bf42c8f5 100644 --- a/yarn-project/aztec-nr/aztec/src/lib.nr +++ b/yarn-project/aztec-nr/aztec/src/lib.nr @@ -2,6 +2,7 @@ mod abi; mod context; mod hash; mod history; +mod key; mod log; mod messaging; mod note; diff --git a/yarn-project/aztec-nr/aztec/src/messaging.nr b/yarn-project/aztec-nr/aztec/src/messaging.nr index ef659f198ecd..78dc5d33eec7 100644 --- a/yarn-project/aztec-nr/aztec/src/messaging.nr +++ b/yarn-project/aztec-nr/aztec/src/messaging.nr @@ -6,6 +6,8 @@ use l1_to_l2_message_getter_data::make_l1_to_l2_message_getter_data; use crate::abi::PublicContextInputs; use crate::oracle::get_l1_to_l2_message::get_l1_to_l2_message_call; +use dep::std::merkle::compute_merkle_root; + use dep::protocol_types::address::{ AztecAddress, EthAddress, @@ -25,23 +27,32 @@ pub fn process_l1_to_l2_message( let returned_message = get_l1_to_l2_message_call(msg_key); let l1_to_l2_message_data = make_l1_to_l2_message_getter_data(returned_message, 0, secret); - // Check tree roots against the inputs - assert(l1_to_l2_message_data.root == l1_to_l2_root); + // Check that the returned message is actually the message we looked up + let msg_hash = l1_to_l2_message_data.message.hash(); + assert(msg_hash == msg_key, "Message not matching requested key"); + + // Check that the message is in the tree + let root = compute_merkle_root( + msg_hash, + l1_to_l2_message_data.leaf_index, + l1_to_l2_message_data.sibling_path + ); + assert(root == l1_to_l2_root, "Message not in state"); // Validate this is the target contract - assert(l1_to_l2_message_data.message.recipient.eq(storage_contract_address)); + assert(l1_to_l2_message_data.message.recipient.eq(storage_contract_address), "Invalid recipient"); // Validate the sender is the portal contract - assert(l1_to_l2_message_data.message.sender.eq(portal_contract_address)); + assert(l1_to_l2_message_data.message.sender.eq(portal_contract_address), "Invalid sender"); // Validate the chain id is correct - assert(l1_to_l2_message_data.message.chainId == chain_id); + assert(l1_to_l2_message_data.message.chainId == chain_id, "Invalid Chainid"); // Validate the version is correct - assert(l1_to_l2_message_data.message.version == version); + assert(l1_to_l2_message_data.message.version == version, "Invalid Version"); // Validate the message hash is correct - assert(l1_to_l2_message_data.message.content == content); + assert(l1_to_l2_message_data.message.content == content, "Invalid Content"); // Validate the message secret is correct l1_to_l2_message_data.message.validate_message_secret(); diff --git a/yarn-project/aztec-nr/aztec/src/messaging/l1_to_l2_message.nr b/yarn-project/aztec-nr/aztec/src/messaging/l1_to_l2_message.nr index 39aeba687424..a4dfcfa4e527 100644 --- a/yarn-project/aztec-nr/aztec/src/messaging/l1_to_l2_message.nr +++ b/yarn-project/aztec-nr/aztec/src/messaging/l1_to_l2_message.nr @@ -49,10 +49,10 @@ impl L1ToL2Message { pub fn validate_message_secret(self: Self) { let recomputed_hash = pedersen_hash([self.secret], GENERATOR_INDEX__L1_TO_L2_MESSAGE_SECRET); - assert(self.secret_hash == recomputed_hash); + assert(self.secret_hash == recomputed_hash, "Invalid message secret"); } - fn message_hash(self: Self) -> Field { + fn hash(self: Self) -> Field { let mut hash_bytes: [u8; 256] = [0; 256]; let sender_bytes = self.sender.to_field().to_be_bytes(32); let chainId_bytes = self.chainId.to_be_bytes(32); @@ -81,7 +81,7 @@ impl L1ToL2Message { // The nullifier of a l1 to l2 message is the hash of the message salted with the secret and tree index // docs:start:l1_to_l2_message_compute_nullifier pub fn compute_nullifier(self: Self) -> Field { - let message_hash = self.message_hash(); + let message_hash = self.hash(); pedersen_hash([message_hash, self.secret, self.tree_index], GENERATOR_INDEX__NULLIFIER) } // docs:end:l1_to_l2_message_compute_nullifier diff --git a/yarn-project/aztec-nr/aztec/src/messaging/l1_to_l2_message_getter_data.nr b/yarn-project/aztec-nr/aztec/src/messaging/l1_to_l2_message_getter_data.nr index 882103f7fdf3..34f21c60395f 100644 --- a/yarn-project/aztec-nr/aztec/src/messaging/l1_to_l2_message_getter_data.nr +++ b/yarn-project/aztec-nr/aztec/src/messaging/l1_to_l2_message_getter_data.nr @@ -8,12 +8,11 @@ use crate::utils::arr_copy_slice; struct L1ToL2MessageGetterData { message: L1ToL2Message, sibling_path: [Field; L1_TO_L2_MSG_TREE_HEIGHT], - leaf_index: Field, - root: Field, + leaf_index: Field } pub fn l1_to_l2_message_getter_len() -> Field { - L1_TO_L2_MESSAGE_LENGTH + 1 + L1_TO_L2_MSG_TREE_HEIGHT + 1 + L1_TO_L2_MESSAGE_LENGTH + 1 + L1_TO_L2_MSG_TREE_HEIGHT } pub fn make_l1_to_l2_message_getter_data( @@ -32,7 +31,6 @@ pub fn make_l1_to_l2_message_getter_data( fields, [0; L1_TO_L2_MSG_TREE_HEIGHT], L1_TO_L2_MESSAGE_LENGTH + 1 - ), - root: fields[start + L1_TO_L2_MESSAGE_LENGTH + L1_TO_L2_MSG_TREE_HEIGHT + 1] + ) } } diff --git a/yarn-project/aztec-nr/aztec/src/note/lifecycle.nr b/yarn-project/aztec-nr/aztec/src/note/lifecycle.nr index 0eb21346f8d4..ec741e6dbae1 100644 --- a/yarn-project/aztec-nr/aztec/src/note/lifecycle.nr +++ b/yarn-project/aztec-nr/aztec/src/note/lifecycle.nr @@ -60,7 +60,7 @@ pub fn destroy_note( let mut nullifier = 0; let mut nullified_commitment: Field = 0; let compute_nullifier = note_interface.compute_nullifier; - nullifier = compute_nullifier(note); + nullifier = compute_nullifier(note, context); // We also need the note commitment corresponding to the "nullifier" let get_header = note_interface.get_header; diff --git a/yarn-project/aztec-nr/aztec/src/note/note_interface.nr b/yarn-project/aztec-nr/aztec/src/note/note_interface.nr index b56d2030645a..614c20d27770 100644 --- a/yarn-project/aztec-nr/aztec/src/note/note_interface.nr +++ b/yarn-project/aztec-nr/aztec/src/note/note_interface.nr @@ -9,7 +9,9 @@ struct NoteInterface { compute_note_hash: fn (Note) -> Field, - compute_nullifier: fn (Note) -> Field, + compute_nullifier: fn (Note, &mut PrivateContext) -> Field, + + compute_nullifier_without_context: fn (Note) -> Field, get_header: fn (Note) -> NoteHeader, diff --git a/yarn-project/aztec-nr/aztec/src/note/utils.nr b/yarn-project/aztec-nr/aztec/src/note/utils.nr index d9286fad1232..5d88d904a77f 100644 --- a/yarn-project/aztec-nr/aztec/src/note/utils.nr +++ b/yarn-project/aztec-nr/aztec/src/note/utils.nr @@ -3,6 +3,7 @@ use dep::protocol_types::{ hash::pedersen_hash, }; use crate::{ + context::PrivateContext, note::{ note_hash::{compute_inner_hash, compute_siloed_hash, compute_unique_hash}, note_header::NoteHeader, @@ -39,12 +40,16 @@ pub fn compute_unique_siloed_note_hash(note_interface: NoteInterface(note_interface: NoteInterface, note_with_header: Note) -> Field { +pub fn compute_siloed_nullifier( + note_interface: NoteInterface, + note_with_header: Note, + context: &mut PrivateContext +) -> Field { let get_header = note_interface.get_header; let header = get_header(note_with_header); let compute_nullifier = note_interface.compute_nullifier; - let inner_nullifier = compute_nullifier(note_with_header); + let inner_nullifier = compute_nullifier(note_with_header, context); let input = [header.contract_address.to_field(), inner_nullifier]; pedersen_hash(input, GENERATOR_INDEX__OUTER_NULLIFIER) @@ -88,8 +93,8 @@ pub fn compute_note_hash_and_nullifier( let unique_siloed_note_hash = compute_unique_hash(note_header.nonce, siloed_note_hash); - let compute_nullifier = note_interface.compute_nullifier; - let inner_nullifier = compute_nullifier(note); + let compute_nullifier_without_context = note_interface.compute_nullifier_without_context; + let inner_nullifier = compute_nullifier_without_context(note); [inner_note_hash, siloed_note_hash, unique_siloed_note_hash, inner_nullifier] } diff --git a/yarn-project/aztec-nr/aztec/src/oracle.nr b/yarn-project/aztec-nr/aztec/src/oracle.nr index edd47519d2b3..81eb3571a492 100644 --- a/yarn-project/aztec-nr/aztec/src/oracle.nr +++ b/yarn-project/aztec-nr/aztec/src/oracle.nr @@ -11,7 +11,7 @@ mod get_nullifier_membership_witness; mod get_public_data_witness; mod get_membership_witness; mod get_public_key; -mod get_secret_key; +mod nullifier_key; mod get_sibling_path; mod rand; mod enqueue_public_function_call; diff --git a/yarn-project/aztec-nr/aztec/src/oracle/get_secret_key.nr b/yarn-project/aztec-nr/aztec/src/oracle/get_secret_key.nr deleted file mode 100644 index a4da1c2a5857..000000000000 --- a/yarn-project/aztec-nr/aztec/src/oracle/get_secret_key.nr +++ /dev/null @@ -1,25 +0,0 @@ -use crate::oracle::get_public_key::get_public_key; -use dep::protocol_types::{ - address::AztecAddress, - grumpkin_point::GrumpkinPoint, -}; - -#[oracle(getSecretKey)] -fn get_secret_key_oracle(_owner: GrumpkinPoint) -> [Field; dep::std::grumpkin_scalar::GRUMPKIN_SCALAR_SERIALIZED_LEN] {} - -unconstrained fn get_secret_key_internal(owner_public_key: GrumpkinPoint) -> dep::std::grumpkin_scalar::GrumpkinScalar { - dep::std::grumpkin_scalar::deserialize_grumpkin_scalar(get_secret_key_oracle(owner_public_key)) -} - -pub fn get_secret_key(owner: AztecAddress) -> dep::std::grumpkin_scalar::GrumpkinScalar { - let owner_public_key = get_public_key(owner); - let secret = get_secret_key_internal(owner_public_key); - - // Constrain the owner - Nullifier secret key is currently just the encryption private key so we can constrain - // the owner by deriving the public key from the secret key and checking the result. - let computed_public_key = dep::std::grumpkin_scalar_mul::grumpkin_fixed_base(secret); - assert(owner_public_key.x == computed_public_key[0]); - assert(owner_public_key.y == computed_public_key[1]); - - secret -} diff --git a/yarn-project/aztec-nr/aztec/src/oracle/nullifier_key.nr b/yarn-project/aztec-nr/aztec/src/oracle/nullifier_key.nr new file mode 100644 index 000000000000..b97b2d651a3e --- /dev/null +++ b/yarn-project/aztec-nr/aztec/src/oracle/nullifier_key.nr @@ -0,0 +1,29 @@ +use dep::protocol_types::{ + address::AztecAddress, + grumpkin_point::GrumpkinPoint, +}; +use dep::std::grumpkin_scalar::GrumpkinScalar; + +struct KeyPair { + public_key: GrumpkinPoint, + secret_key: GrumpkinScalar, +} + +#[oracle(getNullifierKeyPair)] +fn get_nullifier_key_pair_oracle(_account: AztecAddress) -> [Field; 4] {} + +unconstrained fn get_nullifier_key_pair_internal(account: AztecAddress) -> KeyPair { + let result = get_nullifier_key_pair_oracle(account); + KeyPair { + public_key: GrumpkinPoint { x: result[0], y: result[1] }, + secret_key: GrumpkinScalar { high: result[2], low: result[3] } + } +} + +pub fn get_nullifier_key_pair(account: AztecAddress) -> KeyPair { + get_nullifier_key_pair_internal(account) +} + +pub fn get_nullifier_secret_key(account: AztecAddress) -> GrumpkinScalar { + get_nullifier_key_pair_internal(account).secret_key +} diff --git a/yarn-project/aztec-nr/aztec/src/state_vars/immutable_singleton.nr b/yarn-project/aztec-nr/aztec/src/state_vars/immutable_singleton.nr index e87555d5a82d..5bdc4d072d38 100644 --- a/yarn-project/aztec-nr/aztec/src/state_vars/immutable_singleton.nr +++ b/yarn-project/aztec-nr/aztec/src/state_vars/immutable_singleton.nr @@ -1,6 +1,10 @@ use dep::std::option::Option; use dep::protocol_types::{ address::AztecAddress, + constants::{ + GENERATOR_INDEX__INITIALIZATION_NULLIFIER, + }, + hash::pedersen_hash, }; use crate::context::{PrivateContext, Context}; @@ -11,14 +15,12 @@ use crate::note::{ note_viewer_options::NoteViewerOptions, }; use crate::oracle::notes::check_nullifier_exists; -use crate::state_vars::singleton::compute_singleton_initialization_nullifier; // docs:start:struct struct ImmutableSingleton { context: Option<&mut PrivateContext>, storage_slot: Field, note_interface: NoteInterface, - compute_initialization_nullifier: fn (Field, Option) -> Field, } // docs:end:struct @@ -30,19 +32,27 @@ impl ImmutableSingleton { note_interface: NoteInterface, ) -> Self { assert(storage_slot != 0, "Storage slot 0 not allowed. Storage slots must start from 1."); - ImmutableSingleton { + Self { context: context.private, storage_slot, note_interface, - compute_initialization_nullifier: compute_singleton_initialization_nullifier, } } // docs:end:new + // The following computation is leaky, in that it doesn't hide the storage slot that has been initialized, nor does it hide the contract address of this contract. + // When this initialization nullifier is emitted, an observer could do a dictionary or rainbow attack to learn the preimage of this nullifier to deduce the storage slot and contract address. + // For some applications, leaking the details that a particular state variable of a particular contract has been initialized will be unacceptable. + // Under such circumstances, such application developers might wish to _not_ use this state variable type. + // This is especially dangerous for initial assignment to elements of a `Map` type (for example), because the storage slot often also identifies an actor. + // e.g. the initial assignment to `my_map.at(msg.sender)` will leak: `msg.sender`, the fact that an element of `my_map` was assigned-to for the first time, and the contract_address. + pub fn compute_initialization_nullifier(self) -> Field { + pedersen_hash([self.storage_slot], GENERATOR_INDEX__INITIALIZATION_NULLIFIER) + } + // docs:start:is_initialized - unconstrained pub fn is_initialized(self, owner: Option) -> bool { - let compute_initialization_nullifier = self.compute_initialization_nullifier; - let nullifier = compute_initialization_nullifier(self.storage_slot, owner); + unconstrained pub fn is_initialized(self) -> bool { + let nullifier = self.compute_initialization_nullifier(); check_nullifier_exists(nullifier) } // docs:end:is_initialized @@ -51,14 +61,12 @@ impl ImmutableSingleton { pub fn initialize( self, note: &mut Note, - owner: Option, broadcast: bool, ) { let context = self.context.unwrap(); // Nullify the storage slot. - let compute_initialization_nullifier = self.compute_initialization_nullifier; - let nullifier = compute_initialization_nullifier(self.storage_slot, owner); + let nullifier = self.compute_initialization_nullifier(); context.push_new_nullifier(nullifier, 0); create_note( 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 28cd3ae23b8f..b5a2d3fe2801 100644 --- a/yarn-project/aztec-nr/aztec/src/state_vars/singleton.nr +++ b/yarn-project/aztec-nr/aztec/src/state_vars/singleton.nr @@ -16,28 +16,15 @@ use crate::note::{ note_viewer_options::NoteViewerOptions, }; use crate::oracle::{ - get_secret_key::get_secret_key, + nullifier_key::get_nullifier_secret_key, notes::check_nullifier_exists, }; -pub fn compute_singleton_initialization_nullifier(storage_slot: Field, owner: Option) -> Field { - if owner.is_some() { - let secret = get_secret_key(owner.unwrap_unchecked()); - pedersen_hash( - [storage_slot, secret.low, secret.high], - GENERATOR_INDEX__INITIALIZATION_NULLIFIER - ) - } else { - pedersen_hash([storage_slot], GENERATOR_INDEX__INITIALIZATION_NULLIFIER) - } -} - // docs:start:struct struct Singleton { context: Option<&mut PrivateContext>, storage_slot: Field, note_interface: NoteInterface, - compute_initialization_nullifier: fn (Field, Option) -> Field, } // docs:end:struct @@ -49,19 +36,29 @@ impl Singleton { note_interface: NoteInterface, ) -> Self { assert(storage_slot != 0, "Storage slot 0 not allowed. Storage slots must start from 1."); - Singleton { + Self { context: context.private, storage_slot, note_interface, - compute_initialization_nullifier: compute_singleton_initialization_nullifier, } } // docs:end:new + // The following computation is leaky, in that it doesn't hide the storage slot that has been initialized, nor does it hide the contract address of this contract. + // When this initialization nullifier is emitted, an observer could do a dictionary or rainbow attack to learn the preimage of this nullifier to deduce the storage slot and contract address. + // For some applications, leaking the details that a particular state variable of a particular contract has been initialized will be unacceptable. + // Under such circumstances, such application developers might wish to _not_ use this state variable type. + // This is especially dangerous for initial assignment to elements of a `Map` type (for example), because the storage slot often also identifies an actor. e.g. + // the initial assignment to `my_map.at(msg.sender)` will leak: `msg.sender`, the fact that an element of `my_map` was assigned-to for the first time, and the contract_address. + // Note: subsequent nullification of this state variable, via the `replace` method will not be leaky, if the `compute_nullifier()` method of the underlying note is designed to ensure privacy. + // For example, if the `compute_nullifier()` method injects the secret key of a note owner into the computed nullifier's preimage. + pub fn compute_initialization_nullifier(self) -> Field { + pedersen_hash([self.storage_slot], GENERATOR_INDEX__INITIALIZATION_NULLIFIER) + } + // docs:start:is_initialized - unconstrained pub fn is_initialized(self, owner: Option) -> bool { - let compute_initialization_nullifier = self.compute_initialization_nullifier; - let nullifier = compute_initialization_nullifier(self.storage_slot, owner); + unconstrained pub fn is_initialized(self) -> bool { + let nullifier = self.compute_initialization_nullifier(); check_nullifier_exists(nullifier) } // docs:end:is_initialized @@ -70,14 +67,12 @@ impl Singleton { pub fn initialize( self, note: &mut Note, - owner: Option, broadcast: bool, ) { let context = self.context.unwrap(); // Nullify the storage slot. - let compute_initialization_nullifier = self.compute_initialization_nullifier; - let nullifier = compute_initialization_nullifier(self.storage_slot, owner); + let nullifier = self.compute_initialization_nullifier(); context.push_new_nullifier(nullifier, 0); create_note(context, self.storage_slot, note, self.note_interface, broadcast); diff --git a/yarn-project/aztec-nr/field-note/src/field_note.nr b/yarn-project/aztec-nr/field-note/src/field_note.nr index 6267a7b6016e..8aa8fbe5520c 100644 --- a/yarn-project/aztec-nr/field-note/src/field_note.nr +++ b/yarn-project/aztec-nr/field-note/src/field_note.nr @@ -41,7 +41,12 @@ impl FieldNote { pedersen_hash(self.serialize(), 0) } - pub fn compute_nullifier(self) -> Field { + pub fn compute_nullifier(_self: Self, _context: &mut PrivateContext) -> Field { + // This note is expected to be shared between users and for this reason can't be nullified using a secret. + 0 + } + + pub fn compute_nullifier_without_context(_self: Self) -> Field { // This note is expected to be shared between users and for this reason can't be nullified using a secret. 0 } @@ -63,8 +68,12 @@ fn compute_note_hash(note: FieldNote) -> Field { note.compute_note_hash() } -fn compute_nullifier(note: FieldNote) -> Field { - note.compute_nullifier() +fn compute_nullifier(note: FieldNote, context: &mut PrivateContext) -> Field { + note.compute_nullifier(context) +} + +fn compute_nullifier_without_context(note: FieldNote) -> Field { + note.compute_nullifier_without_context() } fn get_header(note: FieldNote) -> NoteHeader { @@ -86,6 +95,7 @@ global FieldNoteMethods = NoteInterface { serialize, compute_note_hash, compute_nullifier, + compute_nullifier_without_context, get_header, set_header, broadcast, diff --git a/yarn-project/aztec-nr/value-note/src/value_note.nr b/yarn-project/aztec-nr/value-note/src/value_note.nr index d02037e49982..4cffea0d4fa3 100644 --- a/yarn-project/aztec-nr/value-note/src/value_note.nr +++ b/yarn-project/aztec-nr/value-note/src/value_note.nr @@ -7,7 +7,7 @@ use dep::aztec::{ }, oracle::{ rand::rand, - get_secret_key::get_secret_key, + nullifier_key::get_nullifier_secret_key, get_public_key::get_public_key, }, log::emit_encrypted_log, @@ -58,9 +58,9 @@ impl ValueNote { // docs:start:nullifier - pub fn compute_nullifier(self) -> Field { + pub fn compute_nullifier(self, context: &mut PrivateContext) -> Field { let note_hash_for_nullify = compute_note_hash_for_read_or_nullify(ValueNoteMethods, self); - let secret = get_secret_key(self.owner); + let secret = context.request_nullifier_secret_key(self.owner); // TODO(#1205) Should use a non-zero generator index. pedersen_hash([ note_hash_for_nullify, @@ -71,6 +71,17 @@ impl ValueNote { // docs:end:nullifier + pub fn compute_nullifier_without_context(self) -> Field { + let note_hash_for_nullify = compute_note_hash_for_read_or_nullify(ValueNoteMethods, self); + let secret = get_nullifier_secret_key(self.owner); + // TODO(#1205) Should use a non-zero generator index. + pedersen_hash([ + note_hash_for_nullify, + secret.low, + secret.high, + ],0) + } + pub fn set_header(&mut self, header: NoteHeader) { self.header = header; } @@ -100,8 +111,12 @@ fn compute_note_hash(note: ValueNote) -> Field { note.compute_note_hash() } -fn compute_nullifier(note: ValueNote) -> Field { - note.compute_nullifier() +fn compute_nullifier(note: ValueNote, context: &mut PrivateContext) -> Field { + note.compute_nullifier(context) +} + +fn compute_nullifier_without_context(note: ValueNote) -> Field { + note.compute_nullifier_without_context() } fn get_header(note: ValueNote) -> NoteHeader { @@ -122,6 +137,7 @@ global ValueNoteMethods = NoteInterface { serialize, compute_note_hash, compute_nullifier, + compute_nullifier_without_context, get_header, set_header, broadcast, diff --git a/yarn-project/aztec.js/.eslintrc.cjs b/yarn-project/aztec.js/.eslintrc.cjs index e659927475c0..ec1dd3e14de0 100644 --- a/yarn-project/aztec.js/.eslintrc.cjs +++ b/yarn-project/aztec.js/.eslintrc.cjs @@ -1 +1 @@ -module.exports = require('@aztec/foundation/eslint'); +module.exports = require('@aztec/foundation/eslint.docs'); diff --git a/yarn-project/circuit-types/src/keys/key_store.ts b/yarn-project/circuit-types/src/keys/key_store.ts index 682aa89862e5..d9da2be7d50b 100644 --- a/yarn-project/circuit-types/src/keys/key_store.ts +++ b/yarn-project/circuit-types/src/keys/key_store.ts @@ -1,4 +1,4 @@ -import { GrumpkinPrivateKey, PublicKey } from '@aztec/circuits.js'; +import { AztecAddress, GrumpkinPrivateKey, PublicKey } from '@aztec/circuits.js'; /** * Represents a secure storage for managing keys. @@ -36,4 +36,29 @@ export interface KeyStore { * @deprecated We should not require a keystore to expose private keys in plain. */ getAccountPrivateKey(pubKey: PublicKey): Promise; + + /** + * Retrieves the nullifier secret key of the account associated with the specified AztecAddress. + * Throws an error if the provided public key is not found in the list of registered accounts. + * @param pubKey - The public key of the account for which the secret key is requested. + * @returns A Promise that resolves to the nullifier secret key. + */ + getNullifierSecretKey(pubKey: PublicKey): Promise; + + /** + * Retrieves the nullifier public key of the account associated with the specified AztecAddress. + * Throws an error if the provided public key is not found in the list of registered accounts. + * @param pubKey - The public key of the account for which the nullifier public key is requested. + * @returns A Promise that resolves to the nullifier public key. + */ + getNullifierPublicKey(pubKey: PublicKey): Promise; + + /** + * Retrieves the nullifier secret key for use in a specific contract. + * Throws an error if the provided public key is not found in the list of registered accounts. + * @param pubKey - The public key of the account for which the private key is requested. + * @param contractAddress - The address of the contract requesting the nullifier key. + * @returns A Promise that resolves to the nullifier secret key. + */ + getSiloedNullifierSecretKey(pubKey: PublicKey, contractAddress: AztecAddress): Promise; } diff --git a/yarn-project/circuit-types/src/l1_to_l2_message.ts b/yarn-project/circuit-types/src/l1_to_l2_message.ts index a072e6c270ba..2165d4bd49ec 100644 --- a/yarn-project/circuit-types/src/l1_to_l2_message.ts +++ b/yarn-project/circuit-types/src/l1_to_l2_message.ts @@ -1,5 +1,6 @@ import { AztecAddress } from '@aztec/foundation/aztec-address'; import { toBigIntBE, toBufferBE } from '@aztec/foundation/bigint-buffer'; +import { sha256 } from '@aztec/foundation/crypto'; import { EthAddress } from '@aztec/foundation/eth-address'; import { Fr } from '@aztec/foundation/fields'; import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; @@ -116,6 +117,10 @@ export class L1ToL2Message { return serializeToBuffer(this.sender, this.recipient, this.content, this.secretHash, this.deadline, this.fee); } + hash(): Fr { + return Fr.fromBufferReduce(sha256(serializeToBuffer(...this.toFieldArray()))); + } + static fromBuffer(buffer: Buffer | BufferReader): L1ToL2Message { const reader = BufferReader.asReader(buffer); const sender = reader.readObject(L1Actor); diff --git a/yarn-project/circuits.js/src/constants.gen.ts b/yarn-project/circuits.js/src/constants.gen.ts index 79cd3856febc..39a05fee9ca7 100644 --- a/yarn-project/circuits.js/src/constants.gen.ts +++ b/yarn-project/circuits.js/src/constants.gen.ts @@ -48,7 +48,7 @@ export const NUM_FIELDS_PER_SHA256 = 2; export const ARGS_HASH_CHUNK_LENGTH = 32; export const ARGS_HASH_CHUNK_COUNT = 16; export const L1_TO_L2_MESSAGE_LENGTH = 8; -export const L1_TO_L2_MESSAGE_ORACLE_CALL_LENGTH = 26; +export const L1_TO_L2_MESSAGE_ORACLE_CALL_LENGTH = 25; export const MAX_NOTE_FIELDS_LENGTH = 20; export const GET_NOTE_ORACLE_RETURN_LENGTH = 23; export const MAX_NOTES_PER_PAGE = 10; diff --git a/yarn-project/circuits.js/src/index.ts b/yarn-project/circuits.js/src/index.ts index 91e7dd069b3b..347db88ae51b 100644 --- a/yarn-project/circuits.js/src/index.ts +++ b/yarn-project/circuits.js/src/index.ts @@ -1,4 +1,5 @@ export * from './structs/index.js'; export * from './contract/index.js'; +export * from './keys/index.js'; export * from './types/index.js'; export * from './constants.gen.js'; diff --git a/yarn-project/circuits.js/src/keys/index.ts b/yarn-project/circuits.js/src/keys/index.ts new file mode 100644 index 000000000000..09ec99767c4d --- /dev/null +++ b/yarn-project/circuits.js/src/keys/index.ts @@ -0,0 +1,44 @@ +import { AztecAddress } from '@aztec/foundation/aztec-address'; +import { pedersenHash } from '@aztec/foundation/crypto'; +import { Fr, GrumpkinScalar } from '@aztec/foundation/fields'; + +import { Grumpkin } from '../barretenberg/crypto/grumpkin/index.js'; +import { GrumpkinPrivateKey } from '../types/grumpkin_private_key.js'; + +/** + * Derives the public key of a secret key. + */ +export function derivePublicKey(secretKey: GrumpkinPrivateKey) { + const grumpkin = new Grumpkin(); + return grumpkin.mul(grumpkin.generator(), secretKey); +} + +/** + * Derives a new secret key from a secret key and an index. + */ +function _deriveSecretKey(secretKey: GrumpkinPrivateKey, index: Fr): GrumpkinPrivateKey { + // TODO: Temporary hack. Should replace it with a secure way to derive the secret key. + const hash = pedersenHash([secretKey.high, secretKey.low, index].map(v => v.toBuffer())); + return new GrumpkinScalar(hash); +} + +/** + * Computes the nullifier secret key from seed secret key. + */ +export function computeNullifierSecretKey(seedSecretKey: GrumpkinPrivateKey): GrumpkinPrivateKey { + // TODO + // return deriveSecretKey(seedSecretKey, new Fr(1)); + return seedSecretKey; +} + +/** + * Computes the nullifier secret key for a contract. + */ +export function computeSiloedNullifierSecretKey( + nullifierSecretKey: GrumpkinPrivateKey, + _contractAddress: AztecAddress, +): GrumpkinPrivateKey { + // TODO + // return deriveSecretKey(nullifierSecretKey, contractAddress); + return nullifierSecretKey; +} diff --git a/yarn-project/circuits.js/src/types/grumpkin_private_key.ts b/yarn-project/circuits.js/src/types/grumpkin_private_key.ts index 8a394773730d..16ed36795871 100644 --- a/yarn-project/circuits.js/src/types/grumpkin_private_key.ts +++ b/yarn-project/circuits.js/src/types/grumpkin_private_key.ts @@ -1,4 +1,4 @@ -import { GrumpkinScalar } from '../index.js'; +import { GrumpkinScalar } from '@aztec/foundation/fields'; /** A type alias for private key which belongs to the scalar field of Grumpkin curve. */ export type GrumpkinPrivateKey = GrumpkinScalar; diff --git a/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts b/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts index 4f01c5b41e15..f3bb23e15d8a 100644 --- a/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts +++ b/yarn-project/end-to-end/src/e2e_cross_chain_messaging.test.ts @@ -161,7 +161,7 @@ describe('e2e_cross_chain_messaging', () => { secretForL2MessageConsumption, ) .simulate(), - ).rejects.toThrowError("Cannot satisfy constraint 'l1_to_l2_message_data.message.content == content"); + ).rejects.toThrowError("Invalid Content 'l1_to_l2_message_data.message.content == content'"); // send the right one - const consumptionTx = l2Bridge @@ -234,8 +234,6 @@ describe('e2e_cross_chain_messaging', () => { .withWallet(user2Wallet) .methods.claim_public(ownerAddress, bridgeAmount, ethAccount, messageKey, secretForL2MessageConsumption) .simulate(), - ).rejects.toThrowError( - "Failed to solve brillig function, reason: explicit trap hit in brillig 'l1_to_l2_message_data.message.content == content'", - ); + ).rejects.toThrowError("Invalid Content 'l1_to_l2_message_data.message.content == content'"); }, 120_000); }); diff --git a/yarn-project/end-to-end/src/e2e_lending_contract.test.ts b/yarn-project/end-to-end/src/e2e_lending_contract.test.ts index 77c58873e463..bc6baf42a99d 100644 --- a/yarn-project/end-to-end/src/e2e_lending_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_lending_contract.test.ts @@ -250,18 +250,6 @@ describe('e2e_lending_contract', () => { .send(), ); }); - describe('failure cases', () => { - it('calling internal _deposit function directly', async () => { - // Try to call the internal `_deposit` function directly - // This should: - // - not change any storage values. - // - fail - - await expect( - lendingContract.methods._deposit(lendingAccount.address.toField(), 42n, collateralAsset.address).simulate(), - ).rejects.toThrow(); - }); - }); }); describe('Borrow', () => { diff --git a/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts b/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts index a6975b6b0f8f..ea57f757f733 100644 --- a/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts +++ b/yarn-project/end-to-end/src/e2e_public_cross_chain_messaging.test.ts @@ -136,7 +136,7 @@ describe('e2e_public_cross_chain_messaging', () => { .withWallet(user2Wallet) .methods.claim_public(user2Wallet.getAddress(), bridgeAmount, ethAccount, messageKey, secret) .simulate(), - ).rejects.toThrow(); + ).rejects.toThrow("Invalid Content 'l1_to_l2_message_data.message.content == content'"); // user2 consumes owner's L1-> L2 message on bridge contract and mints public tokens on L2 logger("user2 consumes owner's message on L2 Publicly"); @@ -185,6 +185,6 @@ describe('e2e_public_cross_chain_messaging', () => { .withWallet(user2Wallet) .methods.claim_private(secretHash, bridgeAmount, ethAccount, messageKey, secret) .simulate(), - ).rejects.toThrowError("Cannot satisfy constraint 'l1_to_l2_message_data.message.content == content"); + ).rejects.toThrowError("Invalid Content 'l1_to_l2_message_data.message.content == content'"); }, 60_000); }); diff --git a/yarn-project/end-to-end/src/e2e_singleton.test.ts b/yarn-project/end-to-end/src/e2e_singleton.test.ts new file mode 100644 index 000000000000..6c1407ef053d --- /dev/null +++ b/yarn-project/end-to-end/src/e2e_singleton.test.ts @@ -0,0 +1,142 @@ +import { TxStatus, Wallet } from '@aztec/aztec.js'; +import { DocsExampleContract } from '@aztec/noir-contracts'; + +import { setup } from './fixtures/utils.js'; + +describe('e2e_singleton', () => { + let wallet: Wallet; + + let teardown: () => Promise; + let contract: DocsExampleContract; + + const POINTS = 1n; + const RANDOMNESS = 2n; + + beforeAll(async () => { + ({ teardown, wallet } = await setup()); + contract = await DocsExampleContract.deploy(wallet).send().deployed(); + }, 25_000); + + afterAll(() => teardown()); + + describe('Singleton', () => { + it('fail to read uninitialized singleton', async () => { + expect(await contract.methods.is_legendary_initialized().view()).toEqual(false); + await expect(contract.methods.get_legendary_card().view()).rejects.toThrowError(); + }); + + it('initialize singleton', async () => { + expect(await contract.methods.is_legendary_initialized().view()).toEqual(false); + const receipt = await contract.methods.initialize_private(RANDOMNESS, POINTS).send().wait(); + expect(receipt.status).toEqual(TxStatus.MINED); + + const tx = await wallet.getTx(receipt.txHash); + expect(tx?.newCommitments.length).toEqual(1); + // 1 for the tx, another for the initializer + expect(tx?.newNullifiers.length).toEqual(2); + expect(await contract.methods.is_legendary_initialized().view()).toEqual(true); + }); + + it('fail to reinitialize', async () => { + expect(await contract.methods.is_legendary_initialized().view()).toEqual(true); + await expect(contract.methods.initialize_private(RANDOMNESS, POINTS).send().wait()).rejects.toThrowError(); + expect(await contract.methods.is_legendary_initialized().view()).toEqual(true); + }); + + it('read initialized singleton', async () => { + expect(await contract.methods.is_legendary_initialized().view()).toEqual(true); + const { points, randomness } = await contract.methods.get_legendary_card().view(); + expect(points).toEqual(POINTS); + expect(randomness).toEqual(RANDOMNESS); + }); + + it('replace with same value', async () => { + expect(await contract.methods.is_legendary_initialized().view()).toEqual(true); + const noteBefore = await contract.methods.get_legendary_card().view(); + const receipt = await contract.methods.update_legendary_card(RANDOMNESS, POINTS).send().wait(); + expect(receipt.status).toEqual(TxStatus.MINED); + + const tx = await wallet.getTx(receipt.txHash); + expect(tx?.newCommitments.length).toEqual(1); + // 1 for the tx, another for the nullifier of the previous note + expect(tx?.newNullifiers.length).toEqual(2); + + const noteAfter = await contract.methods.get_legendary_card().view(); + + expect(noteBefore.owner).toEqual(noteAfter.owner); + expect(noteBefore.points).toEqual(noteAfter.points); + expect(noteBefore.randomness).toEqual(noteAfter.randomness); + expect(noteBefore.header.contract_address).toEqual(noteAfter.header.contract_address); + expect(noteBefore.header.storage_slot).toEqual(noteAfter.header.storage_slot); + expect(noteBefore.header.is_transient).toEqual(noteAfter.header.is_transient); + // !!! Nonce must be different + expect(noteBefore.header.nonce).not.toEqual(noteAfter.header.nonce); + }); + + it('replace singleton with other values', async () => { + expect(await contract.methods.is_legendary_initialized().view()).toEqual(true); + const receipt = await contract.methods + .update_legendary_card(RANDOMNESS + 2n, POINTS + 1n) + .send() + .wait(); + expect(receipt.status).toEqual(TxStatus.MINED); + const tx = await wallet.getTx(receipt.txHash); + expect(tx?.newCommitments.length).toEqual(1); + // 1 for the tx, another for the nullifier of the previous note + expect(tx?.newNullifiers.length).toEqual(2); + + const { points, randomness } = await contract.methods.get_legendary_card().view(); + expect(points).toEqual(POINTS + 1n); + expect(randomness).toEqual(RANDOMNESS + 2n); + }); + + it('replace singleton dependent on prior value', async () => { + expect(await contract.methods.is_legendary_initialized().view()).toEqual(true); + const noteBefore = await contract.methods.get_legendary_card().view(); + const receipt = await contract.methods.increase_legendary_points().send().wait(); + expect(receipt.status).toEqual(TxStatus.MINED); + const tx = await wallet.getTx(receipt.txHash); + expect(tx?.newCommitments.length).toEqual(1); + // 1 for the tx, another for the nullifier of the previous note + expect(tx?.newNullifiers.length).toEqual(2); + + const { points, randomness } = await contract.methods.get_legendary_card().view(); + expect(points).toEqual(noteBefore.points + 1n); + expect(randomness).toEqual(noteBefore.randomness); + }); + }); + + describe('Immutable Singleton', () => { + it('fail to read uninitialized singleton', async () => { + expect(await contract.methods.is_imm_initialized().view()).toEqual(false); + await expect(contract.methods.get_imm_card().view()).rejects.toThrowError(); + }); + + it('initialize singleton', async () => { + expect(await contract.methods.is_imm_initialized().view()).toEqual(false); + const receipt = await contract.methods.initialize_immutable_singleton(RANDOMNESS, POINTS).send().wait(); + expect(receipt.status).toEqual(TxStatus.MINED); + + const tx = await wallet.getTx(receipt.txHash); + expect(tx?.newCommitments.length).toEqual(1); + // 1 for the tx, another for the initializer + expect(tx?.newNullifiers.length).toEqual(2); + expect(await contract.methods.is_imm_initialized().view()).toEqual(true); + }); + + it('fail to reinitialize', async () => { + expect(await contract.methods.is_imm_initialized().view()).toEqual(true); + await expect( + contract.methods.initialize_immutable_singleton(RANDOMNESS, POINTS).send().wait(), + ).rejects.toThrowError(); + expect(await contract.methods.is_imm_initialized().view()).toEqual(true); + }); + + it('read initialized singleton', async () => { + expect(await contract.methods.is_imm_initialized().view()).toEqual(true); + const { points, randomness } = await contract.methods.get_imm_card().view(); + expect(points).toEqual(POINTS); + expect(randomness).toEqual(RANDOMNESS); + }); + }); +}); diff --git a/yarn-project/foundation/.eslintrc.cjs b/yarn-project/foundation/.eslintrc.cjs index 31c960d6c127..daa6e7a51ebd 100644 --- a/yarn-project/foundation/.eslintrc.cjs +++ b/yarn-project/foundation/.eslintrc.cjs @@ -1,41 +1,3 @@ -// See https://typescript-eslint.io/play/#ts=5.1.6&showAST=es&fileType=.ts -const contexts = [ - // All methods in an interface - 'TSInterfaceDeclaration TSMethodSignature', - // All public methods in a class that does not implement an interface - 'ClassDeclaration[implements.length=0] MethodDefinition[accessibility=public]', - // TODO: All methods public by default in a class that does not implement an interface - // 'ClassDeclaration[implements.length=0] MethodDefinition[accessibility=undefined][key.type=Identifier]', - // TODO: All export const from the top level of a file - // 'ExportNamedDeclaration[declaration.type=VariableDeclaration]', - // Legacy contexts (needs review) - 'TSParameterProperty[accessibility=public]', - 'TSPropertySignature', - 'PropertySignature', - 'TSInterfaceDeclaration', - 'InterfaceDeclaration', - 'TSPropertyDefinition[accessibility=public]', - 'PropertyDefinition[accessibility=public]', - 'TSTypeAliasDeclaration', - 'TypeAliasDeclaration', - 'TSTypeDeclaration', - 'TypeDeclaration', - 'TSEnumDeclaration', - 'EnumDeclaration', - 'TSClassDeclaration', - 'ClassDeclaration', - 'TSClassExpression', - 'ClassExpression', - 'TSFunctionExpression', - 'FunctionExpression', - 'TSInterfaceExpression', - 'InterfaceExpression', - 'TSEnumExpression', - 'EnumExpression', -]; - -const JSDOC_RULES_LEVEL = 'error'; - module.exports = { extends: [ 'eslint:recommended', @@ -112,27 +74,8 @@ module.exports = { ], 'import/no-extraneous-dependencies': 'error', 'import/no-cycle': 'warn', - 'tsdoc/syntax': JSDOC_RULES_LEVEL, - 'jsdoc/require-jsdoc': [ - JSDOC_RULES_LEVEL, - { - contexts, - checkConstructors: false, - checkGetters: true, - checkSetters: true, - }, - ], - 'jsdoc/require-description': [JSDOC_RULES_LEVEL, { contexts }], - 'jsdoc/require-hyphen-before-param-description': [JSDOC_RULES_LEVEL], - 'jsdoc/require-param': [JSDOC_RULES_LEVEL, { contexts, checkDestructured: false }], - 'jsdoc/require-param-description': [JSDOC_RULES_LEVEL, { contexts }], - 'jsdoc/require-param-name': [JSDOC_RULES_LEVEL, { contexts }], - 'jsdoc/require-property': [JSDOC_RULES_LEVEL, { contexts }], - 'jsdoc/require-property-description': [JSDOC_RULES_LEVEL, { contexts }], - 'jsdoc/require-property-name': [JSDOC_RULES_LEVEL, { contexts }], - 'jsdoc/require-returns': 'off', // this unfortunately doesn't block `fit` and `fdescribe` 'no-only-tests/no-only-tests': ['error'], }, - ignorePatterns: ['node_modules', 'dest*', 'dist', '*.js', '.eslintrc.cjs'], + ignorePatterns: ['node_modules', 'dest*', 'dist', '*.js', '.eslintrc.cjs', '.eslintrc.*.cjs'], }; diff --git a/yarn-project/foundation/.eslintrc.docs.cjs b/yarn-project/foundation/.eslintrc.docs.cjs new file mode 100644 index 000000000000..cac8e4f90959 --- /dev/null +++ b/yarn-project/foundation/.eslintrc.docs.cjs @@ -0,0 +1,69 @@ +// See https://typescript-eslint.io/play/#ts=5.1.6&showAST=es&fileType=.ts +const contexts = [ + // All methods in an interface + 'TSInterfaceDeclaration TSMethodSignature', + // All public methods in a class that does not implement an interface + 'ClassDeclaration[implements.length=0] MethodDefinition[accessibility=public]', + // TODO: All methods public by default in a class that does not implement an interface + // 'ClassDeclaration[implements.length=0] MethodDefinition[accessibility=undefined][key.type=Identifier]', + // TODO: All export const from the top level of a file + // 'ExportNamedDeclaration[declaration.type=VariableDeclaration]', + // Legacy contexts below (needs review) + 'TSParameterProperty[accessibility=public]', + 'TSPropertySignature', + 'PropertySignature', + 'TSInterfaceDeclaration', + 'InterfaceDeclaration', + 'TSPropertyDefinition[accessibility=public]', + 'PropertyDefinition[accessibility=public]', + 'TSTypeAliasDeclaration', + 'TypeAliasDeclaration', + 'TSTypeDeclaration', + 'TypeDeclaration', + 'TSEnumDeclaration', + 'EnumDeclaration', + 'TSClassDeclaration', + 'ClassDeclaration', + 'TSClassExpression', + 'ClassExpression', + 'TSFunctionExpression', + 'FunctionExpression', + 'TSInterfaceExpression', + 'InterfaceExpression', + 'TSEnumExpression', + 'EnumExpression', +]; + +const base = require('./.eslintrc.cjs'); +const JSDOC_RULES_LEVEL = 'error'; + +module.exports = { + ...base, + plugins: [...base.plugins, 'jsdoc'], + overrides: [ + ...base.overrides, + { files: '*.test.ts', rules: { 'jsdoc/require-jsdoc': 'off' } }, + ], + rules: { + ...base.rules, + 'tsdoc/syntax': JSDOC_RULES_LEVEL, + 'jsdoc/require-jsdoc': [ + JSDOC_RULES_LEVEL, + { + contexts, + checkConstructors: false, + checkGetters: true, + checkSetters: true, + }, + ], + 'jsdoc/require-description': [JSDOC_RULES_LEVEL, { contexts }], + 'jsdoc/require-hyphen-before-param-description': [JSDOC_RULES_LEVEL], + 'jsdoc/require-param': [JSDOC_RULES_LEVEL, { contexts, checkDestructured: false }], + 'jsdoc/require-param-description': [JSDOC_RULES_LEVEL, { contexts }], + 'jsdoc/require-param-name': [JSDOC_RULES_LEVEL, { contexts }], + 'jsdoc/require-property': [JSDOC_RULES_LEVEL, { contexts }], + 'jsdoc/require-property-description': [JSDOC_RULES_LEVEL, { contexts }], + 'jsdoc/require-property-name': [JSDOC_RULES_LEVEL, { contexts }], + 'jsdoc/require-returns': 'off', + } +}; diff --git a/yarn-project/foundation/package.json b/yarn-project/foundation/package.json index 0851e5c79d57..35d2d9480e21 100644 --- a/yarn-project/foundation/package.json +++ b/yarn-project/foundation/package.json @@ -7,6 +7,7 @@ "types": "./dest/index.d.ts", "exports": { "./eslint": "./.eslintrc.cjs", + "./eslint.docs": "./.eslintrc.docs.cjs", "./prettier": "./.prettierrc.json", "./abi": "./dest/abi/index.js", "./async-map": "./dest/async-map/index.js", diff --git a/yarn-project/key-store/src/test_key_store.ts b/yarn-project/key-store/src/test_key_store.ts index 1a5a96c2d1b8..f0af31ee6da9 100644 --- a/yarn-project/key-store/src/test_key_store.ts +++ b/yarn-project/key-store/src/test_key_store.ts @@ -1,5 +1,13 @@ import { KeyPair, KeyStore, PublicKey } from '@aztec/circuit-types'; -import { GrumpkinPrivateKey, GrumpkinScalar, Point } from '@aztec/circuits.js'; +import { + AztecAddress, + GrumpkinPrivateKey, + GrumpkinScalar, + Point, + computeNullifierSecretKey, + computeSiloedNullifierSecretKey, + derivePublicKey, +} from '@aztec/circuits.js'; import { Grumpkin } from '@aztec/circuits.js/barretenberg'; import { AztecKVStore, AztecMap } from '@aztec/kv-store'; @@ -38,6 +46,21 @@ export class TestKeyStore implements KeyStore { return Promise.resolve(account.getPrivateKey()); } + public async getNullifierSecretKey(pubKey: PublicKey) { + const privateKey = await this.getAccountPrivateKey(pubKey); + return computeNullifierSecretKey(privateKey); + } + + public async getNullifierPublicKey(pubKey: PublicKey) { + const secretKey = await this.getNullifierSecretKey(pubKey); + return derivePublicKey(secretKey); + } + + public async getSiloedNullifierSecretKey(pubKey: PublicKey, contractAddress: AztecAddress) { + const secretKey = await this.getNullifierSecretKey(pubKey); + return computeSiloedNullifierSecretKey(secretKey, contractAddress); + } + /** * Retrieve the KeyPair object associated with a given pub key. * Searches through the 'accounts' array for a matching public key and returns the corresponding account (KeyPair). diff --git a/yarn-project/noir-compiler/src/contract-interface-gen/typescript.ts b/yarn-project/noir-compiler/src/contract-interface-gen/typescript.ts index c17d0d7abb48..90b622b6115c 100644 --- a/yarn-project/noir-compiler/src/contract-interface-gen/typescript.ts +++ b/yarn-project/noir-compiler/src/contract-interface-gen/typescript.ts @@ -166,7 +166,7 @@ function generateAbiStatement(name: string, artifactImportPath: string) { * @returns The corresponding ts code. */ export function generateTypescriptContractInterface(input: ContractArtifact, artifactImportPath?: string) { - const methods = input.functions.filter(f => f.name !== 'constructor').map(generateMethod); + const methods = input.functions.filter(f => f.name !== 'constructor' && !f.isInternal).map(generateMethod); const deploy = artifactImportPath && generateDeploy(input); const ctor = artifactImportPath && generateConstructor(input.name); const at = artifactImportPath && generateAt(input.name); diff --git a/yarn-project/noir-contracts/contracts/card_game_contract/src/cards.nr b/yarn-project/noir-contracts/contracts/card_game_contract/src/cards.nr index 6672ad559bc4..b0b17ef7ac15 100644 --- a/yarn-project/noir-contracts/contracts/card_game_contract/src/cards.nr +++ b/yarn-project/noir-contracts/contracts/card_game_contract/src/cards.nr @@ -12,7 +12,6 @@ use dep::aztec::{ note_viewer_options::NoteViewerOptions, note_getter::view_notes, }, - oracle::get_secret_key::get_secret_key, state_vars::set::Set, }; use dep::std; @@ -196,9 +195,9 @@ impl Deck { global PACK_CARDS = 3; // Limited by number of write requests (max 4) -pub fn get_pack_cards(seed: Field, owner: AztecAddress) -> [Card; PACK_CARDS] { +pub fn get_pack_cards(seed: Field, owner: AztecAddress, context: &mut PrivateContext) -> [Card; PACK_CARDS] { // generate pseudo randomness deterministically from 'seed' and user secret - let secret = get_secret_key(owner); + let secret = context.request_nullifier_secret_key(owner); let mix = secret.high + secret.low + seed; let random_bytes = std::hash::sha256(mix.to_le_bytes(32)); diff --git a/yarn-project/noir-contracts/contracts/card_game_contract/src/main.nr b/yarn-project/noir-contracts/contracts/card_game_contract/src/main.nr index f0f85b6e0cd9..4aacb388d9ab 100644 --- a/yarn-project/noir-contracts/contracts/card_game_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/card_game_contract/src/main.nr @@ -112,7 +112,7 @@ contract CardGame { fn buy_pack(seed: Field // The randomness used to generate the cards. Passed in for now. ) { let buyer = context.msg_sender(); - let mut cards = get_pack_cards(seed, buyer); + let mut cards = get_pack_cards(seed, buyer, &mut context); let mut collection = storage.collections.at(buyer); let _inserted_cards = collection.add_cards(cards, buyer); diff --git a/yarn-project/noir-contracts/contracts/docs_example_contract/src/account_contract_interface.nr b/yarn-project/noir-contracts/contracts/docs_example_contract/src/account_contract_interface.nr deleted file mode 100644 index 0701b4819be2..000000000000 --- a/yarn-project/noir-contracts/contracts/docs_example_contract/src/account_contract_interface.nr +++ /dev/null @@ -1,11 +0,0 @@ -struct AccountContractInterface { - address: Field, -} - -impl AccountContractInterface { - pub fn at(address: Field) -> Self { - AccountContractInterface { address } - } - - pub fn send_rewards(_self: Self, _rewards: u8) {} -} diff --git a/yarn-project/noir-contracts/contracts/docs_example_contract/src/actions.nr b/yarn-project/noir-contracts/contracts/docs_example_contract/src/actions.nr deleted file mode 100644 index 9c9423f31ea8..000000000000 --- a/yarn-project/noir-contracts/contracts/docs_example_contract/src/actions.nr +++ /dev/null @@ -1,156 +0,0 @@ -use dep::aztec::protocol_types::{ - address::AztecAddress, - constants::{MAX_NOTES_PER_PAGE, MAX_READ_REQUESTS_PER_CALL}, -}; -use dep::aztec::note::{ - note_getter_options::NoteGetterOptions, note_viewer_options::NoteViewerOptions, -}; -use dep::aztec::state_vars::{ - immutable_singleton::ImmutableSingleton, map::Map, public_state::PublicState, set::Set, - singleton::Singleton, -}; -use dep::aztec::types::type_serialization::bool_serialization::BOOL_SERIALIZED_LEN; -use dep::std::option::Option; - -use crate::types::{ - card_note::{CardNote, CARD_NOTE_LEN}, - profile_note::{ProfileNote, PROFILE_NOTE_LEN}, - queen::{Queen, QUEEN_SERIALIZED_LEN}, - rules_note::{RulesNote, RULES_NOTE_LEN}, -}; - -// docs:start:state_vars-PublicStateRead -pub fn is_locked(state_var: PublicState) -> bool { - state_var.read() -} -// docs:end:state_vars-PublicStateRead - -// docs:start:state_vars-PublicStateWrite -pub fn lock(state_var: PublicState) { - state_var.write(true); -} -// docs:end:state_vars-PublicStateWrite - -pub fn unlock(state_var: PublicState) { - state_var.write(false); -} - -// docs:start:state_vars-PublicStateReadCustom -pub fn get_current_queen(state_var: PublicState) -> Queen { - state_var.read() -} -// docs:end:state_vars-PublicStateReadCustom - -pub fn can_replace_queen(state_var: PublicState, new_queen: Queen) -> bool { - let current_queen = get_current_queen(state_var); - new_queen.points > current_queen.points -} - -// docs:start:state_vars-PublicStateWriteCustom -pub fn replace_queen(state_var: PublicState, new_queen: Queen) { - state_var.write(new_queen); -} -// docs:end:state_vars-PublicStateWriteCustom - -// docs:start:state_vars-PublicStateReadWriteCustom -pub fn add_points_to_queen(state_var: PublicState, new_points: u8) { - let mut queen = state_var.read(); - queen.points += new_points; - state_var.write(queen); -} -// docs:end:state_vars-PublicStateReadWriteCustom - -// docs:start:state_vars-SingletonInit -pub fn init_legendary_card(state_var: Singleton, card: &mut CardNote) { - state_var.initialize(card, Option::some(card.owner), true); -} -// docs:end:state_vars-SingletonInit - -// docs:start:state_vars-SingletonReplace -pub fn update_legendary_card(state_var: Singleton, card: &mut CardNote) { - state_var.replace(card, true); -} -// docs:end:state_vars-SingletonReplace - -// docs:start:state_vars-SingletonGet -pub fn get_legendary_card(state_var: Singleton) -> CardNote { - state_var.get_note(true) -} -// docs:end:state_vars-SingletonGet - -// docs:start:state_vars-ImmutableSingletonInit -pub fn init_game_rules(state_var: ImmutableSingleton, rules: &mut RulesNote) { - state_var.initialize(rules, Option::none(), true); -} -// docs:end:state_vars-ImmutableSingletonInit - -// docs:start:state_vars-ImmutableSingletonGet -pub fn is_valid_card(state_var: ImmutableSingleton, card: CardNote) -> bool { - let rules = state_var.get_note(); - card.points >= rules.min_points & card.points <= rules.max_points -} -// docs:end:state_vars-ImmutableSingletonGet - -// docs:start:state_vars-SetInsert -pub fn add_new_card(state_var: Set, card: &mut CardNote) { - state_var.insert(card, true); -} -// docs:end:state_vars-SetInsert - -// docs:start:state_vars-SetRemove -pub fn remove_card(state_var: Set, card: CardNote) { - state_var.remove(card); -} -// docs:end:state_vars-SetRemove - -// docs:start:state_vars-SetGet -pub fn get_cards( - state_var: Set, - options: NoteGetterOptions -) -> [Option; MAX_READ_REQUESTS_PER_CALL] { - state_var.get_notes(options) -} -// docs:end:state_vars-SetGet - -// docs:start:state_vars-SetView -unconstrained pub fn view_cards( - state_var: Set, - options: NoteViewerOptions -) -> [Option; MAX_NOTES_PER_PAGE] { - state_var.view_notes(options) -} -// docs:end:state_vars-SetView - -unconstrained pub fn get_total_points(state_var: Set, account: AztecAddress, offset: u32) -> u8 { - let options = NoteViewerOptions::new().select(2, account.to_field()).set_offset(offset); - let mut total_points = 0; - let notes = view_cards(state_var, options); - for i in 0..notes.len() { - if notes[i].is_some() { - total_points += notes[i].unwrap_unchecked().points; - } - } - if notes[notes.len() - 1].is_some() { - total_points += get_total_points(state_var, account, offset + notes.len() as u32); - } - total_points -} - -// docs:start:state_vars-MapAtSingletonInit -pub fn add_new_profile( - state_var: Map>, - account: AztecAddress, - profile: &mut ProfileNote -) { - state_var.at(account).initialize(profile, Option::some(account), true); -} -// docs:end:state_vars-MapAtSingletonInit - -// docs:start:state_vars-MapAtSingletonGet -pub fn get_profile( - state_var: Map>, - account: AztecAddress -) -> ProfileNote { - state_var.at(account).get_note(true) -} -// docs:end:state_vars-MapAtSingletonGet diff --git a/yarn-project/noir-contracts/contracts/docs_example_contract/src/main.nr b/yarn-project/noir-contracts/contracts/docs_example_contract/src/main.nr index 8870c2972670..e7c9befa319f 100644 --- a/yarn-project/noir-contracts/contracts/docs_example_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/docs_example_contract/src/main.nr @@ -1,210 +1,164 @@ -mod account_contract_interface; -mod actions; mod options; mod types; +// Following is a very simple game to show case use of singleton in as minimalistic way as possible +// It also serves as an e2e test that you can read and then replace the singleton in the same call +// (tests ordering in the circuit) + +// you have a card (singleton). Anyone can create a bigger card. Whoever is bigger will be the leader. +// it also has dummy methods and other examples used for documentation e.g. +// how to create custom notes, a custom struct for public state, a custom note that may be unencrypted +// also has `options.nr` which shows various ways of using `NoteGetterOptions` to query notes +// it also shows what our macros do behind the scenes! + contract DocsExample { + // how to import dependencies defined in your workspace use dep::aztec::protocol_types::{ - address::AztecAddress, abis::function_selector::FunctionSelector, + address::AztecAddress, }; - use dep::std::option::Option; use dep::aztec::{ - context::{PrivateContext, PublicContext, Context}, - state_vars::{ - immutable_singleton::ImmutableSingleton, map::Map, public_state::PublicState, set::Set, - singleton::Singleton, + note::{ + note_header::NoteHeader, + utils as note_utils, }, + context::{PrivateContext, PublicContext, Context}, + state_vars::{map::Map, public_state::PublicState,singleton::Singleton, immutable_singleton::ImmutableSingleton}, }; - // docs:start:state_vars-PublicStateBoolImport - use dep::aztec::types::type_serialization::bool_serialization::{ - BoolSerializationMethods, BOOL_SERIALIZED_LEN, - }; - // docs:end:state_vars-PublicStateBoolImport - use crate::account_contract_interface::AccountContractInterface; - use crate::actions; + // how to import methods from other files/folders within your workspace use crate::options::create_account_card_getter_options; use crate::types::{ card_note::{CardNote, CardNoteMethods, CARD_NOTE_LEN}, - profile_note::{ProfileNote, ProfileNoteMethods, PROFILE_NOTE_LEN}, - queen::{Queen, QueenSerializationMethods, QUEEN_SERIALIZED_LEN}, - rules_note::{RulesNote, RulesNoteMethods, RULES_NOTE_LEN}, + leader::{Leader, LeaderSerializationMethods, LEADER_SERIALIZED_LEN}, }; - // docs:start:storage-struct-declaration struct Storage { - locked: PublicState, - queen: PublicState, - game_rules: ImmutableSingleton, + // Shows how to create a custom struct in Public + leader: PublicState, // docs:start:storage-singleton-declaration legendary_card: Singleton, // docs:end:storage-singleton-declaration - cards: Set, + // just used for docs example to show how to create a singleton map. // docs:start:storage-map-singleton-declaration - profiles: Map>, + profiles: Map>, // docs:end:storage-map-singleton-declaration + imm_singleton: ImmutableSingleton, } - // docs:end:storage-struct-declaration - // docs:start:storage-declaration - // docs:start:state_vars-PublicState - // docs:start:state_vars-PublicStateCustomStruct - // docs:start:state_vars-Singleton - // docs:start:state_vars-ImmutableSingleton - // docs:start:state_vars-Set - // docs:start:state_vars-MapSingleton impl Storage { fn init(context: Context) -> Self { Storage { - // highlight-next-line:state_vars-PublicState - locked: PublicState::new(context, 1, BoolSerializationMethods), - // highlight-next-line:state_vars-PublicStateCustomStruct - queen: PublicState::new( + leader: PublicState::new( context, - 2, - QueenSerializationMethods, + 1, + LeaderSerializationMethods, ), - // highlight-next-line:state_vars-ImmutableSingleton - game_rules: ImmutableSingleton::new(context, 3, RulesNoteMethods), - // highlight-next-line:state_vars-Singleton // docs:start:start_vars_singleton - legendary_card: Singleton::new(context, 4, CardNoteMethods), + legendary_card: Singleton::new(context, 2, CardNoteMethods), // docs:end:start_vars_singleton - // highlight-next-line:state_vars-Set - cards: Set::new(context, 5, CardNoteMethods), - // highlight-next-line:state_vars-MapSingleton + // just used for docs example (not for game play): + // docs:start:state_vars-MapSingleton profiles: Map::new( context, - 6, + 3, |context, slot| { - Singleton::new(context, slot, ProfileNoteMethods) + Singleton::new(context, slot, CardNoteMethods) }, ), + // docs:end:state_vars-MapSingleton + imm_singleton: ImmutableSingleton::new(context, 4, CardNoteMethods), } } } - // docs:end:state_vars-PublicState - // docs:end:state_vars-PublicStateCustomStruct - // docs:end:state_vars-Singleton - // docs:end:state_vars-ImmutableSingleton - // docs:end:state_vars-Set - // docs:end:state_vars-MapSingleton - // docs:end:storage-declaration - global REPLACE_QUEEN_FUNCTION_SELECTOR = 11111111; - global GET_POINTS_OF_COMMON_CARD_FUNCTION_SELECTOR = 11111111; + #[aztec(private)] + fn constructor() {} #[aztec(private)] - fn constructor(min_points: u8, max_points: u8, legendary_card_secret: Field) { - let mut game_rules = RulesNote::new(min_points, max_points, Option::some(AztecAddress::zero())); - actions::init_game_rules(storage.game_rules, &mut game_rules); + fn initialize_immutable_singleton(randomness: Field, points: u8) { + let mut new_card = CardNote::new(points, randomness, context.msg_sender()); + storage.imm_singleton.initialize(&mut new_card, true); + } - let mut legendary_card = CardNote::new(0, legendary_card_secret, AztecAddress::zero()); - actions::init_legendary_card(storage.legendary_card, &mut legendary_card); + #[aztec(private)] + // msg_sender() is 0 at deploy time. So created another function + fn initialize_private(randomness: Field, points: u8) { + let mut legendary_card = CardNote::new(points, randomness, context.msg_sender()); + // create and broadcast note + storage.legendary_card.initialize(&mut legendary_card, true); } - // docs:start:storage-init - #[aztec(public)] - fn lock() { - // highlight-next-line:storage-init + #[aztec(private)] + fn update_legendary_card(randomness: Field, points: u8) { + let mut new_card = CardNote::new(points, randomness, context.msg_sender()); + storage.legendary_card.replace(&mut new_card, true); - storage.locked.write(true); + context.call_public_function( + context.this_address(), + FunctionSelector::from_signature("update_leader((Field),u8)"), + [context.msg_sender().to_field(), points as Field] + ); } - // docs:end:storage-init - // docs:start:functions-OpenFunction - #[aztec(public)] - fn unlock() { - actions::unlock(storage.locked); - } - // docs:end:functions-OpenFunction + #[aztec(private)] + fn increase_legendary_points() { + // Ensure `points` > current value + // Also serves as a e2e test that you can `get_note()` and then `replace()` - #[aztec(public)] - fn replace_queen(account: AztecAddress, points: u8) { - let new_queen = Queen { account, points }; + // docs:start:state_vars-SingletonGet + let card = storage.legendary_card.get_note(false); + // docs:end:state_vars-SingletonGet - assert(actions::can_replace_queen(storage.queen, new_queen)); + let points = card.points + 1; - actions::replace_queen(storage.queen, new_queen); + let mut new_card = CardNote::new(points, card.randomness, context.msg_sender()); + // docs:start:state_vars-SingletonReplace + storage.legendary_card.replace(&mut new_card, true); + // docs:end:state_vars-SingletonReplace + + context.call_public_function( + context.this_address(), + FunctionSelector::from_signature("update_leader((Field),u8)"), + [context.msg_sender().to_field(), points as Field] + ); } - // docs:start:state_vars-PublicStateWriteBeforeCall #[aztec(public)] - fn replace_queen_unsafe() { - let account = context.msg_sender(); - let points = actions::get_total_points(storage.cards, account, 0); - - let current_queen = storage.queen.read(); - assert(!account.eq(current_queen.account)); - assert(points > current_queen.points); - - AccountContractInterface::at(account.to_field()).send_rewards(current_queen.points); - - let new_queen = Queen { account, points }; - storage.queen.write(new_queen); + internal fn update_leader(account: AztecAddress, points: u8) { + let new_leader = Leader { account, points }; + storage.leader.write(new_leader); } - // docs:end:state_vars-PublicStateWriteBeforeCall - // docs:start:functions-SecretFunction - #[aztec(private)] - fn add_common_cards(secrets: [Field; 4]) { - for i in 0..secrets.len() as u8 { - let mut card = CardNote::new(0, secrets[i], AztecAddress::zero()); - actions::add_new_card(storage.cards, &mut card); - } + unconstrained fn get_leader() -> pub Leader { + storage.leader.read() } - // docs:end:functions-SecretFunction - - #[aztec(private)] - fn update_legendary_card(new_points: u8, new_secret: Field) { - let owner = inputs.call_context.msg_sender; - let mut updated_card = CardNote::new(new_points, new_secret, owner); - assert(actions::is_valid_card(storage.game_rules, updated_card)); - - actions::update_legendary_card(storage.legendary_card, &mut updated_card); + unconstrained fn get_legendary_card() -> pub CardNote { + storage.legendary_card.view_note() } - #[aztec(private)] - fn become_queen() { - let legendary_card = actions::get_legendary_card(storage.legendary_card); - - let owner = legendary_card.owner; - let result = context.call_private_function( - inputs.call_context.storage_contract_address, - FunctionSelector::from_field(GET_POINTS_OF_COMMON_CARD_FUNCTION_SELECTOR), - [owner.to_field(), 0] - ); - let total_points = legendary_card.points + result[0] as u8; - - context.call_public_function( - inputs.call_context.storage_contract_address, - FunctionSelector::from_field(REPLACE_QUEEN_FUNCTION_SELECTOR), - [owner.to_field(), total_points as Field] - ); + unconstrained fn is_legendary_initialized() -> pub bool { + storage.legendary_card.is_initialized() } - #[aztec(private)] - fn get_points_of_common_cards(account: AztecAddress, offset: u32) { - let mut total_points = 0; - let options = create_account_card_getter_options(account, offset); - let cards = actions::get_cards(storage.cards, options); - for i in 0..cards.len() { - if (cards[i].is_some()) { - let card = cards[i].unwrap_unchecked(); - assert(card.owner.eq(account)); - total_points += card.points; - } - } + unconstrained fn get_imm_card() -> pub CardNote { + storage.imm_singleton.view_note() + } - context.return_values.push(total_points as Field); + unconstrained fn is_imm_initialized() -> pub bool { + storage.imm_singleton.is_initialized() } - // docs:start:functions-UnconstrainedFunction - unconstrained fn get_total_points(account: AztecAddress) -> pub u8 { - actions::get_total_points(storage.cards, account, 0) + // TODO: remove this placeholder once https://github.com/AztecProtocol/aztec-packages/issues/2918 is implemented + unconstrained fn compute_note_hash_and_nullifier( + contract_address: AztecAddress, + nonce: Field, + storage_slot: Field, + serialized_note: [Field; CARD_NOTE_LEN] + ) -> pub [Field; 4] { + let note_header = NoteHeader::new(contract_address, nonce, storage_slot); + note_utils::compute_note_hash_and_nullifier(CardNoteMethods, note_header, serialized_note) } - // docs:end:functions-UnconstrainedFunction /// Macro equivalence section use dep::aztec::abi; @@ -269,21 +223,4 @@ contract DocsExample { // ************************************************************ } // docs:end:simple_macro_example_expanded - - // Cross chain messaging section - // Demonstrates a cross chain message - // docs:start:l1_to_l2_cross_chain_message - #[aztec(private)] - fn send_to_l1() {} - // docs:end:l1_to_l2_cross_chain_message - - // TODO: remove this placeholder once https://github.com/AztecProtocol/aztec-packages/issues/2918 is implemented - unconstrained fn compute_note_hash_and_nullifier( - contract_address: AztecAddress, - nonce: Field, - storage_slot: Field, - serialized_note: [Field; 0] - ) -> pub [Field; 4] { - [0, 0, 0, 0] - } } diff --git a/yarn-project/noir-contracts/contracts/docs_example_contract/src/options.nr b/yarn-project/noir-contracts/contracts/docs_example_contract/src/options.nr index 8fb26e6e7d73..9742345f8ca7 100644 --- a/yarn-project/noir-contracts/contracts/docs_example_contract/src/options.nr +++ b/yarn-project/noir-contracts/contracts/docs_example_contract/src/options.nr @@ -6,6 +6,8 @@ use dep::aztec::protocol_types::{ use dep::aztec::note::note_getter_options::{NoteGetterOptions, Sort, SortOrder}; use dep::std::option::Option; +// Shows how to use NoteGetterOptions and query for notes. + // docs:start:state_vars-NoteGetterOptionsSelectSortOffset pub fn create_account_card_getter_options( account: AztecAddress, diff --git a/yarn-project/noir-contracts/contracts/docs_example_contract/src/types.nr b/yarn-project/noir-contracts/contracts/docs_example_contract/src/types.nr index b8bf6dc7bfd8..630d5c9b87e6 100644 --- a/yarn-project/noir-contracts/contracts/docs_example_contract/src/types.nr +++ b/yarn-project/noir-contracts/contracts/docs_example_contract/src/types.nr @@ -1,4 +1,2 @@ mod card_note; -mod profile_note; -mod queen; -mod rules_note; +mod leader; diff --git a/yarn-project/noir-contracts/contracts/docs_example_contract/src/types/card_note.nr b/yarn-project/noir-contracts/contracts/docs_example_contract/src/types/card_note.nr index 97da78e65192..f185518c412f 100644 --- a/yarn-project/noir-contracts/contracts/docs_example_contract/src/types/card_note.nr +++ b/yarn-project/noir-contracts/contracts/docs_example_contract/src/types/card_note.nr @@ -6,7 +6,7 @@ use dep::aztec::{ utils::compute_note_hash_for_read_or_nullify, }, oracle::{ - get_secret_key::get_secret_key, + nullifier_key::get_nullifier_secret_key, get_public_key::get_public_key, }, log::emit_encrypted_log, @@ -14,35 +14,37 @@ use dep::aztec::{ context::PrivateContext, }; +// Shows how to create a custom note + global CARD_NOTE_LEN: Field = 3; // docs:start:state_vars-CardNote struct CardNote { points: u8, - secret: Field, + randomness: Field, owner: AztecAddress, header: NoteHeader, } // docs:end:state_vars-CardNote impl CardNote { - pub fn new(points: u8, secret: Field, owner: AztecAddress) -> Self { + pub fn new(points: u8, randomness: Field, owner: AztecAddress) -> Self { CardNote { points, - secret, + randomness, owner, header: NoteHeader::empty(), } } pub fn serialize(self) -> [Field; CARD_NOTE_LEN] { - [self.points as Field, self.secret, self.owner.to_field()] + [self.points as Field, self.randomness, self.owner.to_field()] } pub fn deserialize(serialized_note: [Field; CARD_NOTE_LEN]) -> Self { CardNote { points: serialized_note[0] as u8, - secret: serialized_note[1], + randomness: serialized_note[1], owner: AztecAddress::from_field(serialized_note[2]), header: NoteHeader::empty(), } @@ -51,14 +53,24 @@ impl CardNote { pub fn compute_note_hash(self) -> Field { pedersen_hash([ self.points as Field, - self.secret, + self.randomness, self.owner.to_field(), ],0) } - pub fn compute_nullifier(self) -> Field { + pub fn compute_nullifier(self, context: &mut PrivateContext) -> Field { let note_hash_for_nullify = compute_note_hash_for_read_or_nullify(CardNoteMethods, self); - let secret = get_secret_key(self.owner); + let secret = context.request_nullifier_secret_key(self.owner); + pedersen_hash([ + note_hash_for_nullify, + secret.high, + secret.low, + ],0) + } + + pub fn compute_nullifier_without_context(self) -> Field { + let note_hash_for_nullify = compute_note_hash_for_read_or_nullify(CardNoteMethods, self); + let secret = get_nullifier_secret_key(self.owner); pedersen_hash([ note_hash_for_nullify, secret.high, @@ -95,8 +107,12 @@ fn compute_note_hash(note: CardNote) -> Field { note.compute_note_hash() } -fn compute_nullifier(note: CardNote) -> Field { - note.compute_nullifier() +fn compute_nullifier(note: CardNote, context: &mut PrivateContext) -> Field { + note.compute_nullifier(context) +} + +fn compute_nullifier_without_context(note: CardNote) -> Field { + note.compute_nullifier_without_context() } fn get_header(note: CardNote) -> NoteHeader { @@ -117,6 +133,7 @@ global CardNoteMethods = NoteInterface { serialize, compute_note_hash, compute_nullifier, + compute_nullifier_without_context, get_header, set_header, broadcast, diff --git a/yarn-project/noir-contracts/contracts/docs_example_contract/src/types/leader.nr b/yarn-project/noir-contracts/contracts/docs_example_contract/src/types/leader.nr new file mode 100644 index 000000000000..ca034261ec00 --- /dev/null +++ b/yarn-project/noir-contracts/contracts/docs_example_contract/src/types/leader.nr @@ -0,0 +1,23 @@ +use dep::aztec::protocol_types::address::AztecAddress; +use dep::aztec::types::type_serialization::TypeSerializationInterface; + +// Shows how to create a custom struct in Public +struct Leader { + account: AztecAddress, + points: u8, +} + +global LEADER_SERIALIZED_LEN: Field = 2; + +fn deserialize(fields: [Field; LEADER_SERIALIZED_LEN]) -> Leader { + Leader { account: AztecAddress::from_field(fields[0]), points: fields[1] as u8 } +} + +fn serialize(leader: Leader) -> [Field; LEADER_SERIALIZED_LEN] { + [leader.account.to_field(), leader.points as Field] +} + +global LeaderSerializationMethods = TypeSerializationInterface { + deserialize, + serialize, +}; diff --git a/yarn-project/noir-contracts/contracts/docs_example_contract/src/types/profile_note.nr b/yarn-project/noir-contracts/contracts/docs_example_contract/src/types/profile_note.nr deleted file mode 100644 index 201c796c8052..000000000000 --- a/yarn-project/noir-contracts/contracts/docs_example_contract/src/types/profile_note.nr +++ /dev/null @@ -1,119 +0,0 @@ -use dep::std::option::Option; -use dep::aztec::{ - protocol_types::address::AztecAddress, - note::{ - note_header::NoteHeader, - note_interface::NoteInterface, - }, - oracle::get_public_key::get_public_key, - log::emit_encrypted_log, - hash::pedersen_hash, - context::PrivateContext, -}; - -global PROFILE_NOTE_LEN: Field = 2; - -struct ProfileNote { - avatar: Field, - xp: Field, - maybe_owner: Option, - header: NoteHeader, -} - -impl ProfileNote { - pub fn new(avatar: Field, xp: Field, maybe_owner: Option) -> Self { - ProfileNote { - avatar, - xp, - maybe_owner, - header: NoteHeader::empty(), - } - } - - pub fn serialize(self) -> [Field; PROFILE_NOTE_LEN] { - [self.avatar, self.xp] - } - - pub fn deserialize(serialized_note: [Field; PROFILE_NOTE_LEN]) -> Self { - ProfileNote { - avatar: serialized_note[0], - xp: serialized_note[1], - maybe_owner: Option::none(), - header: NoteHeader::empty(), - } - } - - pub fn compute_note_hash(self) -> Field { - pedersen_hash([ - self.avatar, - self.xp, - ],0) - } - - pub fn compute_nullifier(_self: Self) -> Field { - assert(false); // Not allowed. - 0 - } - - pub fn set_header(&mut self, header: NoteHeader) { - self.header = header; - } - - pub fn set_owner(&mut self, owner: AztecAddress) { - self.maybe_owner = Option::some(owner); - } - - // Broadcasts the note as an encrypted log on L1. - pub fn broadcast(self, context: &mut PrivateContext, slot: Field) { - assert(self.maybe_owner.is_some(), "Note owner must be set when the broadcast flow is triggered."); - let owner = self.maybe_owner.unwrap_unchecked(); - - let encryption_pub_key = get_public_key(owner); - emit_encrypted_log( - context, - (*context).this_address(), - slot, - encryption_pub_key, - self.serialize(), - ); - } -} - -fn deserialize(serialized_note: [Field; PROFILE_NOTE_LEN]) -> ProfileNote { - ProfileNote::deserialize(serialized_note) -} - -fn serialize(note: ProfileNote) -> [Field; PROFILE_NOTE_LEN] { - note.serialize() -} - -fn compute_note_hash(note: ProfileNote) -> Field { - note.compute_note_hash() -} - -fn compute_nullifier(note: ProfileNote) -> Field { - note.compute_nullifier() -} - -fn get_header(note: ProfileNote) -> NoteHeader { - note.header -} - -fn set_header(note: &mut ProfileNote, header: NoteHeader) { - note.set_header(header) -} - -// Broadcasts the note as an encrypted log on L1. -fn broadcast(context: &mut PrivateContext, slot: Field, note: ProfileNote) { - note.broadcast(context, slot); -} - -global ProfileNoteMethods = NoteInterface { - deserialize, - serialize, - compute_note_hash, - compute_nullifier, - get_header, - set_header, - broadcast, -}; diff --git a/yarn-project/noir-contracts/contracts/docs_example_contract/src/types/queen.nr b/yarn-project/noir-contracts/contracts/docs_example_contract/src/types/queen.nr deleted file mode 100644 index acd4ed0f7caf..000000000000 --- a/yarn-project/noir-contracts/contracts/docs_example_contract/src/types/queen.nr +++ /dev/null @@ -1,26 +0,0 @@ -use dep::aztec::protocol_types::address::AztecAddress; -use dep::aztec::types::type_serialization::TypeSerializationInterface; - -// docs:start:state_vars-CustomStruct -struct Queen { - account: AztecAddress, - points: u8, -} -// docs:end:state_vars-CustomStruct - -// docs:start:state_vars-PublicStateCustomStruct -global QUEEN_SERIALIZED_LEN: Field = 2; - -fn deserialize(fields: [Field; QUEEN_SERIALIZED_LEN]) -> Queen { - Queen { account: AztecAddress::from_field(fields[0]), points: fields[1] as u8 } -} - -fn serialize(queen: Queen) -> [Field; QUEEN_SERIALIZED_LEN] { - [queen.account.to_field(), queen.points as Field] -} - -global QueenSerializationMethods = TypeSerializationInterface { - deserialize, - serialize, -}; -// docs:end:state_vars-PublicStateCustomStruct diff --git a/yarn-project/noir-contracts/contracts/docs_example_contract/src/types/rules_note.nr b/yarn-project/noir-contracts/contracts/docs_example_contract/src/types/rules_note.nr deleted file mode 100644 index d3abaecb5d18..000000000000 --- a/yarn-project/noir-contracts/contracts/docs_example_contract/src/types/rules_note.nr +++ /dev/null @@ -1,119 +0,0 @@ -use dep::std::option::Option; -use dep::aztec::{ - protocol_types::address::AztecAddress, - note::{ - note_header::NoteHeader, - note_interface::NoteInterface, - }, - oracle::get_public_key::get_public_key, - log::emit_encrypted_log, - hash::pedersen_hash, - context::PrivateContext, -}; - -global RULES_NOTE_LEN: Field = 2; - -struct RulesNote { - min_points: u8, - max_points: u8, - maybe_owner: Option, - header: NoteHeader, -} - -impl RulesNote { - pub fn new(min_points: u8, max_points: u8, maybe_owner: Option) -> Self { - RulesNote { - min_points, - max_points, - maybe_owner, - header: NoteHeader::empty(), - } - } - - pub fn serialize(self) -> [Field; RULES_NOTE_LEN] { - [self.min_points as Field, self.max_points as Field] - } - - pub fn deserialize(serialized_note: [Field; RULES_NOTE_LEN]) -> Self { - RulesNote { - min_points: serialized_note[0] as u8, - max_points: serialized_note[1] as u8, - maybe_owner: Option::none(), - header: NoteHeader::empty(), - } - } - - pub fn compute_note_hash(self) -> Field { - pedersen_hash([ - self.min_points as Field, - self.max_points as Field, - ],0) - } - - pub fn compute_nullifier(_self: Self) -> Field { - // Not used - 0 - } - - pub fn set_header(&mut self, header: NoteHeader) { - self.header = header; - } - - pub fn set_owner(&mut self, owner: AztecAddress) { - self.maybe_owner = Option::some(owner); - } - - // Broadcasts the note as an encrypted log on L1. - pub fn broadcast(self, context: &mut PrivateContext, slot: Field) { - assert(self.maybe_owner.is_some(), "Note owner must be set when the broadcast flow is triggered."); - let owner = self.maybe_owner.unwrap_unchecked(); - - let encryption_pub_key = get_public_key(owner); - emit_encrypted_log( - context, - (*context).this_address(), - slot, - encryption_pub_key, - self.serialize(), - ); - } -} - -fn deserialize(serialized_note: [Field; RULES_NOTE_LEN]) -> RulesNote { - RulesNote::deserialize(serialized_note) -} - -fn serialize(note: RulesNote) -> [Field; RULES_NOTE_LEN] { - note.serialize() -} - -fn compute_note_hash(note: RulesNote) -> Field { - note.compute_note_hash() -} - -fn compute_nullifier(note: RulesNote) -> Field { - note.compute_nullifier() -} - -fn get_header(note: RulesNote) -> NoteHeader { - note.header -} - -fn set_header(note: &mut RulesNote, header: NoteHeader) { - note.set_header(header) -} - -// Broadcasts the note as an encrypted log on L1. -fn broadcast(context: &mut PrivateContext, slot: Field, note: RulesNote) { - note.broadcast(context, slot); -} - -global RulesNoteMethods = NoteInterface { - deserialize, - serialize, - compute_note_hash, - compute_nullifier, - get_header, - set_header, - broadcast, -}; diff --git a/yarn-project/noir-contracts/contracts/easy_private_voting_contract/src/main.nr b/yarn-project/noir-contracts/contracts/easy_private_voting_contract/src/main.nr index 54db9e4017a9..ceddb93c70c2 100644 --- a/yarn-project/noir-contracts/contracts/easy_private_voting_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/easy_private_voting_contract/src/main.nr @@ -6,7 +6,6 @@ contract EasyPrivateVoting { address::AztecAddress, }, context::{PrivateContext, Context}, - oracle::get_secret_key::get_secret_key, // used to compute nullifier state_vars::{ map::Map, public_state::PublicState,}, types::type_serialization::{ // serialization methods for using booleans and aztec addresses bool_serialization::{BoolSerializationMethods, BOOL_SERIALIZED_LEN}, @@ -71,7 +70,7 @@ contract EasyPrivateVoting { // docs:start:cast_vote #[aztec(private)] // annotation to mark function as private and expose private context fn cast_vote(candidate: Field) { - let secret = get_secret_key(context.msg_sender()); // get secret key of caller of function + let secret = context.request_nullifier_secret_key(context.msg_sender()); // get secret key of caller of function let nullifier = dep::std::hash::pedersen_hash([context.msg_sender().to_field(), secret.low, secret.high]); // compute nullifier with this secret key so others can't descrypt it context.push_new_nullifier(nullifier, 0); // push nullifier context.call_public_function( diff --git a/yarn-project/noir-contracts/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr b/yarn-project/noir-contracts/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr index c0aea096b20b..779c8debeccc 100644 --- a/yarn-project/noir-contracts/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr +++ b/yarn-project/noir-contracts/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr @@ -6,7 +6,7 @@ use dep::aztec::{ utils::compute_unique_siloed_note_hash, }, oracle::{ - get_secret_key::get_secret_key, + nullifier_key::get_nullifier_secret_key, get_public_key::get_public_key, }, log::emit_encrypted_log, @@ -60,9 +60,20 @@ impl EcdsaPublicKeyNote { [x, last_x, y, last_y, self.owner.to_field()] } - pub fn compute_nullifier(self) -> Field { + pub fn compute_nullifier(self, context: &mut PrivateContext) -> Field { let unique_siloed_note_hash = compute_unique_siloed_note_hash(EcdsaPublicKeyNoteInterface, self); - let secret = get_secret_key(self.owner); + let secret = context.request_nullifier_secret_key(self.owner); + // TODO(#1205) Should use a non-zero generator index. + pedersen_hash([ + unique_siloed_note_hash, + secret.low, + secret.high, + ],0) + } + + pub fn compute_nullifier_without_context(self) -> Field { + let unique_siloed_note_hash = compute_unique_siloed_note_hash(EcdsaPublicKeyNoteInterface, self); + let secret = get_nullifier_secret_key(self.owner); // TODO(#1205) Should use a non-zero generator index. pedersen_hash([ unique_siloed_note_hash, @@ -116,8 +127,12 @@ fn compute_note_hash(note: EcdsaPublicKeyNote) -> Field { pedersen_hash(note.serialize(), 0) } -fn compute_nullifier(note: EcdsaPublicKeyNote) -> Field { - note.compute_nullifier() +fn compute_nullifier(note: EcdsaPublicKeyNote, context: &mut PrivateContext) -> Field { + note.compute_nullifier(context) +} + +fn compute_nullifier_without_context(note: EcdsaPublicKeyNote) -> Field { + note.compute_nullifier_without_context() } fn get_header(note: EcdsaPublicKeyNote) -> NoteHeader { @@ -138,6 +153,7 @@ global EcdsaPublicKeyNoteInterface = NoteInterface { serialize, compute_note_hash, compute_nullifier, + compute_nullifier_without_context, get_header, set_header, broadcast, diff --git a/yarn-project/noir-contracts/contracts/ecdsa_account_contract/src/main.nr b/yarn-project/noir-contracts/contracts/ecdsa_account_contract/src/main.nr index a12e0c02600f..da730b23c32f 100644 --- a/yarn-project/noir-contracts/contracts/ecdsa_account_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/ecdsa_account_contract/src/main.nr @@ -45,7 +45,7 @@ contract EcdsaAccount { fn constructor(signing_pub_key_x: pub [u8; 32], signing_pub_key_y: pub [u8; 32]) { let this = context.this_address(); let mut pub_key_note = EcdsaPublicKeyNote::new(signing_pub_key_x, signing_pub_key_y, this); - storage.public_key.initialize(&mut pub_key_note, Option::none(), true); + storage.public_key.initialize(&mut pub_key_note, true); } // Note: If you globally change the entrypoint signature don't forget to update default_entrypoint.ts diff --git a/yarn-project/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr b/yarn-project/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr index f0882caff1b5..5b99fdd60bbc 100644 --- a/yarn-project/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr @@ -23,11 +23,11 @@ contract InclusionProofs { note_header::NoteHeader, utils as note_utils, }, - + // docs:start:imports history::{ contract_inclusion::{ prove_contract_inclusion, - }, + }, note_inclusion::{ prove_note_commitment_inclusion, prove_note_inclusion, @@ -46,9 +46,11 @@ contract InclusionProofs { prove_public_value_inclusion, }, }, + // docs:end:imports }; + // docs:start:value_note_imports use dep::value_note::value_note::{ValueNote, ValueNoteMethods, VALUE_NOTE_LEN}; - + // docs:end:value_note_imports struct Storage { private_values: Map>, public_value: PublicState, @@ -84,6 +86,7 @@ contract InclusionProofs { storage.public_value.write(value); } + // docs:start:create_note // Creates a value note owned by `owner`. #[aztec(private)] fn create_note(owner: AztecAddress, value: Field) { @@ -91,6 +94,7 @@ contract InclusionProofs { let mut note = ValueNote::new(value, owner); owner_private_values.insert(&mut note, true); } + // docs:end:create_note // Proves that the owner owned a ValueNote at block `block_number`. #[aztec(private)] @@ -102,20 +106,24 @@ contract InclusionProofs { // PXE performs note commitment inclusion check when you add a new note). spare_commitment: Field ) { + // docs:start:get_note_from_pxe // 1) Get the note from PXE. let private_values = storage.private_values.at(owner); let options = NoteGetterOptions::new().select(1, owner.to_field()).set_limit(1); let notes = private_values.get_notes(options); let maybe_note = notes[0]; + // docs:end:get_note_from_pxe // 2) Prove the note inclusion if maybe_note.is_some() { + // docs:start:prove_note_inclusion prove_note_inclusion( ValueNoteMethods, maybe_note.unwrap_unchecked(), block_number, context ); + // docs:end:prove_note_inclusion } else { // Note was not found so we will prove inclusion of the spare commitment prove_note_commitment_inclusion(spare_commitment, block_number, context); @@ -140,15 +148,19 @@ contract InclusionProofs { // 3) Compute the nullifier from the note if maybe_note.is_some() { + // docs:start:prove_note_not_nullified prove_note_not_nullified( ValueNoteMethods, maybe_note.unwrap_unchecked(), block_number, - context + &mut context ); + // docs:end:prove_note_not_nullified } else { // Note was not found so we will use the spare nullifier + // docs:start:prove_nullifier_non_inclusion prove_nullifier_non_inclusion(spare_nullifier, block_number, context); + // docs:end:prove_nullifier_non_inclusion }; } @@ -164,9 +176,12 @@ contract InclusionProofs { let note = notes[0].unwrap(); // 2) Prove the note validity - prove_note_validity(ValueNoteMethods, note, block_number, context); + // docs:start:prove_note_validity + prove_note_validity(ValueNoteMethods, note, block_number, &mut context); + // docs:end:prove_note_validity } + // docs:start:nullify_note #[aztec(private)] fn nullify_note(owner: AztecAddress) { let private_values = storage.private_values.at(owner); @@ -176,6 +191,7 @@ contract InclusionProofs { private_values.remove(note); } + // docs:end:nullify_note // Proves nullifier existed at block `block_number`. // Note: I am not getting a nullifier of the note that was created in this contract in this function because it is @@ -185,7 +201,9 @@ contract InclusionProofs { nullifier: Field, block_number: u32 // The block at which we'll prove that the nullifier not exists in the tree ) { + // docs:start:prove_nullifier_inclusion prove_nullifier_inclusion(nullifier, block_number, context); + // docs:end:prove_nullifier_inclusion } #[aztec(private)] diff --git a/yarn-project/noir-contracts/contracts/schnorr_account_contract/src/main.nr b/yarn-project/noir-contracts/contracts/schnorr_account_contract/src/main.nr index 77203a70388a..001437e9c9df 100644 --- a/yarn-project/noir-contracts/contracts/schnorr_account_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/schnorr_account_contract/src/main.nr @@ -46,7 +46,7 @@ contract SchnorrAccount { let this = context.this_address(); // docs:start:initialize let mut pub_key_note = PublicKeyNote::new(signing_pub_key_x, signing_pub_key_y, this); - storage.signing_public_key.initialize(&mut pub_key_note, Option::none(), true); + storage.signing_public_key.initialize(&mut pub_key_note, true); // docs:end:initialize } diff --git a/yarn-project/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr b/yarn-project/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr index 3d3eb1ecfa1a..2db16db6be3b 100644 --- a/yarn-project/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr +++ b/yarn-project/noir-contracts/contracts/schnorr_account_contract/src/public_key_note.nr @@ -6,7 +6,7 @@ use dep::aztec::{ }, hash::pedersen_hash, oracle::{ - get_secret_key::get_secret_key, + nullifier_key::get_nullifier_secret_key, get_public_key::get_public_key, }, log::emit_encrypted_log, @@ -40,9 +40,20 @@ impl PublicKeyNote { [self.x, self.y, self.owner.to_field()] } - pub fn compute_nullifier(self) -> Field { + pub fn compute_nullifier(self, context: &mut PrivateContext) -> Field { let unique_siloed_note_hash = compute_unique_siloed_note_hash(PublicKeyNoteMethods, self); - let secret = get_secret_key(self.owner); + let secret = context.request_nullifier_secret_key(self.owner); + // TODO(#1205) Should use a non-zero generator index. + pedersen_hash([ + unique_siloed_note_hash, + secret.low, + secret.high, + ],0) + } + + pub fn compute_nullifier_without_context(self) -> Field { + let unique_siloed_note_hash = compute_unique_siloed_note_hash(PublicKeyNoteMethods, self); + let secret = get_nullifier_secret_key(self.owner); // TODO(#1205) Should use a non-zero generator index. pedersen_hash([ unique_siloed_note_hash, @@ -86,8 +97,12 @@ fn compute_note_hash(note: PublicKeyNote) -> Field { pedersen_hash(note.serialize(), 0) } -fn compute_nullifier(note: PublicKeyNote) -> Field { - note.compute_nullifier() +fn compute_nullifier(note: PublicKeyNote, context: &mut PrivateContext) -> Field { + note.compute_nullifier(context) +} + +fn compute_nullifier_without_context(note: PublicKeyNote) -> Field { + note.compute_nullifier_without_context() } fn get_header(note: PublicKeyNote) -> NoteHeader { @@ -108,6 +123,7 @@ global PublicKeyNoteMethods = NoteInterface { serialize, compute_note_hash, compute_nullifier, + compute_nullifier_without_context, get_header, set_header, broadcast, diff --git a/yarn-project/noir-contracts/contracts/test_contract/src/main.nr b/yarn-project/noir-contracts/contracts/test_contract/src/main.nr index aac608c1bd82..6402ec444e81 100644 --- a/yarn-project/noir-contracts/contracts/test_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/test_contract/src/main.nr @@ -193,7 +193,7 @@ contract Test { #[aztec(private)] fn set_constant(value: Field) { let mut note = FieldNote::new(value); - storage.example_constant.initialize(&mut note, Option::none(), false); + storage.example_constant.initialize(&mut note, false); } unconstrained fn get_constant() -> pub Field { diff --git a/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/main.nr b/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/main.nr index 0845c0ec0daa..46ff827b00c9 100644 --- a/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/main.nr @@ -110,7 +110,7 @@ contract TokenBlacklist { #[aztec(private)] fn constructor(admin: AztecAddress, slow_updates_contract: AztecAddress) { let mut slow_note = FieldNote::new(slow_updates_contract.to_field()); - storage.slow_update.initialize(&mut slow_note, Option::none(), false); + storage.slow_update.initialize(&mut slow_note, false); // docs:end:constructor let selector = FunctionSelector::from_signature("_initialize((Field),(Field))"); context.call_public_function( diff --git a/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/balance_set.nr b/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/balance_set.nr index f0ecb0797296..e63efeab3064 100644 --- a/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/balance_set.nr +++ b/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/balance_set.nr @@ -16,12 +16,6 @@ use dep::aztec::note::{ note_interface::NoteInterface, utils::compute_note_hash_for_read_or_nullify, }; -use dep::aztec::oracle::{ - rand::rand, - get_secret_key::get_secret_key, - get_public_key::get_public_key, -}; - use crate::types::token_note::{TokenNote, TOKEN_NOTE_LEN, TokenNoteMethods}; // A set implementing standard manipulation of balances. diff --git a/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr b/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr index 8a2275361911..41e921d16d0c 100644 --- a/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr +++ b/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/token_note.nr @@ -13,7 +13,7 @@ use dep::aztec::{ }; use dep::aztec::oracle::{ rand::rand, - get_secret_key::get_secret_key, + nullifier_key::get_nullifier_secret_key, get_public_key::get_public_key, }; use dep::safe_math::SafeU120; @@ -68,9 +68,9 @@ impl TokenNote { } // docs:start:nullifier - pub fn compute_nullifier(self) -> Field { + pub fn compute_nullifier(self, context: &mut PrivateContext) -> Field { let note_hash_for_nullify = compute_note_hash_for_read_or_nullify(TokenNoteMethods, self); - let secret = get_secret_key(self.owner); + let secret = context.request_nullifier_secret_key(self.owner); // TODO(#1205) Should use a non-zero generator index. pedersen_hash([ note_hash_for_nullify, @@ -80,6 +80,17 @@ impl TokenNote { } // docs:end:nullifier + pub fn compute_nullifier_without_context(self) -> Field { + let note_hash_for_nullify = compute_note_hash_for_read_or_nullify(TokenNoteMethods, self); + let secret = get_nullifier_secret_key(self.owner); + // TODO(#1205) Should use a non-zero generator index. + pedersen_hash([ + note_hash_for_nullify, + secret.low, + secret.high, + ],0) + } + pub fn set_header(&mut self, header: NoteHeader) { self.header = header; } @@ -112,8 +123,12 @@ fn compute_note_hash(note: TokenNote) -> Field { note.compute_note_hash() } -fn compute_nullifier(note: TokenNote) -> Field { - note.compute_nullifier() +fn compute_nullifier(note: TokenNote, context: &mut PrivateContext) -> Field { + note.compute_nullifier(context) +} + +fn compute_nullifier_without_context(note: TokenNote) -> Field { + note.compute_nullifier_without_context() } fn get_header(note: TokenNote) -> NoteHeader { @@ -134,6 +149,7 @@ global TokenNoteMethods = NoteInterface { serialize, compute_note_hash, compute_nullifier, + compute_nullifier_without_context, get_header, set_header, broadcast, diff --git a/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr b/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr index 12772aed42fe..98867d1225cc 100644 --- a/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr +++ b/yarn-project/noir-contracts/contracts/token_blacklist_contract/src/types/transparent_note.nr @@ -70,7 +70,11 @@ impl TransparentNote { ],0) } - pub fn compute_nullifier(self) -> Field { + pub fn compute_nullifier(self, _context: &mut PrivateContext) -> Field { + self.compute_nullifier_without_context() + } + + pub fn compute_nullifier_without_context(self) -> Field { // TODO(#1386): should use `compute_note_hash_for_read_or_nullify` once public functions inject nonce! let siloed_note_hash = compute_siloed_note_hash(TransparentNoteMethods, self); // TODO(#1205) Should use a non-zero generator index. @@ -102,8 +106,12 @@ fn compute_note_hash(note: TransparentNote) -> Field { note.compute_note_hash() } -fn compute_nullifier(note: TransparentNote) -> Field { - note.compute_nullifier() +fn compute_nullifier(note: TransparentNote, context: &mut PrivateContext) -> Field { + note.compute_nullifier(context) +} + +fn compute_nullifier_without_context(note: TransparentNote) -> Field { + note.compute_nullifier_without_context() } fn get_header(note: TransparentNote) -> NoteHeader { @@ -123,6 +131,7 @@ global TransparentNoteMethods = NoteInterface { serialize, compute_note_hash, compute_nullifier, + compute_nullifier_without_context, get_header, set_header, broadcast, diff --git a/yarn-project/noir-contracts/contracts/token_contract/src/types/balance_set.nr b/yarn-project/noir-contracts/contracts/token_contract/src/types/balance_set.nr index 80b6a2ceeddd..fc2303da23b2 100644 --- a/yarn-project/noir-contracts/contracts/token_contract/src/types/balance_set.nr +++ b/yarn-project/noir-contracts/contracts/token_contract/src/types/balance_set.nr @@ -18,12 +18,6 @@ use dep::aztec::note::{ note_interface::NoteInterface, utils::compute_note_hash_for_read_or_nullify, }; -use dep::aztec::oracle::{ - rand::rand, - get_secret_key::get_secret_key, - get_public_key::get_public_key, -}; - use crate::types::token_note::{TokenNote, TOKEN_NOTE_LEN, TokenNoteMethods}; // A set implementing standard manipulation of balances. diff --git a/yarn-project/noir-contracts/contracts/token_contract/src/types/token_note.nr b/yarn-project/noir-contracts/contracts/token_contract/src/types/token_note.nr index d2d9ef68f1fb..f87ccd3cef2d 100644 --- a/yarn-project/noir-contracts/contracts/token_contract/src/types/token_note.nr +++ b/yarn-project/noir-contracts/contracts/token_contract/src/types/token_note.nr @@ -17,7 +17,7 @@ use dep::aztec::{ }; use dep::aztec::oracle::{ rand::rand, - get_secret_key::get_secret_key, + nullifier_key::get_nullifier_secret_key, get_public_key::get_public_key, }; use dep::safe_math::SafeU120; @@ -72,9 +72,9 @@ impl TokenNote { } // docs:start:nullifier - pub fn compute_nullifier(self) -> Field { + pub fn compute_nullifier(self, context: &mut PrivateContext) -> Field { let note_hash_for_nullify = compute_note_hash_for_read_or_nullify(TokenNoteMethods, self); - let secret = get_secret_key(self.owner); + let secret = context.request_nullifier_secret_key(self.owner); // TODO(#1205) Should use a non-zero generator index. pedersen_hash([ note_hash_for_nullify, @@ -84,6 +84,17 @@ impl TokenNote { } // docs:end:nullifier + pub fn compute_nullifier_without_context(self) -> Field { + let note_hash_for_nullify = compute_note_hash_for_read_or_nullify(TokenNoteMethods, self); + let secret = get_nullifier_secret_key(self.owner); + // TODO(#1205) Should use a non-zero generator index. + pedersen_hash([ + note_hash_for_nullify, + secret.low, + secret.high, + ],0) + } + pub fn set_header(&mut self, header: NoteHeader) { self.header = header; } @@ -116,8 +127,12 @@ fn compute_note_hash(note: TokenNote) -> Field { note.compute_note_hash() } -fn compute_nullifier(note: TokenNote) -> Field { - note.compute_nullifier() +fn compute_nullifier(note: TokenNote, context: &mut PrivateContext) -> Field { + note.compute_nullifier(context) +} + +fn compute_nullifier_without_context(note: TokenNote) -> Field { + note.compute_nullifier_without_context() } fn get_header(note: TokenNote) -> NoteHeader { @@ -138,6 +153,7 @@ global TokenNoteMethods = NoteInterface { serialize, compute_note_hash, compute_nullifier, + compute_nullifier_without_context, get_header, set_header, broadcast, diff --git a/yarn-project/noir-contracts/contracts/token_contract/src/types/transparent_note.nr b/yarn-project/noir-contracts/contracts/token_contract/src/types/transparent_note.nr index 034b4b3390f7..deb2bcdf6f1b 100644 --- a/yarn-project/noir-contracts/contracts/token_contract/src/types/transparent_note.nr +++ b/yarn-project/noir-contracts/contracts/token_contract/src/types/transparent_note.nr @@ -70,7 +70,11 @@ impl TransparentNote { ],0) } - pub fn compute_nullifier(self) -> Field { + pub fn compute_nullifier(self, _context: &mut PrivateContext) -> Field { + self.compute_nullifier_without_context() + } + + pub fn compute_nullifier_without_context(self) -> Field { // TODO(#1386): should use `compute_note_hash_for_read_or_nullify` once public functions inject nonce! let siloed_note_hash = compute_siloed_note_hash(TransparentNoteMethods, self); // TODO(#1205) Should use a non-zero generator index. @@ -102,8 +106,12 @@ fn compute_note_hash(note: TransparentNote) -> Field { note.compute_note_hash() } -fn compute_nullifier(note: TransparentNote) -> Field { - note.compute_nullifier() +fn compute_nullifier(note: TransparentNote, context: &mut PrivateContext) -> Field { + note.compute_nullifier(context) +} + +fn compute_nullifier_without_context(note: TransparentNote) -> Field { + note.compute_nullifier_without_context() } fn get_header(note: TransparentNote) -> NoteHeader { @@ -123,6 +131,7 @@ global TransparentNoteMethods = NoteInterface { serialize, compute_note_hash, compute_nullifier, + compute_nullifier_without_context, get_header, set_header, broadcast, diff --git a/yarn-project/noir-protocol-circuits/src/crates/types/src/constants.nr b/yarn-project/noir-protocol-circuits/src/crates/types/src/constants.nr index c0b05053066e..ae5fa0d5e191 100644 --- a/yarn-project/noir-protocol-circuits/src/crates/types/src/constants.nr +++ b/yarn-project/noir-protocol-circuits/src/crates/types/src/constants.nr @@ -86,7 +86,7 @@ global ARGS_HASH_CHUNK_COUNT: u32 = 16; // Move these constants to a noir file once the issue bellow is resolved: // https://github.com/noir-lang/noir/issues/1734 global L1_TO_L2_MESSAGE_LENGTH: Field = 8; -global L1_TO_L2_MESSAGE_ORACLE_CALL_LENGTH: Field = 26; +global L1_TO_L2_MESSAGE_ORACLE_CALL_LENGTH: Field = 25; global MAX_NOTE_FIELDS_LENGTH: Field = 20; // GET_NOTE_ORACLE_RETURN_LENGT = MAX_NOTE_FIELDS_LENGTH + 1 + 2 // The plus 1 is 1 extra field for nonce. diff --git a/yarn-project/pxe/src/simulator_oracle/index.ts b/yarn-project/pxe/src/simulator_oracle/index.ts index 1caa8fb88452..50d62d00996f 100644 --- a/yarn-project/pxe/src/simulator_oracle/index.ts +++ b/yarn-project/pxe/src/simulator_oracle/index.ts @@ -1,4 +1,4 @@ -import { DBOracle, MessageLoadOracleInputs } from '@aztec/acir-simulator'; +import { DBOracle, KeyPair, MessageLoadOracleInputs } from '@aztec/acir-simulator'; import { KeyStore, L2Block, @@ -7,16 +7,7 @@ import { PublicDataWitness, StateInfoProvider, } from '@aztec/circuit-types'; -import { - AztecAddress, - BlockHeader, - CompleteAddress, - EthAddress, - Fr, - FunctionSelector, - GrumpkinPrivateKey, - PublicKey, -} from '@aztec/circuits.js'; +import { AztecAddress, BlockHeader, CompleteAddress, EthAddress, Fr, FunctionSelector } from '@aztec/circuits.js'; import { FunctionArtifactWithDebugMetadata } from '@aztec/foundation/abi'; import { createDebugLogger } from '@aztec/foundation/log'; @@ -35,8 +26,11 @@ export class SimulatorOracle implements DBOracle { private log = createDebugLogger('aztec:pxe:simulator_oracle'), ) {} - getSecretKey(_contractAddress: AztecAddress, pubKey: PublicKey): Promise { - return this.keyStore.getAccountPrivateKey(pubKey); + async getNullifierKeyPair(accountAddress: AztecAddress, contractAddress: AztecAddress): Promise { + const accountPublicKey = (await this.db.getCompleteAddress(accountAddress))!.publicKey; + const publicKey = await this.keyStore.getNullifierPublicKey(accountPublicKey); + const secretKey = await this.keyStore.getSiloedNullifierSecretKey(accountPublicKey, contractAddress); + return { publicKey, secretKey }; } async getCompleteAddress(address: AztecAddress): Promise { diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock index 5e7bbb294741..53d6be964455 100644 --- a/yarn-project/yarn.lock +++ b/yarn-project/yarn.lock @@ -2784,7 +2784,7 @@ __metadata: resolution: "@noir-lang/backend_barretenberg@portal:../noir/packages/backend_barretenberg::locator=%40aztec%2Faztec3-packages%40workspace%3A." dependencies: "@aztec/bb.js": 0.19.0 - "@noir-lang/types": 0.22.0 + "@noir-lang/types": 0.23.0 fflate: ^0.8.0 languageName: node linkType: soft @@ -2793,9 +2793,9 @@ __metadata: version: 0.0.0-use.local resolution: "@noir-lang/noir_js@portal:../noir/packages/noir_js::locator=%40aztec%2Faztec3-packages%40workspace%3A." dependencies: - "@noir-lang/acvm_js": 0.38.0 - "@noir-lang/noirc_abi": 0.22.0 - "@noir-lang/types": 0.22.0 + "@noir-lang/acvm_js": 0.39.0 + "@noir-lang/noirc_abi": 0.23.0 + "@noir-lang/types": 0.23.0 languageName: node linkType: soft @@ -2809,7 +2809,7 @@ __metadata: version: 0.0.0-use.local resolution: "@noir-lang/types@portal:../noir/packages/types::locator=%40aztec%2Faztec3-packages%40workspace%3A." dependencies: - "@noir-lang/noirc_abi": 0.22.0 + "@noir-lang/noirc_abi": 0.23.0 languageName: node linkType: soft From 0b254233e22ddb6d65efc7f71f1817240d2b3358 Mon Sep 17 00:00:00 2001 From: josh crites Date: Wed, 24 Jan 2024 16:06:45 -0500 Subject: [PATCH 04/27] Update scalar_multiplication.test.cpp --- .../cpp/src/barretenberg/srs/scalar_multiplication.test.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/barretenberg/cpp/src/barretenberg/srs/scalar_multiplication.test.cpp b/barretenberg/cpp/src/barretenberg/srs/scalar_multiplication.test.cpp index d5c257ada4ed..53e50ecef098 100644 --- a/barretenberg/cpp/src/barretenberg/srs/scalar_multiplication.test.cpp +++ b/barretenberg/cpp/src/barretenberg/srs/scalar_multiplication.test.cpp @@ -36,7 +36,8 @@ template class ScalarMultiplicationTests : public ::testing::Te } }(); - static void read_transcript_g2(std::string const& srs_path) requires srs::HasG2 + static void read_transcript_g2(std::string const& srs_path) + requires srs::HasG2 { typename Curve::G2AffineElement g2_x; srs::IO::read_transcript_g2(g2_x, srs_path); From 64de80b814394bd5150cd3bc7f14d01d6a447951 Mon Sep 17 00:00:00 2001 From: josh crites Date: Wed, 24 Jan 2024 16:07:02 -0500 Subject: [PATCH 05/27] Update scalar_multiplication.test.cpp --- .../cpp/src/barretenberg/srs/scalar_multiplication.test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/barretenberg/cpp/src/barretenberg/srs/scalar_multiplication.test.cpp b/barretenberg/cpp/src/barretenberg/srs/scalar_multiplication.test.cpp index 53e50ecef098..9ed7c2e40484 100644 --- a/barretenberg/cpp/src/barretenberg/srs/scalar_multiplication.test.cpp +++ b/barretenberg/cpp/src/barretenberg/srs/scalar_multiplication.test.cpp @@ -36,7 +36,7 @@ template class ScalarMultiplicationTests : public ::testing::Te } }(); - static void read_transcript_g2(std::string const& srs_path) + static void read_transcript_g2(std::string const& srs_path) requires srs::HasG2 { typename Curve::G2AffineElement g2_x; From ea3917200926ede53d1c0471dad8755815946b34 Mon Sep 17 00:00:00 2001 From: josh crites Date: Wed, 24 Jan 2024 16:07:45 -0500 Subject: [PATCH 06/27] Update thread.hpp --- .../cpp/src/barretenberg/common/thread.hpp | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/common/thread.hpp b/barretenberg/cpp/src/barretenberg/common/thread.hpp index d75ae5d43897..15433b5aee63 100644 --- a/barretenberg/cpp/src/barretenberg/common/thread.hpp +++ b/barretenberg/cpp/src/barretenberg/common/thread.hpp @@ -28,19 +28,10 @@ void run_loop_in_parallel(size_t num_points, size_t no_multhreading_if_less_or_equal = 0); template -requires( - std::is_same_v> || - std::is_same_v>) void run_loop_in_parallel_if_effective_internal(size_t, - const FunctionType&, - size_t, - size_t, - size_t, - size_t, - size_t, - size_t, - size_t); + requires(std::is_same_v> || + std::is_same_v>) +void run_loop_in_parallel_if_effective_internal( + size_t, const FunctionType&, size_t, size_t, size_t, size_t, size_t, size_t, size_t); /** * @brief Runs loop in parallel if parallelization if useful (costs less than the algorith) * @@ -98,4 +89,4 @@ inline void run_loop_in_parallel_if_effective_with_index(size_t num_points, group_element_doublings_per_iteration, scalar_multiplications_per_iteration, sequential_copy_ops_per_iteration); -} \ No newline at end of file +} From de1b625b5e7565d03459e2165b163d1b3ea59b33 Mon Sep 17 00:00:00 2001 From: josh crites Date: Wed, 24 Jan 2024 16:08:50 -0500 Subject: [PATCH 07/27] Update hmac.hpp --- barretenberg/cpp/src/barretenberg/crypto/hmac/hmac.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/crypto/hmac/hmac.hpp b/barretenberg/cpp/src/barretenberg/crypto/hmac/hmac.hpp index a5d811fd21e9..655e82513749 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/hmac/hmac.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/hmac/hmac.hpp @@ -93,8 +93,8 @@ std::array hmac(const MessageContainer& message, con * @return Fr output field element as uint512_t( H(10...0 || HMAC(k,m)) || H(00...0 || HMAC(k,m)) ) % r */ template -Fr get_unbiased_field_from_hmac(const MessageContainer& message, - const KeyContainer& key) requires(Hash::OUTPUT_SIZE == 32) +Fr get_unbiased_field_from_hmac(const MessageContainer& message, const KeyContainer& key) + requires(Hash::OUTPUT_SIZE == 32) { // Strong assumption that works for now with our suite of Hashers static_assert(Hash::BLOCK_SIZE > Hash::OUTPUT_SIZE); From 7132dadd63586387e9bcd46da95477090c9b1be8 Mon Sep 17 00:00:00 2001 From: josh crites Date: Wed, 24 Jan 2024 16:09:20 -0500 Subject: [PATCH 08/27] Update affine_element.hpp --- .../cpp/src/barretenberg/ecc/groups/affine_element.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.hpp b/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.hpp index 44f29ab98a8c..117dab0ff2be 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element.hpp @@ -78,8 +78,8 @@ template class alignas(64) affine_el * @return A randomly chosen point on the curve */ static affine_element random_element(numeric::RNG* engine = nullptr) noexcept; - static constexpr affine_element hash_to_curve( - const std::vector& seed, uint8_t attempt_count = 0) noexcept requires SupportsHashToCurve; + static constexpr affine_element hash_to_curve(const std::vector& seed, uint8_t attempt_count = 0) noexcept + requires SupportsHashToCurve; constexpr bool operator==(const affine_element& other) const noexcept; From 56da56217caa3e0f6d732e17fef34cb17e146ca3 Mon Sep 17 00:00:00 2001 From: josh crites Date: Wed, 24 Jan 2024 16:09:53 -0500 Subject: [PATCH 09/27] Update affine_element_impl.hpp --- .../cpp/src/barretenberg/ecc/groups/affine_element_impl.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element_impl.hpp b/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element_impl.hpp index 9a87eee6f119..f2ec2c908965 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element_impl.hpp @@ -221,9 +221,9 @@ constexpr std::optional> affine_element::de * @return constexpr affine_element */ template -constexpr affine_element affine_element::hash_to_curve( - const std::vector& seed, uint8_t attempt_count) noexcept requires SupportsHashToCurve - +constexpr affine_element affine_element::hash_to_curve(const std::vector& seed, + uint8_t attempt_count) noexcept + requires SupportsHashToCurve { std::vector target_seed(seed); // expand by 2 bytes to cover incremental hash attempts From e6efe0325cce8bd640fc2bd3800291df3e65c935 Mon Sep 17 00:00:00 2001 From: josh crites Date: Wed, 24 Jan 2024 16:10:12 -0500 Subject: [PATCH 10/27] Update affine_element_impl.hpp --- .../cpp/src/barretenberg/ecc/groups/affine_element_impl.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element_impl.hpp b/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element_impl.hpp index f2ec2c908965..a227ba273125 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element_impl.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/groups/affine_element_impl.hpp @@ -224,6 +224,7 @@ template constexpr affine_element affine_element::hash_to_curve(const std::vector& seed, uint8_t attempt_count) noexcept requires SupportsHashToCurve + { std::vector target_seed(seed); // expand by 2 bytes to cover incremental hash attempts From 17059a3ed18aa30bb5d2a6da40a89eed30cfc6fd Mon Sep 17 00:00:00 2001 From: josh crites Date: Wed, 24 Jan 2024 16:11:13 -0500 Subject: [PATCH 11/27] Update polynomial.hpp --- .../barretenberg/polynomials/polynomial.hpp | 42 +++++++++++-------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/polynomials/polynomial.hpp b/barretenberg/cpp/src/barretenberg/polynomials/polynomial.hpp index d1b6112eef87..801733a96edf 100644 --- a/barretenberg/cpp/src/barretenberg/polynomials/polynomial.hpp +++ b/barretenberg/cpp/src/barretenberg/polynomials/polynomial.hpp @@ -90,26 +90,32 @@ template class Polynomial { Fr evaluate(const Fr& z, size_t target_size) const; Fr evaluate(const Fr& z) const; - Fr compute_barycentric_evaluation(const Fr& z, const EvaluationDomain& domain) requires - polynomial_arithmetic::SupportsFFT; + Fr compute_barycentric_evaluation(const Fr& z, const EvaluationDomain& domain) + requires polynomial_arithmetic::SupportsFFT; Fr evaluate_from_fft(const EvaluationDomain& large_domain, const Fr& z, - const EvaluationDomain& small_domain) requires polynomial_arithmetic::SupportsFFT; - void fft(const EvaluationDomain& domain) requires polynomial_arithmetic::SupportsFFT; - void partial_fft(const EvaluationDomain& domain, - Fr constant = 1, - bool is_coset = false) requires polynomial_arithmetic::SupportsFFT; - void coset_fft(const EvaluationDomain& domain) requires polynomial_arithmetic::SupportsFFT; - void coset_fft(const EvaluationDomain& domain, - const EvaluationDomain& large_domain, - size_t domain_extension) requires polynomial_arithmetic::SupportsFFT; - void coset_fft_with_constant(const EvaluationDomain& domain, - const Fr& constant) requires polynomial_arithmetic::SupportsFFT; - void coset_fft_with_generator_shift(const EvaluationDomain& domain, - const Fr& constant) requires polynomial_arithmetic::SupportsFFT; - void ifft(const EvaluationDomain& domain) requires polynomial_arithmetic::SupportsFFT; - void ifft_with_constant(const EvaluationDomain& domain, - const Fr& constant) requires polynomial_arithmetic::SupportsFFT; + const EvaluationDomain& small_domain) + requires polynomial_arithmetic::SupportsFFT; + void fft(const EvaluationDomain& domain) + requires polynomial_arithmetic::SupportsFFT; + void partial_fft(const EvaluationDomain& domain, Fr constant = 1, bool is_coset = false) + requires polynomial_arithmetic::SupportsFFT; + void coset_fft(const EvaluationDomain& domain) + requires polynomial_arithmetic::SupportsFFT; + size_t domain_extension) + requires polynomial_arithmetic::SupportsFFT; + void coset_fft_with_constant(const EvaluationDomain& domain, const Fr& constant) + requires polynomial_arithmetic::SupportsFFT; + void coset_fft_with_generator_shift(const EvaluationDomain& domain, const Fr& constant) + requires polynomial_arithmetic::SupportsFFT; + void ifft(const EvaluationDomain& domain) + requires polynomial_arithmetic::SupportsFFT; + void ifft_with_constant(const EvaluationDomain& domain, const Fr& constant) + requires polynomial_arithmetic::SupportsFFT; + void coset_ifft(const EvaluationDomain& domain) + requires polynomial_arithmetic::SupportsFFT; + Fr compute_kate_opening_coefficients(const Fr& z) + requires polynomial_arithmetic::SupportsFFT; void coset_ifft(const EvaluationDomain& domain) requires polynomial_arithmetic::SupportsFFT; Fr compute_kate_opening_coefficients(const Fr& z) requires polynomial_arithmetic::SupportsFFT; From b6b843b8227a6162874adde66d65b63c34bc4626 Mon Sep 17 00:00:00 2001 From: josh crites Date: Wed, 24 Jan 2024 16:12:31 -0500 Subject: [PATCH 12/27] Update polynomial.hpp --- .../cpp/src/barretenberg/polynomials/polynomial.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/polynomials/polynomial.hpp b/barretenberg/cpp/src/barretenberg/polynomials/polynomial.hpp index 801733a96edf..30fed45f9d6e 100644 --- a/barretenberg/cpp/src/barretenberg/polynomials/polynomial.hpp +++ b/barretenberg/cpp/src/barretenberg/polynomials/polynomial.hpp @@ -90,7 +90,7 @@ template class Polynomial { Fr evaluate(const Fr& z, size_t target_size) const; Fr evaluate(const Fr& z) const; - Fr compute_barycentric_evaluation(const Fr& z, const EvaluationDomain& domain) + Fr compute_barycentric_evaluation(const Fr& z, const EvaluationDomain& domain) requires polynomial_arithmetic::SupportsFFT; Fr evaluate_from_fft(const EvaluationDomain& large_domain, const Fr& z, @@ -102,6 +102,8 @@ template class Polynomial { requires polynomial_arithmetic::SupportsFFT; void coset_fft(const EvaluationDomain& domain) requires polynomial_arithmetic::SupportsFFT; + void coset_fft(const EvaluationDomain& domain, + const EvaluationDomain& large_domain, size_t domain_extension) requires polynomial_arithmetic::SupportsFFT; void coset_fft_with_constant(const EvaluationDomain& domain, const Fr& constant) @@ -114,8 +116,6 @@ template class Polynomial { requires polynomial_arithmetic::SupportsFFT; void coset_ifft(const EvaluationDomain& domain) requires polynomial_arithmetic::SupportsFFT; - Fr compute_kate_opening_coefficients(const Fr& z) - requires polynomial_arithmetic::SupportsFFT; void coset_ifft(const EvaluationDomain& domain) requires polynomial_arithmetic::SupportsFFT; Fr compute_kate_opening_coefficients(const Fr& z) requires polynomial_arithmetic::SupportsFFT; From e1e7c1e1bfb289da5ac4669845c420513d5009bc Mon Sep 17 00:00:00 2001 From: josh crites Date: Wed, 24 Jan 2024 16:14:23 -0500 Subject: [PATCH 13/27] Update polynomial.hpp --- barretenberg/cpp/src/barretenberg/polynomials/polynomial.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/polynomials/polynomial.hpp b/barretenberg/cpp/src/barretenberg/polynomials/polynomial.hpp index 30fed45f9d6e..305585773e4e 100644 --- a/barretenberg/cpp/src/barretenberg/polynomials/polynomial.hpp +++ b/barretenberg/cpp/src/barretenberg/polynomials/polynomial.hpp @@ -116,8 +116,8 @@ template class Polynomial { requires polynomial_arithmetic::SupportsFFT; void coset_ifft(const EvaluationDomain& domain) requires polynomial_arithmetic::SupportsFFT; - void coset_ifft(const EvaluationDomain& domain) requires polynomial_arithmetic::SupportsFFT; - Fr compute_kate_opening_coefficients(const Fr& z) requires polynomial_arithmetic::SupportsFFT; + Fr compute_kate_opening_coefficients(const Fr& z) + requires polynomial_arithmetic::SupportsFFT; bool is_empty() const { return size_ == 0; } From 1f7ae0febb719699d1c9ac4e1bef952668ced24f Mon Sep 17 00:00:00 2001 From: josh crites Date: Wed, 24 Jan 2024 16:14:51 -0500 Subject: [PATCH 14/27] Update thread.hpp From a322930802400b291f5f72e4d3104e20d345afce Mon Sep 17 00:00:00 2001 From: josh crites Date: Wed, 24 Jan 2024 16:15:18 -0500 Subject: [PATCH 15/27] Update thread.hpp From 96546ce1827d06f416cdb670b74bc89082afbce4 Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Wed, 24 Jan 2024 16:16:41 -0500 Subject: [PATCH 16/27] remove last line --- .../cpp/src/barretenberg/common/thread.hpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/common/thread.hpp b/barretenberg/cpp/src/barretenberg/common/thread.hpp index 15433b5aee63..d75ae5d43897 100644 --- a/barretenberg/cpp/src/barretenberg/common/thread.hpp +++ b/barretenberg/cpp/src/barretenberg/common/thread.hpp @@ -28,10 +28,19 @@ void run_loop_in_parallel(size_t num_points, size_t no_multhreading_if_less_or_equal = 0); template - requires(std::is_same_v> || - std::is_same_v>) -void run_loop_in_parallel_if_effective_internal( - size_t, const FunctionType&, size_t, size_t, size_t, size_t, size_t, size_t, size_t); +requires( + std::is_same_v> || + std::is_same_v>) void run_loop_in_parallel_if_effective_internal(size_t, + const FunctionType&, + size_t, + size_t, + size_t, + size_t, + size_t, + size_t, + size_t); /** * @brief Runs loop in parallel if parallelization if useful (costs less than the algorith) * @@ -89,4 +98,4 @@ inline void run_loop_in_parallel_if_effective_with_index(size_t num_points, group_element_doublings_per_iteration, scalar_multiplications_per_iteration, sequential_copy_ops_per_iteration); -} +} \ No newline at end of file From ed3fd243bf170372c80aac94a68bab3c1e55ecff Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Wed, 24 Jan 2024 16:17:41 -0500 Subject: [PATCH 17/27] undo fmt From 8ba302cbbff548424ffe7dd21543dd40ce172d17 Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Wed, 24 Jan 2024 16:19:05 -0500 Subject: [PATCH 18/27] undo fmt From e496064fb9a6a499b8ea13f38e0a6a3c69594db9 Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Wed, 24 Jan 2024 16:20:02 -0500 Subject: [PATCH 19/27] undo fmt From 968b21468f780d665baab36ad1555a9dfe8913ea Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Wed, 24 Jan 2024 16:20:39 -0500 Subject: [PATCH 20/27] undo fmt From 86f11cc1c40488cbd8c01aaf357bd14e9c900cda Mon Sep 17 00:00:00 2001 From: josh crites Date: Wed, 24 Jan 2024 16:21:25 -0500 Subject: [PATCH 21/27] Update thread.hpp --- .../cpp/src/barretenberg/common/thread.hpp | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/common/thread.hpp b/barretenberg/cpp/src/barretenberg/common/thread.hpp index d75ae5d43897..15433b5aee63 100644 --- a/barretenberg/cpp/src/barretenberg/common/thread.hpp +++ b/barretenberg/cpp/src/barretenberg/common/thread.hpp @@ -28,19 +28,10 @@ void run_loop_in_parallel(size_t num_points, size_t no_multhreading_if_less_or_equal = 0); template -requires( - std::is_same_v> || - std::is_same_v>) void run_loop_in_parallel_if_effective_internal(size_t, - const FunctionType&, - size_t, - size_t, - size_t, - size_t, - size_t, - size_t, - size_t); + requires(std::is_same_v> || + std::is_same_v>) +void run_loop_in_parallel_if_effective_internal( + size_t, const FunctionType&, size_t, size_t, size_t, size_t, size_t, size_t, size_t); /** * @brief Runs loop in parallel if parallelization if useful (costs less than the algorith) * @@ -98,4 +89,4 @@ inline void run_loop_in_parallel_if_effective_with_index(size_t num_points, group_element_doublings_per_iteration, scalar_multiplications_per_iteration, sequential_copy_ops_per_iteration); -} \ No newline at end of file +} From c0d3cd601415bd40e862b29b6743ad2e829a7f99 Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Wed, 24 Jan 2024 16:32:42 -0500 Subject: [PATCH 22/27] update public state --- .../dev_docs/contracts/syntax/storage/main.md | 2 +- .../contracts/syntax/storage/public_state.md | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/docs/dev_docs/contracts/syntax/storage/main.md b/docs/docs/dev_docs/contracts/syntax/storage/main.md index bed2a65fe384..89b61684fbb0 100644 --- a/docs/docs/dev_docs/contracts/syntax/storage/main.md +++ b/docs/docs/dev_docs/contracts/syntax/storage/main.md @@ -10,7 +10,7 @@ These state variables come in two forms: public and private. Public variables ar Aztec.nr has a few abstractions to help define the type of data your contract holds. These include Singletons, ImmutableSingletons, Set, and Map. -On this page, you’ll learn: +On this and the following pages in this section, you’ll learn: - How to manage a smart contract's storage structure - The distinctions and applications of public and private state variables diff --git a/docs/docs/dev_docs/contracts/syntax/storage/public_state.md b/docs/docs/dev_docs/contracts/syntax/storage/public_state.md index e603cef5e42a..5ef81e3b44fc 100644 --- a/docs/docs/dev_docs/contracts/syntax/storage/public_state.md +++ b/docs/docs/dev_docs/contracts/syntax/storage/public_state.md @@ -2,6 +2,12 @@ title: Public State --- +On this page we will look at how to manage public state in Aztec contracts. We will look at how to declare public state, how to read and write to it, and how to use it in your contracts. + +For a higher level overview of the state model in Aztec, see the [state model](../../../../concepts/foundation/state_model/main.md) page, or jump back to the previous page on [Storage](./main.md). + +## Overview + The `PublicState` struct is generic over the variable type `T` and its serialized size `T_SERIALIZED_LEN`. :::info @@ -10,23 +16,17 @@ Currently, the length of the types must be specified when declaring the storage The struct contains a `storage_slot` which, similar to Ethereum, is used to figure out _where_ in storage the variable is located. Notice that while we don't have the exact same [state model](../../../../concepts/foundation/state_model/main.md) as EVM chains it will look similar from the contract developers point of view. -Beyond the struct, the `PublicState` also contains `serialization_methods`, which is a struct with methods that instruct the `PublicState` how to serialize and deserialize the variable. You can find the details of `PublicState` in the implementation [here](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/aztec-nr/aztec/src/state_vars/public_state.nr). - -:::info -The British haven't surrendered fully to US spelling, so serialization is currently inconsistent. -::: +Beyond the struct, the `PublicState` also contains `serialization_methods`, which is a struct with methods that instruct the `PublicState` how to serialize and deserialize the variable. You can find the details of `PublicState` in the implementation [here](https://github.com/AztecProtocol/aztec-packages/blob/#include_aztec_version/yarn-project/aztec-nr/aztec/src/state_vars/public_state.nr). The Aztec.nr library provides serialization methods for various common types. :::info -An example using a larger struct can be found in the [lending example](https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/noir-contracts/contracts/lending_contract)'s use of an [`Asset`](https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/noir-contracts/contracts/lending_contract/src/asset.nr). +An example using a larger struct can be found in the [lending example](https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/noir-contracts/contracts/lending_contract)'s use of an [`Asset`](https://github.com/AztecProtocol/aztec-packages/tree/#include_aztec_version/yarn-project/noir-contracts/contracts/lending_contract/src/asset.nr). ::: ### `new` -When declaring the storage for `T` as a persistent public storage variable, we use the `PublicState::new()` constructor. As seen below, this takes the `storage_slot` and the `serialization_methods` as arguments along with the [`Context`](../context.mdx), which in this case is used to share interface with other structures. - -#include_code public_state_struct_new /yarn-project/aztec-nr/aztec/src/state_vars/public_state.nr rust +When declaring the storage for `T` as a persistent public storage variable, we use the `PublicState::new()` constructor. As seen below, this takes the `storage_slot` and the `serialization_methods` as arguments along with the [`Context`](../context.mdx), which in this case is used to share interface with other structures. You can view the implementation [here](https://github.com/AztecProtocol/aztec-packages/blob/#include_aztec_version/yarn-project/aztec-nr/aztec/src/state_vars/public_state.nr). #### Single value example From abd7796831321f396ee5ee9ae909e802015c4885 Mon Sep 17 00:00:00 2001 From: Josh Crites Date: Wed, 24 Jan 2024 20:21:57 -0500 Subject: [PATCH 23/27] update private state docs --- .../contracts/syntax/storage/private_state.md | 72 +++++++++++-------- .../docs_example_contract/src/main.nr | 2 + 2 files changed, 45 insertions(+), 29 deletions(-) diff --git a/docs/docs/dev_docs/contracts/syntax/storage/private_state.md b/docs/docs/dev_docs/contracts/syntax/storage/private_state.md index 8b38bb0a3657..c663f7c187f5 100644 --- a/docs/docs/dev_docs/contracts/syntax/storage/private_state.md +++ b/docs/docs/dev_docs/contracts/syntax/storage/private_state.md @@ -2,11 +2,17 @@ title: Private State --- +On this page we will look at how to manage private state in Aztec contracts. We will look at how to declare private state, how to read and write to it, and how to use it in your contracts. + +For a higher level overview of the state model in Aztec, see the [state model](../../../../concepts/foundation/state_model/main.md) page, or jump back to the previous page on [Storage](./main.md). + +## Overview + In contrast to public state, private state is persistent state that is **not** visible to the whole world. Depending on the logic of the smart contract, a private state variable's current value will only be known to one entity, or a closed group of entities. The value of a private state variable can either be shared via an [encrypted log](../events.md#encrypted-events), or offchain via web2, or completely offline: it's up to the app developer. -Aztec private state follows a utxo-based model. That is, a private state's current value is represented as one or many [notes](#notes). Each note is stored as an individual leaf in a utxo-based merkle tree: the [private state tree](../../../../concepts/foundation/state_model/main.md). +Aztec private state follows a [utxo](https://en.wikipedia.org/wiki/Unspent_transaction_output)-based model. That is, a private state's current value is represented as one or many [notes](#notes). Each note is stored as an individual leaf in a utxo-based merkle tree: the [private state tree](../../../../concepts/advanced/data_structures/trees.md). To greatly simplify the experience of writing private state, Aztec.nr provides three different types of private state variable: @@ -34,21 +40,25 @@ The interplay between a private state variable and its notes can be confusing. H A private state variable (of type `Singleton`, `ImmutableSingleton` or `Set`) may be declared in storage. -Every note contains (as a 'header') the contract address and storage slot of the state variable to which it "belongs". A note is said to "belong" to a private state if the storage slot of the private state matches the storage slot contained in the note's header. The header provides information that helps the user interpret the note's data. Without it the user would have to figure out where it belongs by brute-forcing the address and contract space. +Every note contains a header, which contains the contract address and storage slot of the state variable to which it is associated. A note is associated with a private state variable if the storage slot of the private state variable matches the storage slot contained in the note's header. The header provides information that helps the user interpret the note's data. -Management of this 'header' is abstracted-away from developers who use the `ImmutableSingleton`, `Singleton` and `Set` types. +Management of the header is abstracted-away from developers who use the `ImmutableSingleton`, `Singleton` and `Set` types. -A private state variable is colloquially said to "point" to one or many notes (depending on the type), if those note(s) all "belong" to that private state, and those note(s) haven't-yet been nullified. +A private state variable points to one or many notes (depending on the type). The note(s) are all valid private state if the note(s) haven't yet been nullified. -An `ImmutableSingleton` will point to _one_ note over the lifetime of the contract. ("One", hence "Singleton"). This note is a struct of information that is persisted forever. +An `ImmutableSingleton` will point to _one_ note over the lifetime of the contract. This note is a struct of information that is persisted forever. -A `Singleton` may point to _one_ note at a time. ("One", hence "Singleton"). But since it's not "immutable", the note that it points to may be [replaced](#replace) by functions of the contract, over time. The "current value" of a `Singleton` is interpreted as the one note which has not-yet been nullified. The act of 'replacing' a Singleton's note is how a `Singleton` state may be modified by functions. +A `Singleton` may point to _one_ note at a time. But since it's not "immutable", the note that it points to may be [replaced](#replace) by functions of the contract. The current value of a `Singleton` is interpreted as the one note which has not-yet been nullified. The act of replacing a Singleton's note is how a `Singleton` state may be modified by functions. -`Singleton` is a useful type when declaring a private state which may only ever be modified by those who are privy to the current value of that state. +`Singleton` is a useful type when declaring a private state variable which may only ever be modified by those who are privy to the current value of that state. -A `Set` may point to _multiple_ notes at a time. The "current value" of a private state variable of type `Set` is some 'accumulation' of all not-yet nullified notes which "belong" to the `Set`. The term "some accumulation" is intentionally vague. The interpretation of the "current value" of a `Set` must be expressed by the smart contract developer. A common use case for a `Set` is to represent the sum of a collection of values (in which case 'accumulation' is 'summation'). +A `Set` may point to _multiple_ notes at a time. The "current value" of a private state variable of type `Set` is some accumulation of all not-yet nullified notes which belong to the `Set`. + +:::note +The term "some accumulation" is intentionally vague. The interpretation of the "current value" of a `Set` must be expressed by the smart contract developer. A common use case for a `Set` is to represent the sum of a collection of values (in which case 'accumulation' is 'summation'). Think of a ZCash balance (or even a Bitcoin balance). The "current value" of a user's ZCash balance is the sum of all unspent (not-yet nullified) notes belonging to that user. To modify the "current value" of a `Set` state variable, is to [`insert`](#insert) new notes into the `Set`, or [`remove`](#remove) notes from that set. +::: Interestingly, if a developer requires a private state to be modifiable by users who _aren't_ privy to the value of that state, a `Set` is a very useful type. The `insert` method allows new notes to be added to the `Set` without knowing any of the other notes in the set! (Like posting an envelope into a post box, you don't know what else is in there!). @@ -75,7 +85,9 @@ As mentioned, the Singleton is initialized to create the first note and value. When this function is called, a nullifier of the storage slot is created, preventing this Singleton from being initialized again. :::danger Privacy-Leak -Beware that because this nullifier is created only from the storage slot without randomness it is "leaky". This means that if the storage slot depends on the an address then it is possible to link the nullifier to the address. For example, if the singleton is part of a `map` with an `AztecAddress` as the key then the nullifier will be linked to the address. +Beware that because this nullifier is created only from the storage slot without randomness it leaks privacy. This means that it is possible for an external observer to determine when the note is nullified. + +For example, if the storage slot depends on the an address then it is possible to link the nullifier to the address. If the singleton is part of a `map` with an `AztecAddress` as the key then the nullifier will be linked to the address. ::: Unlike public states, which have a default initial value of `0` (or many zeros, in the case of a struct, array or map), a private state (of type `Singleton`, `ImmutableSingleton` or `Set`) does not have a default initial value. The `initialize` method (or `insert`, in the case of a `Set`) must be called. @@ -86,7 +98,9 @@ Extend on what happens if you try to use non-initialized state. ### `is_initialized` -An unconstrained method to check whether the Singleton has been initialized or not. It takes an optional owner and returns a boolean. You can view the implementation [here](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/aztec-nr/aztec/src/state_vars/singleton.nr). +An unconstrained method to check whether the Singleton has been initialized or not. It takes an optional owner and returns a boolean. You can view the implementation [here](https://github.com/AztecProtocol/aztec-packages/blob/#include_aztec_version/yarn-project/aztec-nr/aztec/src/state_vars/singleton.nr). + +#include_code singleton_is_initialized /yarn-project/noir-contracts/contracts/docs_example_contract/src/main.nr rust ### `replace` @@ -106,7 +120,9 @@ This function allows us to get the note of a Singleton, essentially reading the #### Nullifying Note reads -It's possible that at the time this function is called, the system hasn't synced to the block where the latest note was created. Or a malicious user might feed an old state to this function, tricking the proving system into thinking that the value hasn't changed. To avoid an attack around it, this function will destroy the current note, and replace it with a duplicated note that has the same fields. Because the nullifier of the latest note will be emitted, if two people are trying to use this function against the same note, only one will succeed (no duplicate nullifiers allowed). +To ensure that a user's private execution always uses the latest value of a Singleton, the `get_note` function will nullify the note that it is reading. This means that if two people are trying to use this function with the same note, only one will succeed (no duplicate nullifiers allowed). + +This also makes read operations indistinguishable from write operations and allows the sequencer to verifying correct execution without learning anything about the value of the note. ### `view_note` @@ -114,9 +130,7 @@ Functionally similar to [`get_note`](#get_note), but executed in unconstrained f ## `ImmutableSingleton` -ImmutableSingleton represents a unique private state variable that, as the name suggests, is immutable. Once initialized, its value cannot be altered. - -#include_code struct /yarn-project/aztec-nr/aztec/src/state_vars/immutable_singleton.nr rust +`ImmutableSingleton` represents a unique private state variable that, as the name suggests, is immutable. Once initialized, its value cannot be altered. You can view the implementation [here](https://github.com/AztecProtocol/aztec-packages/blob/#include_aztec_version/yarn-project/aztec-nr/aztec/src/state_vars/immutable_singleton.nr). ### `new` @@ -129,7 +143,9 @@ As part of the initialization of the `Storage` struct, the `Singleton` is create When this function is invoked, it creates a nullifier for the storage slot, ensuring that the ImmutableSingleton cannot be initialized again. :::danger Privacy-Leak -Beware that because this nullifier is created only from the storage slot without randomness it is "leaky". This means that if the storage slot depends on the an address then it is possible to link the nullifier to the address. For example, if the singleton is part of a `map` with an `AztecAddress` as the key then the nullifier will be linked to the address. +Beware that because this nullifier is created only from the storage slot without randomness it leaks privacy. This means that it is possible for an external observer to determine when the note is nullified. + +For example, if the storage slot depends on the an address then it is possible to link the nullifier to the address. If the singleton is part of a `map` with an `AztecAddress` as the key then the nullifier will be linked to the address. ::: Set the value of an ImmutableSingleton by calling the `initialize` method: @@ -140,7 +156,7 @@ Once initialized, an ImmutableSingleton's value remains unchangeable. This metho ### `is_initialized` -An unconstrained method to check if the ImmutableSingleton has been initialized. Takes an optional owner and returns a boolean. You can find the implementation [here](https://github.com/AztecProtocol/aztec-packages/blob/master//yarn-project/aztec-nr/aztec/src/state_vars/immutable_singleton.nr). +An unconstrained method to check if the ImmutableSingleton has been initialized. Takes an optional owner and returns a boolean. You can find the implementation [here](https://github.com/AztecProtocol/aztec-packages/blob/#include_aztec_version/yarn-project/aztec-nr/aztec/src/state_vars/immutable_singleton.nr). ### `get_note` @@ -150,9 +166,9 @@ Use this method to retrieve the value of an initialized ImmutableSingleton. #include_code get_note /yarn-project/noir-contracts/contracts/schnorr_account_contract/src/main.nr rust -Unlike a `Singleton`, the `get_note` function for an ImmutableSingleton doesn't destroy the current note in the background. This means that multiple accounts can concurrently call this function to read the value. +Unlike a `Singleton`, the `get_note` function for an ImmutableSingleton doesn't nullify the current note in the background. This means that multiple accounts can concurrently call this function to read the value. -This function will throw if the ImmutableSingleton hasn't been initialized. +This function will throw if the `ImmutableSingleton` hasn't been initialized. ### `view_note` @@ -160,9 +176,9 @@ Functionally similar to `get_note`, but executed unconstrained and can be used b ## `Set` -Set is used for managing a collection of notes. All notes in a set are of the same `NoteType`. But whether these notes all belong to one entity, or are accessible and editable by different entities, is totally up to the developer. Due to our state model, the set is a collection of notes inserted into the data-tree, but notes are never removed from the tree itself, they are only nullified. +Set is used for managing a collection of notes. All notes in a Set are of the same `NoteType`. But whether these notes all belong to one entity, or are accessible and editable by different entities, is up to the developer. The set is a collection of notes inserted into the data-tree, but notes are never removed from the tree itself, they are only nullified. -#include_code struct /yarn-project/aztec-nr/aztec/src/state_vars/set.nr rust +You can view the implementation [here](https://github.com/AztecProtocol/aztec-packages/blob/#include_aztec_version/yarn-project/aztec-nr/aztec/src/state_vars/set.nr). And can be added to the `Storage` struct as follows. Here adding a set for a custom note, the TransparentNote (useful for [public -> private communication](../functions.md#public---private)). @@ -180,17 +196,15 @@ We can initialize the set as follows: Allows us to modify the storage by inserting a note into the set. -A commitment from the note will be generated, and inserted into data-tree, allowing us to later use in contract interactions. - -A commitment from the note will be generated, and inserted into data-tree, allowing us to later use in contract interactions. Recall that the content of the note should be shared with the owner to allow them to use it, as mentioned this can be done via an [encrypted log](../events.md#encrypted-events), or offchain via web2, or completely offline. +A hash of the note will be generated, and inserted into the note hash tree, allowing us to later use in contract interactions. Recall that the content of the note should be shared with the owner to allow them to use it, as mentioned this can be done via an [encrypted log](../events.md#encrypted-events), or offchain via web2, or completely offline. #include_code insert /yarn-project/aztec-nr/easy-private-state/src/easy_private_state.nr rust ### `insert_from_public` -While we don't support private functions to directly alter public storage, the opposite direction is possible. The `insert_from_public` allow public function to insert notes into private storage. This is very useful when we want to support private function calls that must have been initiated in public, such as shielding or the like. +The `insert_from_public` allow public function to insert notes into private storage. This is very useful when we want to support private function calls that have been initiated in public, such as shielding in the [example token contract](../../../tutorials/writing_token_contract.md#shield). -The usage is rather straight-forward and very similar to using the `insert` method with the difference that this one is called in public functions. +The usage is similar to using the `insert` method with the difference that this one is called in public functions. #include_code insert_from_public /yarn-project/noir-contracts/contracts/token_contract/src/main.nr rust @@ -208,11 +222,11 @@ An example of how to use this operation is visible in the `easy_private_state`: This function returns the notes the account has access to. -The kernel circuits are constrained to a maximum number of notes this function can return at a time. Check [here](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/noir-protocol-circuits/src/crates/types/src/constants.nr) and look for `MAX_READ_REQUESTS_PER_CALL` for the up-to-date number. +The kernel circuits are constrained to a maximum number of notes this function can return at a time. Check [here](https://github.com/AztecProtocol/aztec-packages/blob/#include_aztec_version/yarn-project/noir-protocol-circuits/src/crates/types/src/constants.nr) and look for `MAX_READ_REQUESTS_PER_CALL` for the up-to-date number. Because of this limit, we should always consider using the second argument `NoteGetterOptions` to limit the number of notes we need to read and constrain in our programs. This is quite important as every extra call increases the time used to prove the program and we don't want to spend more time than necessary. -An example of such options is using the [filter_notes_min_sum](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/aztec-nr/value-note/src/filter.nr) to get "enough" notes to cover a given value. Essentially, this function will return just enough notes to cover the amount specified such that we don't need to read all our notes. For users with a lot of notes, this becomes increasingly important. +An example of such options is using the [filter_notes_min_sum](https://github.com/AztecProtocol/aztec-packages/blob/#include_aztec_version/yarn-project/aztec-nr/value-note/src/filter.nr) to get "enough" notes to cover a given value. Essentially, this function will return just enough notes to cover the amount specified such that we don't need to read all our notes. For users with a lot of notes, this becomes increasingly important. #include_code get_notes /yarn-project/aztec-nr/easy-private-state/src/easy_private_state.nr rust @@ -222,7 +236,7 @@ Functionally similar to [`get_notes`](#get_notes), but executed unconstrained an #include_code view_notes /yarn-project/aztec-nr/value-note/src/balance_utils.nr rust -There's also a limit on the maximum number of notes that can be returned in one go. To find the current limit, refer to [this file](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/noir-protocol-circuits/src/crates/types/src/constants.nr) and look for `MAX_NOTES_PER_PAGE`. +There's also a limit on the maximum number of notes that can be returned in one go. To find the current limit, refer to [this file](https://github.com/AztecProtocol/aztec-packages/blob/#include_aztec_version/yarn-project/noir-protocol-circuits/src/crates/types/src/constants.nr) and look for `MAX_NOTES_PER_PAGE`. The key distinction is that this method is unconstrained. It does not perform a check to verify if the notes actually exist, which is something the [`get_notes`](#get_notes) method does under the hood. Therefore, it should only be used in an unconstrained contract function. @@ -232,7 +246,7 @@ This function requires a `NoteViewerOptions`. The `NoteViewerOptions` is essenti `NoteGetterOptions` encapsulates a set of configurable options for filtering and retrieving a selection of notes from a [data oracle](../functions.md#oracle-functions). Developers can design instances of `NoteGetterOptions`, to determine how notes should be filtered and returned to the functions of their smart contracts. -#include_code NoteGetterOptions /yarn-project/aztec-nr/aztec/src/note/note_getter_options.nr rust +You can view the implementation [here](https://github.com/AztecProtocol/aztec-packages/blob/#include_aztec_version/yarn-project/aztec-nr/aztec/src/note/note_getter_options.nr). #### `selects: BoundedVec, N>` diff --git a/yarn-project/noir-contracts/contracts/docs_example_contract/src/main.nr b/yarn-project/noir-contracts/contracts/docs_example_contract/src/main.nr index e7c9befa319f..10cb5f3d4dd4 100644 --- a/yarn-project/noir-contracts/contracts/docs_example_contract/src/main.nr +++ b/yarn-project/noir-contracts/contracts/docs_example_contract/src/main.nr @@ -137,9 +137,11 @@ contract DocsExample { storage.legendary_card.view_note() } + // docs:start:singleton_is_initialized unconstrained fn is_legendary_initialized() -> pub bool { storage.legendary_card.is_initialized() } + // docs:end:singleton_is_initialized unconstrained fn get_imm_card() -> pub CardNote { storage.imm_singleton.view_note() From 69e9eae4c476e15a819d670178b1d02796ebe3f5 Mon Sep 17 00:00:00 2001 From: josh crites Date: Wed, 24 Jan 2024 20:24:45 -0500 Subject: [PATCH 24/27] Update thread.hpp From 24e0b01491ff4b5ccc6cadf15a321bb8023994eb Mon Sep 17 00:00:00 2001 From: josh crites Date: Wed, 24 Jan 2024 20:27:47 -0500 Subject: [PATCH 25/27] Update thread.hpp --- barretenberg/cpp/src/barretenberg/common/thread.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/barretenberg/cpp/src/barretenberg/common/thread.hpp b/barretenberg/cpp/src/barretenberg/common/thread.hpp index 15433b5aee63..32bd1b8b89ee 100644 --- a/barretenberg/cpp/src/barretenberg/common/thread.hpp +++ b/barretenberg/cpp/src/barretenberg/common/thread.hpp @@ -90,3 +90,4 @@ inline void run_loop_in_parallel_if_effective_with_index(size_t num_points, scalar_multiplications_per_iteration, sequential_copy_ops_per_iteration); } + From d9d753b172eea8b8360355148327866657e22331 Mon Sep 17 00:00:00 2001 From: josh crites Date: Wed, 24 Jan 2024 20:28:11 -0500 Subject: [PATCH 26/27] Update thread.hpp --- barretenberg/cpp/src/barretenberg/common/thread.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/barretenberg/cpp/src/barretenberg/common/thread.hpp b/barretenberg/cpp/src/barretenberg/common/thread.hpp index 32bd1b8b89ee..15433b5aee63 100644 --- a/barretenberg/cpp/src/barretenberg/common/thread.hpp +++ b/barretenberg/cpp/src/barretenberg/common/thread.hpp @@ -90,4 +90,3 @@ inline void run_loop_in_parallel_if_effective_with_index(size_t num_points, scalar_multiplications_per_iteration, sequential_copy_ops_per_iteration); } - From 525cbcacbca86897078797e5ebfc888d86af8e7c Mon Sep 17 00:00:00 2001 From: Cat McGee Date: Fri, 26 Jan 2024 10:26:41 +0900 Subject: [PATCH 27/27] fixed thread.hpp --- barretenberg/cpp/src/barretenberg/common/thread.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/barretenberg/cpp/src/barretenberg/common/thread.hpp b/barretenberg/cpp/src/barretenberg/common/thread.hpp index 15433b5aee63..c2d3ec767445 100644 --- a/barretenberg/cpp/src/barretenberg/common/thread.hpp +++ b/barretenberg/cpp/src/barretenberg/common/thread.hpp @@ -89,4 +89,4 @@ inline void run_loop_in_parallel_if_effective_with_index(size_t num_points, group_element_doublings_per_iteration, scalar_multiplications_per_iteration, sequential_copy_ops_per_iteration); -} +} \ No newline at end of file