-
Notifications
You must be signed in to change notification settings - Fork 17
Description
As per title. While this might be intentional design, causes some confusion and inconsistencies when trying to use both in our codebase.
Some context: we're trying to change Scroll's poseidon-circuit library to point to Axiom's halo2 backend. Later, we'd like to make a custom builder that combines halo2 & halo2-lib circuit creations, inspired by zkevm-keccak (as discussed offline with @nyunyunyunyu). Then, whenever there's hashing in our circuit, use the optimized cell assignment from Scroll's adaptation that we're working on, rather than the Chip currently in community-edition that uses vertical gates under the hood.
Here's our current attempt with @Antonio95:
https://github.com/HungryCatsStudio/poseidon-circuit/tree/axiom-backend.
We have run into the following issue: Axiom's region.assign_advice_from_constant has the following prototype
pub fn assign_advice_from_constant<VR, A, AR>(
&mut self,
annotation: A,
column: Column<Advice>,
offset: usize,
constant: VR,
) -> Result<AssignedCell<VR, F>, Error>
where
for<'vr> Assigned<F>: From<&'vr VR>,
A: Fn() -> AR,
AR: Into<String>,
This is in contrast to analogous Region methods such as
pub fn assign_advice<'v>(
...
) -> AssignedCell<&'v Assigned<F>, F>;
The return type of assign_advice_from_constant is causing an inconsistency in our code: we would like to be able to call assign_advice and assign_advice_from_constant and get the same return type. See:
https://github.com/HungryCatsStudio/poseidon-circuit/blob/88fc90c714453f9fcc5272d3ae9fe9e84c0f37b7/src/poseidon/pow5.rs#L358
We have thought of a couple of solutions:
- Since the
assign_advice_from_constantis generic onVR, we can try to produce convert the caller's parameter from typeFto&'v Assigned<F>, but I'm not sure that's possible. - Alternatively, we could leave the call to
assign_advice_from_constantas is, and try to transform its output from typeAssignedCell<F, F>intoAssignedCell<&'v Assigned<F>, F>. Again, we're not sure how we could achieve that, direct construction isn't possible since fields ofAssignedCellare private (cf.https://github.com/axiom-crypto/halo2/blob/main/halo2_proofs/src/circuit.rs#L110C1-L114C2).
In view of this, do you guys see a way to make things work? Either with one of the above approaches or a slight redesign of assign_advice_from_constant's prototype? It could also be that we're completely missing the point here and barking at the wrong tree.
See also discussion on a PR in halo2-lib.