Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
holgerd77 committed Aug 6, 2024
1 parent d61aa47 commit 610852b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/evm/src/precompiles/07-ecmul.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { bytesToHex, short } from '@ethereumjs/util'

import { OOGResult } from '../evm.js'
import { EvmErrorResult, OOGResult } from '../evm.js'
import { ERROR, EvmError } from '../exceptions.js'

import { equalityLengthCheck } from './util.js'

import type { EVM } from '../evm.js'
import type { ExecResult } from '../types.js'
Expand All @@ -23,6 +26,14 @@ export function precompile07(opts: PrecompileInput): ExecResult {
return OOGResult(opts.gasLimit)
}

if (!equalityLengthCheck(opts, 128, 'ECMUL (0x07)')) {
// TODO: I changed opts.gasLimit (as being used for BLS) to gasUsed
// This passes the local npx vitest run test/precompiles/07-ecmul.spec.ts test,
// getting to the expected 40000 (instead of 65535), a bit spooky though.
// Should be analyzed if both cases (BLS and BN254) are correctly applied.
return EvmErrorResult(new EvmError(ERROR.INVALID_INPUT_LENGTH), gasUsed)
}

const returnData = (opts._EVM as EVM)['_bn254'].mul(opts.data.subarray(0, 128))

// check ecmul success or failure by comparing the output length
Expand Down

0 comments on commit 610852b

Please sign in to comment.