mirror of
https://github.com/erhant/circomkit.git
synced 2026-05-05 03:00:37 -04:00
added main comp generator, some rfks
This commit is contained in:
@@ -78,9 +78,6 @@ case $FUNC in
|
||||
verify)
|
||||
verify $CIRCUIT $INPUT
|
||||
;;
|
||||
keygen)
|
||||
compile $CIRCUIT && ptau $CIRCUIT $NUM_CONTRIBS
|
||||
;;
|
||||
*)
|
||||
echo "Usage:"
|
||||
echo " -f <function>"
|
||||
|
||||
@@ -5,13 +5,14 @@ compile() {
|
||||
local CIRCOM_IN=./circuits/main/$CIRCUIT.circom
|
||||
local CIRCOM_OUT=./build/$CIRCUIT
|
||||
|
||||
echo "Compiler: $CLIENV_COMPILER_ARGS"
|
||||
# generate the circuit main component
|
||||
node ./scripts/instantiate.js $CIRCUIT
|
||||
|
||||
# create build dir if not exists already
|
||||
mkdir -p $CIRCOM_OUT
|
||||
|
||||
# compile with circom
|
||||
circom $CIRCOM_IN -o $CIRCOM_OUT --r1cs --sym --wasm
|
||||
circom $CIRCOM_IN -o $CIRCOM_OUT --r1cs --wasm --sym
|
||||
|
||||
echo -e "${CLIENV_COLOR_LOG}Built artifacts under $CIRCOM_OUT${CLIENV_COLOR_RESET}"
|
||||
}
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
## Parse the symbols file and generate types for TypeScript
|
||||
## Parse the template circuit that you are using for your main component
|
||||
## and generate TypeScript interfaces for it
|
||||
## TODO: not sure i need this yet
|
||||
type() {
|
||||
echo -e "\n${CLIENV_COLOR_TITLE}=== Generating types ===${CLIENV_COLOR_RESET}"
|
||||
CIRCUIT=$1
|
||||
SYM=./build/$CIRCUIT/$CIRCUIT.sym
|
||||
set -e
|
||||
|
||||
# choose lines with 1 dot only (these are the signals in main file), extract their names
|
||||
cat $SYM | grep -E '^.+main[^.]*\.[^.]*$'
|
||||
echo -e "\n${CLIENV_COLOR_TITLE}=== Generating types ===${CLIENV_COLOR_RESET}"
|
||||
local CIRCUIT=$1
|
||||
local SYM=./build/$CIRCUIT/$CIRCUIT.sym
|
||||
local TMP=./scripts/utils.tmp.txt
|
||||
|
||||
# choose lines with 1 dot only (these are the signals of the main component), extract their names
|
||||
cat $SYM | awk -F '.' '{print $2}'
|
||||
|
||||
echo -e "\n${CLIENV_COLOR_LOG}Types generated!${CLIENV_COLOR_RESET}"
|
||||
}
|
||||
|
||||
# cat ./build/multiplier3/multiplier3.sym | awk -F '.' 'NF==2{print $2}'
|
||||
|
||||
17
scripts/instantiate.js
Normal file
17
scripts/instantiate.js
Normal file
@@ -0,0 +1,17 @@
|
||||
const ejs = require('ejs');
|
||||
const {writeFileSync, readFileSync} = require('fs');
|
||||
const config = require('../circuit.config.cjs');
|
||||
|
||||
// read circuit from config
|
||||
const target = process.argv[2];
|
||||
if (!(target in config)) {
|
||||
throw new Error(`Target ${target} not found in config.`);
|
||||
}
|
||||
|
||||
// generate the main component code
|
||||
let circuit = ejs.render(readFileSync('./circuits/main/_template.circom').toString(), config[target]);
|
||||
|
||||
// output to file
|
||||
const targetPath = `./circuits/main/${target}.circom`;
|
||||
writeFileSync(targetPath, circuit);
|
||||
console.log(`Main component created at: ${targetPath}\n`);
|
||||
@@ -1,3 +0,0 @@
|
||||
for (let arg of process.argv.slice(2)) {
|
||||
console.log(arg);
|
||||
}
|
||||
Reference in New Issue
Block a user