mirror of
https://github.com/CryptKeeperZK/ffjavascript.git
synced 2026-05-03 03:00:11 -04:00
Fix fftExt totalBits
This commit is contained in:
File diff suppressed because one or more lines are too long
6
package-lock.json
generated
6
package-lock.json
generated
@@ -2274,9 +2274,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"wasmcurves": {
|
||||
"version": "0.0.10",
|
||||
"resolved": "https://registry.npmjs.org/wasmcurves/-/wasmcurves-0.0.10.tgz",
|
||||
"integrity": "sha512-bCIZni6RzeQrgt3Hri+KiblRJJq9s7a2F0bGIpa9Eaj+V9jDxscMH6wDWbIYMTuVMW4dqO8eL8gUI/nm/p2SeA==",
|
||||
"version": "0.0.11",
|
||||
"resolved": "https://registry.npmjs.org/wasmcurves/-/wasmcurves-0.0.11.tgz",
|
||||
"integrity": "sha512-iRuX0slhizCSYGScgQH0P7j2GS5qgfnpYVPtKoj+wrlLGPZQZiviGj8AwJdeg7fI68yVw4Wquvyp0ZCPfcb0wQ==",
|
||||
"requires": {
|
||||
"big-integer": "^1.6.42",
|
||||
"blakejs": "^1.1.0"
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
"homepage": "https://github.com/iden3/ffjs#readme",
|
||||
"dependencies": {
|
||||
"big-integer": "^1.6.48",
|
||||
"wasmcurves": "0.0.10",
|
||||
"wasmcurves": "0.0.11",
|
||||
"worker-threads": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -305,6 +305,7 @@ export default function buildFFT(curve, groupName) {
|
||||
|
||||
async function _fftJoinExt(buff1, buff2, fn, first, inc, inType, outType, logger, loggerTxt) {
|
||||
const MAX_CHUNK_SIZE = 1<<16;
|
||||
const MIN_CHUNK_SIZE = 1<<4;
|
||||
|
||||
let fnName;
|
||||
let fnIn2Mid, fnMid2Out;
|
||||
@@ -357,11 +358,15 @@ export default function buildFFT(curve, groupName) {
|
||||
throw new Error("Invalid number of points");
|
||||
}
|
||||
|
||||
let chunkSize = Math.floor(nPoints /tm.concurrency);
|
||||
if (chunkSize < MIN_CHUNK_SIZE) chunkSize = MIN_CHUNK_SIZE;
|
||||
if (chunkSize > MAX_CHUNK_SIZE) chunkSize = MAX_CHUNK_SIZE;
|
||||
|
||||
const opPromises = [];
|
||||
|
||||
for (let i=0; i<nPoints; i += MAX_CHUNK_SIZE) {
|
||||
for (let i=0; i<nPoints; i += chunkSize) {
|
||||
if (logger) logger.debug(`${loggerTxt}: fftJoinExt Start: ${i}/${nPoints}`);
|
||||
const n= Math.min(nPoints - i, MAX_CHUNK_SIZE);
|
||||
const n= Math.min(nPoints - i, chunkSize);
|
||||
|
||||
const firstChunk = Fr.mul(first, Fr.exp( inc, i));
|
||||
const task = [];
|
||||
@@ -369,7 +374,6 @@ export default function buildFFT(curve, groupName) {
|
||||
const b1 = buff1.slice(i*sIn, (i+n)*sIn);
|
||||
const b2 = buff2.slice(i*sIn, (i+n)*sIn);
|
||||
|
||||
|
||||
task.push({cmd: "ALLOC", var: 0, len: sMid*n});
|
||||
task.push({cmd: "SET", var: 0, buff: b1});
|
||||
task.push({cmd: "ALLOC", var: 1, len: sMid*n});
|
||||
@@ -385,7 +389,8 @@ export default function buildFFT(curve, groupName) {
|
||||
{var: 1},
|
||||
{val: n},
|
||||
{var: 2},
|
||||
{var: 3}
|
||||
{var: 3},
|
||||
{val: Fr.s},
|
||||
]});
|
||||
if (fnMid2Out) {
|
||||
task.push({cmd: "CALL", fnName:fnMid2Out, params: [{var:0}, {val: n}, {var: 0}]});
|
||||
|
||||
Reference in New Issue
Block a user