Skip to content

Commit

Permalink
dirname shim and move it to plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
phated committed Aug 17, 2023
1 parent 70d34d2 commit df205c9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
4 changes: 0 additions & 4 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
/* eslint-disable no-console */

import fs from "fs";
import url from "url";

import {readR1cs} from "r1csfile";

Expand All @@ -41,7 +40,6 @@ import * as plonk from "./src/plonk.js";
import * as fflonk from "./src/fflonk.js";
import * as wtns from "./src/wtns.js";
import * as curves from "./src/curves.js";
import path from "path";
import bfj from "bfj";

import Logger from "logplease";
Expand All @@ -50,8 +48,6 @@ import * as binFileUtils from "@iden3/binfileutils";
const logger = Logger.create("snarkJS", {showTimestamp: false});
Logger.setLogLevel("INFO");

const __dirname = path.dirname(url.fileURLToPath(import.meta.url));

const commands = [
{
cmd: "powersoftau new <curve> <power> [powersoftau_0000.ptau]",
Expand Down
14 changes: 9 additions & 5 deletions snarkjs-generate-solidity/main.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@

Object.defineProperty(exports, '__esModule', { value: true });

var ejs = require('ejs');
var fs = require('fs');
var url = require('url');
var path = require('path');
var ejs = require('ejs');
var ffjavascript = require('ffjavascript');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var ejs__default = /*#__PURE__*/_interopDefaultLegacy(ejs);
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
var url__default = /*#__PURE__*/_interopDefaultLegacy(url);
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
var ejs__default = /*#__PURE__*/_interopDefaultLegacy(ejs);

const {unstringifyBigInts, stringifyBigInts} = ffjavascript.utils;

const __dirname$1 = path__default["default"].dirname(url__default["default"].fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('main.cjs', document.baseURI).href))));

async function getCurveFromName(name) {
let curve;
const normName = normalizeName(name);
Expand All @@ -34,12 +38,12 @@ async function getCurveFromName(name) {


async function groth16SolidityVerifier(verificationKey, logger) {
const template = await fs__default["default"].promises.readFile(path__default["default"].join(__dirname, "templates", "verifier_groth16.sol.ejs"), "utf8");
const template = await fs__default["default"].promises.readFile(path__default["default"].join(__dirname$1, "templates", "verifier_groth16.sol.ejs"), "utf8");
return ejs__default["default"].render(template, verificationKey);
}

async function plonkSolidityVerifier(verificationKey, logger) {
const template = await fs__default["default"].promises.readFile(path__default["default"].join(__dirname, "templates", "verifier_plonk.sol.ejs"), "utf8");
const template = await fs__default["default"].promises.readFile(path__default["default"].join(__dirname$1, "templates", "verifier_plonk.sol.ejs"), "utf8");
return ejs__default["default"].render(template, verificationKey);
}

Expand All @@ -65,7 +69,7 @@ async function fflonkSolidityVerifier(vk, logger) {
vk["w8_" + i] = toVkey(acc);
}

let template = await fs__default["default"].promises.readFile(path__default["default"].join(__dirname, "templates", "verifier_fflonk.sol.ejs"), "utf8");
let template = await fs__default["default"].promises.readFile(path__default["default"].join(__dirname$1, "templates", "verifier_fflonk.sol.ejs"), "utf8");

if (logger) logger.info("FFLONK EXPORT SOLIDITY VERIFIER FINISHED");

Expand Down
6 changes: 5 additions & 1 deletion snarkjs-generate-solidity/main.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import ejs from "ejs";
import fs from "fs";
import url from "url";
import path from "path";

import ejs from "ejs";
import { buildBn128, buildBls12381, utils } from "ffjavascript";

const {unstringifyBigInts, stringifyBigInts} = utils;

const __dirname = path.dirname(url.fileURLToPath(import.meta.url));

async function getCurveFromName(name) {
let curve;
const normName = normalizeName(name);
Expand Down

0 comments on commit df205c9

Please sign in to comment.