Added options for new circom compiler builds

pull/4674/head
ioedeveloper 8 months ago
parent 0592510806
commit 575e44dd65
  1. 21
      apps/circuit-compiler/src/app/components/configurations.tsx
  2. 23
      apps/circuit-compiler/src/app/services/circomPluginClient.ts
  3. 2
      package.json
  4. 13422
      yarn.lock

@ -42,6 +42,27 @@ export function Configurations ({primeValue, setPrimeValue, versionValue}: Confi
<option value="vesta">vesta</option>
</>
</RenderIf>
<RenderIf condition={versionValue === '2.1.7'}>
<>
<option value="bn128">bn128</option>
<option value="bls12381">bls12381</option>
<option value="goldilocks">goldilocks</option>
<option value="grumpkin">grumpkin</option>
<option value="pallas">pallas</option>
<option value="vesta">vesta</option>
</>
</RenderIf>
<RenderIf condition={versionValue === '2.1.8'}>
<>
<option value="bn128">bn128</option>
<option value="bls12381">bls12381</option>
<option value="goldilocks">goldilocks</option>
<option value="grumpkin">grumpkin</option>
<option value="pallas">pallas</option>
<option value="vesta">vesta</option>
<option value="secq256r1">secq256r1</option>
</>
</RenderIf>
</select>
</div>
</CustomTooltip>

@ -2,7 +2,9 @@ import { PluginClient } from '@remixproject/plugin'
import { createClient } from '@remixproject/plugin-webview'
import EventManager from 'events'
import pathModule from 'path'
import { compiler_list } from 'circom_wasm'
import { compiler_list, parse, compile, generate_r1cs, generate_witness } from 'circom_wasm'
import * as compilerV218 from 'circom_wasm/v2.1.8'
import * as compilerV217 from 'circom_wasm/v2.1.7'
import * as compilerV216 from 'circom_wasm/v2.1.6'
import * as compilerV215 from 'circom_wasm/v2.1.5'
import { extractNameFromKey, extractParentFromKey } from '@remix-ui/helper'
@ -11,7 +13,7 @@ import { CompilationConfig, CompilerReport, PrimeValue, ResolverOutput } from '.
export class CircomPluginClient extends PluginClient {
public internalEvents: EventManager
private _compilationConfig: CompilationConfig = {
version: "2.1.6",
version: "2.1.8",
prime: "bn128"
}
private lastCompiledCircuitPath: string = ''
@ -40,11 +42,16 @@ export class CircomPluginClient extends PluginClient {
this._compilationConfig.version = version
if (version === '2.1.5') this.compiler = compilerV215
else if (version === '2.1.6') this.compiler = compilerV216
else if (version === '2.1.7') this.compiler = compilerV217
else if (version === '2.1.8') this.compiler = compilerV218
else this.compiler = null
}
set compilerPrime (prime: PrimeValue) {
if ((prime !== "bn128") && (prime !== "bls12381") && (prime !== "goldilocks") && (this._compilationConfig.version === '2.1.5')) throw new Error('Invalid prime value')
if ((prime !== "bn128") && (prime !== "bls12381") && (prime !== "goldilocks") && (prime !== "grumpkin") && (prime !== "pallas") && (prime !== "vesta") && (this._compilationConfig.version === '2.1.6')) throw new Error('Invalid prime value')
if ((prime !== "bn128") && (prime !== "bls12381") && (prime !== "goldilocks") && (prime !== "grumpkin") && (prime !== "pallas") && (prime !== "vesta") && (this._compilationConfig.version === '2.1.7')) throw new Error('Invalid prime value')
if ((prime !== "bn128") && (prime !== "bls12381") && (prime !== "goldilocks") && (prime !== "grumpkin") && (prime !== "pallas") && (prime !== "vesta") && (prime !== "secq256r1") && (this._compilationConfig.version === '2.1.8')) throw new Error('Invalid prime value')
this._compilationConfig.prime = prime
}
@ -54,7 +61,7 @@ export class CircomPluginClient extends PluginClient {
fileContent = await this.call('fileManager', 'readFile', path)
}
this.lastParsedFiles = await this.resolveDependencies(path, fileContent)
const parsedOutput = this.compiler.parse(path, this.lastParsedFiles)
const parsedOutput = this.compiler ? this.compiler.parse(path, this.lastParsedFiles) : parse(path, this.lastParsedFiles)
try {
const result: CompilerReport[] = JSON.parse(parsedOutput.report())
@ -145,7 +152,7 @@ export class CircomPluginClient extends PluginClient {
this.compilerVersion = version
this.compilerPrime = prime
}
const circuitApi = this.compiler.compile(path, this.lastParsedFiles, { prime: this._compilationConfig.prime })
const circuitApi = this.compiler ? this.compiler.compile(path, this.lastParsedFiles, { prime: this._compilationConfig.prime }) : compile(path, this.lastParsedFiles, { prime: this._compilationConfig.prime })
const circuitProgram = circuitApi.program()
if (circuitProgram.length < 1) {
@ -175,7 +182,7 @@ export class CircomPluginClient extends PluginClient {
log && this.call('terminal', 'log', { type: 'log', value: log })
})
// @ts-ignore
this.call('terminal', 'log', { type: 'typewritersuccess', value: 'Everything went okay, circom safe' })
this.call('terminal', 'log', { type: 'typewritersuccess', value: 'Everything went okay' })
}
}
@ -203,7 +210,7 @@ export class CircomPluginClient extends PluginClient {
this.compilerVersion = version
this.compilerPrime = prime
}
const r1csApi = this.compiler.generate_r1cs(path, this.lastParsedFiles, { prime: this._compilationConfig.prime })
const r1csApi = this.compiler ? this.compiler.generate_r1cs(path, this.lastParsedFiles, { prime: this._compilationConfig.prime }) : generate_r1cs(path, this.lastParsedFiles, { prime: this._compilationConfig.prime })
const r1csProgram = r1csApi.program()
if (r1csProgram.length < 1) {
@ -222,7 +229,7 @@ export class CircomPluginClient extends PluginClient {
log && this.call('terminal', 'log', { type: 'log', value: log })
})
// @ts-ignore
this.call('terminal', 'log', { type: 'typewritersuccess', value: 'Everything went okay, circom safe' })
this.call('terminal', 'log', { type: 'typewritersuccess', value: 'Everything went okay' })
}
}
@ -234,7 +241,7 @@ export class CircomPluginClient extends PluginClient {
// @ts-ignore
const buffer: any = await this.call('fileManager', 'readFile', wasmPath, { encoding: null })
const dataRead = new Uint8Array(buffer)
const witness = await this.compiler.generate_witness(dataRead, input)
const witness = this.compiler ? await this.compiler.generate_witness(dataRead, input) : generate_witness(dataRead, input)
// @ts-ignore
await this.call('fileManager', 'writeFile', wasmPath.replace('.wasm', '.wtn'), witness, true)
this.internalEvents.emit('circuit_computing_witness_done')

@ -167,7 +167,7 @@
"brace": "^0.8.0",
"change-case": "^4.1.1",
"chokidar": "^2.1.8",
"circom_wasm": "^0.2.1",
"circom_wasm": "https://github.com/remix-project-org/circom_wasm.git",
"color-support": "^1.1.3",
"commander": "^9.4.1",
"core-js": "^3.6.5",

13422
yarn.lock

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save