### Verify Spartan Cluster Connectivity Source: https://github.com/aztecprotocol/aztec-packages/blob/next/spartan/README.md Confirms successful connection to the Spartan cluster by listing its services. A successful response displays a list of services with their IPs. ```bash kubectl get svc ``` -------------------------------- ### Example Spartan Cluster Service Output Source: https://github.com/aztecprotocol/aztec-packages/blob/next/spartan/README.md Illustrates the expected output when verifying connectivity to the Spartan cluster, showing a sample service and its details. ```text NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE example-service ClusterIP 10.0.0.1 80/TCP 15m ``` -------------------------------- ### Access Spartan Metrics Dashboard Source: https://github.com/aztecprotocol/aztec-packages/blob/next/spartan/metrics/README.md Execute this script from the spartan/metrics directory to forward the dashboard access. Follow the on-screen instructions. ```bash # From the spartan/metrics directory ./forward.sh ``` -------------------------------- ### Deploy Metrics to KIND Source: https://github.com/aztecprotocol/aztec-packages/blob/next/yarn-project/end-to-end/src/spartan/DEVELOP.md Deploys metrics infrastructure to the KIND cluster using the spartan bootstrap script. ```bash ./spartan/bootstrap.sh metrics-kind ``` -------------------------------- ### Update Kubeconfig for Spartan Cluster Source: https://github.com/aztecprotocol/aztec-packages/blob/next/spartan/README.md Authenticates the kubectl CLI to the Spartan cluster by creating a local kubeconfig file. Ensure AWS CLI tools and authentication are configured beforehand. ```bash aws eks update-kubeconfig --region us-east-1 --name spartan ``` -------------------------------- ### Install Spartan Metrics Chart Source: https://github.com/aztecprotocol/aztec-packages/blob/next/spartan/metrics/README.md Run this script from the spartan/metrics directory to install the monitoring chart. ```bash # From the spartan/metrics directory ./install.sh ``` -------------------------------- ### Spartan Local Kubernetes Setup Source: https://github.com/aztecprotocol/aztec-packages/blob/next/spartan/quickstart.md Run these scripts once to set up the local Kubernetes environment and install necessary components. ```bash # one time setup ./spartan/scripts/setup_local_k8s.sh ./spartan/scripts/create_k8s_dashboard.sh # Go into spartan/metrics ./install.sh # forward ports (in separate terminals) ./spartan/scripts/forward_k8s_dashboard.sh ./spartan/metrics/forward.sh # build images locally ./bootstrap.sh image-e2e ``` -------------------------------- ### Run End-to-End Tests with Spartan Source: https://github.com/aztecprotocol/aztec-packages/blob/next/spartan/quickstart.md Execute end-to-end tests using a specific Docker tag, namespace, and values file. Ensure you replace `` with the actual tag. ```bash AZTEC_DOCKER_TAG= NAMESPACE=smoke FRESH_INSTALL=true VALUES_FILE="3-validators-with-metrics.yaml" ./scripts/network_test.sh ./src/spartan/smoke.test.ts ``` -------------------------------- ### Commit to Degree Check Polynomial Source: https://github.com/aztecprotocol/aztec-packages/blob/next/barretenberg/cpp/src/barretenberg/goblin/MERGE_PROTOCOL.md Sends the commitment of the reversed batched left tables to the verifier. ```cpp transcript->send_to_verifier("REVERSED_BATCHED_LEFT_TABLES", pcs_commitment_key.commit(reversed_batched_left_tables)); ``` -------------------------------- ### Compute Degree Check Polynomial in C++ Source: https://github.com/aztecprotocol/aztec-packages/blob/next/barretenberg/cpp/src/barretenberg/goblin/MERGE_PROTOCOL.md Computes the reversed batched left table polynomial used for degree verification in the merge prover. ```cpp MergeProver::Polynomial MergeProver::compute_degree_check_polynomial( const std::array& left_table, const std::vector& degree_check_challenges) const { Polynomial reversed_batched_left_tables(fixed_append_shift_size); for (size_t idx = 0; idx < NUM_WIRES; idx++) { reversed_batched_left_tables.add_scaled(left_table[idx], degree_check_challenges[idx]); } return reversed_batched_left_tables.reverse(); } ``` -------------------------------- ### Update CheckpointParameter 'latest' to 'checkpointed' Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/developer_versioned_docs/version-v5.0.1/docs/resources/migration_notes.md The 'latest' literal is no longer supported for checkpoint lookups; use 'checkpointed' to retrieve the latest confirmed checkpoint. ```diff - await node.getCheckpoint('latest'); + await node.getCheckpoint('checkpointed'); ``` -------------------------------- ### Apply multiple selection criteria Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/developer_versioned_docs/version-v5.0.1/docs/aztec-nr/framework-description/advanced/how_to_retrieve_filter_notes.md Chain multiple select calls to filter notes by several fields simultaneously. ```rust let mut options = NoteGetterOptions::new(); options = options .select(MyNote::properties().value, Comparator.EQ, value) .select(MyNote::properties().owner, Comparator.EQ, owner); ``` -------------------------------- ### Derive Packable for notes Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/developer_versioned_docs/version-v5.0.1/docs/resources/migration_notes.md Manual implementation or derivation of the Packable trait is now required for notes. ```diff +use aztec::protocol::traits::Packable; +#[derive(Packable)] #[note] pub struct UintNote { owner: AztecAddress, randomness: Field, value: u128, } ``` -------------------------------- ### Serialize trait implementation Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/testnet/protocol_types/abis/partial_state_reference/struct.PartialStateReference.html Methods for serializing the PartialStateReference to fields or a writer. ```rust pub fn serialize(self) -> [[Field; 6] pub fn stream_serialize(self, writer: &mut Writer) ``` -------------------------------- ### Implement Packable for notes Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/docs-developers/docs/resources/migration_notes.md Notes now require manual implementation or derivation of the Packable trait. ```diff +use aztec::protocol::traits::Packable; +#[derive(Packable)] #[note] pub struct UintNote { owner: AztecAddress, randomness: Field, value: u128, } ``` ```rust impl Packable for UintNote { let N: u32 = 3; fn pack(self) -> [Field; Self::N] { [self.owner.to_field(), randomness, value as Field] } fn unpack(fields: [Field; Self::N]) -> Self { let owner = AztecAddress::from_field(fields[0]); let randomness = fields[1]; let value = fields[2] as u128; UintNote { owner, randomness, value } } } ``` -------------------------------- ### Shplonk Batched MSM Computation Source: https://github.com/aztecprotocol/aztec-packages/blob/next/barretenberg/cpp/src/barretenberg/commitment_schemes/shplonk/README.md Illustrates how the verifier computes the batched commitment [G] as a single MSM. This involves combining the quotient commitment [Q], individual polynomial commitments [f_i], and the identity commitment [1] with specific scalars. ```plaintext MSM(commitments, scalars) where: commitments = [[Q], [f_1], ..., [f_n], [1]] scalars = [ 1, s_1, ..., s_n, θ ] Where: - $ s_i = - ext{sum}_{j: f_j ext{ uses } [f_i]} rac{ u^{j-1} ext{·} a_j}{z - x_j} $ (scalar for commitment $ [f_i] $) - $ heta = ext{sum}_j rac{ u^{j-1} ext{·} v_j}{z - x_j} $ (scalar for identity $ [1] $) ``` -------------------------------- ### Finalize Folding Batch Source: https://github.com/aztecprotocol/aztec-packages/blob/next/barretenberg/cpp/src/barretenberg/chonk/README.md Reduces cached claims and the previous accumulator into a single accumulator at a common point. ```cpp auto [batch_proof, new_accumulator] = prover.finalize(previous_accumulator); ``` -------------------------------- ### Finalize game winner with finalize_game Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/developer_versioned_docs/version-v5.0.1/docs/tutorials/js_tutorials/webapp/01-the-contract.md Compares track totals to declare a winner and updates win history after the game deadline. ```rust /// Determines the winner after both players have revealed and the game has expired. #[external("public")] fn finalize_game(game_id: Field) { let game_in_progress = self.storage.races.at(game_id).read(); let winner = game_in_progress.calculate_winner(self.context.block_number()); let previous_wins = self.storage.win_history.at(winner).read(); self.storage.win_history.at(winner).write(previous_wins + 1); } ``` -------------------------------- ### Select::new Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/noir_aztec/note/note_getter_options/struct.Select.html Constructs a new Select instance. This is used to specify a condition for filtering notes based on a specific property, a comparison operator, and a value. ```APIDOC ## `Select::new` ### Description Constructs a new `Select` instance. This is used to specify a condition for filtering notes based on a specific property, a comparison operator, and a value. ### Method Signature `pub fn new(property_selector: PropertySelector, comparator: u8, value: Field) -> Self` ### Parameters * **property_selector** (`PropertySelector`) - Required - The property of the note to select. * **comparator** (`u8`) - Required - The comparison operator to use (e.g., equality, inequality). * **value** (`Field`) - Required - The value to compare against. ``` -------------------------------- ### Deserialize trait implementation Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/testnet/protocol_types/abis/partial_state_reference/struct.PartialStateReference.html Methods for deserializing the PartialStateReference from fields or a reader. ```rust pub fn deserialize(fields: [[Field; 6]) -> Self pub fn stream_deserialize(reader: &mut Reader) -> Self ``` -------------------------------- ### Game State Packable Example Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/docs-developers/docs/aztec-nr/framework-description/data_packing.md Example of a custom Packable implementation for game state, demonstrating how to pack multiple fields into a single Field element. ```rust #[derive(Debug, PartialEq, Eq, Clone, Copy)] struct GameState { turn: u8, score: u16, level: u8, active: bool, } impl Packable for GameState { // N = 1, because all fields fit into a single Field // turn: 8 bits, score: 16 bits, level: 8 bits, active: 1 bit // Total: 33 bits, well within the 253-bit safe limit of a Field fn pack(self) -> Field { (self.turn as u32 | (self.score as u32) << 8 | (self.level as u32) << (8 + 16) | (self.active as u32) << (8 + 16 + 8)) as Field } fn unpack(from: Field) -> Self { let turn = (from & 0xff) as u8; let score = ((from >> 8) & 0xffff) as u16; let level = ((from >> (8 + 16)) & 0xff) as u8; let active = ((from >> (8 + 16 + 8)) & 1) != 0; Self { turn, score, level, active } } } ``` -------------------------------- ### poseidon2_hash_with_separator_bounded_vec Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/noir_aztec/protocol/hash/index.html Computes a Poseidon2 hash with a separator for a bounded vector. ```APIDOC ## poseidon2_hash_with_separator_bounded_vec ### Description Computes a Poseidon2 hash with a separator for a bounded vector. ### Method N/A (Function call within Noir) ### Parameters * **inputs** (bounded_vec of fields) - Required - The input bounded vector of fields. * **separator** (field) - Required - The separator field. ### Response * **hash_result** (field) - The resulting Poseidon2 hash. ``` -------------------------------- ### Manually implement Packable for notes Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/developer_versioned_docs/version-v5.0.1/docs/resources/migration_notes.md Alternative to deriving Packable, you can implement the trait manually for custom note types. ```rust impl Packable for UintNote { let N: u32 = 3; fn pack(self) -> [Field; Self::N] { [self.owner.to_field(), randomness, value as Field] } fn unpack(fields: [Field; Self::N]) -> Self { let owner = AztecAddress::from_field(fields[0]); let randomness = fields[1]; let value = fields[2] as u128; UintNote { owner, randomness, value } } } ``` -------------------------------- ### Poseidon2 Hash with Separator Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/protocol_types/hash/fn.poseidon2_hash_with_separator.html Computes a Poseidon2 hash using an array of fields and a separator. The separator must implement the ToField trait. ```rust pub fn poseidon2_hash_with_separator(inputs: [Field; N], separator: T) -> Field where T: ToField ``` -------------------------------- ### poseidon2_hash_with_separator_bounded_vec Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/noir_aztec/protocol/hash/fn.poseidon2_hash_with_separator_bounded_vec.html Computes a Poseidon2 hash using a bounded vector of inputs and a separator. The function is unconstrained and generic over the number of inputs (N) and the type of the separator (T), which must implement ToField. ```APIDOC ## Function: poseidon2_hash_with_separator_bounded_vec ### Description Computes a Poseidon2 hash of a bounded vector of fields with a specified separator. This function is designed for use in unconstrained contexts within the Aztec Noir protocol. ### Signature ```rust pub unconstrained fn poseidon2_hash_with_separator_bounded_vec(inputs: BoundedVec, separator: T) -> Field where T: ToField ``` ### Parameters * **inputs** (BoundedVec): A bounded vector of `Field` elements to be hashed. The size of the vector is constrained by `N`. * **separator** (T): The separator to be used in the hashing process. The type `T` must implement the `ToField` trait, allowing it to be converted into a `Field` element. ### Returns * **Field**: The resulting hash value as a `Field` element. ``` -------------------------------- ### Implement Custom Packable for Optimized Note Storage Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/developer_versioned_docs/version-v5.0.1/docs/aztec-nr/framework-description/data_packing.md Manually implement Packable to combine multiple smaller types into a single Field, reducing the note hash input size. ```rust // A note with two u32 members. Derived Packable would give N = 2; // a custom impl halves that to N = 1, reducing note-hash inputs. #[derive(Eq)] #[note] pub struct CardNote { pub strength: u32, pub points: u32, } impl Packable for CardNote { let N: u32 = 1; fn pack(self) -> [Field; Self::N] { [(self.strength as Field) * 2.pow_32(32) + (self.points as Field)] } fn unpack(packed: [Field; Self::N]) -> Self { let points = packed[0] as u32; let strength = ((packed[0] - points as Field) / 2.pow_32(32)) as u32; Self { strength, points } } } ``` -------------------------------- ### Packable Trait Implementation for FieldNote Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/field_note/struct.FieldNote.html Enables packing and unpacking of FieldNote instances into a compact array of Fields, useful for storage and transmission. ```APIDOC ## impl Packable for FieldNote ### Methods * `pack(self) -> [Field; 1]`: Packs the FieldNote into a single-element array of Fields. * `unpack(packed: [Field; 1]) -> Self`: Unpacks an array of Fields back into a FieldNote instance. ``` -------------------------------- ### Implement Packable trait for custom packing Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/developer_versioned_docs/version-v5.0.1/docs/resources/migration_notes.md Manual implementation of the Packable trait for notes requiring custom packing logic. ```diff + use dep::aztec::protocol::traits::Packable; +impl Packable for YourNote { + fn pack(self) -> [Field; N] { + ... + } + + fn unpack(fields: [Field; N]) -> Self { + ... + } +} ``` -------------------------------- ### Manually implement Packable Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/noir_aztec/protocol/traits/trait.Packable.html Manual implementation allows for bit-packing smaller elements into a single Field, reducing storage and gas costs. ```rust struct TwoBooleans { a: bool, b: bool, } impl Packable for TwoBooleans { let N: u32 = 1; fn pack(self) -> [Field; Self::N] { // a in bit 1, b in bit 0 [(self.a as Field) * 2.pow_32(1) + (self.b as Field)] } fn unpack(packed: [Field; Self::N]) -> Self { let b = (packed[0] as u8) % 2 != 0; let a = ((packed[0] - b as Field) / 2.pow_32(1)) != 0; Self { a, b } } } ``` -------------------------------- ### hash_2 Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/poseidon/poseidon/bn254/index.html Computes the Poseidon hash for two inputs. ```APIDOC ## hash_2 ### Description Computes the Poseidon hash for two inputs. ### Function Signature `hash_2(input1: Field, input2: Field)` ### Parameters * **input1** (Field) - The first field element to hash. * **input2** (Field) - The second field element to hash. ``` -------------------------------- ### Dispatching Subset of Relations with Selectors Source: https://github.com/aztecprotocol/aztec-packages/blob/next/barretenberg/cpp/pil/vm2/docs/recipes.md Shows how to activate specific relations from a larger set using boolean selector columns. This allows for dynamic toggling of constraints based on VM state. ```mathematica q_1 * P_1(x_1, x_2) = 0 AND q_2 * P_2(x_1, x_2) = 0 AND q_3 * P_3(x_1, x_2) = 0 ``` -------------------------------- ### hash_3 Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/poseidon/poseidon/bn254/index.html Computes the Poseidon hash for three inputs. ```APIDOC ## hash_3 ### Description Computes the Poseidon hash for three inputs. ### Function Signature `hash_3(input1: Field, input2: Field, input3: Field)` ### Parameters * **input1** (Field) - The first field element to hash. * **input2** (Field) - The second field element to hash. * **input3** (Field) - The third field element to hash. ``` -------------------------------- ### Pack two u32 values into one Field Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/developer_versioned_docs/version-v5.0.1/docs/aztec-nr/framework-description/data_packing.md Manual implementation of Packable for a struct containing two u32 values, reducing storage from two Fields to one. ```rust // Two u32 values packed into a single Field. // Derived Packable would give N = 2; manual packing gives N = 1. #[derive(Deserialize, Eq, Serialize)] pub struct Card { pub strength: u32, pub points: u32, } impl Packable for Card { let N: u32 = 1; fn pack(self) -> [Field; Self::N] { [(self.strength as Field) * 2.pow_32(32) + (self.points as Field)] } fn unpack(packed: [Field; Self::N]) -> Self { let points = packed[0] as u32; let strength = ((packed[0] - points as Field) / 2.pow_32(32)) as u32; Self { strength, points } } } ``` -------------------------------- ### Struct with Derived Packable (Game State Example) Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/docs-developers/docs/aztec-nr/framework-description/data_packing.md Illustrates a struct where deriving `Packable` leads to inefficient storage usage (N=3) because each member, regardless of its bit size, occupies a full `Field`. ```rust #[derive(Packable)] struct GameState { started: bool, // 1 bit, but uses 1 whole Field round: u32, // 32 bits, but uses 1 whole Field score: u32, // 32 bits, but uses 1 whole Field } ``` -------------------------------- ### Custom Packable Implementation for GameState Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/docs-developers/docs/aztec-nr/framework-description/data_packing.md A custom `Packable` implementation for `GameState` that achieves bit-packing, reducing storage usage from N=3 to N=1 Field. This optimizes gas costs for storage operations. ```rust #[derive(Eq, Packable)] struct GameState { started: bool, round: u32, score: u32, } impl Packable for GameState { // ... custom pack/unpack implementation ... } ``` -------------------------------- ### pub fn x5_3(state: [Field; 3]) -> [Field; 3] Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/testnet/poseidon/poseidon/bn254/perm/fn.x5_3.html Performs a Poseidon permutation on a state array of 3 Field elements. ```APIDOC ## x5_3 ### Description Performs a Poseidon permutation on a state array of 3 Field elements. This function is part of the Poseidon hash implementation for the BN254 curve. ### Signature `pub fn x5_3(state: [Field; 3]) -> [Field; 3]` ### Parameters - **state** ([Field; 3]) - The input state array consisting of 3 Field elements. ### Returns - **[Field; 3]** - The permuted state array. ``` -------------------------------- ### CheckpointsQuery Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/typescript-api/mainnet/stdlib.md Query a range of confirmed checkpoints by start/limit, slot anchor, or epoch. ```typescript type CheckpointsQuery = { from: CheckpointNumber; limit: number } | { fromSlot: SlotNumber; limit: number; reverse?: boolean } | { epoch: EpochNumber } ``` -------------------------------- ### hash_4 Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/poseidon/poseidon/bn254/index.html Computes the Poseidon hash for four inputs. ```APIDOC ## hash_4 ### Description Computes the Poseidon hash for four inputs. ### Function Signature `hash_4(input1: Field, input2: Field, input3: Field, input4: Field)` ### Parameters * **input1** (Field) - The first field element to hash. * **input2** (Field) - The second field element to hash. * **input3** (Field) - The third field element to hash. * **input4** (Field) - The fourth field element to hash. ``` -------------------------------- ### hash_7 Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/poseidon/poseidon/bn254/index.html Computes the Poseidon hash for seven inputs. ```APIDOC ## hash_7 ### Description Computes the Poseidon hash for seven inputs. ### Function Signature `hash_7(input1: Field, input2: Field, input3: Field, input4: Field, input5: Field, input6: Field, input7: Field)` ### Parameters * **input1** (Field) - The first field element to hash. * **input2** (Field) - The second field element to hash. * **input3** (Field) - The third field element to hash. * **input4** (Field) - The fourth field element to hash. * **input5** (Field) - The fifth field element to hash. * **input6** (Field) - The sixth field element to hash. * **input7** (Field) - The seventh field element to hash. ``` -------------------------------- ### Implement Storage trait for state variables Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/developer_versioned_docs/version-v5.0.1/docs/resources/migration_notes.md Bind the serialization length to the Storage trait for state variables. ```diff + impl Storage for MyStateVar where T: Serialize { }; ``` -------------------------------- ### hash_9 Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/poseidon/poseidon/bn254/index.html Computes the Poseidon hash for nine inputs. ```APIDOC ## hash_9 ### Description Computes the Poseidon hash for nine inputs. ### Function Signature `hash_9(input1: Field, input2: Field, input3: Field, input4: Field, input5: Field, input6: Field, input7: Field, input8: Field, input9: Field)` ### Parameters * **input1** (Field) - The first field element to hash. * **input2** (Field) - The second field element to hash. * **input3** (Field) - The third field element to hash. * **input4** (Field) - The fourth field element to hash. * **input5** (Field) - The fifth field element to hash. * **input6** (Field) - The sixth field element to hash. * **input7** (Field) - The seventh field element to hash. * **input8** (Field) - The eighth field element to hash. * **input9** (Field) - The ninth field element to hash. ``` -------------------------------- ### pub fn x5_9(state: [Field; 9]) -> [Field; 9] Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/testnet/poseidon/poseidon/bn254/perm/fn.x5_9.html Performs a Poseidon permutation on a state array of 9 Field elements. ```APIDOC ## Function: x5_9 ### Description Performs a Poseidon permutation operation on a state array of 9 Field elements for the BN254 curve. ### Signature `pub fn x5_9(state: [Field; 9]) -> [Field; 9]` ### Parameters - **state** ([Field; 9]) - The input state array consisting of 9 Field elements. ### Returns - **[Field; 9]** - The resulting state array after the permutation. ``` -------------------------------- ### Send Zero Univariate for ZK Flavors Source: https://github.com/aztecprotocol/aztec-packages/blob/next/barretenberg/cpp/src/barretenberg/sumcheck/Sumcheck.md Prover sends a zero univariate to the transcript during virtual rounds in ZK flavors to maintain consistency. ```cpp auto zero_univariate = bb::Univariate::zero(); transcript->send_to_verifier("Sumcheck:univariate_" + std::to_string(k), zero_univariate); ``` -------------------------------- ### Poseidon2Sponge Deserialize Method (Direct) Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/noir_aztec/protocol/poseidon2/struct.Poseidon2Sponge.html Implements the Deserialize trait for Poseidon2Sponge, providing a direct deserialization method that takes an array of 9 Fields. ```rust pub fn deserialize(fields: [Field; 9]) -> Self ``` -------------------------------- ### Manual Packable Implementation Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/developer_versioned_docs/version-v5.0.1/docs/aztec-nr/framework-description/data_packing.md Custom implementation of Packable to pack multiple fields into a single Field element. ```rust // Mixed-width with a bool: started (1 bit) + round (32 bits) + score (32 bits). // Derived Packable would give N = 3; manual packing gives N = 1. #[derive(Eq, Serialize)] pub struct GameState { pub started: bool, pub round: u32, pub score: u32, } impl Packable for GameState { let N: u32 = 1; fn pack(self) -> [Field; Self::N] { // Layout within a single Field: // [ started (1 bit) | round (32 bits) | score (32 bits) ] // bit 64 bits 32..63 bits 0..31 [ (self.started as Field) * 2.pow_32(64) // shift left by 64 bits + (self.round as Field) * 2.pow_32(32) // shift left by 32 bits + (self.score as Field), // lowest bits ] } fn unpack(packed: [Field; Self::N]) -> Self { // 1. Extract lowest value via truncating cast let score = packed[0] as u32; // 2. Subtract and shift right to get next value let round = ((packed[0] - score as Field) / 2.pow_32(32)) as u32; // 3. Subtract and shift right to get highest value. // Bools are extracted by comparing the resulting Field to 0. let started = ((packed[0] - score as Field - (round as Field) * 2.pow_32(32)) / 2.pow_32(64)) != 0; Self { started, round, score } } } ``` -------------------------------- ### batch Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/developer_versioned_docs/version-v5.0.1/docs/aztec-js/aztec_js_reference.md Batches multiple method calls into a single transaction. ```typescript batch[]>(methods: T): Promise> ``` -------------------------------- ### Update NoteGetterOptions Select Method Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/developer_versioned_docs/version-v5.0.1/docs/resources/migration_notes.md Pass an explicit comparator to select and update parameter order to (lhs, operator, rhs). ```diff - options.select(ValueNote::properties().value, amount, Option::none()) + options.select(ValueNote::properties().value, Comparator.EQ, amount) ``` -------------------------------- ### hash_6 Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/poseidon/poseidon/bn254/index.html Computes the Poseidon hash for six inputs. ```APIDOC ## hash_6 ### Description Computes the Poseidon hash for six inputs. ### Function Signature `hash_6(input1: Field, input2: Field, input3: Field, input4: Field, input5: Field, input6: Field)` ### Parameters * **input1** (Field) - The first field element to hash. * **input2** (Field) - The second field element to hash. * **input3** (Field) - The third field element to hash. * **input4** (Field) - The fourth field element to hash. * **input5** (Field) - The fifth field element to hash. * **input6** (Field) - The sixth field element to hash. ``` -------------------------------- ### Packable Implementation for HintedNote Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/noir_aztec/note/struct.HintedNote.html Provides methods for packing and unpacking a HintedNote to and from a fixed-size array of fields. This implementation requires the generic Note type to also implement Packable. ```rust pub fn pack(self) -> [[Field](../../std/primitive.Field.html); <(resolved type) as Packable>::N + 6] ``` ```rust pub fn unpack(packed: [[Field](../../std/primitive.Field.html); <(resolved type) as Packable>::N + 6]) -> Self ``` -------------------------------- ### Multi-Row Computation Trace Relations (Variant without Start) Source: https://github.com/aztecprotocol/aztec-packages/blob/next/barretenberg/cpp/pil/vm2/docs/recipes.md A simplified set of relations for multi-row computations that only require an 'end' selector, omitting the 'start' selector. This ensures a contiguous active trace ending with 'end == 1'. ```plaintext sel * (1 - sel) = 0; end * (1 - end) = 0; pol LATCH_CONDITION = end + precomputed.first_row; #[SEL_ON_END] end * (1 - sel) = 0; #[TRACE_CONTINUITY] (1 - LATCH_CONDITION) * (sel - sel') = 0; ``` -------------------------------- ### hash_10 Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/poseidon/poseidon/bn254/index.html Computes the Poseidon hash for ten inputs. ```APIDOC ## hash_10 ### Description Computes the Poseidon hash for ten inputs. ### Function Signature `hash_10(input1: Field, input2: Field, input3: Field, input4: Field, input5: Field, input6: Field, input7: Field, input8: Field, input9: Field, input10: Field)` ### Parameters * **input1** (Field) - The first field element to hash. * **input2** (Field) - The second field element to hash. * **input3** (Field) - The third field element to hash. * **input4** (Field) - The fourth field element to hash. * **input5** (Field) - The fifth field element to hash. * **input6** (Field) - The sixth field element to hash. * **input7** (Field) - The seventh field element to hash. * **input8** (Field) - The eighth field element to hash. * **input9** (Field) - The ninth field element to hash. * **input10** (Field) - The tenth field element to hash. ``` -------------------------------- ### Conditional Helm Deployments Source: https://github.com/aztecprotocol/aztec-packages/blob/next/spartan/AGENTS.md Uses ternary operators and for expressions to manage dynamic release generation based on replica counts. ```hcl prover = tonumber(var.PROVER_REPLICAS) > 0 ? { ... } : null ``` ```hcl validator_releases = tonumber(var.VALIDATOR_REPLICAS) > 0 ? { for idx in range(1 + var.VALIDATOR_HA_REPLICAS) : "validators${idx > 0 ? "-ha-${idx}" : ""}" => { ... } } : {} ``` -------------------------------- ### hash_14 Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/poseidon/poseidon/bn254/index.html Computes the Poseidon hash for fourteen inputs. ```APIDOC ## hash_14 ### Description Computes the Poseidon hash for fourteen inputs. ### Function Signature `hash_14(input1: Field, input2: Field, input3: Field, input4: Field, input5: Field, input6: Field, input7: Field, input8: Field, input9: Field, input10: Field, input11: Field, input12: Field, input13: Field, input14: Field)` ### Parameters * **input1** (Field) - The first field element to hash. * **input2** (Field) - The second field element to hash. * **input3** (Field) - The third field element to hash. * **input4** (Field) - The fourth field element to hash. * **input5** (Field) - The fifth field element to hash. * **input6** (Field) - The sixth field element to hash. * **input7** (Field) - The seventh field element to hash. * **input8** (Field) - The eighth field element to hash. * **input9** (Field) - The ninth field element to hash. * **input10** (Field) - The tenth field element to hash. * **input11** (Field) - The eleventh field element to hash. * **input12** (Field) - The twelfth field element to hash. * **input13** (Field) - The thirteenth field element to hash. * **input14** (Field) - The fourteenth field element to hash. ``` -------------------------------- ### hash_8 Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/poseidon/poseidon/bn254/index.html Computes the Poseidon hash for eight inputs. ```APIDOC ## hash_8 ### Description Computes the Poseidon hash for eight inputs. ### Function Signature `hash_8(input1: Field, input2: Field, input3: Field, input4: Field, input5: Field, input6: Field, input7: Field, input8: Field)` ### Parameters * **input1** (Field) - The first field element to hash. * **input2** (Field) - The second field element to hash. * **input3** (Field) - The third field element to hash. * **input4** (Field) - The fourth field element to hash. * **input5** (Field) - The fifth field element to hash. * **input6** (Field) - The sixth field element to hash. * **input7** (Field) - The seventh field element to hash. * **input8** (Field) - The eighth field element to hash. ``` -------------------------------- ### hash_16 Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/poseidon/poseidon/bn254/index.html Computes the Poseidon hash for sixteen inputs. ```APIDOC ## hash_16 ### Description Computes the Poseidon hash for sixteen inputs. ### Function Signature `hash_16(input1: Field, input2: Field, input3: Field, input4: Field, input5: Field, input6: Field, input7: Field, input8: Field, input9: Field, input10: Field, input11: Field, input12: Field, input13: Field, input14: Field, input15: Field, input16: Field)` ### Parameters * **input1** (Field) - The first field element to hash. * **input2** (Field) - The second field element to hash. * **input3** (Field) - The third field element to hash. * **input4** (Field) - The fourth field element to hash. * **input5** (Field) - The fifth field element to hash. * **input6** (Field) - The sixth field element to hash. * **input7** (Field) - The seventh field element to hash. * **input8** (Field) - The eighth field element to hash. * **input9** (Field) - The ninth field element to hash. * **input10** (Field) - The tenth field element to hash. * **input11** (Field) - The eleventh field element to hash. * **input12** (Field) - The twelfth field element to hash. * **input13** (Field) - The thirteenth field element to hash. * **input14** (Field) - The fourteenth field element to hash. * **input15** (Field) - The fifteenth field element to hash. * **input16** (Field) - The sixteenth field element to hash. ``` -------------------------------- ### pub fn x5_16(state: [Field; 16]) -> [Field; 16] Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/testnet/poseidon/poseidon/bn254/perm/fn.x5_16.html Performs a Poseidon permutation on a state array of 16 Field elements. ```APIDOC ## Function: x5_16 ### Description Performs the Poseidon permutation operation on a state array consisting of 16 Field elements. This is part of the cryptographic primitives for the BN254 curve. ### Signature `pub fn x5_16(state: [Field; 16]) -> [Field; 16]` ### Parameters - **state** ([Field; 16]) - The input state array of 16 Field elements to be permuted. ### Returns - **[Field; 16]** - The resulting state array after the permutation. ``` -------------------------------- ### pub fn x5_2(state: [Field; 2]) -> [Field; 2] Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/testnet/poseidon/poseidon/bn254/perm/fn.x5_2.html Performs a Poseidon permutation on a state array of 2 Field elements. ```APIDOC ## Function: x5_2 ### Description Performs the Poseidon permutation operation on a state consisting of 2 Field elements. This function is part of the bn254 curve implementation within the Aztec Noir library. ### Signature `pub fn x5_2(state: [Field; 2]) -> [Field; 2]` ### Parameters - **state** ([Field; 2]) - The input state array containing 2 Field elements to be permuted. ### Returns - **[Field; 2]** - The resulting state array after the permutation. ``` -------------------------------- ### pub fn x5_13(state: [Field; 13]) -> [Field; 13] Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/testnet/poseidon/poseidon/bn254/perm/fn.x5_13.html Performs a Poseidon permutation on a state array of 13 Field elements. ```APIDOC ## Function: x5_13 ### Description Performs a Poseidon permutation operation on a state array of 13 Field elements. This function is part of the Poseidon hash implementation for the BN254 curve. ### Signature `pub fn x5_13(state: [Field; 13]) -> [Field; 13]` ### Parameters - **state** ([Field; 13]) - The input state array consisting of 13 Field elements. ### Returns - **[Field; 13]** - The permuted state array. ``` -------------------------------- ### poseidon2_hash_with_separator Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/protocol_types/hash/fn.poseidon2_hash_with_separator.html Computes a Poseidon2 hash of a subarray of fields, incorporating a separator. This function is part of the hash module within the protocol_types of the Aztec Native Rust API. ```APIDOC ## Function: poseidon2_hash_with_separator ### Description Computes a Poseidon2 hash of a subarray of fields, incorporating a separator. This function is part of the hash module within the protocol_types of the Aztec Native Rust API. ### Signature ```rust pub fn poseidon2_hash_with_separator(inputs: [Field; N], separator: T) -> Field where T: ToField ``` ### Parameters * **inputs** (`[Field; N]`): An array of `Field` elements to be hashed. `N` is a compile-time constant determining the size of the input array. * **separator** (`T`): A value that implements the `ToField` trait, used as a separator in the hashing process. ### Returns * **Field**: The resulting hash value as a `Field` element. ``` -------------------------------- ### hash_1 Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/poseidon/poseidon/bn254/index.html Computes the Poseidon hash for a single input. ```APIDOC ## hash_1 ### Description Computes the Poseidon hash for a single input. ### Function Signature `hash_1(input: Field)` ### Parameters * **input** (Field) - The single field element to hash. ``` -------------------------------- ### hash_11 Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/poseidon/poseidon/bn254/index.html Computes the Poseidon hash for eleven inputs. ```APIDOC ## hash_11 ### Description Computes the Poseidon hash for eleven inputs. ### Function Signature `hash_11(input1: Field, input2: Field, input3: Field, input4: Field, input5: Field, input6: Field, input7: Field, input8: Field, input9: Field, input10: Field, input11: Field)` ### Parameters * **input1** (Field) - The first field element to hash. * **input2** (Field) - The second field element to hash. * **input3** (Field) - The third field element to hash. * **input4** (Field) - The fourth field element to hash. * **input5** (Field) - The fifth field element to hash. * **input6** (Field) - The sixth field element to hash. * **input7** (Field) - The seventh field element to hash. * **input8** (Field) - The eighth field element to hash. * **input9** (Field) - The ninth field element to hash. * **input10** (Field) - The tenth field element to hash. * **input11** (Field) - The eleventh field element to hash. ``` -------------------------------- ### Display Game Status Component Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/developer_versioned_docs/version-v5.0.1/docs/tutorials/js_tutorials/webapp/04-contract-interaction.md A React component that renders the current game ID, player address, and round progress. It highlights that point allocations remain private while round progress is tracked publicly. ```typescript /** * Displays the current game status. * * In the Pod Racing contract, round progress is tracked publicly * (which round each player is on), but point allocations are private. * The currentRound is tracked locally in React state and incremented * after each successful play_round transaction. */ export function GameStatus({ account, gameId, currentRound }: GameStatusProps) { const addr = account.toString(); const display = `${addr.slice(0, 10)}...${addr.slice(-6)}`; return (

Game Status

Game ID: {gameId.toString()}

Playing as: {display}

Current Round: {currentRound} / 3

Your point allocations are stored as private notes. Opponents cannot see your strategy until you reveal scores.

); } ``` -------------------------------- ### Define the GameRoundNote structure Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/developer_versioned_docs/version-v5.0.1/docs/tutorials/js_tutorials/webapp/01-the-contract.md Implements a private note using the #[note] macro to store player point allocations for a specific round. ```rust use aztec::{macros::notes::note, protocol::{traits::Packable, address::AztecAddress}}; /// A private note storing a player's point allocation for one round. /// These notes remain private until the player calls finish_game to reveal totals. #[derive(Eq, Packable)] #[note] pub struct GameRoundNote { pub track1: u8, pub track2: u8, pub track3: u8, pub track4: u8, pub track5: u8, pub round: u8, pub owner: AztecAddress, } impl GameRoundNote { pub fn new(track1: u8, track2: u8, track3: u8, track4: u8, track5: u8, round: u8, owner: AztecAddress) -> Self { Self { track1, track2, track3, track4, track5, round, owner } } } ``` -------------------------------- ### poseidon2_hash_with_separator Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/noir_aztec/protocol/hash/index.html Computes a Poseidon2 hash with a separator. ```APIDOC ## poseidon2_hash_with_separator ### Description Computes a Poseidon2 hash with a separator. ### Method N/A (Function call within Noir) ### Parameters * **inputs** (array of fields) - Required - The input fields to hash. * **separator** (field) - Required - The separator field. ### Response * **hash_result** (field) - The resulting Poseidon2 hash. ``` -------------------------------- ### Initialize PartialStateReference Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/typescript-api/mainnet/stdlib.md Constructor for creating a new snapshot of the note hash, nullifier, and public data trees. ```typescript new PartialStateReference(noteHashTree: AppendOnlyTreeSnapshot, nullifierTree: AppendOnlyTreeSnapshot, publicDataTree: AppendOnlyTreeSnapshot) ``` -------------------------------- ### pub fn x5_10(state: [Field; 10]) -> [Field; 10] Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/testnet/poseidon/poseidon/bn254/perm/fn.x5_10.html Performs the Poseidon permutation on a state array of 10 Field elements. ```APIDOC ## Function: x5_10 ### Description Performs the Poseidon permutation operation on a state consisting of 10 Field elements. This is part of the bn254 curve implementation within the Aztec Noir library. ### Signature `pub fn x5_10(state: [Field; 10]) -> [Field; 10]` ### Parameters - **state** ([Field; 10]) - The input state array of 10 Field elements to be permuted. ### Returns - **[Field; 10]** - The resulting state array after the permutation. ``` -------------------------------- ### hash_2(input: [Field; 2]) -> Field Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/testnet/poseidon/poseidon/bn254/fn.hash_2.html Computes the Poseidon hash of a two-element Field array. ```APIDOC ## Function: hash_2 ### Description Computes a Poseidon hash for a given input array of two Field elements. ### Signature `pub fn hash_2(input: [Field; 2]) -> Field` ### Parameters - **input** ([Field; 2]) - Required - An array containing exactly two Field elements to be hashed. ### Returns - **Field** - The resulting hash value. ``` -------------------------------- ### CheckpointQuery Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/typescript-api/mainnet/stdlib.md Lookup a single confirmed checkpoint by number, slot, or tag. ```typescript type CheckpointQuery = { number: CheckpointNumber } | { slot: SlotNumber } | { tag: "checkpointed" | "proven" | "finalized" } ``` -------------------------------- ### Poseidon2Sponge Serialize Method (Direct) Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/noir_aztec/protocol/poseidon2/struct.Poseidon2Sponge.html Implements the Serialize trait for Poseidon2Sponge, providing a direct serialization method that returns an array of 9 Fields. ```rust pub fn serialize(self) -> [Field; 9] ``` -------------------------------- ### aztec compute-selector Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/docs-developers/docs/cli/aztec_cli_reference.md Computes a selector given a function signature. ```APIDOC ## aztec compute-selector ### Description Given a function signature, it computes a selector. ### Usage `aztec compute-selector [options] ` ``` -------------------------------- ### selector() Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/noir_aztec/context/struct.PublicContext.html Returns the 4-byte function selector of the currently-executing function, similar to msg.sig in Solidity. ```APIDOC ## selector() ### Description Returns the function selector of the currently-executing function. ### Returns - **FunctionSelector** - The 4-byte function identifier. ``` -------------------------------- ### Partial Mitigation using assert_equal Constraints Source: https://github.com/aztecprotocol/aztec-packages/blob/next/barretenberg/cpp/src/barretenberg/stdlib/primitives/field/CODEC_README.md Demonstrates partial protection against aliased inputs in Mega circuits using assert_equal constraints. These constraints can be avoided by a malicious prover. ```cpp // biggroup_goblin.hpp:181-190 op_tuple = builder->queue_ecc_add_accum(other.get_value()); x_lo.assert_equal(other._x.limbs[0]); x_hi.assert_equal(other._x.limbs[1]); ``` -------------------------------- ### hash_13 Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/poseidon/poseidon/bn254/index.html Computes the Poseidon hash for thirteen inputs. ```APIDOC ## hash_13 ### Description Computes the Poseidon hash for thirteen inputs. ### Function Signature `hash_13(input1: Field, input2: Field, input3: Field, input4: Field, input5: Field, input6: Field, input7: Field, input8: Field, input9: Field, input10: Field, input11: Field, input12: Field, input13: Field)` ### Parameters * **input1** (Field) - The first field element to hash. * **input2** (Field) - The second field element to hash. * **input3** (Field) - The third field element to hash. * **input4** (Field) - The fourth field element to hash. * **input5** (Field) - The fifth field element to hash. * **input6** (Field) - The sixth field element to hash. * **input7** (Field) - The seventh field element to hash. * **input8** (Field) - The eighth field element to hash. * **input9** (Field) - The ninth field element to hash. * **input10** (Field) - The tenth field element to hash. * **input11** (Field) - The eleventh field element to hash. * **input12** (Field) - The twelfth field element to hash. * **input13** (Field) - The thirteenth field element to hash. ``` -------------------------------- ### Update UnconstrainedContext specialization Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/developer_versioned_docs/version-v5.0.1/docs/resources/migration_notes.md Update custom state variable implementations to use UnconstrainedContext for top-level unconstrained execution. ```diff + use dep::aztec::context::UnconstrainedContext; - impl MyStateVariable<()> { + impl MyStateVariable { ``` -------------------------------- ### pub fn x5_14(state: [Field; 14]) -> [Field; 14] Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/testnet/poseidon/poseidon/bn254/perm/fn.x5_14.html Performs the Poseidon permutation on a state array of 14 Field elements. ```APIDOC ## Function: x5_14 ### Description Performs the Poseidon permutation operation on a state vector of 14 Field elements. This is a core component of the Poseidon hash function implementation for the BN254 curve. ### Signature `pub fn x5_14(state: [Field; 14]) -> [Field; 14]` ### Parameters - **state** ([Field; 14]) - The input state array consisting of 14 Field elements to be permuted. ### Returns - **[Field; 14]** - The resulting state array after the permutation process. ``` -------------------------------- ### hash_13 Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/poseidon/poseidon/bn254/fn.hash_13.html Computes the Poseidon hash for 13 field elements. ```APIDOC ## hash_13 ### Description Computes the Poseidon hash for an input array of 13 field elements. ### Function Signature `pub fn hash_13(input: [Field; 13]) -> Field` ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **input** (Array of 13 Fields) - Required - The 13 field elements to hash. ``` -------------------------------- ### pub fn hash_16(input: [Field; 16]) -> Field Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/testnet/poseidon/poseidon/bn254/fn.hash_16.html Computes the Poseidon hash of a fixed-size array of 16 Field elements. ```APIDOC ## hash_16 ### Description Computes the Poseidon hash for an input array of 16 Field elements. ### Signature `pub fn hash_16(input: [Field; 16]) -> Field` ### Parameters - **input** ([Field; 16]) - The array of 16 Field elements to be hashed. ### Returns - **Field** - The resulting hash value. ``` -------------------------------- ### Define Subrelation Partial Lengths and Independence Source: https://github.com/aztecprotocol/aztec-packages/blob/next/barretenberg/cpp/src/barretenberg/multilinear_batching/README.md Configuration constants for the MultilinearBatchingRelation subrelations. ```cpp SUBRELATION_PARTIAL_LENGTHS = { 3, 3 }; // non-shifted, shifted SUBRELATION_LINEARLY_INDEPENDENT = { false, false }; ``` -------------------------------- ### fn x5_7 Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/testnet/poseidon/poseidon/bn254/perm/fn.x5_7.html Performs the Poseidon permutation on a state array of 7 Field elements. ```APIDOC ## Function: x5_7 ### Description Performs a Poseidon permutation operation on a state vector of 7 Field elements. This function is part of the Poseidon hash implementation for the BN254 curve. ### Signature `pub fn x5_7(state: [Field; 7]) -> [Field; 7]` ### Parameters - **state** ([Field; 7]) - The input state array consisting of 7 Field elements to be permuted. ### Returns - **[Field; 7]** - The resulting state array after the permutation. ``` -------------------------------- ### bb batch_verify Source: https://github.com/aztecprotocol/aztec-packages/blob/next/barretenberg/docs/docs/bb-cli-reference.md Batch-verify multiple Chonk proofs with a single IPA SRS MSM. This command is used for efficiently verifying multiple proofs simultaneously. ```APIDOC ## bb batch_verify ### Description Batch-verify multiple Chonk proofs with a single IPA SRS MSM. ### Usage ```bash bb batch_verify [OPTIONS] ``` ### Options - `-h,--help` - Print this help message and exit - `--help-extended` - Show all options including advanced ones. - `--proofs_dir` - Directory containing proof_N/vk_N pairs. ``` -------------------------------- ### pub fn x5_15(state: [Field; 15]) -> [Field; 15] Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/testnet/poseidon/poseidon/bn254/perm/fn.x5_15.html Performs a Poseidon permutation on a state array of 15 Field elements. ```APIDOC ## Function: x5_15 ### Description Performs the Poseidon permutation operation on a state vector of 15 Field elements. This is part of the cryptographic primitives for the BN254 curve. ### Signature `pub fn x5_15(state: [Field; 15]) -> [Field; 15]` ### Parameters - **state** ([Field; 15]) - The input state array of 15 Field elements to be permuted. ### Returns - **[Field; 15]** - The resulting state array after the permutation. ``` -------------------------------- ### pub fn x5_12(state: [Field; 12]) -> [Field; 12] Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/testnet/poseidon/poseidon/bn254/perm/fn.x5_12.html Performs the Poseidon permutation on a state array of 12 Field elements. ```APIDOC ## Function: x5_12 ### Description Performs the Poseidon permutation operation on a state array of 12 Field elements for the bn254 curve. ### Signature `pub fn x5_12(state: [Field; 12]) -> [Field; 12]` ### Parameters - **state** ([Field; 12]) - The input state array consisting of 12 Field elements. ### Returns - **[Field; 12]** - The resulting state array after the permutation. ``` -------------------------------- ### fn x5_17 Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/testnet/poseidon/poseidon/bn254/perm/fn.x5_17.html Performs a Poseidon permutation on a state array of 17 Field elements. ```APIDOC ## Function: x5_17 ### Description Performs a Poseidon permutation on a state array of 17 Field elements for the bn254 curve. ### Signature `pub fn x5_17(state: [Field; 17]) -> [Field; 17]` ### Parameters - **state** ([Field; 17]) - The input state array of 17 Field elements to be permuted. ### Returns - **[Field; 17]** - The resulting state array after the permutation. ``` -------------------------------- ### hash_8 Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/poseidon/poseidon/bn254/fn.hash_8.html Computes a Poseidon hash for an array of 8 field elements. ```APIDOC ## hash_8 ### Description Computes a Poseidon hash for an array of 8 field elements. ### Function Signature `pub fn hash_8(input: [Field; 8]) -> Field` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **input** (`[Field; 8]`) - Required - An array of 8 field elements to be hashed. ``` -------------------------------- ### Select::new Function Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/noir_aztec/note/note_getter_options/struct.Select.html Constructor for the Select struct. Use this to create a new selection criterion for notes, specifying the property to select, the comparison type, and the value to compare against. ```rust pub fn new(property_selector: PropertySelector, comparator: u8, value: Field) -> Self ``` -------------------------------- ### Finish Game Function (Reveal) Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/docs-developers/docs/tutorials/js_tutorials/webapp/01-the-contract.md Allows players to reveal their aggregated scores after all rounds are played. This is a private function. ```rust // Reveals the aggregated scores for each player and updates the game state. // This is a private function. #[aztec(private)] fn finish_game(mut self, race_id: Field) { let msg_sender = msg_sender(); let mut race = self.races.get(race_id); // Ensure the game is active and the sender is a valid player. assert(race.player_2 != 0, "Game has not started yet"); assert(msg_sender == race.player_1 || msg_sender == race.player_2, "Invalid player"); // Read all private round notes for the game. let round_note = self.progress.get(race_id); // Calculate total points per track for each player. let mut player_1_total_points = [0; 5]; let mut player_2_total_points = [0; 5]; for i in 0..5 { player_1_total_points[i] = round_note.player_1_points[i]; player_2_total_points[i] = round_note.player_2_points[i]; } // Update the race state with the aggregated scores (implicitly done by calling public function). // The actual score update happens in the public function `validate_and_play_round`. // This private function's role is to trigger the reveal. abi::reveal_scores(race_id, player_1_total_points, player_2_total_points); } ``` -------------------------------- ### Duplex Sponge Construction for Challenge Generation Source: https://github.com/aztecprotocol/aztec-packages/blob/next/barretenberg/cpp/src/barretenberg/transcript/README.md Explains the duplex sponge construction used for challenge generation, showing how subsequent challenges are derived from previous ones and round data. ```cpp c_next = H(c_prev || round_data) - First challenge: c_0 = H(round_0_data) - Subsequent: c_i = H(c_{i-1} || round_i_data) - Generates pairs: [127-bit, 127-bit, 127-bit, 127-bit, ...] ``` -------------------------------- ### batch Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/developer_versioned_docs/version-v5.0.1/docs/aztec-js/aztec_js_reference.md Executes a batch of methods. ```APIDOC ## batch ### Signature `batch[]>(methods: T): Promise>` ### Parameters - **methods** (T) - Required - The list of methods to batch. ### Returns - **Promise>** - The results of the batched methods. ``` -------------------------------- ### Define BatchResults type Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/developer_versioned_docs/version-v5.0.1/docs/aztec-js/aztec_js_reference.md Maps a tuple of BatchedMethod to a tuple of their wrapped return types. ```typescript export type BatchResults[]> = { [K in keyof T]: BatchedMethodResultWrapper; }; ``` -------------------------------- ### Packable for WithHash Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/noir_aztec/utils/struct.WithHash.html Implementation of the Packable trait for the WithHash struct, allowing it to be packed and unpacked. ```APIDOC ## impl Packable for WithHash ### Description Implementation of the `Packable` trait for the `WithHash` struct, allowing it to be packed into field elements and unpacked back into a `WithHash` instance. ### Methods * `pack(self) -> [Field; M + 1]`: Packs the `WithHash` instance into an array of field elements. * `unpack(packed: [Field; M + 1]) -> Self`: Unpacks an array of field elements into a `WithHash` instance. ``` -------------------------------- ### fn x5_4 Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/testnet/poseidon/poseidon/bn254/perm/fn.x5_4.html Performs a Poseidon permutation on a state array of 4 Field elements. ```APIDOC ## Function: x5_4 ### Description Performs the Poseidon permutation operation on a state consisting of 4 Field elements. This is part of the cryptographic primitives provided by the Aztec Noir library for the BN254 curve. ### Signature `pub fn x5_4(state: [Field; 4]) -> [Field; 4]` ### Parameters - **state** ([Field; 4]) - The input state array containing 4 Field elements to be permuted. ### Returns - **[Field; 4]** - The resulting state array after the permutation. ``` -------------------------------- ### Simple Noir circuit: assert x != y Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/docs-developers/docs/tutorials/contract_tutorials/recursive_verification.md This is a minimal Noir circuit that proves two field values, `x` and `y`, are not equal. `x` is a private input, and `y` is a public input. This circuit can be extended for more complex computations. ```rust fn main( x: Field, y: pub Field ) { assert(x != y); } ``` -------------------------------- ### Implement Packable trait for U128 Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/developer_versioned_docs/version-v5.0.1/docs/resources/migration_notes.md Example implementation of the Packable trait to minimize Field array size during serialization. ```rust use crate::traits::{Packable, ToField}; let U128_PACKED_LEN: u32 = 1; impl Packable for U128 { fn pack(self) -> [Field; U128_PACKED_LEN] { [self.to_field()] } fn unpack(fields: [Field; U128_PACKED_LEN]) -> Self { U128::from_integer(fields[0]) } } ``` -------------------------------- ### CompressedString Packable Implementation Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/compressed_string/struct.CompressedString.html Implements the Packable trait for CompressedString, providing methods to pack the string into an array of Fields and unpack it back. This is essential for integrating CompressedString with Noir's packing and unpacking mechanisms. ```rust pub fn pack(self) -> [Field; N * 1] ``` ```rust pub fn unpack(packed: [Field; N * 1]) -> Self ``` -------------------------------- ### hash_6 Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/poseidon/poseidon/bn254/fn.hash_6.html Computes the Poseidon hash for an input of 6 fields. ```APIDOC ## hash_6 ### Description Computes the Poseidon hash for an input of 6 fields. ### Signature `pub fn hash_6(input: [Field; 6]) -> Field` ### Parameters * `input` - An array of 6 `Field` elements to be hashed. ``` -------------------------------- ### SerializeToColumns Trait Definition Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/testnet/noir_aztec/protocol/proof/traits/trait.SerializeToColumns.html Defines the trait interface requiring the implementation of serialize_to_columns to return an array of N Fields. ```noir pub trait SerializeToColumns { // Required methods pub fn serialize_to_columns(self) -> [Field; N]; } ``` -------------------------------- ### hash_11 Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/poseidon/poseidon/bn254/fn.hash_11.html Computes a Poseidon hash for a fixed-size input of 11 field elements. ```APIDOC ## hash_11 ### Description Computes a Poseidon hash for a fixed-size input of 11 field elements. ### Signature `pub fn hash_11(input: [Field; 11]) -> Field` ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **input** (`[Field; 11]`) - Required - An array of 11 field elements to be hashed. ### Request Example ```json { "input": [ "0x123", "0x456", "0x789", "0xabc", "0xdef", "0x1a2", "0x3b4", "0x5c6", "0x7d8", "0x9e0", "0xf11" ] } ``` ### Response #### Success Response (200) - **hash** (`Field`) - The resulting hash value as a single field element. #### Response Example ```json { "hash": "0xabcdef1234567890" } ``` ``` -------------------------------- ### C++: Valid Pattern - Interaction via Challenges Source: https://github.com/aztecprotocol/aztec-packages/blob/next/barretenberg/cpp/src/barretenberg/transcript/README.md Illustrates a valid pattern for interacting with data from different rounds in a Fiat-Shamir protocol. Data is combined only after obtaining a challenge (`beta`), ensuring that the interaction is properly bound by the protocol's challenge mechanism. This pattern satisfies the `check_round_provenance` security requirements. ```cpp auto beta = transcript->get_challenge("beta"); // round_provenance = 0x0001...0000 (upper) auto mixed = a * beta; // ✅ OK - has challenge bit set auto result = mixed + b; // ✅ OK - mixed has challenge bit, prevents violation ``` -------------------------------- ### Poseidon2Sponge Trait Implementations Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/protocol_types/poseidon2/struct.Poseidon2Sponge.html Documentation for the Deserialize, Eq, and Serialize trait implementations for the Poseidon2Sponge struct. ```APIDOC ## Poseidon2Sponge Trait Implementations ### `impl Deserialize for Poseidon2Sponge` Provides methods for deserializing a `Poseidon2Sponge` instance. - **`deserialize(fields: [Field; 9]) -> Self`**: Deserializes from an array of 9 fields. - **`stream_deserialize(reader: &mut Reader) -> Self`**: Deserializes from a reader stream. ``` ```APIDOC ### `impl Eq for Poseidon2Sponge` Provides the equality comparison for `Poseidon2Sponge` instances. - **`eq(_self: Self, _other: Self) -> bool`**: Compares two `Poseidon2Sponge` instances for equality. ``` ```APIDOC ### `impl Serialize for Poseidon2Sponge` Provides methods for serializing a `Poseidon2Sponge` instance. - **`serialize(self) -> [Field; 9]`**: Serializes the sponge into an array of 9 fields. - **`stream_serialize(self, writer: &mut Writer)`**: Serializes the sponge into a writer stream. ``` -------------------------------- ### ProposedCheckpointQuery Type Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/typescript-api/mainnet/stdlib.md Query structure for looking up proposed, non-L1-confirmed checkpoints. ```typescript type ProposedCheckpointQuery = { number: CheckpointNumber } | { slot: SlotNumber } | { tag: "proposed" } ``` -------------------------------- ### Query synced L2 epoch number via JSON RPC Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/docs-operate/operators/reference/node-api-reference.md Retrieves the last L2 epoch number fully synchronized from L1. ```bash curl -X POST http://localhost:8080 \ -H 'Content-Type: application/json' \ -d '{"jsonrpc":"2.0","method":"aztec_getSyncedL2EpochNumber","params":[],"id":1}' ``` -------------------------------- ### poseidon2_hash_with_separator Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/noir_aztec/protocol/hash/fn.poseidon2_hash_with_separator.html Computes a Poseidon2 hash of an array of fields, incorporating a separator. This function is part of the hash module within the noir_aztec protocol. ```APIDOC ## Function: poseidon2_hash_with_separator ### Description Computes a Poseidon2 hash of an array of fields, incorporating a separator. This function is part of the hash module within the noir_aztec protocol. ### Signature ```rust pub fn poseidon2_hash_with_separator(inputs: [Field; N], separator: T) -> Field where T: ToField ``` ### Parameters * `inputs`: An array of `Field` elements of size `N` to be hashed. * `separator`: A value of type `T` that implements `ToField`, used as a separator in the hashing process. ### Returns A `Field` representing the computed Poseidon2 hash. ``` -------------------------------- ### Serialize and Deserialize Chonk Proofs and VKs Source: https://github.com/aztecprotocol/aztec-packages/blob/next/barretenberg/cpp/src/barretenberg/chonk/README.md Methods for converting proofs and verification keys to field elements, msgpack buffers, or files. ```cpp // Proof to/from field elements std::vector fields = proof.to_field_elements(); ChonkProof proof = ChonkProof::from_field_elements(fields); // Proof to/from msgpack msgpack::sbuffer buf = proof.to_msgpack_buffer(); ChonkProof proof = ChonkProof::from_msgpack_buffer(buf); // Proof to/from file proof.to_file_msgpack("proof.bin"); ChonkProof proof = ChonkProof::from_file_msgpack("proof.bin"); // VK serialization std::vector fields = vk.to_field_elements(); vk.from_field_elements(fields); ``` -------------------------------- ### getCheckpoint Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/typescript-api/mainnet/stdlib.md Gets a single confirmed checkpoint matching the given query. ```APIDOC ## getCheckpoint(query: CheckpointQuery) => Promise ### Description Retrieves a confirmed checkpoint. Note that this includes nested full L2Blocks with transaction bodies. ``` -------------------------------- ### Sumcheck Utilities: Convert Edges to Polynomials Source: https://github.com/aztecprotocol/aztec-packages/blob/next/barretenberg/cpp/notebook.ipynb Converts a list of edges, where each edge is a pair of coefficients, into a list of polynomials. This is used in sumcheck calculations. ```python def convert_to_polys(edge_list): return [edge[0] * (1-X) + edge[1] * X for edge in edge_list] ``` -------------------------------- ### Logical Conjunction of Relations Source: https://github.com/aztecprotocol/aztec-packages/blob/next/barretenberg/cpp/pil/vm2/docs/recipes.md Demonstrates how to enforce multiple sub-relations simultaneously using logical AND. This is useful when several independent constraints must hold true for the VM's execution trace. ```mathematica x_1(x_1 - 1) = 0 AND x_2 - 2x_3 = 0 ``` -------------------------------- ### hash_4 Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/poseidon/poseidon/bn254/fn.hash_4.html Computes a Poseidon hash for an input array of 4 field elements. ```APIDOC ## hash_4 ### Description Computes a Poseidon hash for an input array of 4 field elements. ### Signature `pub fn hash_4(input: [Field; 4]) -> Field` ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **input** (`[Field; 4]`) - Required - An array of 4 field elements to be hashed. ### Request Example ```json { "input": [ "0x123...", "0x456...", "0x789...", "0xabc..." ] } ``` ### Response #### Success Response (200) - **hash** (`Field`) - The resulting hash value as a field element. #### Response Example ```json { "hash": "0xdef..." } ``` ``` -------------------------------- ### Query checkpoint attestations via JSON-RPC Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/docs-operate/operators/reference/node-api-reference.md Retrieves checkpoint attestations from the pool for a specific slot, optionally filtered by proposal payload hash. ```bash curl -X POST http://localhost:8080 \ -H 'Content-Type: application/json' \ -d '{"jsonrpc":"2.0","method":"aztec_getCheckpointAttestationsForSlot","params":["100","0x1234..."],"id":1}' ``` -------------------------------- ### Create Private Function Context Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/developer_versioned_docs/version-v5.0.1/docs/aztec-nr/framework-description/functions/function_transforms.md Serializes and hashes input parameters using Poseidon2 before initializing the PrivateContext. ```rust // Parameters are serialized into an array let serialized_args: [Field; N] = /* serialized parameters */; // Hash the arguments using poseidon2 let args_hash = aztec::hash::hash_args(serialized_args); // Create the context with the inputs and args hash let mut context = PrivateContext::new(inputs, args_hash); ``` -------------------------------- ### Serialize Implementation for HintedNote Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/noir_aztec/note/struct.HintedNote.html Provides methods for serializing a HintedNote to a sequence of fields or a stream. This implementation requires the generic Note type to also implement Serialize. ```rust pub fn serialize(self) -> [[Field](../../std/primitive.Field.html); <(resolved type) as Serialize>::N + 6] ``` ```rust pub fn stream_serialize(self, writer: &mut [Writer](../../serde/writer/struct.Writer.html)) ``` -------------------------------- ### Boolean OR Operation Source: https://github.com/aztecprotocol/aztec-packages/blob/next/barretenberg/cpp/pil/vm2/docs/recipes.md Implements the logical OR operation between two boolean variables 'x' and 'y' using algebraic constraints. This is essential for combining conditions. ```mathematica (1-x)(1-y) = 0 ``` -------------------------------- ### hash_5 Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/poseidon/poseidon/bn254/index.html Computes the Poseidon hash for five inputs. ```APIDOC ## hash_5 ### Description Computes the Poseidon hash for five inputs. ### Function Signature `hash_5(input1: Field, input2: Field, input3: Field, input4: Field, input5: Field)` ### Parameters * **input1** (Field) - The first field element to hash. * **input2** (Field) - The second field element to hash. * **input3** (Field) - The third field element to hash. * **input4** (Field) - The fourth field element to hash. * **input5** (Field) - The fifth field element to hash. ``` -------------------------------- ### hash_12 Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/poseidon/poseidon/bn254/index.html Computes the Poseidon hash for twelve inputs. ```APIDOC ## hash_12 ### Description Computes the Poseidon hash for twelve inputs. ### Function Signature `hash_12(input1: Field, input2: Field, input3: Field, input4: Field, input5: Field, input6: Field, input7: Field, input8: Field, input9: Field, input10: Field, input11: Field, input12: Field)` ### Parameters * **input1** (Field) - The first field element to hash. * **input2** (Field) - The second field element to hash. * **input3** (Field) - The third field element to hash. * **input4** (Field) - The fourth field element to hash. * **input5** (Field) - The fifth field element to hash. * **input6** (Field) - The sixth field element to hash. * **input7** (Field) - The seventh field element to hash. * **input8** (Field) - The eighth field element to hash. * **input9** (Field) - The ninth field element to hash. * **input10** (Field) - The tenth field element to hash. * **input11** (Field) - The eleventh field element to hash. * **input12** (Field) - The twelfth field element to hash. ``` -------------------------------- ### absorb_checkpoint_end_marker Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/testnet/protocol_types/blob_data/struct.SpongeBlob.html Absorbs the checkpoint end marker into the sponge. ```APIDOC ### absorb_checkpoint_end_marker #### Description Absorbs the checkpoint end marker into the sponge. #### Signature `pub fn absorb_checkpoint_end_marker(&mut self)` ``` -------------------------------- ### NoteViewerOptions::select Method Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/noir_aztec/note/note_viewer_options/struct.NoteViewerOptions.html Adds a selection criterion to the NoteViewerOptions. ```rust pub fn select( &mut self, property_selector: PropertySelector, comparator: u8, value: T, ) -> Self where T: ToField ``` -------------------------------- ### Perform elliptic curve point doubling with BigNum Source: https://github.com/aztecprotocol/aztec-packages/blob/next/noir-projects/noir-protocol-circuits/crates/bignum/README.md Demonstrates elliptic curve point doubling by constructing witnesses and constraining them using evaluate_quadratic_expression to minimize modular reductions. ```rust use dep::bignum::BigNum; use dep::bignum::BN254_Fq as Fq; use dep::bignum::RuntimeBigNum; use dep::bignum::bignum::evaluate_quadratic_expression; fn example_ecc_double(x: Fq, y: Fq) -> (Fq, Fq) { // Step 1: construct witnesses // Safety: out-of-circuit (x3, y3) computation let (lambda, x3, y3) = unsafe { // lambda = 3*x*x / 2y let mut lambda_numerator = x.__sqr(); lambda_numerator = lambda_numerator.__add(lambda_numerator.__add(lambda_numerator)); let lambda_denominator = y.__add(y); let lambda_ = lambda_numerator.__div(lambda_denominator); // x3 = lambda * lambda - x - x let x3_ = lambda_.__mul(lambda_).__sub(x.__add(x)); // y3 = lambda * (x - x3) - y let y3_ = lambda_.__mul(x.__sub(x3)).__sub(y); lambda_, x3_, y3_ } // Step 2: constrain witnesses to be correct using minimal number of modular reductions (3) // assuming y can't be 0, otherwise we should additionally call y.assert_is_not_zero() // 2y * lambda - 3x^2 = 0 // (y + y) * lambda + (x + x + x) * (-x) = 0 evaluate_quadratic_expression( [[lambda], [x]], [[false], [true]], [[y, y, Fq::new()], [x, x, x]], [[false, false, false], [false, false, false]], [], [] ); // lambda * lambda - x - x - x3 = 0 evaluate_quadratic_expression( [[lambda]], [[false]], [[lambda]], [[false]], [x3,x,x], [true, true, true] ); // lambda * (x - x3) - y - y3= 0 evaluate_quadratic_expression( [[lambda]], [[false]], [[x, x3]], [[false, true]], [y, y3], [true, true] ); (x3, y3) } ``` -------------------------------- ### hash_5 Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/poseidon/poseidon/bn254/fn.hash_5.html Computes a Poseidon hash for 5 input fields. ```APIDOC ## hash_5 ### Description Computes a Poseidon hash for 5 input fields. ### Signature `pub fn hash_5(input: [Field; 5]) -> Field` ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **input** ([Field; 5]) - Required - An array of 5 Field elements to be hashed. ``` -------------------------------- ### hash_15 Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/poseidon/poseidon/bn254/index.html Computes the Poseidon hash for fifteen inputs. ```APIDOC ## hash_15 ### Description Computes the Poseidon hash for fifteen inputs. ### Function Signature `hash_15(input1: Field, input2: Field, input3: Field, input4: Field, input5: Field, input6: Field, input7: Field, input8: Field, input9: Field, input10: Field, input11: Field, input12: Field, input13: Field, input14: Field, input15: Field)` ### Parameters * **input1** (Field) - The first field element to hash. * **input2** (Field) - The second field element to hash. * **input3** (Field) - The third field element to hash. * **input4** (Field) - The fourth field element to hash. * **input5** (Field) - The fifth field element to hash. * **input6** (Field) - The sixth field element to hash. * **input7** (Field) - The seventh field element to hash. * **input8** (Field) - The eighth field element to hash. * **input9** (Field) - The ninth field element to hash. * **input10** (Field) - The tenth field element to hash. * **input11** (Field) - The eleventh field element to hash. * **input12** (Field) - The twelfth field element to hash. * **input13** (Field) - The thirteenth field element to hash. * **input14** (Field) - The fourteenth field element to hash. * **input15** (Field) - The fifteenth field element to hash. ``` -------------------------------- ### Packing Logic for GameState Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/docs-developers/docs/aztec-nr/framework-description/data_packing.md Demonstrates the bit-packing logic for the `GameState` struct. It shifts and adds member values to concatenate them into a single `Field`. The `score` is placed at the lowest bits for efficient extraction. ```rust fn pack(self) -> Field { let mut packed = Field::zero(); // Pack score (u32) into the lowest 32 bits packed += Field::from(self.score) % 2.pow_32(0); // Pack round (u32) into the next 32 bits packed += Field::from(self.round) % 2.pow_32(32); // Pack started (bool) into the next bit (bit 64) packed += Field::from(self.started) % 2.pow_32(64); packed } ``` -------------------------------- ### Set Player Scores and Calculate Winner in Noir Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/developer_versioned_docs/version-v5.0.1/docs/tutorials/js_tutorials/webapp/01-the-contract.md Methods for updating player track scores and determining the game winner based on track-by-track comparisons. ```rust pub fn set_player_scores(self, player: AztecAddress, track1_final: u64, track2_final: u64, track3_final: u64, track4_final: u64, track5_final: u64) -> Race { let ret = if player.eq(self.player1) { assert( self.player1_track1_final + self.player1_track2_final + self.player1_track3_final + self.player1_track4_final + self.player1_track5_final == 0 ); Option::some(Self { player1: self.player1, player2: self.player2, total_rounds: self.total_rounds, player1_round: self.player1_round, player2_round: self.player2_round, player1_track1_final: track1_final, player1_track2_final: track2_final, player1_track3_final: track3_final, player1_track4_final: track4_final, player1_track5_final: track5_final, player2_track1_final: self.player2_track1_final, player2_track2_final: self.player2_track2_final, player2_track3_final: self.player2_track3_final, player2_track4_final: self.player2_track4_final, player2_track5_final: self.player2_track5_final, end_block: self.end_block, }) } else if player.eq(self.player2) { assert( self.player2_track1_final + self.player2_track2_final + self.player2_track3_final + self.player2_track4_final + self.player2_track5_final == 0 ); Option::some(Self { player1: self.player1, player2: self.player2, total_rounds: self.total_rounds, player1_round: self.player1_round, player2_round: self.player2_round, player1_track1_final: self.player1_track1_final, player1_track2_final: self.player1_track2_final, player1_track3_final: self.player1_track3_final, player1_track4_final: self.player1_track4_final, player1_track5_final: self.player1_track5_final, player2_track1_final: track1_final, player2_track2_final: track2_final, player2_track3_final: track3_final, player2_track4_final: track4_final, player2_track5_final: track5_final, end_block: self.end_block, }) } else { Option::none() }; ret.unwrap() } pub fn calculate_winner(self, current_block_number: u32) -> AztecAddress { assert(current_block_number > self.end_block); let mut player1_wins = 0; let mut player2_wins = 0; if self.player1_track1_final > self.player2_track1_final { player1_wins += 1; } else { player2_wins += 1; }; if self.player1_track2_final > self.player2_track2_final { player1_wins += 1; } else { player2_wins += 1; }; if self.player1_track3_final > self.player2_track3_final { player1_wins += 1; } else { player2_wins += 1; }; if self.player1_track4_final > self.player2_track4_final { player1_wins += 1; } else { player2_wins += 1; }; if self.player1_track5_final > self.player2_track5_final { player1_wins += 1; } else { player2_wins += 1; }; if (player1_wins > player2_wins) { self.player1 } else { self.player2 } } } ``` -------------------------------- ### getSyncedL2EpochNumber Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/typescript-api/mainnet/stdlib.md Returns the last L2 epoch number that has been fully synchronized from L1. ```APIDOC ## getSyncedL2EpochNumber() => Promise ### Description Returns the last fully synchronized L2 epoch number. ``` -------------------------------- ### Sample ROM Challenges Source: https://github.com/aztecprotocol/aztec-packages/blob/next/barretenberg/cpp/src/barretenberg/relations/ROM_README.md Sample the eta and rom_logup_gamma challenges from the transcript using the get_challenges function. ```cpp get_challenges({"eta", "rom_logup_gamma"}) ``` -------------------------------- ### Build Time Metrics (Median and 95th Percentile) Source: https://github.com/aztecprotocol/aztec-packages/blob/next/ci3/dashboard/ci-metrics/views/ci-health-report.html An array of objects showing the median (p50) and 95th percentile (p95) build times in weeks. ```javascript const BUILD_TIMES = [ {w:'W05', p50:31.0, p95:45.3}, {w:'W06', p50:32.2, p95:49.5}, {w:'W07', p50:33.6, p95:55.1}, ]; ``` -------------------------------- ### Update 'proposed' tag usage Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/developer_versioned_docs/version-v5.0.1/docs/resources/migration_notes.md Updates code relying on the old 'proposed' alias to use 'checkpointed' for confirmed checkpoint retrieval. ```diff - const cp = await node.getCheckpoint('proposed'); - const n = await node.getCheckpointNumber('proposed'); + const cp = await node.getCheckpoint('checkpointed'); + const n = await node.getCheckpointNumber('checkpointed'); ``` -------------------------------- ### fn x5_5 Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/testnet/poseidon/poseidon/bn254/perm/fn.x5_5.html Performs a Poseidon permutation on a state of 5 Field elements. ```APIDOC ## Function: x5_5 ### Description Performs the Poseidon permutation operation on a state consisting of 5 Field elements. This is part of the cryptographic primitives for the BN254 curve. ### Signature `pub fn x5_5(state: [Field; 5]) -> [Field; 5]` ### Parameters - **state** ([Field; 5]) - The input state array of 5 Field elements to be permuted. ### Returns - **[Field; 5]** - The resulting state array after the permutation. ``` -------------------------------- ### Shplemini Shifted Polynomial Scalars Source: https://github.com/aztecprotocol/aztec-packages/blob/next/barretenberg/cpp/src/barretenberg/commitment_schemes/shplonk/README.md Details the scalar formulas used in Shplemini for unshifted and shifted polynomials, highlighting the mathematical difference that accounts for the $ 1/X $ factor in shifted polynomials. ```plaintext | Batch | Scalar Formula | |-------|----------------| | Unshifted $ f $ | $ \frac{1}{z-r} + \frac{\nu}{z+r} $ | | Shifted $ g = f/X $ | $ \frac{1}{r}\left(\frac{1}{z-r} - \frac{\nu}{z+r}\right) $ | ``` -------------------------------- ### hash_15 Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/poseidon/poseidon/bn254/fn.hash_15.html Computes a Poseidon hash for an array of 15 fields using the bn254 curve. ```APIDOC ## hash_15 ### Description Computes a Poseidon hash for an array of 15 fields. ### Signature `pub fn hash_15(input: [Field; 15]) -> Field` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **input** ([Field; 15]) - Required - An array of 15 fields to be hashed. ``` -------------------------------- ### Deploy with BatchCall Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/developer_versioned_docs/version-v5.0.1/docs/aztec-js/how_to_deploy_contract.md Bundles a contract deployment and subsequent method calls into a single transaction using BatchCall. ```typescript // Create a contract instance and make the PXE aware of it const deployMethod = StatefulTestContract.deploy(wallet, owner, 42, { deployer: defaultAccountAddress }); const contract = await deployMethod.register(); // Batch deployment and a public call into the same transaction const publicCall = contract.methods.increment_public_value(owner, 84); await new BatchCall(wallet, [deployMethod, publicCall]).send({ from: defaultAccountAddress }); ``` -------------------------------- ### pub fn x5_11(state: [Field; 11]) -> [Field; 11] Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/testnet/poseidon/poseidon/bn254/perm/fn.x5_11.html The x5_11 function performs a Poseidon permutation on a state array of 11 Field elements. ```APIDOC ## Function: x5_11 ### Description Performs a Poseidon permutation on a state of 11 Field elements. This is part of the internal cryptographic primitives for the BN254 curve implementation in Noir. ### Signature `pub fn x5_11(state: [Field; 11]) -> [Field; 11]` ### Parameters - **state** ([Field; 11]) - The input state array consisting of 11 Field elements to be permuted. ### Returns - **[Field; 11]** - The resulting state array after the permutation. ``` -------------------------------- ### Construct Final Decider Proof Source: https://github.com/aztecprotocol/aztec-packages/blob/next/barretenberg/cpp/src/barretenberg/chonk/README.md Generates the final proof after all folding operations are complete using the HypernovaDeciderProver. ```cpp HypernovaDeciderProver decider_prover(transcript); HonkProof decider_proof = decider_prover.construct_proof(commitment_key, accumulator); ``` -------------------------------- ### Eq Implementation for HintedNote Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/noir_aztec/note/struct.HintedNote.html Implements the equality comparison for HintedNote. This requires the generic Note type to also implement Eq. ```rust pub fn eq(_self: Self, _other: Self) -> [bool](../../std/primitive.bool.html) ``` -------------------------------- ### Calculate Time in Mesh (P1) Score Source: https://github.com/aztecprotocol/aztec-packages/blob/next/yarn-project/p2p/src/services/gossipsub/README.md Defines the slot-based normalization for P1 scores, which rewards peers for time spent in the mesh. ```typescript timeInMeshQuantum = slotDurationMs // Score increases by ~1 per slot timeInMeshCap = 3600 / slotDurationSeconds // Cap at 1 hour (50 slots for 72s slots) timeInMeshWeight = MAX_P1_SCORE / cap // Normalized so max P1 = 8 ``` -------------------------------- ### GameRoundNote Struct Definition Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/docs-developers/docs/tutorials/js_tutorials/webapp/01-the-contract.md Defines the private GameRoundNote struct used to store a player's point allocation for a single round in the Pod Racing game. ```rust struct GameRoundNote { owner: Field, round: u8, track1: u16, track2: u16, track3: u16, track4: u16, track5: u16, } ``` -------------------------------- ### Activating Relation Conditioned by Boolean Disjunction Source: https://github.com/aztecprotocol/aztec-packages/blob/next/barretenberg/cpp/pil/vm2/docs/recipes.md Explains how to activate a relation based on any of several boolean selectors being true. This is useful for conditional execution paths within the circuit. ```mathematica (q_1 + q_2 + q_3 ...)P() = 0 ``` -------------------------------- ### x5_10_config Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/poseidon/poseidon/bn254/consts/fn.x5_10_config.html Provides the configuration for the Poseidon hash function with 10 inputs and 140 rounds. This configuration is specific to the bn254 curve and is part of the consts module. ```APIDOC ## x5_10_config() ### Description Provides the configuration for the Poseidon hash function with 10 inputs and 140 rounds. This configuration is specific to the bn254 curve and is part of the consts module. ### Signature `pub fn x5_10_config() -> PoseidonConfig<10, 140, 1140>` ### Returns A `PoseidonConfig` struct containing the parameters for the Poseidon hash function with 10 inputs and 140 rounds. ``` -------------------------------- ### PrivateExecutionProfileResult Constructor Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/typescript-api/mainnet/stdlib.md Initializes a new profile result object containing timing information for oracles and witness generation. ```typescript new PrivateExecutionProfileResult(timings: { oracles?: Record; witgen: number }) ``` -------------------------------- ### sponge Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/poseidon/poseidon/bn254/index.html Performs a sponge operation with Poseidon. ```APIDOC ## sponge ### Description Performs a sponge operation with Poseidon. ### Function Signature `sponge(inputs: [Field], rate: u16, capacity: u16)` ### Parameters * **inputs** (Array) - An array of field elements to be absorbed. * **rate** (u16) - The rate of the sponge. * **capacity** (u16) - The capacity of the sponge. ``` -------------------------------- ### Deserialize Implementation for HintedNote Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/noir_aztec/note/struct.HintedNote.html Provides methods for deserializing a HintedNote from a sequence of fields or a stream. This implementation requires the generic Note type to also implement Deserialize. ```rust pub fn deserialize(fields: [[Field](../../std/primitive.Field.html); <(resolved type) as Deserialize>::N + 6]) -> Self ``` ```rust pub fn stream_deserialize(reader: &mut [Reader](../../serde/reader/struct.Reader.html)) -> Self ``` -------------------------------- ### LogUp Term Encoding with Challenges Source: https://github.com/aztecprotocol/aztec-packages/blob/next/barretenberg/cpp/src/barretenberg/relations/LOGUP_README.md Encodes lookup and table terms using independent challenges gamma (offset) and beta (column batching). Derived terms are computed using the accumulator trick. ```plaintext W = γ + (table_1 + table_2·β + table_3·β² + table_4·β³) R = γ + (derived_1 + derived_2·β + derived_3·β² + table_index·β³) where `derived_i = w_i + step_size_i · w_i_shift` ``` -------------------------------- ### Packable Implementation for FieldNote Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/field_note/struct.FieldNote.html Provides methods for packing and unpacking a FieldNote into a slice of Fields. ```rust pub fn pack(self) -> [Field; 1]> ``` ```rust pub fn unpack(packed: [Field; 1]) -> Self> ``` -------------------------------- ### permute(pos_conf: PoseidonConfig, state: [Field; T]) -> [Field; T] Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/testnet/poseidon/poseidon/fn.permute.html Performs the Poseidon permutation on the provided state array using the given configuration. ```APIDOC ## Function: permute ### Description Performs a Poseidon permutation on a state array of type `[Field; T]` using the provided `PoseidonConfig`. ### Signature `pub fn permute(pos_conf: PoseidonConfig, state: [Field; T]) -> [Field; T]` ### Parameters - **pos_conf** (`PoseidonConfig`) - The configuration parameters for the Poseidon permutation. - **state** (`[Field; T]`) - The input state array to be permuted. ### Returns - `[Field; T]` - The resulting state array after the permutation. ``` -------------------------------- ### SerializeToColumns Trait Definition Source: https://github.com/aztecprotocol/aztec-packages/blob/next/docs/static/aztec-nr-api/mainnet/noir_aztec/protocol/proof/traits/trait.SerializeToColumns.html Defines the SerializeToColumns trait with a generic parameter N for the number of columns. It requires implementing types to provide a `serialize_to_columns` method. ```rust pub trait SerializeToColumns { // Required methods pub fn serialize_to_columns(self) -> [Field; N]; } ``` -------------------------------- ### Checkpoint Proposal Preparation Constraint Source: https://github.com/aztecprotocol/aztec-packages/blob/next/yarn-project/stdlib/src/timetable/README.md Defines the time required to prepare a checkpoint proposal. ```text checkpoint_proposal_send_time - last_block_build_time = checkpoint_proposal_prepare_time ```