Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Polyeval{Instance, Witness} #315

Merged
merged 5 commits into from
Feb 12, 2024

Conversation

huitseeker
Copy link
Contributor

@huitseeker huitseeker commented Feb 11, 2024

After #305 (which it includes, so go review there plz)

Refactors Polynomial evaluation instances / witnesses to express the specialized functions in terms of the general ones.

For review: the refactoring of PolyEvalInstance::batch_diff_size, which is strict about the size of its arguments and inspects it ,to be the implementation of PolyEvalInstance::batch, has revealed the later call sites are not rigorous about the size of their arguments, nor do they inspect them.

I've patched call-sites to be compliant with the rigor of batch_diff_size, but there's another "looser" variant of this PR that would eliminate x from the PolyEvalInstance.

@huitseeker huitseeker force-pushed the refactor_polyeval branch 2 times, most recently from 6afc212 to 76aa3db Compare February 11, 2024 23:25
}
}

impl<E: Engine> PolyEvalInstance<E> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Now with generic PolyEvalInstance we can derive various implementations of it, right? Do we use that already (or have plans to create and use) and if so where concretely (more exactly - do we have / need alternative implementation which is different comparing to the previous reference one implemented at Solidity side of things)?

Copy link
Contributor Author

@huitseeker huitseeker Feb 12, 2024

Choose a reason for hiding this comment

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

PolyEvalInstance has been generic since the beginning, and the type itself has not changed:
https://github.com/microsoft/Nova/blob/37871d04ba04771bf19c51e5b336e45fdb86c7f7/src/spartan/mod.rs#L117-L121
I'm not sure I understand the question?

The idea here is that batch_diff_size is a more general function that performs a re-scaling in case the passed-in arguments have a different # of variables. When the # of variables is the same for every argument, batch and batch_diff_size produce exactly the same output, which allows implementing one in terms of the other.

Copy link
Contributor

@storojs72 storojs72 Feb 12, 2024

Choose a reason for hiding this comment

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

Right, the question is actually - does new PolyEvalInstanse preserve compatibility with older one and where alt_batch is planning to be used (since as far as I see it is absent in upstream)

Copy link
Contributor Author

@huitseeker huitseeker Feb 12, 2024

Choose a reason for hiding this comment

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

alt_batch isn't new, it's the moved, old implementation of batch. it is here in a tests module, gated by #[cfg(test)] and is not planned to be used anywhere. It is here specifically to ensure (through fuzzing unit tests) that PolyEval{Instance, Witness}::batch remains backward-compatible.

@huitseeker huitseeker changed the title Refactor polyeval (after #305) Refactor Polyeval{Instance, Witness} Feb 12, 2024
@huitseeker huitseeker marked this pull request as draft February 12, 2024 16:46
@huitseeker huitseeker marked this pull request as ready for review February 12, 2024 17:22
@huitseeker huitseeker enabled auto-merge February 12, 2024 17:32
@storojs72 storojs72 self-requested a review February 12, 2024 17:43
@huitseeker huitseeker added this pull request to the merge queue Feb 12, 2024
Merged via the queue into lurk-lang:dev with commit 26fd303 Feb 12, 2024
11 checks passed
@huitseeker huitseeker deleted the refactor_polyeval branch February 12, 2024 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants