)
}
diff --git a/apps/circuit-compiler/src/app/components/options.tsx b/apps/circuit-compiler/src/app/components/options.tsx
index adf083ae2f..85161c1b3f 100644
--- a/apps/circuit-compiler/src/app/components/options.tsx
+++ b/apps/circuit-compiler/src/app/components/options.tsx
@@ -4,7 +4,7 @@ import { CompileOptionsProps } from '../types'
export function CompileOptions ({autoCompile, hideWarnings, setCircuitAutoCompile, setCircuitHideWarnings}: CompileOptionsProps) {
return (
-
+
- }
- >
-
-
-
- )
-}
\ No newline at end of file
diff --git a/apps/circuit-compiler/src/app/components/setupExports.tsx b/apps/circuit-compiler/src/app/components/setupExports.tsx
new file mode 100644
index 0000000000..2116c6a8ec
--- /dev/null
+++ b/apps/circuit-compiler/src/app/components/setupExports.tsx
@@ -0,0 +1,123 @@
+import { CustomTooltip } from "@remix-ui/helper"
+import { FormattedMessage } from "react-intl"
+import { SetupExportsBtn } from "./setupExportsBtn"
+import { useContext } from "react"
+import { CircuitAppContext } from "../contexts"
+import { runSetupAndExport } from "../actions"
+
+export function SetupExports () {
+ const circuitApp = useContext(CircuitAppContext)
+
+ const handleRunSetup = async () => {
+ try {
+ circuitApp.dispatch({ type: 'SET_COMPILER_STATUS', payload: 'exporting' })
+ await runSetupAndExport(circuitApp.plugin, circuitApp.appState)
+ circuitApp.dispatch({ type: 'SET_COMPILER_STATUS', payload: 'idle' })
+ circuitApp.dispatch({ type: 'SET_SETUP_EXPORT_STATUS', payload: 'done' })
+ } catch (e) {
+ circuitApp.dispatch({ type: 'SET_COMPILER_STATUS', payload: 'errored' })
+ circuitApp.dispatch({ type: 'SET_SETUP_EXPORT_FEEDBACK', payload: e.message })
+ console.error(e)
+ }
+ }
+
+ return (
+
+
+
+
+
+ circuitApp.dispatch({ type: 'SET_PROVING_SCHEME', payload: 'groth16' })}
+ value='groth16'
+ checked={circuitApp.appState.provingScheme === 'groth16'}
+ readOnly
+ />
+
+
+
+ circuitApp.dispatch({ type: 'SET_PROVING_SCHEME', payload: 'plonk' })}
+ value='plonk'
+ checked={circuitApp.appState.provingScheme === 'plonk'}
+ readOnly
+ />
+
+
+
+
+
+
{'To choose the from the list of ptau files'}}
+ >
+
+
+
+
+
+ circuitApp.dispatch({ type: 'SET_EXPORT_VERIFICATION_CONTRACT', payload: !circuitApp.appState.exportVerificationContract })}
+ checked={circuitApp.appState.exportVerificationContract}
+ />
+
+
+
+ circuitApp.dispatch({ type: 'SET_EXPORT_VERIFICATION_KEY', payload: !circuitApp.appState.exportVerificationKey })}
+ checked={circuitApp.appState.exportVerificationKey}
+ />
+
+
+
+
+
+
+ )
+}
\ No newline at end of file
diff --git a/apps/circuit-compiler/src/app/components/setupExportsBtn.tsx b/apps/circuit-compiler/src/app/components/setupExportsBtn.tsx
new file mode 100644
index 0000000000..a1bfdc7691
--- /dev/null
+++ b/apps/circuit-compiler/src/app/components/setupExportsBtn.tsx
@@ -0,0 +1,34 @@
+import { CustomTooltip, RenderIf } from "@remix-ui/helper"
+import { FormattedMessage } from "react-intl"
+import { CompilerStatus } from "../types"
+
+export function SetupExportsBtn ({ handleRunSetup, status }: { handleRunSetup: () => Promise
, status: CompilerStatus }) {
+ return
+ }
+ >
+
+
+
+}
\ No newline at end of file
diff --git a/apps/circuit-compiler/src/app/components/toggler.tsx b/apps/circuit-compiler/src/app/components/toggler.tsx
new file mode 100644
index 0000000000..ec90a231a8
--- /dev/null
+++ b/apps/circuit-compiler/src/app/components/toggler.tsx
@@ -0,0 +1,50 @@
+import { useEffect, useState } from "react"
+import { FormattedMessage } from "react-intl"
+import { CustomTooltip, RenderIf, RenderIfNot } from "@remix-ui/helper"
+
+export function Toggler ({ children, title, dataId, show = false, icon, iconTooltip }: { children: JSX.Element, title: string, dataId: string, show?: boolean, icon?: string, iconTooltip?: string }) {
+ const [toggleExpander, setToggleExpander] = useState
(show)
+
+ useEffect(() => {
+ setToggleExpander(show)
+ }, [show])
+
+ const toggleConfigurations = () => {
+ setToggleExpander(!toggleExpander)
+ }
+
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ { children }
+
+
+ )
+}
\ No newline at end of file
diff --git a/apps/circuit-compiler/src/app/components/witness.tsx b/apps/circuit-compiler/src/app/components/witness.tsx
index 08f82ca171..0a14537cde 100644
--- a/apps/circuit-compiler/src/app/components/witness.tsx
+++ b/apps/circuit-compiler/src/app/components/witness.tsx
@@ -34,37 +34,32 @@ export function WitnessSection ({ plugin, signalInputs, status }: {plugin: Circo
}
return (
-
-
-
0}>
- <>
- {
- signalInputs.map((input, index) => (
-
-
-
-
- ))
- }
-
- >
-
-
+
)
}
\ No newline at end of file
diff --git a/apps/circuit-compiler/src/app/components/witnessToggler.tsx b/apps/circuit-compiler/src/app/components/witnessToggler.tsx
deleted file mode 100644
index 60027c2ebe..0000000000
--- a/apps/circuit-compiler/src/app/components/witnessToggler.tsx
+++ /dev/null
@@ -1,36 +0,0 @@
-import { useState } from "react"
-import { FormattedMessage } from "react-intl"
-import { RenderIf, RenderIfNot } from "@remix-ui/helper"
-
-export function WitnessToggler ({ children }: { children: JSX.Element }) {
- const [toggleExpander, setToggleExpander] = useState
(false)
-
- const toggleConfigurations = () => {
- setToggleExpander(!toggleExpander)
- }
-
- return (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- { children }
-
-
- )
-}
\ No newline at end of file
diff --git a/apps/circuit-compiler/src/app/reducers/state.ts b/apps/circuit-compiler/src/app/reducers/state.ts
index e63b5e5a2a..ceee26f60e 100644
--- a/apps/circuit-compiler/src/app/reducers/state.ts
+++ b/apps/circuit-compiler/src/app/reducers/state.ts
@@ -1,3 +1,4 @@
+import { PTAU_LIST } from '../actions/constant'
import { Actions, AppState } from '../types'
import { compiler_list } from 'circom_wasm'
@@ -11,7 +12,15 @@ export const appInitialState: AppState = {
autoCompile: false,
hideWarnings: false,
signalInputs: [],
- feedback: null
+ compilerFeedback: null,
+ computeFeedback: null,
+ setupExportFeedback: null,
+ setupExportStatus: null,
+ provingScheme: 'groth16',
+ ptauList: PTAU_LIST,
+ ptauValue: "final_14.ptau",
+ exportVerificationContract: true,
+ exportVerificationKey: true
}
export const appReducer = (state = appInitialState, action: Actions): AppState => {
@@ -62,7 +71,19 @@ export const appReducer = (state = appInitialState, action: Actions): AppState =
case 'SET_COMPILER_FEEDBACK':
return {
...state,
- feedback: action.payload
+ compilerFeedback: action.payload
+ }
+
+ case 'SET_COMPUTE_FEEDBACK':
+ return {
+ ...state,
+ computeFeedback: action.payload
+ }
+
+ case 'SET_SETUP_EXPORT_FEEDBACK':
+ return {
+ ...state,
+ setupExportFeedback: action.payload
}
case 'SET_FILE_PATH_TO_ID':
@@ -71,6 +92,36 @@ export const appReducer = (state = appInitialState, action: Actions): AppState =
filePathToId: action.payload
}
+ case 'SET_PROVING_SCHEME':
+ return {
+ ...state,
+ provingScheme: action.payload
+ }
+
+ case 'SET_PTAU_VALUE':
+ return {
+ ...state,
+ ptauValue: action.payload
+ }
+
+ case 'SET_EXPORT_VERIFICATION_CONTRACT':
+ return {
+ ...state,
+ exportVerificationContract: action.payload
+ }
+
+ case 'SET_EXPORT_VERIFICATION_KEY':
+ return {
+ ...state,
+ exportVerificationKey: action.payload
+ }
+
+ case 'SET_SETUP_EXPORT_STATUS':
+ return {
+ ...state,
+ setupExportStatus: action.payload
+ }
+
default:
throw new Error()
}
diff --git a/apps/circuit-compiler/src/app/services/circomPluginClient.ts b/apps/circuit-compiler/src/app/services/circomPluginClient.ts
index 93a2445861..f6817fe7a5 100644
--- a/apps/circuit-compiler/src/app/services/circomPluginClient.ts
+++ b/apps/circuit-compiler/src/app/services/circomPluginClient.ts
@@ -197,24 +197,15 @@ export class CircomPluginClient extends PluginClient {
}
async generateR1cs (path: string, compilationConfig?: CompilationConfig): Promise {
- this.internalEvents.emit('circuit_generating_r1cs_start')
- this.emit('statusChanged', { key: 'loading', title: 'Generating...', type: 'info' })
- // @ts-ignore
- this.call('terminal', 'log', { type: 'log', value: 'Generating R1CS for ' + path })
const [parseErrors, filePathToId] = await this.parse(path)
if (parseErrors && (parseErrors.length > 0)) {
if (parseErrors[0].type === 'Error') {
- this.internalEvents.emit('circuit_parsing_errored', parseErrors)
this.logCompilerReport(parseErrors)
return
} else if (parseErrors[0].type === 'Warning') {
- this.internalEvents.emit('circuit_parsing_warning', parseErrors)
this.logCompilerReport(parseErrors)
}
- } else {
- this.internalEvents.emit('circuit_parsing_done', parseErrors, filePathToId)
- this.emit('statusChanged', { key: 'succeed', title: 'r1cs generated successfully', type: 'success' })
}
if (compilationConfig) {
const { prime, version } = compilationConfig
@@ -232,7 +223,6 @@ export class CircomPluginClient extends PluginClient {
this._paq.push(['trackEvent', 'circuit-compiler', 'generateR1cs', 'R1CS Generation failed'])
throw new Error(r1csErrors)
} else {
- this.internalEvents.emit('circuit_generating_r1cs_done')
const fileName = extractNameFromKey(path)
const writePath = extractParentFromKey(path) + "/.bin/" + fileName.replace('circom', 'r1cs')
diff --git a/apps/circuit-compiler/src/app/types/index.ts b/apps/circuit-compiler/src/app/types/index.ts
index 64f3b3281f..4be4b6a9f6 100644
--- a/apps/circuit-compiler/src/app/types/index.ts
+++ b/apps/circuit-compiler/src/app/types/index.ts
@@ -2,7 +2,19 @@ import { compiler_list } from 'circom_wasm'
import { Dispatch } from 'react'
import type { CircomPluginClient } from '../services/circomPluginClient'
-export type CompilerStatus = "compiling" | "generating" | "computing" | "idle" | "errored" | "warning"
+export type CompilerStatus = "compiling" | "computing" | "idle" | "errored" | "warning" | "exporting"
+
+export type ProvingScheme = 'groth16' | 'plonk'
+
+export type SetupExportStatus = 'done' | 'update'
+
+export type PtauFile = {
+ name: string,
+ power: number,
+ maxConstraint: string,
+ ipfsHash: string,
+ blake2bHash: string
+}
export interface ICircuitAppContext {
appState: AppState
dispatch: Dispatch,
@@ -17,8 +29,15 @@ export interface ActionPayloadTypes {
SET_AUTO_COMPILE: boolean,
SET_HIDE_WARNINGS: boolean,
SET_SIGNAL_INPUTS: string[],
- SET_COMPILER_FEEDBACK: string | CompilerReport[]
- SET_FILE_PATH_TO_ID: Record
+ SET_COMPILER_FEEDBACK: string | CompilerReport[],
+ SET_COMPUTE_FEEDBACK: string | CompilerReport[],
+ SET_SETUP_EXPORT_FEEDBACK: string | CompilerReport[],
+ SET_FILE_PATH_TO_ID: Record,
+ SET_PROVING_SCHEME: ProvingScheme,
+ SET_PTAU_VALUE: string,
+ SET_EXPORT_VERIFICATION_CONTRACT: boolean,
+ SET_EXPORT_VERIFICATION_KEY: boolean,
+ SET_SETUP_EXPORT_STATUS: SetupExportStatus
}
export interface Action {
type: T
@@ -37,7 +56,15 @@ export interface AppState {
autoCompile: boolean,
hideWarnings: boolean,
signalInputs: string[],
- feedback: string | CompilerReport[]
+ compilerFeedback: string | CompilerReport[],
+ computeFeedback: string | CompilerReport[],
+ setupExportFeedback: string | CompilerReport[],
+ setupExportStatus: SetupExportStatus,
+ provingScheme: ProvingScheme,
+ ptauList: Array,
+ ptauValue: string,
+ exportVerificationContract: boolean,
+ exportVerificationKey: boolean
}
export type CompilationConfig = {
diff --git a/apps/circuit-compiler/src/css/app.css b/apps/circuit-compiler/src/css/app.css
index e901a5ef76..f229a913b4 100644
--- a/apps/circuit-compiler/src/css/app.css
+++ b/apps/circuit-compiler/src/css/app.css
@@ -37,8 +37,6 @@ body {
text-transform: uppercase;
}
.circuit_errors_box {
- padding-left: 5px;
- padding-right: 5px;
word-break: break-word;
}
.circuit_feedback.success,
diff --git a/apps/circuit-compiler/src/profile.json b/apps/circuit-compiler/src/profile.json
index 9ee0e0f0dc..250c519385 100644
--- a/apps/circuit-compiler/src/profile.json
+++ b/apps/circuit-compiler/src/profile.json
@@ -4,7 +4,7 @@
"displayName": "Circom ZKP compiler",
"events": [],
"version": "2.0.0",
- "methods": ["init", "parse", "compile", "generateR1cs"],
+ "methods": ["init", "parse", "compile"],
"canActivate": [],
"url": "",
"description": "Enables circuit compilation and computing a witness for ZK proofs",
diff --git a/apps/remix-ide-e2e/src/tests/circom.test.ts b/apps/remix-ide-e2e/src/tests/circom.test.ts
index ac14415ea9..4b30e815e5 100644
--- a/apps/remix-ide-e2e/src/tests/circom.test.ts
+++ b/apps/remix-ide-e2e/src/tests/circom.test.ts
@@ -72,17 +72,38 @@ module.exports = {
.waitForElementPresent('[data-id="treeViewLitreeViewItemcircuits/.bin/simple.wasm"]')
.waitForElementVisible('[data-id="treeViewLitreeViewItemcircuits/.bin/simple.wasm"]')
},
- 'Should generate R1CS for a simple circuit #group2': function (browser: NightwatchBrowser) {
+ 'Should run Groth16 setup and export for a simple circuit using the GUI #group2': function (browser: NightwatchBrowser) {
browser
.clickLaunchIcon('circuit-compiler')
.frame(0)
- .waitForElementPresent('button[data-id="generate_r1cs_btn"]')
- .waitForElementVisible('button[data-id="generate_r1cs_btn"]')
- .click('button[data-id="generate_r1cs_btn"]')
+ .waitForElementVisible('[data-id="setup_exports_toggler"]')
+ .waitForElementPresent('[data-id="groth16ProvingScheme"]')
+ .click('[data-id="groth16ProvingScheme"]')
+ .waitForElementVisible('[data-id="circuitPtauSelect"]')
+ .click('[data-id="circuitPtauSelect"]')
+ .waitForElementVisible('[data-id="dropdown-item-final_8.ptau"]')
+ .click('[data-id="dropdown-item-final_8.ptau"]')
+ .click('[data-id="runSetupBtn"]')
+ .waitForElementVisible('[data-id="setup_exports_toggler"] .fa-check-circle')
.frameParent()
.clickLaunchIcon('filePanel')
- .waitForElementPresent('[data-id="treeViewLitreeViewItemcircuits/.bin/simple.r1cs"]')
- .waitForElementVisible('[data-id="treeViewLitreeViewItemcircuits/.bin/simple.r1cs"]')
+ .waitForElementVisible('*[data-id="treeViewLitreeViewItemcircuits/groth16/zk/keys/verification_key.json"]')
+ .waitForElementVisible('*[data-id="treeViewLitreeViewItemcircuits/groth16/zk/keys/zkey_final.txt"]')
+ },
+ 'Should run Plonk setup and export for a simple circuit using the GUI #group2': function (browser: NightwatchBrowser) {
+ browser
+ .clickLaunchIcon('circuit-compiler')
+ .frame(0)
+ .waitForElementVisible('[data-id="setup_exports_toggler"]')
+ .click('[data-id="setup_exports_toggler"]')
+ .waitForElementPresent('[data-id="plonkProvingScheme"]')
+ .click('[data-id="plonkProvingScheme"]')
+ .click('[data-id="runSetupBtn"]')
+ .waitForElementVisible('[data-id="setup_exports_toggler"] .fa-check-circle')
+ .frameParent()
+ .clickLaunchIcon('filePanel')
+ .waitForElementVisible('*[data-id="treeViewLitreeViewItemcircuits/plonk/zk/keys/verification_key.json"]')
+ .waitForElementVisible('*[data-id="treeViewLitreeViewItemcircuits/plonk/zk/keys/zkey_final.txt"]')
},
'Should compile a simple circuit using CTRL + S from the editor #group3': function (browser: NightwatchBrowser) {
browser
@@ -176,10 +197,7 @@ module.exports = {
.waitForElementPresent('[data-id="verticalIconsKindcircuit-compiler"]')
.waitForElementVisible('[data-id="verticalIconsKindcircuit-compiler"]')
.click('[data-id="play-editor"]')
- .pause(2000)
- .journalLastChildIncludes('Generating R1CS for circuits/calculate_hash.circom')
- .pause(5000)
- .journalLastChildIncludes('Everything went okay')
+ .pause(7000)
.journalLastChildIncludes('newZkey')
.pause(25000)
.journalLastChildIncludes('setup done.')
@@ -214,10 +232,7 @@ module.exports = {
.waitForElementPresent('[data-id="verticalIconsKindcircuit-compiler"]')
.waitForElementVisible('[data-id="verticalIconsKindcircuit-compiler"]')
.click('[data-id="play-editor"]')
- .pause(2000)
- .journalLastChildIncludes('Generating R1CS for circuits/calculate_hash.circom')
- .pause(5000)
- .journalLastChildIncludes('Everything went okay')
+ .pause(7000)
.journalLastChildIncludes('plonk setup')
.pause(10000)
.journalLastChildIncludes('setup done')
diff --git a/apps/remix-ide/src/app/tabs/locales/en/circuit.json b/apps/remix-ide/src/app/tabs/locales/en/circuit.json
index 61184793f5..4a10ba5f43 100644
--- a/apps/remix-ide/src/app/tabs/locales/en/circuit.json
+++ b/apps/remix-ide/src/app/tabs/locales/en/circuit.json
@@ -11,5 +11,13 @@
"circuit.generateR1cs": "Generate R1CS",
"circuit.computeWitness": "Compute Witness",
"circuit.signalInput": "Signal Input",
- "circuit.compute": "Compute"
+ "circuit.compute": "Compute",
+ "circuit.setupExports": "Setup and Exports",
+ "circuit.provingScheme": "Proving Scheme",
+ "circuit.ptau": "POWER OF TAU (PTAU)",
+ "circuit.randomText": "Ceremony: Random Text",
+ "circuit.randomBeacon": "Ceremony: Random Beacon",
+ "circuit.exportVerifierContract": "Export verifier contract",
+ "circuit.exportVerificationKey": "Export verification key",
+ "circuit.runSetup": "Run setup"
}