Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(nifs): remaster permutation in PlonkStructure #351

Merged
merged 5 commits into from
Sep 30, 2024

Conversation

cyphersnake
Copy link
Collaborator

@cyphersnake cyphersnake commented Sep 24, 2024

Motivation
As part of #316, we will need to remove some copy constraints before checking for correctness. To achieve this, I saved the information needed to build the matrix and built it on demand.

Next PR will add copy constraint cutout

Overview
This PR refactors the PlonkStructure by introducing the PermutationData struct to manage permutation matrix data. It replaces direct usage of SparseMatrix with a method to construct the permutation matrix on demand.

@cyphersnake cyphersnake requested a review from chaosma September 24, 2024 13:43
@cyphersnake cyphersnake self-assigned this Sep 24, 2024
Base automatically changed from 316-refactor-relaxed-plonk-instance to main September 25, 2024 05:11
**Motivation**
As part of #316, we will need to remove some copy constraints before
checking for correctness. To achieve this, I saved the information
needed to build the matrix and built it on demand.

Следующий PR добавит вырезание copy constraint

**Overview**
This PR refactors the `PlonkStructure` by introducing the `PermutationData`
struct to manage permutation matrix data. It replaces direct usage of
`SparseMatrix` with a method to construct the permutation matrix on demand.
@cyphersnake cyphersnake force-pushed the 316-refactoring-permutation branch from 255876a to 143fd38 Compare September 25, 2024 13:37
**Motivation**
Since the path chosen under #316 is to translate the copy constraint on
the instance column of the step-circuit to a private input (by
additional copy-constraint), we also need to cut the original copy
constraints before checking permutation, which is what this PR does

**Overview**
This PR makes significant changes to how copy constraints are handled within
the step-circuit and their impact on permutation checks in our proof system:

1. **Removal of Original Copy Constraints**:
   - Introduced a mechanism to remove copy constraints on instance columns before permutation checks.
   - Added the function `rm_copy_constraints` to the `PermutationData` structure to filter out specific instance columns from permutation mappings.

2. **Adjusted Permutation Data Handling**:
   - Added the function `permutation_data_without_step_circuit_instances` to manage permutation data, ensuring non-essential instance columns are excluded from permutations.
   - This ensures that only the consistency markers instance column are considered during the permutation checks.

3. **Instance Column Accumulation**:
   - Updated the `iter_flat_instances_with_padding` function to handle the accumulation of instance columns correctly.
   - Ensures that instance columns are aligned correctly, padding as necessary based on the structure’s configuration.

4. **Algorithm for Copy Constraint Removal**:
   - Implemented a detailed algorithm to remove copy constraints from the permutation mapping, preserving the integrity of remaining columns.
   - Ensures that permutation cycles are correctly maintained even after certain instance columns have been excluded.

These changes are hand-tested due to current constraints on the number of instance columns within the step-circuit. Further adjustments and instance accumulation will be addressed in future updates.

NOTE: Please pay special attention to the algorithm for cutting non-target copy-constraint. I am currently writing a test to double-check by phasing the data, but it is better to make sure that the algorithm is correct by hand too
cyphersnake and others added 2 commits September 30, 2024 13:00
**Motivation**
As part of #316, we need to accumulate `instance`, using a poseidon
hash. This PR should provide a consistent way to do this
{on,off}-circuit within nifs::vanilla

**Overview**
- New Module
- Added `instances_accumulator_computation.rs` to handle the
accumulation of `instances` using the Poseidon hash function.
- Functions:
- `fold_step_circuit_instances_hash_accumulator` for off-circuit hash
accumulation.
- `fold_assign_step_circuit_instances_hash_accumulator` for on-circuit
hash accumulation
- Testing:
- Added comprehensive unit tests to verify the consistency of the
accumulator computation.
**Motivation**
As part of #316, we will need to remove some copy constraints before
checking for correctness. To achieve this, I saved the information
needed to build the matrix and built it on demand.

Следующий PR добавит вырезание copy constraint

**Overview**
This PR refactors the `PlonkStructure` by introducing the `PermutationData`
struct to manage permutation matrix data. It replaces direct usage of
`SparseMatrix` with a method to construct the permutation matrix on demand.
@cyphersnake cyphersnake force-pushed the 316-refactoring-permutation branch from 172c7e0 to 475e9a8 Compare September 30, 2024 11:09
@cyphersnake cyphersnake merged commit ca9b784 into main Sep 30, 2024
1 check passed
@cyphersnake cyphersnake deleted the 316-refactoring-permutation branch September 30, 2024 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants