From 4fb5825f7e8447d1d90958be8ba3b8f01721f255 Mon Sep 17 00:00:00 2001 From: 0xisk <0xisk@proton.me> Date: Mon, 25 Mar 2024 06:55:58 +0100 Subject: [PATCH 1/3] fix: halo2-wasm template struct name --- halo2-wasm/template/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/halo2-wasm/template/src/lib.rs b/halo2-wasm/template/src/lib.rs index 91efbf0..d1c5e5c 100644 --- a/halo2-wasm/template/src/lib.rs +++ b/halo2-wasm/template/src/lib.rs @@ -18,7 +18,7 @@ impl MyCircuit { #[wasm_bindgen(constructor)] pub fn new(circuit: &Halo2Wasm) -> Self { let gate = GateChip::new(); - Halo2WasmTemplate { + MyCircuit { gate, builder: Arc::clone(&circuit.circuit), } From b77662e618092a41302abf4efcb67856107e3479 Mon Sep 17 00:00:00 2001 From: 0xisk <0xisk@proton.me> Date: Wed, 27 Mar 2024 07:19:50 +0100 Subject: [PATCH 2/3] fix: renaming template constructor param --- halo2-wasm/template/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/halo2-wasm/template/src/lib.rs b/halo2-wasm/template/src/lib.rs index d1c5e5c..ef0fa99 100644 --- a/halo2-wasm/template/src/lib.rs +++ b/halo2-wasm/template/src/lib.rs @@ -16,11 +16,11 @@ pub struct MyCircuit { #[wasm_bindgen] impl MyCircuit { #[wasm_bindgen(constructor)] - pub fn new(circuit: &Halo2Wasm) -> Self { + pub fn new(halo2_wasm: &Halo2Wasm) -> Self { let gate = GateChip::new(); MyCircuit { gate, - builder: Arc::clone(&circuit.circuit), + builder: Arc::clone(&halo2_wasm.circuit), } } From 0f5b1fcc2c663b007892f0c1a8a63b4606c21d21 Mon Sep 17 00:00:00 2001 From: 0xisk <0xisk@proton.me> Date: Wed, 27 Mar 2024 08:42:46 +0100 Subject: [PATCH 3/3] fix: renaming Halo2Wasm and Halo2LibWasm param names --- halo2-wasm/src/halo2lib.rs | 16 +++++++-------- halo2-wasm/src/halo2lib/ecc.rs | 36 +++++++++++++++++----------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/halo2-wasm/src/halo2lib.rs b/halo2-wasm/src/halo2lib.rs index da84507..7d03764 100644 --- a/halo2-wasm/src/halo2lib.rs +++ b/halo2-wasm/src/halo2lib.rs @@ -42,17 +42,17 @@ pub struct Halo2LibWasm { #[wasm_bindgen] impl Halo2LibWasm { #[wasm_bindgen(constructor)] - pub fn new(circuit: &Halo2Wasm) -> Self { + pub fn new(halo2_wasm: &Halo2Wasm) -> Self { let gate = GateChip::new(); - let lookup_bits = circuit.circuit_params.clone().unwrap().lookup_bits.unwrap(); + let lookup_bits = halo2_wasm.circuit_params.clone().unwrap().lookup_bits.unwrap(); let range = RangeChip::new( lookup_bits, - circuit.circuit.borrow().lookup_manager().clone(), + halo2_wasm.circuit.borrow().lookup_manager().clone(), ); Halo2LibWasm { gate, range, - builder: Rc::clone(&circuit.circuit), + builder: Rc::clone(&halo2_wasm.circuit), } } @@ -470,16 +470,16 @@ impl Halo2LibWasm { self.to_js_assigned_value(constant) } - pub fn make_public(&mut self, circuit: &mut Halo2Wasm, a: usize, col: usize) { + pub fn make_public(&mut self, halo2_wasm: &mut Halo2Wasm, a: usize, col: usize) { let a = self.get_assigned_value(a); - let public = circuit.public.get_mut(col).unwrap(); + let public = halo2_wasm.public.get_mut(col).unwrap(); public.push(a); } - pub fn log(&mut self, circuit: &Halo2Wasm, a: usize) { + pub fn log(&mut self, halo2_wasm: &Halo2Wasm, a: usize) { let val = self.value(a); unsafe { - circuit.log(val); + halo2_wasm.log(val); } } diff --git a/halo2-wasm/src/halo2lib/ecc.rs b/halo2-wasm/src/halo2lib/ecc.rs index 1350c92..401c0a7 100644 --- a/halo2-wasm/src/halo2lib/ecc.rs +++ b/halo2-wasm/src/halo2lib/ecc.rs @@ -36,12 +36,12 @@ type FqPoint = ProperCrtUint; pub struct Bn254FqPoint(ProperCrtUint); #[wasm_bindgen] impl Bn254FqPoint { - fn to_hi_lo(&self, lib_wasm: &Halo2LibWasm) -> [AssignedValue; 2] { - convert_3limbs88bits_to_hi_lo(lib_wasm, self.0.limbs()) + fn to_hi_lo(&self, halo2_lib_wasm: &Halo2LibWasm) -> [AssignedValue; 2] { + convert_3limbs88bits_to_hi_lo(halo2_lib_wasm, self.0.limbs()) } - pub fn to_circuit_value_256(&self, lib_wasm: &Halo2LibWasm) -> JsCircuitValue256 { - let [hi, lo] = self.to_hi_lo(lib_wasm); - let [hi, lo] = [hi, lo].map(|x| lib_wasm.to_js_assigned_value(x)); + pub fn to_circuit_value_256(&self, halo2_lib_wasm: &Halo2LibWasm) -> JsCircuitValue256 { + let [hi, lo] = self.to_hi_lo(halo2_lib_wasm); + let [hi, lo] = [hi, lo].map(|x| halo2_lib_wasm.to_js_assigned_value(x)); JsCircuitValue256 { hi, lo } } } @@ -96,12 +96,12 @@ impl Bn254G2AffinePoint { pub struct Secp256k1FpPoint(ProperCrtUint); #[wasm_bindgen] impl Secp256k1FpPoint { - fn to_hi_lo(&self, lib_wasm: &Halo2LibWasm) -> [AssignedValue; 2] { - convert_3limbs88bits_to_hi_lo(lib_wasm, self.0.limbs()) + fn to_hi_lo(&self, halo2_lib_wasm: &Halo2LibWasm) -> [AssignedValue; 2] { + convert_3limbs88bits_to_hi_lo(halo2_lib_wasm, self.0.limbs()) } - pub fn to_circuit_value_256(&self, lib_wasm: &Halo2LibWasm) -> JsCircuitValue256 { - let [hi, lo] = self.to_hi_lo(lib_wasm); - let [hi, lo] = [hi, lo].map(|x| lib_wasm.to_js_assigned_value(x)); + pub fn to_circuit_value_256(&self, halo2_lib_wasm: &Halo2LibWasm) -> JsCircuitValue256 { + let [hi, lo] = self.to_hi_lo(halo2_lib_wasm); + let [hi, lo] = [hi, lo].map(|x| halo2_lib_wasm.to_js_assigned_value(x)); JsCircuitValue256 { hi, lo } } } @@ -114,12 +114,12 @@ impl Secp256k1FpPoint { pub struct Secp256k1FqPoint(ProperCrtUint); #[wasm_bindgen] impl Secp256k1FqPoint { - fn to_hi_lo(&self, lib_wasm: &Halo2LibWasm) -> [AssignedValue; 2] { - convert_3limbs88bits_to_hi_lo(lib_wasm, self.0.limbs()) + fn to_hi_lo(&self, halo2_lib_wasm: &Halo2LibWasm) -> [AssignedValue; 2] { + convert_3limbs88bits_to_hi_lo(halo2_lib_wasm, self.0.limbs()) } - pub fn to_circuit_value_256(&self, lib_wasm: &Halo2LibWasm) -> JsCircuitValue256 { - let [hi, lo] = self.to_hi_lo(lib_wasm); - let [hi, lo] = [hi, lo].map(|x| lib_wasm.to_js_assigned_value(x)); + pub fn to_circuit_value_256(&self, halo2_lib_wasm: &Halo2LibWasm) -> JsCircuitValue256 { + let [hi, lo] = self.to_hi_lo(halo2_lib_wasm); + let [hi, lo] = [hi, lo].map(|x| halo2_lib_wasm.to_js_assigned_value(x)); JsCircuitValue256 { hi, lo } } } @@ -519,14 +519,14 @@ fn constrain_limbs_equality( } fn convert_3limbs88bits_to_hi_lo( - lib_wasm: &Halo2LibWasm, + halo2_lib_wasm: &Halo2LibWasm, limbs: &[AssignedValue], ) -> [AssignedValue; 2] { assert_eq!(limbs.len(), 3); let lo_bits = 128 - 88; let hi_bits = 88 - lo_bits; - let mut builder = lib_wasm.builder.borrow_mut(); - let range = &lib_wasm.range; + let mut builder = halo2_lib_wasm.builder.borrow_mut(); + let range = &halo2_lib_wasm.range; let gate = &range.gate; let ctx = builder.main(0); let (limb1_hi, limb1_lo) = range.div_mod(ctx, limbs[1], BigUint::one() << lo_bits, 88);