Compare commits

...

7 Commits

Author SHA1 Message Date
Jordi Baylina
25759e53cd 0.0.13 2018-10-24 20:00:07 +02:00
Jordi Baylina
4fa0c79e26 If without else 2018-10-24 19:59:50 +02:00
Jordi Baylina
e685392523 Fix title in readme 2018-10-23 08:06:23 +02:00
Jordi Baylina
e81c4f1331 0.0.12 2018-10-22 08:36:49 +02:00
Jordi Baylina
483c9c0c26 deps 2018-10-22 08:36:43 +02:00
Jordi Baylina
eb1834833d 0.0.11 2018-10-22 07:00:00 +02:00
Jordi Baylina
49a6120eeb Cli parameters standarized to C 2018-10-22 06:59:47 +02:00
7 changed files with 25 additions and 19 deletions

View File

@@ -1,4 +1,4 @@
# Circon
# Circom
Circon is a language designed to write arithmetic circuits that can be used in zero knowledge proofs.

9
cli.js
View File

@@ -30,10 +30,8 @@ const version = require("./package").version;
const argv = require("yargs")
.version(version)
.usage("circom -s [input source circuit file] -o [output definition circuit file]")
.alias("s", "source")
.usage("circom [input source circuit file] -o [output definition circuit file]")
.alias("o", "output")
.require(["s","o"])
.help("h")
.alias("h", "help")
.epilogue(`Copyright (C) 2018 0kims association
@@ -43,10 +41,11 @@ const argv = require("yargs")
repo directory at https://github.com/iden3/circom `)
.argv;
const fullFileName = path.resolve(process.cwd(), argv.source);
const fullFileName = path.resolve(process.cwd(), argv._[0]);
const outName = argv.output ? argv.output : "circuit.json";
compiler(fullFileName).then( (cir) => {
fs.writeFileSync(argv.output, JSON.stringify(cir, null, 1), "utf8");
fs.writeFileSync(outName, JSON.stringify(cir, null, 1), "utf8");
}, (err) => {
console.log(err);
console.error(`ERROR at ${err.errFile}:${err.pos.first_line},${err.pos.first_column}-${err.pos.last_line},${err.pos.last_column} ${err.errStr}`);

11
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "circom",
"version": "0.0.10",
"version": "0.0.13",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -1469,14 +1469,15 @@
}
},
"snarkjs": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/snarkjs/-/snarkjs-0.1.0.tgz",
"integrity": "sha512-i+OOKwATef3/oUleae9FHt/qACPYH1M5gjQkdYYkyRYqScIuZHCmNSf6Q5RWJT5hmOkTEor+T2C5qwKSrzzGSg==",
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/snarkjs/-/snarkjs-0.1.3.tgz",
"integrity": "sha512-z5HhuNt019ZzNzUztETK31rpjRRSz3Uzy8TjGgSROf+9ZT9i6dbdWkjTC3fh5o9H+R/2+hcR+7IKAmpIR56V+A==",
"dev": true,
"requires": {
"big-integer": "^1.6.35",
"chai": "^4.1.2",
"eslint": "^5.3.0"
"eslint": "^5.3.0",
"yargs": "^12.0.2"
},
"dependencies": {
"ajv": {

View File

@@ -1,6 +1,6 @@
{
"name": "circom",
"version": "0.0.10",
"version": "0.0.13",
"description": "Language to generate logic circuits",
"main": "index.js",
"directories": {
@@ -38,6 +38,6 @@
"eslint": "^5.0.1",
"eslint-plugin-mocha": "^5.0.0",
"jison": "^0.4.18",
"snarkjs": "0.1.3"
"snarkjs": "0.1.4"
}
}

View File

@@ -31,7 +31,7 @@ module.exports = compile;
const parser = require("../parser/jaz.js").parser;
const timeout = ms => new Promise(res => setTimeout(res, ms))
const timeout = ms => new Promise(res => setTimeout(res, ms));
async function compile(srcFile) {
const fullFileName = srcFile;

View File

@@ -578,8 +578,10 @@ function execIf(ctx, ast) {
exec(ctx, ast.then);
if (ctx.error) return;
} else {
exec(ctx, ast.else);
if (ctx.error) return;
if (ast.else) {
exec(ctx, ast.else);
if (ctx.error) return;
}
}
}

View File

@@ -246,9 +246,13 @@ function genIf(ctx, ast) {
if (ctx.error) return;
const thenBody = gen(ctx, ast.then);
if (ctx.error) return;
const elseBody = gen(ctx, ast.else);
if (ctx.error) return;
return `if (${condition}) {\n${thenBody}\n} else {\n${elseBody}\n}\n`;
if (ast.else) {
const elseBody = gen(ctx, ast.else);
if (ctx.error) return;
return `if (${condition}) {\n${thenBody}\n} else {\n${elseBody}\n}\n`;
} else {
return `if (${condition}) {\n${thenBody}\n}\n`;
}
}