Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
Simplify bytecode circuit assignment (#1397)
Browse files Browse the repository at this point in the history
### Description

We simplify the assignment logic in the bytecode circuit by reducing the
number of function arguments. The reduction is achieved by

1. Construct IsZero Chips early and make them a part of the circuit
struct so that they don't stay with the function arguments.
2. Create a new row struct that carries all the relevant data.

### Issue Link

This would be part of #1391. 

### Type of change

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update

### Rationale

- I avoid using `BytecodeRow` in the `bytecode_unroller` since they are
part of the future simplification plan.


### How Has This Been Tested?

Sent to the CI and pray.
  • Loading branch information
ChihChengLiang authored May 10, 2023
1 parent b8ae7af commit fbbe1bd
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 140 deletions.
7 changes: 6 additions & 1 deletion gadgets/src/is_zero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ impl<F: Field> IsZeroConfig<F> {
}
}

#[derive(Debug, Clone)]
/// Wrapper arround [`IsZeroConfig`] for which [`Chip`] is implemented.
pub struct IsZeroChip<F> {
config: IsZeroConfig<F>,
}

#[rustfmt::skip]
impl<F: Field> IsZeroChip<F> {
/// Sets up the configuration of the chip by creating the required columns
Expand Down Expand Up @@ -105,6 +105,11 @@ impl<F: Field> IsZeroChip<F> {
pub fn construct(config: IsZeroConfig<F>) -> Self {
IsZeroChip { config }
}

/// Annotates columns of this gadget embedded within a circuit region.
pub fn annotate_columns_in_region(&self, region: &mut Region<F>, prefix: &str) {
self.config.annotate_columns_in_region(region, prefix)
}
}

impl<F: Field> IsZeroInstruction<F> for IsZeroChip<F> {
Expand Down
Loading

0 comments on commit fbbe1bd

Please sign in to comment.