Merge branch 'circom-desktop' of https://github.com/ethereum/remix-project into circomdesktoptest

pull/5399/head
bunsenstraat 3 months ago
commit af69b9e77a
  1. 2
      apps/circuit-compiler/src/app/actions/index.ts
  2. 6
      apps/circuit-compiler/src/app/services/circomPluginClient.ts
  3. 18
      apps/remix-ide-e2e/src/tests/circom.test.ts
  4. 4
      apps/remixdesktop/src/plugins/circomElectronBasePlugin.ts
  5. 7
      apps/remixdesktop/src/tools/circom.ts
  6. 2
      libs/remix-ws-templates/src/templates/hashchecker/scripts/groth16/groth16_zkproof.ts
  7. 2
      libs/remix-ws-templates/src/templates/hashchecker/scripts/plonk/plonk_zkproof.ts
  8. 2
      libs/remix-ws-templates/src/templates/rln/scripts/groth16/groth16_zkproof.ts
  9. 2
      libs/remix-ws-templates/src/templates/rln/scripts/plonk/plonk_zkproof.ts
  10. 4
      libs/remix-ws-templates/src/templates/semaphore/scripts/groth16/groth16_zkproof.ts
  11. 4
      libs/remix-ws-templates/src/templates/semaphore/scripts/plonk/plonk_zkproof.ts

@ -29,7 +29,7 @@ export const computeWitness = async (plugin: CircomPluginClient, appState: AppSt
const wtns = await snarkjs.wtns.exportJson(witness) const wtns = await snarkjs.wtns.exportJson(witness)
const wtnsJson = wtns.map(wtn => wtn.toString()) const wtnsJson = wtns.map(wtn => wtn.toString())
const fileName = extractNameFromKey(appState.filePath) const fileName = extractNameFromKey(appState.filePath)
const writePath = extractParentFromKey(appState.filePath) + `/.bin/${fileName.replace('.circom', '.wtn.json')}` const writePath = extractParentFromKey(appState.filePath) + `/.bin/${fileName.replace('.circom', '_js')}/${fileName.replace('.circom', '.wtn.json')}`
await plugin.call('fileManager', 'writeFile', writePath, JSON.stringify(wtnsJson, null, 2)) await plugin.call('fileManager', 'writeFile', writePath, JSON.stringify(wtnsJson, null, 2))
plugin._paq.push(['trackEvent', 'circuit-compiler', 'computeWitness', 'wtns.exportJson', writePath]) plugin._paq.push(['trackEvent', 'circuit-compiler', 'computeWitness', 'wtns.exportJson', writePath])

@ -181,7 +181,7 @@ export class CircomPluginClient extends PluginClient {
this.lastCompiledFile = path this.lastCompiledFile = path
const fileName = extractNameFromKey(path) const fileName = extractNameFromKey(path)
this.lastCompiledCircuitPath = extractParentFromKey(path) + "/.bin/" + fileName.replace('circom', 'wasm') this.lastCompiledCircuitPath = extractParentFromKey(path) + "/.bin/" + fileName.replace('.circom', '_js') + '/' + fileName.replace('.circom', '.wasm')
// @ts-ignore // @ts-ignore
await this.call('fileManager', 'writeFile', this.lastCompiledCircuitPath, circuitProgram, { encoding: null }) await this.call('fileManager', 'writeFile', this.lastCompiledCircuitPath, circuitProgram, { encoding: null })
const fileContent = this.lastParsedFiles[path] const fileContent = this.lastParsedFiles[path]
@ -235,7 +235,7 @@ export class CircomPluginClient extends PluginClient {
const { stdout, stderr } = await this.call('circom', 'run', path, versionToInstall, { prime: prime, wasm: "", inputs: "" }) const { stdout, stderr } = await this.call('circom', 'run', path, versionToInstall, { prime: prime, wasm: "", inputs: "" })
const fileName = extractNameFromKey(path) const fileName = extractNameFromKey(path)
this.lastCompiledCircuitPath = pathModule.normalize(extractParentFromKey(path) + "/.bin/" + fileName.replace('.circom', '_js') + "/" + fileName.replace('circom', 'wasm')) this.lastCompiledCircuitPath = pathModule.normalize(extractParentFromKey(path) + "/.bin/" + fileName.replace('.circom', '_js') + "/" + fileName.replace('.circom', '.wasm'))
if (stderr) this.call('terminal', 'log', { type: 'error', value: stderr }) if (stderr) this.call('terminal', 'log', { type: 'error', value: stderr })
if (stdout) this.call('terminal', 'log', { type: 'log', value: stdout }) if (stdout) this.call('terminal', 'log', { type: 'log', value: stdout })
} catch (error) { } catch (error) {
@ -290,7 +290,7 @@ export class CircomPluginClient extends PluginClient {
throw new Error(r1csErrors) throw new Error(r1csErrors)
} else { } else {
const fileName = extractNameFromKey(path) const fileName = extractNameFromKey(path)
const writePath = extractParentFromKey(path) + "/.bin/" + fileName.replace('circom', 'r1cs') const writePath = extractParentFromKey(path) + "/.bin/" + fileName.replace('.circom', '.r1cs')
// @ts-ignore // @ts-ignore
await this.call('fileManager', 'writeFile', writePath, r1csProgram, true) await this.call('fileManager', 'writeFile', writePath, r1csProgram, true)

@ -38,8 +38,8 @@ module.exports = {
.waitForElementPresent('[data-id="verticalIconsKindcircuit-compiler"]') .waitForElementPresent('[data-id="verticalIconsKindcircuit-compiler"]')
.waitForElementVisible('[data-id="verticalIconsKindcircuit-compiler"]') .waitForElementVisible('[data-id="verticalIconsKindcircuit-compiler"]')
.click('[data-id="play-editor"]') .click('[data-id="play-editor"]')
.waitForElementPresent('[data-id="treeViewLitreeViewItemcircuits/.bin/simple.wasm"]') .waitForElementPresent('[data-id="treeViewLitreeViewItemcircuits/.bin/simple_js/simple.wasm"]')
.waitForElementVisible('[data-id="treeViewLitreeViewItemcircuits/.bin/simple.wasm"]') .waitForElementVisible('[data-id="treeViewLitreeViewItemcircuits/.bin/simple_js/simple.wasm"]')
}, },
'Should compute a witness for a simple circuit #group1': function (browser: NightwatchBrowser) { 'Should compute a witness for a simple circuit #group1': function (browser: NightwatchBrowser) {
browser browser
@ -55,8 +55,8 @@ module.exports = {
.click('[data-id="compute_witness_btn"]') .click('[data-id="compute_witness_btn"]')
.frameParent() .frameParent()
.clickLaunchIcon('filePanel') .clickLaunchIcon('filePanel')
.waitForElementPresent('[data-id="treeViewLitreeViewItemcircuits/.bin/simple.wtn"]') .waitForElementPresent('[data-id="treeViewLitreeViewItemcircuits/.bin/simple_js/simple.wtn"]')
.waitForElementVisible('[data-id="treeViewLitreeViewItemcircuits/.bin/simple.wtn"]') .waitForElementVisible('[data-id="treeViewLitreeViewItemcircuits/.bin/simple_js/simple.wtn"]')
}, },
'Should compile a simple circuit using compile button in circom plugin #group2': function (browser: NightwatchBrowser) { 'Should compile a simple circuit using compile button in circom plugin #group2': function (browser: NightwatchBrowser) {
browser browser
@ -70,8 +70,8 @@ module.exports = {
.click('button[data-id="compile_circuit_btn"]') .click('button[data-id="compile_circuit_btn"]')
.frameParent() .frameParent()
.clickLaunchIcon('filePanel') .clickLaunchIcon('filePanel')
.waitForElementPresent('[data-id="treeViewLitreeViewItemcircuits/.bin/simple.wasm"]') .waitForElementPresent('[data-id="treeViewLitreeViewItemcircuits/.bin/simple_js/simple.wasm"]')
.waitForElementVisible('[data-id="treeViewLitreeViewItemcircuits/.bin/simple.wasm"]') .waitForElementVisible('[data-id="treeViewLitreeViewItemcircuits/.bin/simple_js/simple.wasm"]')
}, },
'Should run Groth16 setup and export for a simple circuit using the GUI #group2': function (browser: NightwatchBrowser) { 'Should run Groth16 setup and export for a simple circuit using the GUI #group2': function (browser: NightwatchBrowser) {
browser browser
@ -116,8 +116,8 @@ module.exports = {
return actions.keyDown(this.Keys.CONTROL).sendKeys('s') return actions.keyDown(this.Keys.CONTROL).sendKeys('s')
}) })
.waitForElementPresent('[data-id="treeViewLitreeViewItemcircuits/.bin/simple.wasm"]') .waitForElementPresent('[data-id="treeViewLitreeViewItemcircuits/.bin/simple_js/simple.wasm"]')
.waitForElementVisible('[data-id="treeViewLitreeViewItemcircuits/.bin/simple.wasm"]') .waitForElementVisible('[data-id="treeViewLitreeViewItemcircuits/.bin/simple_js/simple.wasm"]')
}, },
'Should display warnings for compiled circuit without pragma version #group4': function (browser: NightwatchBrowser) { 'Should display warnings for compiled circuit without pragma version #group4': function (browser: NightwatchBrowser) {
browser browser
@ -164,7 +164,7 @@ module.exports = {
.waitForElementNotPresent('[data-id="circuit_feedback"]') .waitForElementNotPresent('[data-id="circuit_feedback"]')
.frameParent() .frameParent()
.clickLaunchIcon('filePanel') .clickLaunchIcon('filePanel')
.waitForElementPresent('[data-id="treeViewLitreeViewItemcircuits/.bin/simple.wasm"]') .waitForElementPresent('[data-id="treeViewLitreeViewItemcircuits/.bin/simple_js/simple.wasm"]')
}, },
'Should create a new workspace using hash checker template #group5 #group6': function (browser: NightwatchBrowser) { 'Should create a new workspace using hash checker template #group5 #group6': function (browser: NightwatchBrowser) {
browser browser

@ -1,6 +1,6 @@
import { ElectronBasePlugin, ElectronBasePluginClient } from "@remixproject/plugin-electron" import { ElectronBasePlugin, ElectronBasePluginClient } from "@remixproject/plugin-electron"
import { Profile } from "@remixproject/plugin-utils" import { Profile } from "@remixproject/plugin-utils"
import { getInstallationPath, circomCli, extractParentFromKey, getInstallationUrl, getLogInputSignalsPath } from "../tools/circom" import { getInstallationPath, circomCli, extractParentFromKey, getInstallationUrl, getLogInputSignalsPath, extractNameFromKey } from "../tools/circom"
import path from "path" import path from "path"
import { existsSync, readFileSync } from "fs" import { existsSync, readFileSync } from "fs"
@ -57,7 +57,7 @@ class CircomElectronPluginClient extends ElectronBasePluginClient {
// @ts-ignore // @ts-ignore
if (process.platform === 'win32' && 'wasm' in options) { if (process.platform === 'win32' && 'wasm' in options) {
// @ts-ignore // @ts-ignore
await this.call('fs', 'rmdir', path.join(extractParentFromKey(filePath), '.bin', 'simple_js')) await this.call('fs', 'rmdir', path.join(extractParentFromKey(filePath), '.bin', extractNameFromKey(filePath).replace('.circom', '_js')))
} }
} }
filePath = path.join(wd, filePath) filePath = path.join(wd, filePath)

@ -127,3 +127,10 @@ export const extractParentFromKey = (key: string):string => {
return keyPath.join('/') return keyPath.join('/')
} }
export const extractNameFromKey = (key: string): string => {
if (!key) return
const keyPath = key.split('/')
return keyPath[keyPath.length - 1]
}

@ -18,7 +18,7 @@ const logger = {
// @ts-ignore // @ts-ignore
await remix.call('circuit-compiler', 'compile', 'circuits/calculate_hash.circom'); await remix.call('circuit-compiler', 'compile', 'circuits/calculate_hash.circom');
// @ts-ignore // @ts-ignore
const wasmBuffer = await remix.call('fileManager', 'readFile', 'circuits/.bin/calculate_hash.wasm', { encoding: null }); const wasmBuffer = await remix.call('fileManager', 'readFile', 'circuits/.bin/calculate_hash_js/calculate_hash.wasm', { encoding: null });
// @ts-ignore // @ts-ignore
const wasm = new Uint8Array(wasmBuffer); const wasm = new Uint8Array(wasmBuffer);

@ -15,7 +15,7 @@ const logger = {
// @ts-ignore // @ts-ignore
await remix.call('circuit-compiler', 'compile', 'circuits/calculate_hash.circom'); await remix.call('circuit-compiler', 'compile', 'circuits/calculate_hash.circom');
// @ts-ignore // @ts-ignore
const wasmBuffer = await remix.call('fileManager', 'readFile', 'circuits/.bin/calculate_hash.wasm', { encoding: null }); const wasmBuffer = await remix.call('fileManager', 'readFile', 'circuits/.bin/calculate_hash_js/calculate_hash.wasm', { encoding: null });
// @ts-ignore // @ts-ignore
const wasm = new Uint8Array(wasmBuffer); const wasm = new Uint8Array(wasmBuffer);
const zkey_final = { const zkey_final = {

@ -79,7 +79,7 @@ async function prove (signals, wasm, wtns, r1cs, zkey_final, vKey) {
// @ts-ignore // @ts-ignore
await remix.call('circuit-compiler', 'compile', 'circuits/rln.circom'); await remix.call('circuit-compiler', 'compile', 'circuits/rln.circom');
// @ts-ignore // @ts-ignore
const wasmBuffer = await remix.call('fileManager', 'readFile', 'circuits/.bin/rln.wasm', { encoding: null }); const wasmBuffer = await remix.call('fileManager', 'readFile', 'circuits/.bin/rln_js/rln.wasm', { encoding: null });
// @ts-ignore // @ts-ignore
const wasm = new Uint8Array(wasmBuffer); const wasm = new Uint8Array(wasmBuffer);

@ -102,7 +102,7 @@ async function prove (signals, wasm, wtns, r1cs, zkey_final, vKey) {
// @ts-ignore // @ts-ignore
await remix.call('circuit-compiler', 'compile', 'circuits/rln.circom'); await remix.call('circuit-compiler', 'compile', 'circuits/rln.circom');
// @ts-ignore // @ts-ignore
const wasmBuffer = await remix.call('fileManager', 'readFile', 'circuits/.bin/rln.wasm', { encoding: null }); const wasmBuffer = await remix.call('fileManager', 'readFile', 'circuits/.bin/rln_js/rln.wasm', { encoding: null });
// @ts-ignore // @ts-ignore
const wasm = new Uint8Array(wasmBuffer); const wasm = new Uint8Array(wasmBuffer);

@ -25,13 +25,13 @@ function hash(message: any): bigint {
(async () => { (async () => {
try { try {
// @ts-ignore // @ts-ignore
const r1csBuffer = await remix.call('fileManager', 'readFile', 'circuits/.bin/semaphore.r1cs', true); const r1csBuffer = await remix.call('fileManager', 'readFile', 'circuits/.bin/semaphore.r1cs', { encoding: null });
// @ts-ignore // @ts-ignore
const r1cs = new Uint8Array(r1csBuffer); const r1cs = new Uint8Array(r1csBuffer);
// @ts-ignore // @ts-ignore
await remix.call('circuit-compiler', 'compile', 'circuits/semaphore.circom'); await remix.call('circuit-compiler', 'compile', 'circuits/semaphore.circom');
// @ts-ignore // @ts-ignore
const wasmBuffer = await remix.call('fileManager', 'readFile', 'circuits/.bin/semaphore.wasm', true); const wasmBuffer = await remix.call('fileManager', 'readFile', 'circuits/.bin/semaphore_js/semaphore.wasm', { encoding: null });
// @ts-ignore // @ts-ignore
const wasm = new Uint8Array(wasmBuffer); const wasm = new Uint8Array(wasmBuffer);

@ -25,13 +25,13 @@ function hash(message: any): bigint {
(async () => { (async () => {
try { try {
// @ts-ignore // @ts-ignore
const r1csBuffer = await remix.call('fileManager', 'readFile', 'circuits/.bin/semaphore.r1cs', true); const r1csBuffer = await remix.call('fileManager', 'readFile', 'circuits/.bin/semaphore.r1cs', { encoding: null });
// @ts-ignore // @ts-ignore
const r1cs = new Uint8Array(r1csBuffer); const r1cs = new Uint8Array(r1csBuffer);
// @ts-ignore // @ts-ignore
await remix.call('circuit-compiler', 'compile', 'circuits/semaphore.circom'); await remix.call('circuit-compiler', 'compile', 'circuits/semaphore.circom');
// @ts-ignore // @ts-ignore
const wasmBuffer = await remix.call('fileManager', 'readFile', 'circuits/.bin/semaphore.wasm', true); const wasmBuffer = await remix.call('fileManager', 'readFile', 'circuits/.bin/semaphore_js/semaphore.wasm', { encoding: null });
// @ts-ignore // @ts-ignore
const wasm = new Uint8Array(wasmBuffer); const wasm = new Uint8Array(wasmBuffer);

Loading…
Cancel
Save