Skip to content

Commit 60dc748

Browse files
committed
perf(proof): use cached curve rather than a new one
1 parent 36958e0 commit 60dc748

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

packages/proof/src/groth16/verify.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ export default async function groth16Verify(_vk_verifier: any, _publicSignals: a
2727
const proof = unstringifyBigInts(_proof)
2828
const publicSignals = unstringifyBigInts(_publicSignals)
2929

30-
const curve = await buildBn128(undefined, undefined)
30+
// @ts-ignore
31+
const curve = globalThis.curve_bn128 ?? (await buildBn128(undefined, undefined))
3132

3233
const IC0 = curve.G1.fromObject(vk_verifier.IC[0])
3334
const IC = new Uint8Array(curve.G1.F.n8 * 2 * publicSignals.length)

packages/proof/src/groth16/zkey-utils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ async function readHeaderGroth16(fd: any, sections: any, toObject: any) {
3131
const n8r = await fd.readULE32()
3232
zkey.n8r = n8r
3333
zkey.r = await binFileUtils.readBigInt(fd, n8r)
34-
zkey.curve = await buildBn128(undefined, undefined)
34+
35+
// @ts-ignore
36+
zkey.curve = globalThis.curve_bn128 ?? (await buildBn128(undefined, undefined))
37+
3538
zkey.nVars = await fd.readULE32()
3639
zkey.nPublic = await fd.readULE32()
3740
zkey.domainSize = await fd.readULE32()

0 commit comments

Comments
 (0)