Skip to content

Commit

Permalink
v2.1.6 changes to UI
Browse files Browse the repository at this point in the history
  • Loading branch information
ioedeveloper committed Dec 6, 2023
1 parent 790861d commit faa2b3b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
5 changes: 4 additions & 1 deletion apps/circuit-compiler/src/app/components/configurations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function Configurations ({primeValue, setPrimeValue}: ConfigurationsProps
placement={"auto"}
tooltipId="circuitPrimeLabelTooltip"
tooltipClasses="text-nowrap"
tooltipText={<span>{'To choose the prime number to use to generate the circuit. Receives the name of the curve (bn128, bls12381, goldilocks) [default: bn128]'}</span>}
tooltipText={<span>{'To choose the prime number to use to generate the circuit. Receives the name of the curve (bn128, bls12381, goldilocks, grumpkin, pallas, vesta)'}</span>}
>
<div>
<select
Expand All @@ -28,6 +28,9 @@ export function Configurations ({primeValue, setPrimeValue}: ConfigurationsProps
<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>
</select>
</div>
</CustomTooltip>
Expand Down
22 changes: 14 additions & 8 deletions apps/circuit-compiler/src/app/services/circomPluginClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ import { PluginClient } from '@remixproject/plugin'
import { createClient } from '@remixproject/plugin-webview'
import EventManager from 'events'
import pathModule from 'path'
import { parse, compile, generate_witness, generate_r1cs, compiler_list } from 'circom_wasm'
import { compiler_list } from 'circom_wasm'
import compilerV216 from 'circom_wasm/v2.1.6'
import compilerV215 from 'circom_wasm/v2.1.5'
import { extractNameFromKey, extractParentFromKey } from '@remix-ui/helper'
import { CompilationConfig, CompilerReport, ResolverOutput } from '../types'

export class CircomPluginClient extends PluginClient {
public internalEvents: EventManager
private _compilationConfig: CompilationConfig = {
version: "2.1.5",
version: "2.1.6",
prime: "bn128"
}
private lastCompiledCircuitPath: string = ''
Expand Down Expand Up @@ -38,7 +40,8 @@ export class CircomPluginClient extends PluginClient {
fileContent = await this.call('fileManager', 'readFile', path)
}
this.lastParsedFiles = await this.resolveDependencies(path, fileContent, { [path]: { content: fileContent, parent: null } })
const parsedOutput = parse(path, this.lastParsedFiles)
const compiler = this._compilationConfig.version === '2.1.5' ? compilerV215 : compilerV216
const parsedOutput = compiler.parse(path, this.lastParsedFiles)

try {
const result: CompilerReport[] = JSON.parse(parsedOutput.report())
Expand Down Expand Up @@ -122,12 +125,13 @@ export class CircomPluginClient extends PluginClient {
if (compilationConfig) {
const { prime, version } = compilationConfig

if ((prime !== "bn128") && (prime !== "bls12381") && (prime !== "goldilocks")) throw new Error('Invalid prime value')
if ((prime !== "bn128") && (prime !== "bls12381") && (prime !== "goldilocks") && (prime !== "grumpkin") && (prime !== "pallas") && (prime !== "vesta")) throw new Error('Invalid prime value')
if (!compiler_list.versions.includes(version)) throw new Error("Unsupported compiler version")
this._compilationConfig.prime = prime
this._compilationConfig.version = version
}
const circuitApi = compile(path, this.lastParsedFiles, { prime: this._compilationConfig.prime })
const compiler = this._compilationConfig.version === '2.1.5' ? compilerV215 : compilerV216
const circuitApi = compiler.compile(path, this.lastParsedFiles, { prime: this._compilationConfig.prime })
const circuitProgram = circuitApi.program()

if (circuitProgram.length < 1) {
Expand Down Expand Up @@ -172,12 +176,13 @@ export class CircomPluginClient extends PluginClient {
if (compilationConfig) {
const { prime, version } = compilationConfig

if ((prime !== "bn128") && (prime !== "bls12381") && (prime !== "goldilocks")) throw new Error('Invalid prime value')
if ((prime !== "bn128") && (prime !== "bls12381") && (prime !== "goldilocks") && (prime !== "grumpkin") && (prime !== "pallas") && (prime !== "vesta")) throw new Error('Invalid prime value')
if (!compiler_list.versions.includes(version)) throw new Error("Unsupported compiler version")
this._compilationConfig.prime = prime
this._compilationConfig.version = version
}
const r1csApi = generate_r1cs(path, this.lastParsedFiles, { prime: this._compilationConfig.prime })
const compiler = this._compilationConfig.version === '2.1.5' ? compilerV215 : compilerV216
const r1csApi = compiler.generate_r1cs(path, this.lastParsedFiles, { prime: this._compilationConfig.prime })
const r1csProgram = r1csApi.program()

if (r1csProgram.length < 1) {
Expand All @@ -202,7 +207,8 @@ 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 generate_witness(dataRead, input)
const compiler = this._compilationConfig.version === '2.1.5' ? compilerV215 : compilerV216
const witness = await compiler.generate_witness(dataRead, input)
// @ts-ignore
await this.call('fileManager', 'writeFile', wasmPath.replace('.wasm', '.wtn'), witness, true)
this.internalEvents.emit('circuit_computing_witness_done')
Expand Down
2 changes: 1 addition & 1 deletion apps/circuit-compiler/src/app/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export type CompilationConfig = {
version: string
}

export type PrimeValue = "bn128" | "bls12381" | "goldilocks"
export type PrimeValue = "bn128" | "bls12381" | "goldilocks" | "grumpkin" | "pallas" | "vesta"

export type CompilerFeedbackProps = {
feedback: string | CompilerReport[],
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
"brace": "^0.8.0",
"change-case": "^4.1.1",
"chokidar": "^2.1.8",
"circom_wasm": "^0.1.0",
"circom_wasm": "0.2.2-alpha",
"color-support": "^1.1.3",
"commander": "^9.4.1",
"core-js": "^3.6.5",
Expand Down Expand Up @@ -202,8 +202,8 @@
"react-tabs": "^3.2.2",
"react-zoom-pan-pinch": "^3.0.2",
"regenerator-runtime": "0.13.7",
"rlp": "^3.0.0",
"remark-gfm": "^3.0.1",
"rlp": "^3.0.0",
"rss-parser": "^3.12.0",
"signale": "^1.4.0",
"snarkjs": "^0.7.0",
Expand Down
17 changes: 4 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9823,10 +9823,10 @@ [email protected]:
dependencies:
ffjavascript "0.2.57"

circom_wasm@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/circom_wasm/-/circom_wasm-0.1.0.tgz#dda76c7ae9046ea6f1e1cd3754c017ad753bd5c1"
integrity sha512-F7ihfVGjfSz+01yFXLHjKocQFm8j9KBageqMw5+olFWB6+7CXHLjnUaFuU6u+7T0FsL7+JuP18jdcAVQEXoQgw==
circom_wasm@0.2.2-alpha:
version "0.2.2-alpha"
resolved "https://registry.yarnpkg.com/circom_wasm/-/circom_wasm-0.2.2-alpha.tgz#ab21d63105e46ed9d6a91173208c4b0d06da5124"
integrity sha512-TMmypDJUEZ+VX3TS6CpooK6uVdA/scgv1yQ6UlDr9Asmbhd/If3OUcQbE3bAU0Ao4mKFL9AhExJIyZAEeF+kTQ==

circular-json@^0.3.0:
version "0.3.3"
Expand Down Expand Up @@ -24778,15 +24778,6 @@ simple-get@^2.5.1:
once "^1.3.1"
simple-concat "^1.0.0"

simple-get@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/simple-get/-/simple-get-4.0.1.tgz#4a39db549287c979d352112fa03fd99fd6bc3543"
integrity sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==
dependencies:
decompress-response "^6.0.0"
once "^1.3.1"
simple-concat "^1.0.0"

simple-get@^4.0.0, simple-get@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/simple-get/-/simple-get-4.0.1.tgz#4a39db549287c979d352112fa03fd99fd6bc3543"
Expand Down

0 comments on commit faa2b3b

Please sign in to comment.