From ee7a328f9b087b62ae067624d7000132ad0d1ff5 Mon Sep 17 00:00:00 2001 From: Gabriel Rocheleau Date: Sat, 19 Apr 2025 13:36:18 -0400 Subject: [PATCH] chore: handling of zero point --- .../evm/src/precompiles/11-bls12-map-fp2-to-g2.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/evm/src/precompiles/11-bls12-map-fp2-to-g2.ts b/packages/evm/src/precompiles/11-bls12-map-fp2-to-g2.ts index 9ec579e92b0..96ed5763ec1 100644 --- a/packages/evm/src/precompiles/11-bls12-map-fp2-to-g2.ts +++ b/packages/evm/src/precompiles/11-bls12-map-fp2-to-g2.ts @@ -47,6 +47,18 @@ export async function precompile11(opts: PrecompileInput): Promise { if (opts._debug !== undefined) { opts._debug(`${pName} failed: ${e.message}`) } + // noble‑curves throws this for inputs that map to the point at infinity + if (e.message === 'bad point: ZERO') { + // return two zeroed field elements (x & y), each the same length as the input + const zeroPoint = new Uint8Array(opts.data.length * 2) + if (opts._debug !== undefined) { + opts._debug(`${pName} mapping to ZERO point, returning zero-filled output`) + } + return { + executionGasUsed: gasUsed, + returnValue: zeroPoint, + } + } return EvmErrorResult(e, opts.gasLimit) }