Skip to content

Commit

Permalink
add optimization comment
Browse files Browse the repository at this point in the history
  • Loading branch information
iammadab committed Jun 27, 2024
1 parent ca607d2 commit d0e1d06
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions singer-utils/src/uint/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ impl<const M: usize, const C: usize> AddSubConstants<UInt<M, C>> {

pub const N_NO_OVERFLOW_WITNESS_UNSAFE_CELLS: usize = Self::N_CARRY_CELLS_NO_OVERFLOW;

// /// The number of `RANGE_CHIP_BIT_WIDTH` cells needed to represent the carry cells, assuming
// /// no overflow.
// pub const N_RANGE_CELLS_IN_CARRY_NO_OVERFLOW: usize =
// Self::N_CARRY_CELLS_NO_OVERFLOW * UInt::<M, C>::N_RANGE_CELLS_PER_CELL;

/// The number of `RANGE_CHIP_BIT_WIDTH` cells needed to represent the carry cells, assuming
/// no overflow.
// TODO: if guaranteed no overflow, then we don't need to range check the highest limb
// hence this can be (N_OPERANDS - 1) * N_RANGE_CELLS_PER_CELL
// update this once, range check logic doesn't assume all limbs
pub const N_RANGE_CELLS_IN_CARRY_NO_OVERFLOW: usize = UInt::<M, C>::N_RANGE_CELLS;
}
4 changes: 2 additions & 2 deletions singer-utils/src/uint/witness_extractors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ impl<const M: usize, const C: usize> UInt<M, C> {
}

pub fn extract_carry_no_overflow(witness: &[CellId]) -> &[CellId] {
&witness[Self::N_RANGE_CELLS..]
&witness[AddSubConstants::<Self>::N_RANGE_CELLS_IN_CARRY_NO_OVERFLOW..]
}

// TODO: why do we need this
Expand All @@ -33,6 +33,6 @@ impl<const M: usize, const C: usize> UInt<M, C> {
}

pub fn extract_range_values_no_overflow(witness: &[CellId]) -> &[CellId] {
&witness[..Self::N_RANGE_CELLS]
&witness[..AddSubConstants::<Self>::N_RANGE_CELLS_IN_CARRY_NO_OVERFLOW]
}
}

0 comments on commit d0e1d06

Please sign in to comment.