Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mixing groth16 and plonk for the same circuit stalls compilation #77

Open
camden-smallwood opened this issue Jan 1, 2023 · 4 comments

Comments

@camden-smallwood
Copy link

camden-smallwood commented Jan 1, 2023

When compiling the same circuit using both the groth16 and plonk protocols, compilation will stall after finishing the first circuit, regardless of order. If I comment out either circuit, compilation finishes successfully, but this requires two separate runs of npx hardhat circom. I am using node.js v16.6.1, running on a mac mini M1 with macOS Ventura 13.0.1. I am using the example Multiplier2 template from the circom tutorial.

Here is my package.json file:

{
  "name": "circom-test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "circomlib": "^2.0.5",
    "hardhat-circom": "^3.3.2"
  },
  "devDependencies": {
    "@nomicfoundation/hardhat-toolbox": "^2.0.0",
    "hardhat": "^2.12.5"
  }
}

Here is my hardhat.config.ts file:

import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
import 'hardhat-circom';

const config: HardhatUserConfig = {
  solidity: {
    compilers: [
      {
        version: '0.6.11',
      },
      {
        version: '0.8.17',
      },
    ],
  },
  circom: {
    inputBasePath: './circuits',
    outputBasePath: './circuits/build',
    ptau: 'powersOfTau28_hez_final_18.ptau',
    circuits: [
      {
        name: 'multiplier2',
        circuit: 'multiplier2.circom',
        input: 'input/multiplier2.json',
      },
      {
        name: 'multiplier2_plonk',
        circuit: 'multiplier2.circom',
        input: 'input/multiplier2.json',
        protocol: 'plonk',
      },
    ]
  }
};

export default config;

Here is my circuits/multiplier2.circom file:

pragma circom 2.0.0;

/*This circuit template checks that c is the multiplication of a and b.*/  

template Multiplier2 () {  

   // Declaration of signals.  
   signal input a;  
   signal input b;  
   signal output c;  

   // Constraints.  
   c <== a * b;  
}

Here is my circuits/input/multiplier2.json file:

{ "a": "3", "b": "11" }
@phated
Copy link
Contributor

phated commented Jan 2, 2023

This worked in circom-starter when I added it, so I'm not sure what issue you are hitting.

@camden-smallwood
Copy link
Author

I just tested the circom-starter repository, and by itself it does indeed work fine. However, if I duplicate the division circuit entry in the hardhat.config.js file and make it use the plonk protocol, it appears to stall just the same as my test project right after printing hardhat-circom:info Written successfully: /Users/camden/Source/circom-starter/circuits/division.sym +0ms.

Here is the modified hardhat.config.js for the circom-starter repository:

require("hardhat-circom");

/**
 * @type import('hardhat/config').HardhatUserConfig
 */
module.exports = {
  solidity: {
    compilers: [
      {
        version: "0.6.11",
      },
      {
        version: "0.8.9",
      },
    ],
  },
  circom: {
    inputBasePath: "./circuits",
    ptau: "https://hermezptau.blob.core.windows.net/ptau/powersOfTau28_hez_final_15.ptau",
    circuits: [
      {
        name: "division",
        // No protocol, so it defaults to groth16
      },
      {
        // duplicate of the division circuit using the plonk protocol
        name: 'division_plonk',
        circuit: 'division.circom',
        input: 'division.json',
        protocol: 'plonk',
      },
      {
        name: "simple-polynomial",
        // Generate PLONK
        protocol: "plonk",
      },
      {
        name: "hash",
        // Explicitly generate groth16
        protocol: "groth16",
      },
    ],
  },
};

@phated
Copy link
Contributor

phated commented Jan 2, 2023

Okay. Using the same circuit multiple times has never been explicitly supported nor tested, so this is more a feature than a bug. Not sure when I'll be able to look/implement. Thanks for the detailed report.

@camden-smallwood camden-smallwood changed the title Mixing groth16 and plonk protocols stalls compilation Mixing groth16 and plonk for the same circuit stalls compilation Jan 2, 2023
@camden-smallwood
Copy link
Author

Thanks for the response, I updated the title to be more clear of the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants