Skip to content

Commit

Permalink
Update unit tests to support the code modifications related to backwa…
Browse files Browse the repository at this point in the history
…rd compatability
  • Loading branch information
dmidem committed Feb 26, 2024
1 parent 067eca5 commit 4cc1473
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 53 deletions.
2 changes: 1 addition & 1 deletion halo2_gadgets/src/ecc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ pub(crate) mod tests {
meta,
advices[9],
lookup_table,
table_range_check_tag,
Some(table_range_check_tag),
);
EccChip::<TestFixedBases>::configure(meta, advices, lagrange_coeffs, range_check)
}
Expand Down
4 changes: 2 additions & 2 deletions halo2_gadgets/src/ecc/chip/mul_fixed/short.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ pub mod tests {
meta,
advices[9],
lookup_table,
table_range_check_tag,
Some(table_range_check_tag),
);
EccChip::<TestFixedBases>::configure(meta, advices, lagrange_coeffs, range_check)
}
Expand Down Expand Up @@ -853,7 +853,7 @@ pub mod tests {
meta,
advices[9],
lookup_table,
table_range_check_tag,
Some(table_range_check_tag),
);
EccChip::<TestFixedBases>::configure(meta, advices, lagrange_coeffs, range_check)
}
Expand Down
4 changes: 2 additions & 2 deletions halo2_gadgets/src/sinsemilla.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,14 +658,14 @@ pub(crate) mod tests {
table_idx,
meta.lookup_table_column(),
meta.lookup_table_column(),
table_range_check_tag,
Some(table_range_check_tag),
);

let range_check = LookupRangeCheckConfig::configure(
meta,
advices[9],
table_idx,
table_range_check_tag,
Some(table_range_check_tag),
);

let ecc_config =
Expand Down
2 changes: 1 addition & 1 deletion halo2_gadgets/src/sinsemilla/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ pub mod tests {
meta.lookup_table_column(),
meta.lookup_table_column(),
meta.lookup_table_column(),
meta.lookup_table_column(),
Some(meta.lookup_table_column()),
);

let range_check =
Expand Down
2 changes: 1 addition & 1 deletion halo2_gadgets/src/utilities/cond_swap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ mod tests {
meta,
advices[9],
table_idx,
table_range_check_tag,
Some(table_range_check_tag),
);

let ecc_config = EccChip::<TestFixedBases>::configure(
Expand Down
110 changes: 64 additions & 46 deletions halo2_gadgets/src/utilities/lookup_range_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,50 +219,68 @@ impl<F: PrimeFieldBits, const K: usize> LookupRangeCheckConfig<F, K> {
layouter.assign_table(
|| "table_idx",
|mut table| {
// We generate the row values lazily (we only need them during keygen).
for index in 0..(1 << K) {
table.assign_cell(
|| "table_idx",
self.table_idx,
index,
|| Value::known(F::from(index as u64)),
)?;
table.assign_cell(
|| "table_range_check_tag",
self.table_range_check_tag,
index,
|| Value::known(F::ZERO),
)?;
}
for index in 0..(1 << 4) {
let new_index = index + (1 << K);
table.assign_cell(
|| "table_idx",
self.table_idx,
new_index,
|| Value::known(F::from(index as u64)),
)?;
table.assign_cell(
|| "table_range_check_tag",
self.table_range_check_tag,
new_index,
|| Value::known(F::from(4_u64)),
)?;
}
for index in 0..(1 << 5) {
let new_index = index + (1 << K) + (1 << 4);
table.assign_cell(
|| "table_idx",
self.table_idx,
new_index,
|| Value::known(F::from(index as u64)),
)?;
table.assign_cell(
|| "table_range_check_tag",
self.table_range_check_tag,
new_index,
|| Value::known(F::from(5_u64)),
)?;
match self.zsa {
// Non-ZSA variant
None => {
// We generate the row values lazily (we only need them during keygen).
for index in 0..(1 << K) {
table.assign_cell(
|| "table_idx",
self.table_idx,
index,
|| Value::known(F::from(index as u64)),
)?;
}
}

// ZSA variant
Some(zsa) => {
// We generate the row values lazily (we only need them during keygen).
for index in 0..(1 << K) {
table.assign_cell(
|| "table_idx",
self.table_idx,
index,
|| Value::known(F::from(index as u64)),
)?;
table.assign_cell(
|| "table_range_check_tag",
zsa.table_range_check_tag,
index,
|| Value::known(F::ZERO),
)?;
}
for index in 0..(1 << 4) {
let new_index = index + (1 << K);
table.assign_cell(
|| "table_idx",
self.table_idx,
new_index,
|| Value::known(F::from(index as u64)),
)?;
table.assign_cell(
|| "table_range_check_tag",
zsa.table_range_check_tag,
new_index,
|| Value::known(F::from(4_u64)),
)?;
}
for index in 0..(1 << 5) {
let new_index = index + (1 << K) + (1 << 4);
table.assign_cell(
|| "table_idx",
self.table_idx,
new_index,
|| Value::known(F::from(index as u64)),
)?;
table.assign_cell(
|| "table_range_check_tag",
zsa.table_range_check_tag,
new_index,
|| Value::known(F::from(5_u64)),
)?;
}
}
}
Ok(())
},
Expand Down Expand Up @@ -539,7 +557,7 @@ mod tests {
meta,
running_sum,
table_idx,
table_range_check_tag,
Some(table_range_check_tag),
)
}

Expand Down Expand Up @@ -644,7 +662,7 @@ mod tests {
meta,
running_sum,
table_idx,
table_range_check_tag,
Some(table_range_check_tag),
)
}

Expand Down

0 comments on commit 4cc1473

Please sign in to comment.