Fix proof generation big proofs
This commit is contained in:
parent
62099732bb
commit
31631db4d6
@ -6180,8 +6180,25 @@ async function buldABC(curve, zkey, witness, coeffs) {
|
|||||||
const concurrency = curve.tm.concurrency;
|
const concurrency = curve.tm.concurrency;
|
||||||
const sCoef = 4*3 + zkey.n8r;
|
const sCoef = 4*3 + zkey.n8r;
|
||||||
|
|
||||||
|
let getUint32;
|
||||||
|
|
||||||
|
if (coeffs instanceof ffjavascript.BigBuffer) {
|
||||||
|
const coeffsDV = [];
|
||||||
|
const PAGE_LEN = coeffs[0].length;
|
||||||
|
for (let i=0; i< coeffs.buffers.length; i++) {
|
||||||
|
coeffsDV.push(new DataView(coeffs.buffers[i]));
|
||||||
|
}
|
||||||
|
getUint32 = function (pos) {
|
||||||
|
return coeffsDV[Math.floor(pos/PAGE_LEN)].getUint32(pos % PAGE_LEN, true);
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
const coeffsDV = new DataView(coeffs.buffer, coeffs.byteOffset, coeffs.byteLength);
|
||||||
|
getUint32 = function (pos) {
|
||||||
|
return coeffsDV.getUint32(pos, true);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const elementsPerChunk = Math.floor(zkey.domainSize/concurrency);
|
const elementsPerChunk = Math.floor(zkey.domainSize/concurrency);
|
||||||
const coeffsDV = new DataView(coeffs.buffer, coeffs.byteOffset, coeffs.byteLength);
|
|
||||||
const promises = [];
|
const promises = [];
|
||||||
|
|
||||||
const cutPoints = [];
|
const cutPoints = [];
|
||||||
@ -6239,10 +6256,10 @@ async function buldABC(curve, zkey, witness, coeffs) {
|
|||||||
|
|
||||||
function getCutPoint(v) {
|
function getCutPoint(v) {
|
||||||
let m = 0;
|
let m = 0;
|
||||||
let n = coeffsDV.getUint32(0, true);
|
let n = getUint32(0);
|
||||||
while (m < n) {
|
while (m < n) {
|
||||||
var k = (n + m) >> 1;
|
var k = (n + m) >> 1;
|
||||||
const va = coeffsDV.getUint32(4 + k*sCoef + 4, true);
|
const va = getUint32(4 + k*sCoef + 4);
|
||||||
if (va > v) {
|
if (va > v) {
|
||||||
n = k - 1;
|
n = k - 1;
|
||||||
} else if (va < v) {
|
} else if (va < v) {
|
||||||
|
@ -1668,8 +1668,25 @@ async function buldABC(curve, zkey, witness, coeffs) {
|
|||||||
const concurrency = curve.tm.concurrency;
|
const concurrency = curve.tm.concurrency;
|
||||||
const sCoef = 4*3 + zkey.n8r;
|
const sCoef = 4*3 + zkey.n8r;
|
||||||
|
|
||||||
|
let getUint32;
|
||||||
|
|
||||||
|
if (coeffs instanceof ffjavascript.BigBuffer) {
|
||||||
|
const coeffsDV = [];
|
||||||
|
const PAGE_LEN = coeffs[0].length;
|
||||||
|
for (let i=0; i< coeffs.buffers.length; i++) {
|
||||||
|
coeffsDV.push(new DataView(coeffs.buffers[i]));
|
||||||
|
}
|
||||||
|
getUint32 = function (pos) {
|
||||||
|
return coeffsDV[Math.floor(pos/PAGE_LEN)].getUint32(pos % PAGE_LEN, true);
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
const coeffsDV = new DataView(coeffs.buffer, coeffs.byteOffset, coeffs.byteLength);
|
||||||
|
getUint32 = function (pos) {
|
||||||
|
return coeffsDV.getUint32(pos, true);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const elementsPerChunk = Math.floor(zkey.domainSize/concurrency);
|
const elementsPerChunk = Math.floor(zkey.domainSize/concurrency);
|
||||||
const coeffsDV = new DataView(coeffs.buffer, coeffs.byteOffset, coeffs.byteLength);
|
|
||||||
const promises = [];
|
const promises = [];
|
||||||
|
|
||||||
const cutPoints = [];
|
const cutPoints = [];
|
||||||
@ -1727,10 +1744,10 @@ async function buldABC(curve, zkey, witness, coeffs) {
|
|||||||
|
|
||||||
function getCutPoint(v) {
|
function getCutPoint(v) {
|
||||||
let m = 0;
|
let m = 0;
|
||||||
let n = coeffsDV.getUint32(0, true);
|
let n = getUint32(0);
|
||||||
while (m < n) {
|
while (m < n) {
|
||||||
var k = (n + m) >> 1;
|
var k = (n + m) >> 1;
|
||||||
const va = coeffsDV.getUint32(4 + k*sCoef + 4, true);
|
const va = getUint32(4 + k*sCoef + 4);
|
||||||
if (va > v) {
|
if (va > v) {
|
||||||
n = k - 1;
|
n = k - 1;
|
||||||
} else if (va < v) {
|
} else if (va < v) {
|
||||||
|
File diff suppressed because one or more lines are too long
2
build/snarkjs.min.js
vendored
2
build/snarkjs.min.js
vendored
File diff suppressed because one or more lines are too long
@ -3,7 +3,7 @@ import * as zkeyUtils from "./zkey_utils.js";
|
|||||||
import * as wtnsUtils from "./wtns_utils.js";
|
import * as wtnsUtils from "./wtns_utils.js";
|
||||||
import { getCurveFromQ as getCurve } from "./curves.js";
|
import { getCurveFromQ as getCurve } from "./curves.js";
|
||||||
import { log2 } from "./misc.js";
|
import { log2 } from "./misc.js";
|
||||||
import { Scalar, utils } from "ffjavascript";
|
import { Scalar, utils, BigBuffer } from "ffjavascript";
|
||||||
const {stringifyBigInts} = utils;
|
const {stringifyBigInts} = utils;
|
||||||
|
|
||||||
export default async function groth16Prove(zkeyFileName, witnessFileName, logger) {
|
export default async function groth16Prove(zkeyFileName, witnessFileName, logger) {
|
||||||
@ -118,8 +118,25 @@ async function buldABC(curve, zkey, witness, coeffs) {
|
|||||||
const concurrency = curve.tm.concurrency;
|
const concurrency = curve.tm.concurrency;
|
||||||
const sCoef = 4*3 + zkey.n8r;
|
const sCoef = 4*3 + zkey.n8r;
|
||||||
|
|
||||||
|
let getUint32;
|
||||||
|
|
||||||
|
if (coeffs instanceof BigBuffer) {
|
||||||
|
const coeffsDV = [];
|
||||||
|
const PAGE_LEN = coeffs[0].length;
|
||||||
|
for (let i=0; i< coeffs.buffers.length; i++) {
|
||||||
|
coeffsDV.push(new DataView(coeffs.buffers[i]));
|
||||||
|
}
|
||||||
|
getUint32 = function (pos) {
|
||||||
|
return coeffsDV[Math.floor(pos/PAGE_LEN)].getUint32(pos % PAGE_LEN, true);
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
const coeffsDV = new DataView(coeffs.buffer, coeffs.byteOffset, coeffs.byteLength);
|
||||||
|
getUint32 = function (pos) {
|
||||||
|
return coeffsDV.getUint32(pos, true);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const elementsPerChunk = Math.floor(zkey.domainSize/concurrency);
|
const elementsPerChunk = Math.floor(zkey.domainSize/concurrency);
|
||||||
const coeffsDV = new DataView(coeffs.buffer, coeffs.byteOffset, coeffs.byteLength);
|
|
||||||
const promises = [];
|
const promises = [];
|
||||||
|
|
||||||
const cutPoints = [];
|
const cutPoints = [];
|
||||||
@ -177,10 +194,10 @@ async function buldABC(curve, zkey, witness, coeffs) {
|
|||||||
|
|
||||||
function getCutPoint(v) {
|
function getCutPoint(v) {
|
||||||
let m = 0;
|
let m = 0;
|
||||||
let n = coeffsDV.getUint32(0, true);
|
let n = getUint32(0);
|
||||||
while (m < n) {
|
while (m < n) {
|
||||||
var k = (n + m) >> 1;
|
var k = (n + m) >> 1;
|
||||||
const va = coeffsDV.getUint32(4 + k*sCoef + 4, true);
|
const va = getUint32(4 + k*sCoef + 4);
|
||||||
if (va > v) {
|
if (va > v) {
|
||||||
n = k - 1;
|
n = k - 1;
|
||||||
} else if (va < v) {
|
} else if (va < v) {
|
||||||
|
Loading…
Reference in New Issue
Block a user