From 7fc457ac9058fd22faee9e459d1d7f27d90c11b1 Mon Sep 17 00:00:00 2001 From: Jordi Baylina Date: Sun, 19 Apr 2020 18:38:10 +0200 Subject: [PATCH] fastfile --- package-lock.json | 12 +++++++++--- package.json | 3 ++- src/r1csfile.js | 30 +++++++++++++++--------------- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/package-lock.json b/package-lock.json index 02ea185..ad11e5d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -581,6 +581,11 @@ "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", "dev": true }, + "fastfile": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/fastfile/-/fastfile-0.0.1.tgz", + "integrity": "sha512-Fk8PWafGWGEUw7oPq/dJen92ASxknCEy4ZC8n4VEvSwCp/jcReyEmVoWsRIWTf+IvAp2MzvFi54vOPeK2LQZtQ==" + }, "ffiasm": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/ffiasm/-/ffiasm-0.0.2.tgz", @@ -1123,10 +1128,11 @@ "dev": true }, "r1csfile": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/r1csfile/-/r1csfile-0.0.4.tgz", - "integrity": "sha512-1Y/zzzEjQVTR/gPlduRaKi2K+yU+UxqtsS+obDLEEb4WAzwCkKGybRfp037CUW5OApeleS1WdGmtKv9K9FPhsA==", + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/r1csfile/-/r1csfile-0.0.5.tgz", + "integrity": "sha512-B+BdKPb/WUTp4N/3X4d1Spgx9Ojx5tFVejGZRJxpTtzq34mC8Vi/czWfiPj85V8kud31lCfYcZ16z7+czvM0Sw==", "requires": { + "fastfile": "0.0.1", "ffjavascript": "0.1.0" } }, diff --git a/package.json b/package.json index 8750724..db405a6 100644 --- a/package.json +++ b/package.json @@ -31,11 +31,12 @@ "dependencies": { "chai": "^4.2.0", "circom_runtime": "0.0.5", + "fastfile": "0.0.1", "ffiasm": "0.0.2", "ffjavascript": "0.1.0", "ffwasm": "0.0.7", "fnv-plus": "^1.3.1", - "r1csfile": "0.0.4", + "r1csfile": "0.0.5", "tmp-promise": "^2.0.2", "wasmbuilder": "0.0.10" }, diff --git a/src/r1csfile.js b/src/r1csfile.js index f046205..ba722a9 100644 --- a/src/r1csfile.js +++ b/src/r1csfile.js @@ -1,16 +1,15 @@ -const fs = require("fs"); +const fastFile = require("fastfile"); const assert = require("assert"); -const Scalar = require("ffjavascript").Scalar; module.exports.buildR1cs = buildR1cs; async function buildR1cs(ctx, fileName) { - const fd = await fs.promises.open(fileName, "w"); + const fd = await fastFile.createOverride(fileName); - await fd.write("r1cs"); // Magic "r1cs" + await fd.write(Buffer.from("r1cs"), 0); // Magic "r1cs" let p = 4; await writeU32(1); // Version @@ -53,7 +52,6 @@ async function buildR1cs(ctx, fileName) { for (let i=0; i