Use Rust macros to simplify halo2-lib-wasm
rpalakkal opened this issue · 0 comments
rpalakkal commented
Currently, wrapping most halo2-lib functions in (halo2-lib-wasm)[https://github.com/axiom-crypto/halo2-browser/blob/22f80b8ff2fd18648277885c32cc02329d314aae/halo2-wasm/src/halo2lib.rs] has a very similar process. For example, take a look at the mul
and add
functions (a lot of the functions follow this same pattern):
pub fn mul(&mut self, a: usize, b: usize) -> usize {
let a = self.get_assigned_value(a);
let b = self.get_assigned_value(b);
let out = self.gate.mul(self.builder.borrow_mut().main(0), a, b);
self.to_js_assigned_value(out)
}
pub fn add(&mut self, a: usize, b: usize) -> usize {
let a = self.get_assigned_value(a);
let b = self.get_assigned_value(b);
let out = self.gate.add(self.builder.borrow_mut().main(0), a, b);
self.to_js_assigned_value(out)
}
Generally, we get the AssignedValue<Fr>
of all the inputs by their cell idx, perform the halo2-lib
circuit operation, and then get the cell idx of the result and return it.
Can we write a Rust macro to automate (or at least further simplify) wrapping halo2-lib
functions?