🛠backwards compatibility fix

This commit is contained in:
Alexey 2019-11-14 12:52:44 +03:00
parent c254b59622
commit d46185ec35

@ -169,7 +169,11 @@ function thread(self) {
}; };
} }
async function build(wasmInitialMemory = 5000) { // We use the Object.assign approach for the backwards compatibility
// @params Number wasmInitialMemory
async function build(params) {
const defaultParams = { wasmInitialMemory: 5000 };
Object.assign(defaultParams, params);
const groth16 = new Groth16(); const groth16 = new Groth16();
groth16.q = bigInt("21888242871839275222246405745257275088696311157297823662689037894645226208583"); groth16.q = bigInt("21888242871839275222246405745257275088696311157297823662689037894645226208583");
@ -178,7 +182,7 @@ async function build(wasmInitialMemory = 5000) {
groth16.n32 = groth16.n64*2; groth16.n32 = groth16.n64*2;
groth16.n8 = groth16.n64*8; groth16.n8 = groth16.n64*8;
groth16.memory = new WebAssembly.Memory({initial:wasmInitialMemory}); groth16.memory = new WebAssembly.Memory({initial:defaultParams.wasmInitialMemory});
groth16.i32 = new Uint32Array(groth16.memory.buffer); groth16.i32 = new Uint32Array(groth16.memory.buffer);
const wasmModule = await WebAssembly.compile(groth16_wasm.code); const wasmModule = await WebAssembly.compile(groth16_wasm.code);