Fix Dataview Offsets

This commit is contained in:
Jordi Baylina 2020-06-16 17:04:49 +02:00
parent 3ba1341404
commit 0e32995f26
No known key found for this signature in database
GPG Key ID: 7480C80C1BE43112
5 changed files with 6 additions and 6 deletions

@ -104,7 +104,7 @@ async function buldABC(curve, zkey, witness, coeffs) {
const sCoef = 4*3 + zkey.n8r; const sCoef = 4*3 + zkey.n8r;
const elementsPerChunk = Math.floor(zkey.domainSize/concurrency); const elementsPerChunk = Math.floor(zkey.domainSize/concurrency);
const coeffsDV = new DataView(coeffs.buffer); const coeffsDV = new DataView(coeffs.buffer, coeffs.byteOffset, coeffs.byteLength);
const promises = []; const promises = [];
const cutPoints = []; const cutPoints = [];

@ -36,7 +36,7 @@ function log2( V )
function formatHash(b) { function formatHash(b) {
const a = new DataView(b.buffer); const a = new DataView(b.buffer, b.byteOffset, b.byteLength);
let S = ""; let S = "";
for (let i=0; i<4; i++) { for (let i=0; i<4; i++) {
if (i>0) S += "\n"; if (i>0) S += "\n";

@ -362,7 +362,7 @@ function keyFromBeacon(curve, challangeHash, beaconHash, numIterationsExp) {
} }
} }
const curHashV = new DataView(curHash.buffer); const curHashV = new DataView(curHash.buffer, curHash.byteOffset, curHash.byteLength);
const seed = []; const seed = [];
for (let i=0; i<8; i++) { for (let i=0; i<8; i++) {
seed[i] = curHashV.getUint32(i*4, false); seed[i] = curHashV.getUint32(i*4, false);

@ -117,7 +117,7 @@ module.exports = async function phase2exportMPCParams(zkeyName, mpcparamsName,
} }
const buffSize = new Uint8Array(4); const buffSize = new Uint8Array(4);
const buffSizeV = new DataView(buffSize.buffer); const buffSizeV = new DataView(buffSize.buffer, buffSize.byteOffset, buffSize.byteLength);
buffSizeV.setUint32(0, buff.byteLength / sG, false); buffSizeV.setUint32(0, buff.byteLength / sG, false);
await fdMPCParams.write(buffSize); await fdMPCParams.write(buffSize);
@ -126,7 +126,7 @@ module.exports = async function phase2exportMPCParams(zkeyName, mpcparamsName,
async function writeU32(n) { async function writeU32(n) {
const buffSize = new Uint8Array(4); const buffSize = new Uint8Array(4);
const buffSizeV = new DataView(buffSize.buffer); const buffSizeV = new DataView(buffSize.buffer, buffSize.byteOffset, buffSize.byteLength);
buffSizeV.setUint32(0, n, false); buffSizeV.setUint32(0, n, false);
await fdMPCParams.write(buffSize); await fdMPCParams.write(buffSize);

@ -471,7 +471,7 @@ module.exports = async function phase2new(r1csName, ptauName, zkeyName, verbose
function hashU32(n) { function hashU32(n) {
const buff = new Uint8Array(4); const buff = new Uint8Array(4);
const buffV = new DataView(buff.buffer); const buffV = new DataView(buff.buffer, buff.byteOffset, buff.byteLength);
buffV.setUint32(0, n, false); buffV.setUint32(0, n, false);
csHasher.update(buff); csHasher.update(buff);
} }