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

add util and fix warning when compiling with halo2-pse feature mode #253

Merged
merged 2 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions halo2-base/src/gates/circuit/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,10 @@ impl<F: ScalarField> BaseCircuitBuilder<F> {
let copy_manager = self.core.copy_manager.lock().unwrap();
let cell =
copy_manager.assigned_advices.get(&cell).expect("instance not assigned");
#[cfg(feature = "halo2-axiom")]
layouter.constrain_instance(*cell, *instance_col, i);
#[cfg(not(feature = "halo2-axiom"))]
layouter.constrain_instance(*cell, *instance_col, i).unwrap();
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions halo2-base/src/utils/halo2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ pub fn constrain_virtual_equals_external<F: Field + Ord>(
match copy_manager.assigned_advices.entry(ctx_cell) {
Entry::Occupied(acell) => {
// The virtual cell has already been assigned, so we can constrain it to equal the external cell.
#[cfg(feature = "halo2-axiom")]
region.constrain_equal(*acell.get(), external_cell);
#[cfg(not(feature = "halo2-axiom"))]
region.constrain_equal(*acell.get(), external_cell).unwrap();
}
Entry::Vacant(assigned) => {
// The virtual cell **must** be an external cell
Expand Down
10 changes: 10 additions & 0 deletions halo2-base/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ pub trait ScalarField: PrimeField + FromUniformBytes<64> + From<bool> + Hash + O
}
lower_64
}

/// Gets the least significant 128 bits of the field element.
fn get_lower_128(&self) -> u128 {
let bytes = self.to_bytes_le();
let mut lower_128 = 0u128;
for (i, byte) in bytes.into_iter().enumerate().take(16) {
lower_128 |= (byte as u128) << (i * 8);
}
lower_128
}
}
// See below for implementations

Expand Down
Loading