Skip to content

EVM: bn256ScalarMul precompile (0x07) does not behave correctly when scalar=0 #1639

@raulk

Description

@raulk

Original report

https://filecoinproject.slack.com/archives/CRK2LKYHW/p1675441024104129

Investigation

Our implementation of the ecMul precompile attempts to place the result of the multiplication (zero) on the alt_bn128 curve, which fails with an EcErr(InvalidEncoding) error. Instead, we should successfully return zero. Other implementations return zero.

Note that according to EIP-196, where this precompile was introduced, zero is a valid scalar argument.

[INFO] Call Precompile:
	address: 0000000000000000000000000000000000000007
	context: PrecompileContext { call_type: StaticCall, gas_limit: 9484863179, value: 0 }
	input: 035cf447ec2f8f21e6ea3d49d80a4a823834b1a776ab1733731587613f5065f821c972c4e0c8eb2430171599b1f4900601fdb8f4b2d248d22ebefe3d5368a80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
[WARN] Precompile failed: error EcErr(InvalidEncoding)

Separately, we should investigate why the input sent to this precompile is longer than it needs to be (appears to include zero padding of some kind)?

Repro

filecoin-project/builtin-actors#1164

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions