Lagrange interpolation over elements in finite field? #952
Unanswered
yousefmoazzam
asked this question in
Q&A
Replies: 1 comment
-
I've not fully figured this out, but have improved my understanding a bit, so I'll partially answer myself in case it could be of any help to anyone else. I think I now understand the resolving comment in #921. In the context of my code example above:
I know that I'm still missing something, because when I evaluate the interpolated polynomial at the 4th roots of unity (I assumed the ordering 1, 4, 16, 13 based on the ordering of the analogous 4th roots of unity over the complex numbers 1, i, -1, -i) I get two of the four coefficients of the polynomial slightly incorrect:
But, things make more sense than before, which is good! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi folks!
Firstly, many thanks to the contributors to the arkworks ecosystem, I've been playing with some of the crates in the project and it's been a fun experience 🙂
I've been working through this online book on zero knowledge programming where the code examples are in python, and I've been trying to test my understanding by doing analagous things in rust, using crates in the arkworks ecosystem when it seemed relevant.
I had a question about Lagrange interpolation of finite field elements to get the coefficients of a polynomial, and I was wondering if the community would be able to help me out a bit?
In the post in the online book on Lagrange interpolation, there's a small code snippet that I believe is doing something like:
For reference, the python code snippet in the post I'm referring to is the following:
Trying to follow the docs here, my best naive attempt so far at doing an analogous thing in rust using crates in the arkworks ecosystem was the following:
However, I get an assertion error:
and if I print the result of the evaluations I see that I get some values I didn't expect for the evaluation of the interpolated polynomial:
After browsing some of the issues, I know that part of why my code is incorrect is because I'm making the same error as in #921, but I admittedly don't understand the resolving comment for that issue. (I did start taking a look at how an IFFT can be used to compute the coefficients of a polynomial, but soon wondered if understanding that was overkill for what I'm wanting to get done, so decided to seek some help before going too far down that rabbit hole).
So, one part of this post was to ask if I could possibly get a bit more info on how that answer resolved the issue. Would I need to provide different values to evaluate the interpolated polynomial at to get what I want, rather than passing in the values in my
x_values
vector?However, I did also want to step back and ask if I'm using the arkworks crates correctly to do Lagrange interpolation, am I using the right things to accomplish what I want? Or am I using the wrong tools fore the job? I did see the
evaluate_all_lagrange_coefficients
method which sort of sounds like what I'm looking for, but I didn't understand how to use it: I was expecting to be able to give it a vector of points/elements or something (like in the python example), so I was thrown-off when I saw that the method takes only one element as a parameter I think?I hope my questions make some sense, please do let me know if I can clarify anything, and thanks in advance for any help! 🙂
Beta Was this translation helpful? Give feedback.
All reactions