forked from Tonnel-Network/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepareZkey.js
30 lines (29 loc) · 1.23 KB
/
prepareZkey.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const splitFile = require('split-file');
const zlib = require('zlib');
const unzip = zlib.createUnzip();
const fs = require('fs');
const splitFiles = [
__dirname + '/build/circuits/circuit_final.zkey.gz.sf-part1',
__dirname + '/build/circuits/circuit_final.zkey.gz.sf-part2',
__dirname + '/build/circuits/circuit_final.zkey.gz.sf-part3',
__dirname + '/build/circuits/circuit_final.zkey.gz.sf-part4',
__dirname + '/build/circuits/circuit_final.zkey.gz.sf-part5',
__dirname + '/build/circuits/circuit_final.zkey.gz.sf-part6',
__dirname + '/build/circuits/circuit_final.zkey.gz.sf-part7',
]
splitFile.mergeFiles(splitFiles, __dirname + '/build/circuits/circuit_final.zkey.compressed.gz')
.then(async () => {
const inp= fs.createReadStream(__dirname + '/build/circuits/circuit_final.zkey.compressed.gz');
const out= fs.createWriteStream(__dirname + '/build/circuits/circuit_final.zkey');
inp.pipe(unzip).pipe(out);
// wait 5 seconds
await new Promise(resolve => setTimeout(resolve, 5000));
fs.unlinkSync(__dirname + '/build/circuits/circuit_final.zkey.compressed.gz');
// delete splitFiles
splitFiles.forEach((file) => {
fs.unlinkSync(file);
})
})
.catch((err) => {
console.log('Error: ', err);
});