From beccc39ff9190e740871235f28e3f8f04f956ecd Mon Sep 17 00:00:00 2001 From: Soham Zemse <22412996+zemse@users.noreply.github.com> Date: Wed, 24 Jan 2024 11:55:49 +0530 Subject: [PATCH 1/2] add `get_lower_128` with impl to `ScalarField` trait --- halo2-base/src/utils/mod.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/halo2-base/src/utils/mod.rs b/halo2-base/src/utils/mod.rs index 98d80870..4a71be58 100644 --- a/halo2-base/src/utils/mod.rs +++ b/halo2-base/src/utils/mod.rs @@ -86,6 +86,16 @@ pub trait ScalarField: PrimeField + FromUniformBytes<64> + From + 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 From 4ecafa378f630e868cfa2d615bc69f6c5736bba4 Mon Sep 17 00:00:00 2001 From: Soham Zemse <22412996+zemse@users.noreply.github.com> Date: Tue, 13 Feb 2024 12:06:10 +0530 Subject: [PATCH 2/2] fix warning --- halo2-base/src/gates/circuit/builder.rs | 3 +++ halo2-base/src/utils/halo2.rs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/halo2-base/src/gates/circuit/builder.rs b/halo2-base/src/gates/circuit/builder.rs index dabd50f1..4d49be7d 100644 --- a/halo2-base/src/gates/circuit/builder.rs +++ b/halo2-base/src/gates/circuit/builder.rs @@ -302,7 +302,10 @@ impl BaseCircuitBuilder { 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(); } } } diff --git a/halo2-base/src/utils/halo2.rs b/halo2-base/src/utils/halo2.rs index 750787f1..78219d12 100644 --- a/halo2-base/src/utils/halo2.rs +++ b/halo2-base/src/utils/halo2.rs @@ -100,7 +100,10 @@ pub fn constrain_virtual_equals_external( 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