Comparing version 0.1.3 to 0.1.4
44
cli.js
@@ -186,3 +186,27 @@ #!/usr/bin/env node | ||
circuit info | ||
============ | ||
snarkjs info <options> | ||
Print statistics of a circuit | ||
-c or --circuit <circuitFile> | ||
Filename of the compiled circuit file generated by circom. | ||
Default: circuit.json | ||
print constraints | ||
================= | ||
snarkjs printconstraints <options> | ||
Print all the constraints of a given circuit | ||
-c or --circuit <circuitFile> | ||
Filename of the compiled circuit file generated by circom. | ||
Default: circuit.json | ||
`) | ||
@@ -223,5 +247,21 @@ .alias("c", "circuit") | ||
try { | ||
if (argv._[0].toUpperCase() == "SETUP") { | ||
if (argv._[0].toUpperCase() == "INFO") { | ||
const cirDef = JSON.parse(fs.readFileSync(circuitName, "utf8")); | ||
const cir = new zkSnark.Circuit(cirDef); | ||
console.log(`# Wires: ${cir.nVars}`); | ||
console.log(`# Constraints: ${cir.nConstraints}`); | ||
console.log(`# Private Inputs: ${cir.nPrvInputs}`); | ||
console.log(`# Public Inputs: ${cir.nPubInputs}`); | ||
console.log(`# Outputs: ${cir.nOutputs}`); | ||
} else if (argv._[0].toUpperCase() == "PRINTCONSTRAINTS") { | ||
const cirDef = JSON.parse(fs.readFileSync(circuitName, "utf8")); | ||
const cir = new zkSnark.Circuit(cirDef); | ||
cir.printConstraints(); | ||
} else if (argv._[0].toUpperCase() == "SETUP") { | ||
const cirDef = JSON.parse(fs.readFileSync(circuitName, "utf8")); | ||
const cir = new zkSnark.Circuit(cirDef); | ||
const setup = zkSnark.setup(cir); | ||
@@ -327,3 +367,3 @@ | ||
inputs = ""; | ||
let inputs = ""; | ||
for (let i=0; i<public.length; i++) { | ||
@@ -330,0 +370,0 @@ if (inputs != "") inputs = inputs + ","; |
{ | ||
"name": "snarkjs", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "zkSNARKs implementation in JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -96,3 +96,4 @@ /* | ||
for (let k in lc) { | ||
const name = this.signals[k].names[0]; | ||
let name = this.signals[k].names[0]; | ||
if (name == "one") name = ""; | ||
let v = bigInt(lc[k]); | ||
@@ -104,3 +105,10 @@ let vs; | ||
} else { | ||
vs = "+"+v.toString(); | ||
if (S!="") { | ||
vs = "+"+v.toString(); | ||
} else { | ||
vs = ""; | ||
} | ||
if (vs!="1") { | ||
vs = vs + v.toString();; | ||
} | ||
} | ||
@@ -111,7 +119,13 @@ | ||
return S; | ||
} | ||
const S = `[ ${lc2str(c[0])} ] * [ ${lc2str(c[1])} ] - [ ${lc2str(c[2])} ]`; | ||
}; | ||
const S = `[ ${lc2str(c[0])} ] * [ ${lc2str(c[1])} ] - [ ${lc2str(c[2])} ] = 0`; | ||
console.log(S); | ||
} | ||
printConstraints() { | ||
for (let i=0; i<this.constraints.length; i++) { | ||
this.printCostraint(this.constraints[i]); | ||
} | ||
} | ||
getSignalIdx(name) { | ||
@@ -118,0 +132,0 @@ if (typeof(this.signalName2Idx[name]) != "undefined") return this.signalName2Idx[name]; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
411914
5835