Skip to content

Conversation

@Galoretka
Copy link
Contributor

Description

  • Add early return in EvalUnivariate when len(P)==0 to return 0 (zero polynomial evaluation) instead of panicking on P[0].
  • Add early error in EvalMultilinearMany when len(M)==0 to avoid panicking on M[0] and clearly signal invalid input.
  • These changes align behavior with existing conventions (e.g., evaluators returning zero for empty input) and harden the API against out-of-range panics, improving robustness without altering normal-path performance.

@ivokub ivokub added the src: community Community originating PRs and issues label Sep 17, 2025
@ivokub ivokub requested review from Copilot and ivokub September 17, 2025 09:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds defensive programming to handle empty inputs in polynomial evaluation methods. The changes prevent panics when empty polynomial arrays are passed and provide appropriate fallback behaviors.

  • Adds early return in EvalUnivariate to return zero for empty polynomial coefficients
  • Adds early validation in EvalMultilinearMany to return an error for empty multilinear polynomial arrays
  • Improves API robustness by preventing index out-of-bounds panics

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@ivokub ivokub changed the base branch from master to typo/fixes-v15 September 17, 2025 09:43
Copy link
Collaborator

@ivokub ivokub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution. Looks good.

I think in EvalMultilinearMany we could also return an empty slice and no error. But most probably it would indicate some error upstream when creating inputs, so we could return an error also. Lets see how it works and if other behaviour is needed then can change.

@ivokub ivokub merged commit 2721757 into Consensys:typo/fixes-v15 Sep 17, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

src: community Community originating PRs and issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants