solidity template dir

This commit is contained in:
Jordi Baylina 2020-07-13 08:37:21 +02:00
parent cc9c460cf4
commit b3ec4930ea
No known key found for this signature in database
GPG Key ID: 7480C80C1BE43112
7 changed files with 16 additions and 7 deletions

@ -115,8 +115,6 @@ snarkjs powersoftau verify pot12_final.ptau
### Create a circuit ### Create a circuit
```sh ```sh
mkdir mycircuit
cd my mycircuit
cat <<EOT > circuit.circom cat <<EOT > circuit.circom
template Multiplier(n) { template Multiplier(n) {
signal private input a; signal private input a;
@ -164,6 +162,7 @@ snarkjs r1cs print circuit.r1cs
### export r1cs to json ### export r1cs to json
```sh ```sh
snarkjs r1cs export json circuit.r1cs circuit.r1cs.json snarkjs r1cs export json circuit.r1cs circuit.r1cs.json
cat circuit.r1cs.json
``` ```

@ -11,6 +11,7 @@ var readline = _interopDefault(require('readline'));
var crypto = _interopDefault(require('crypto')); var crypto = _interopDefault(require('crypto'));
var circomRuntime = _interopDefault(require('circom_runtime')); var circomRuntime = _interopDefault(require('circom_runtime'));
var path = _interopDefault(require('path')); var path = _interopDefault(require('path'));
var appRoot = _interopDefault(require('app-root-path'));
var Logger = _interopDefault(require('logplease')); var Logger = _interopDefault(require('logplease'));
async function open(fileName, openFlags, cacheSize) { async function open(fileName, openFlags, cacheSize) {
@ -739,7 +740,7 @@ async function r1csExportJson(r1csFileName, logger) {
var name = "snarkjs"; var name = "snarkjs";
var type = "module"; var type = "module";
var version = "0.3.0"; var version = "0.3.1";
var description = "zkSNARKs implementation in JavaScript"; var description = "zkSNARKs implementation in JavaScript";
var main = "./build/main.cjs"; var main = "./build/main.cjs";
var module$1 = "./main.js"; var module$1 = "./main.js";
@ -776,6 +777,7 @@ var repository = {
url: "https://github.com/iden3/snarkjs.git" url: "https://github.com/iden3/snarkjs.git"
}; };
var dependencies = { var dependencies = {
"app-root-path": "^3.0.0",
"blake2b-wasm": "https://github.com/jbaylina/blake2b-wasm.git", "blake2b-wasm": "https://github.com/jbaylina/blake2b-wasm.git",
circom_runtime: "0.0.9", circom_runtime: "0.0.9",
fastfile: "0.0.6", fastfile: "0.0.6",
@ -6107,7 +6109,7 @@ async function zkeyExportSolidityVerifier(params, options) {
if (options.verbose) Logger.setLogLevel("DEBUG"); if (options.verbose) Logger.setLogLevel("DEBUG");
const templateName = path.join( __dirname, "templates", "verifier_groth16.sol"); const templateName = path.join( appRoot.path, "templates", "verifier_groth16.sol");
const verifierCode = await exportSolidityVerifier(zkeyName, templateName); const verifierCode = await exportSolidityVerifier(zkeyName, templateName);

File diff suppressed because one or more lines are too long

3
cli.js

@ -38,6 +38,7 @@ import * as groth16 from "./src/groth16.js";
import * as wtns from "./src/wtns.js"; import * as wtns from "./src/wtns.js";
import * as curves from "./src/curves.js"; import * as curves from "./src/curves.js";
import path from "path"; import path from "path";
import appRoot from "app-root-path";
import Logger from "logplease"; import Logger from "logplease";
const logger = Logger.create("snarkJS", {showTimestamp:false}); const logger = Logger.create("snarkJS", {showTimestamp:false});
@ -519,7 +520,7 @@ async function zkeyExportSolidityVerifier(params, options) {
if (options.verbose) Logger.setLogLevel("DEBUG"); if (options.verbose) Logger.setLogLevel("DEBUG");
const templateName = path.join( __dirname, "templates", "verifier_groth16.sol"); const templateName = path.join( appRoot.path, "templates", "verifier_groth16.sol");
const verifierCode = await zkey.exportSolidityVerifier(zkeyName, templateName, logger); const verifierCode = await zkey.exportSolidityVerifier(zkeyName, templateName, logger);

@ -24,8 +24,9 @@ export default {
"ffjavascript", "ffjavascript",
"keccak", "keccak",
"yargs", "yargs",
"logplease" "logplease",
"app-root-path"
], ],
plugins: [ plugins: [
resolve({ resolve({

5
package-lock.json generated

@ -128,6 +128,11 @@
"picomatch": "^2.0.4" "picomatch": "^2.0.4"
} }
}, },
"app-root-path": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/app-root-path/-/app-root-path-3.0.0.tgz",
"integrity": "sha512-qMcx+Gy2UZynHjOHOIXPNvpf+9cjvk3cWrBBK7zg4gH9+clobJRb9NGzcT7mQTcV/6Gm/1WelUtqxVXnNlrwcw=="
},
"argparse": { "argparse": {
"version": "1.0.10", "version": "1.0.10",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",

@ -38,6 +38,7 @@
"url": "https://github.com/iden3/snarkjs.git" "url": "https://github.com/iden3/snarkjs.git"
}, },
"dependencies": { "dependencies": {
"app-root-path": "^3.0.0",
"blake2b-wasm": "https://github.com/jbaylina/blake2b-wasm.git", "blake2b-wasm": "https://github.com/jbaylina/blake2b-wasm.git",
"circom_runtime": "0.0.9", "circom_runtime": "0.0.9",
"fastfile": "0.0.6", "fastfile": "0.0.6",