grandinetech / rust-kzg

Parallelized multi-backend KZG library for Ethereum Data Sharding (aka Proto-Danksharding, EIP-4844)
Apache License 2.0
116 stars 51 forks source link

Incorrect input to batch verification causes panic #208

Open nazar-pc opened 1 year ago

nazar-pc commented 1 year ago

This happened when I created polynomial from 8 scalars and then created proof with compute_proof_multi, but then during verification only sent a single value and n == 1 when calling check_proof_multi. Library must detect incorrect input and returning error rather than panicking

thread 'X' panicked at 'index out of bounds: the len is 1 but the index is 1', ../.cargo/git/checkouts/rust-kzg-f871e5172d08c353/49e7b60/blst-from-scratch/src/types/kzg_settings.rs:143:32

This line specifically: https://github.com/sifraitech/rust-kzg/blob/f014df818fbb3e4f45d66c4224fe000975fdee41/blst-from-scratch/src/types/kzg_settings.rs#L143

sauliusgrigaitis commented 1 year ago

It could simply call a single proof check function if n == 1. Feel free to open PR.

nazar-pc commented 1 year ago

It panics the same way with n == 2 :slightly_smiling_face:

sauliusgrigaitis commented 1 year ago

Then it needs more love :)