Compute witness

pull/5228/head
ioedeveloper 5 months ago committed by bunsenstraat
parent 31bb2b672f
commit 18a9ac7b30
  1. 24
      apps/remixdesktop/src/plugins/circomElectronBasePlugin.ts
  2. 9
      apps/remixdesktop/src/tools/circom.ts

@ -1,7 +1,8 @@
import { ElectronBasePlugin, ElectronBasePluginClient } from "@remixproject/plugin-electron"
import { Profile } from "@remixproject/plugin-utils"
import { circomCli, extractParentFromKey } from "../tools/circom"
import { CIRCOM_INSTALLATION_PATH, circomCli, extractParentFromKey } from "../tools/circom"
import path from "path"
import { existsSync, readFileSync } from "fs"
const profile: Profile = {
displayName: 'circom',
@ -22,7 +23,7 @@ const clientProfile: Profile = {
name: 'circom',
displayName: 'circom',
description: 'Circom Language Compiler',
methods: ['install', 'run',]
methods: ['install', 'run', 'getInputs']
}
class CircomElectronPluginClient extends ElectronBasePluginClient {
@ -53,6 +54,23 @@ class CircomElectronPluginClient extends ElectronBasePluginClient {
const depPath = path.join(wd, '.deps/https/raw.githubusercontent.com/iden3/')
const outputDir = extractParentFromKey(filePath) + '/.bin'
await circomCli.run(`${filePath} -l ${depPath} -o ${outputDir}`, options)
return await circomCli.run(`${filePath} -l ${depPath} -o ${outputDir}`, options)
}
getInputs() {
const inputsFile = extractParentFromKey(CIRCOM_INSTALLATION_PATH) + '/log_input_signals.txt'
const inputsFileExists = existsSync(inputsFile)
const signals: string[] = []
if (inputsFileExists) {
const inputsContent = readFileSync(inputsFile, 'utf-8')
const regexPattern = /main\.(\w+)/g
let match
while ((match = regexPattern.exec(inputsContent)) !== null) {
signals.push(match[1])
}
return signals
}
}
}

@ -6,7 +6,7 @@ import fs, { existsSync } from 'fs'
import axios from 'axios'
const execAsync = promisify(exec)
const CIRCOM_INSTALLATION_PATH = getInstallationPath()
export const CIRCOM_INSTALLATION_PATH = getInstallationPath()
const CIRCOM_INSTALLATION_URL = getInstallationUrl()
async function downloadFile(url: string, dest: string) {
@ -83,12 +83,9 @@ export const circomCli = {
},
async run (filePath: string, options?: Record<string, string>) {
const cmd = `${CIRCOM_INSTALLATION_PATH} ${filePath} ${Object.keys(options || {}).map((key) => `--${key} ${options[key]}`).join(' ')}`
console.log('cmd: ', cmd)
const { stdout, stderr } = await execAsync(cmd)
const cmd = `${CIRCOM_INSTALLATION_PATH} ${filePath} ${Object.keys(options || {}).map((key) => options[key] ? `--${key} ${options[key]}` : `--${key}`).join(' ')}`
if (stderr) return console.error(stderr)
console.log(stdout)
return await execAsync(cmd)
}
}

Loading…
Cancel
Save