Skip to content

Commit

Permalink
feat: support circuit with no instance column or instance value
Browse files Browse the repository at this point in the history
  • Loading branch information
han0110 committed Nov 10, 2023
1 parent 547ac24 commit cbd1775
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,8 @@ impl<'a> SolidityGenerator<'a> {
num_instances: usize,
) -> Self {
assert_ne!(vk.cs().num_advice_columns(), 0);
assert_eq!(
vk.cs().num_instance_columns(),
1,
assert!(
vk.cs().num_instance_columns() <= 1,
"Multiple instance columns is not yet implemented"
);
assert!(
Expand Down
12 changes: 8 additions & 4 deletions templates/Halo2Verifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,9 @@ contract Halo2Verifier {

let mptr := X_N_MPTR
let mptr_end := add(mptr, mul(0x20, add(mload(NUM_INSTANCES_MPTR), {{ num_neg_lagranges }})))
if iszero(mload(NUM_INSTANCES_MPTR)) {
mptr_end := add(mptr_end, 0x20)
}
for
{ let pow_of_omega := mload(OMEGA_INV_TO_L_MPTR) }
lt(mptr, mptr_end)
Expand Down Expand Up @@ -413,11 +416,12 @@ contract Halo2Verifier {
l_blind := addmod(l_blind, mload(l_i_cptr), r)
}

let instance_eval := mulmod(mload(l_i_cptr), calldataload(INSTANCE_CPTR), r)
let instance_cptr := add(INSTANCE_CPTR, 0x20)
l_i_cptr := add(l_i_cptr, 0x20)
let instance_eval := 0
for
{ let instance_cptr_end := add(INSTANCE_CPTR, mul(0x20, mload(NUM_INSTANCES_MPTR))) }
{
let instance_cptr := INSTANCE_CPTR
let instance_cptr_end := add(instance_cptr, mul(0x20, mload(NUM_INSTANCES_MPTR)))
}
lt(instance_cptr, instance_cptr_end)
{
instance_cptr := add(instance_cptr, 0x20)
Expand Down

0 comments on commit cbd1775

Please sign in to comment.