Comparing version 0.0.4 to 0.0.5
{ | ||
"name": "r1csfile", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "r1cs file format parser", | ||
@@ -31,2 +31,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"fastfile": "0.0.1", | ||
"ffjavascript": "0.1.0" | ||
@@ -33,0 +34,0 @@ }, |
const Scalar = require("ffjavascript").Scalar; | ||
const fs = require("fs"); | ||
const assert = require("assert"); | ||
const ZqField = require("ffjavascript").ZqField; | ||
const fastFile = require("fastfile"); | ||
@@ -10,6 +10,5 @@ module.exports.loadR1cs = loadR1cs; | ||
const res = {}; | ||
const fd = await fs.promises.open(fileName, "r"); | ||
const fd = await fastFile.readExisting(fileName); | ||
const b = Buffer.allocUnsafe(4); | ||
await fd.read(b, 0, 4, 0); | ||
const b = await fd.read(0, 4); | ||
@@ -97,4 +96,3 @@ if (b.toString() != "r1cs") assert(false, "Invalid File format"); | ||
async function readU32() { | ||
const b = Buffer.allocUnsafe(4); | ||
await fd.read(b, 0, 4, p); | ||
const b = await fd.read(p, 4); | ||
@@ -107,4 +105,3 @@ p+=4; | ||
async function readU64() { | ||
const b = Buffer.allocUnsafe(8); | ||
await fd.read(b, 0, 8, p); | ||
const b = await fd.read(p, 8); | ||
@@ -120,15 +117,10 @@ p+=8; | ||
async function readBigInt() { | ||
const n32 = n8/4; | ||
const b = Buffer.allocUnsafe(n8); | ||
await fd.read(b, 0, n8, p); | ||
const buff = await fd.read(p, n8); | ||
assert(buff.length == n8); | ||
const buffR = Buffer.allocUnsafe(n8); | ||
for (let i=0; i<n8; i++) buffR[i] = buff[n8-1-i]; | ||
p += n8; | ||
const arr = new Array(n32); | ||
for (let i=0; i<n32; i++) { | ||
arr[n32-1-i] = b.readUInt32LE(i*4); | ||
} | ||
const n = Scalar.fromArray(arr, 0x100000000); | ||
return n; | ||
return Scalar.fromString(buffR.toString("hex"), 16); | ||
} | ||
@@ -135,0 +127,0 @@ |
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
0
118932
2
210
+ Addedfastfile@0.0.1
+ Addedfastfile@0.0.1(transitive)