mratsim / constantine

Constantine: modular, high-performance, zero-dependency cryptography stack for verifiable computation, proof systems and blockchain protocols.
Other
413 stars 44 forks source link

EIP-2537: Potential memory leak in G1 and G2 MSM #384

Closed mratsim closed 5 months ago

mratsim commented 6 months ago

See https://github.com/mratsim/constantine/blob/master/constantine%2Fethereum_evm_precompiles.nim#L907 (link to be edited with fixed commit on a computer)

The code allocates but then can return early without dealloc.

We need to introduce a check macro similar to KZG commitments with early returns.

Note: we don't use Nim's builtin defer to ensure that no exceptions and so no runtime (that need to be initialized before used when building a DLL) is included as much as possible.