-
Notifications
You must be signed in to change notification settings - Fork 497
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
Implement num_traits::pow for Scalar #340
base: develop
Are you sure you want to change the base?
Conversation
I should point out, I also implemented I just implemented these as wrappers around the existing |
Hi @cargodog, thanks for the PR. First, I feel extremely hesitant to implement numeric traits from a non-stdlib crate, especially one that is not yet stabilised. On another note, I took a skim over the arcturus paper and your implementation, and I could definitely be wrong about this but I believe your scalar mu (and field element rho) terms are written multiplicatively, so anything that looks like an exponentiation in those terms is instead a multiplication. It's a little confusing because the author is using additive notation for the group elements and multiplicative for field elements and scalars, but it's (annoyingly) something I've seen in other papers with similar utilisation of polynomial evaluations for secret keys and/or NIZK challenges. Anyway, this is all just to say that unless I'm reading this paper wrong, I'm pretty sure you don't need exponentiation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment above.
I understand this concern, but I disagree that the crate is not yet established. The crate was originally part of That said, I understand pulling in a non-std crate carries risk, and I understand if that's a deal-breaker 😕.
I'm now seeing the author has revised his paper since my original implementation, specifically with regard to The An arguably more significant reason for this patch, is broader compatibility with other numeric crates. The |
Oof, sorry for the wall of text! If the |
Hi @cargodog, I missed that—five pages into their simulation argument—they require DDL, so you're correct that it is actually exponentiation. (On another note, DDL is a rare assumption and it's probably the only actual time I can think of where exponentiation is needed. In any case, I don't think they actually need DDL: they should be able to do the polynomial interpolation as normal requiring only DL, rather than in the exponents, and the resulting protocol would be quite a bit more computationally efficient. Without working through the maths more, I'm not sure what this would do to the size of the proofs.. which might be why they require DDL?) In any case, I'll think about this a bit more, but since it's really uncommon to need exponentiation and many papers have confusing and/or mixed notation, I'd still be a bit nervous that the API would provide an easy foot-gun to users. |
What:
This PR implements num_traits::Pow for the
Scalar
type.Why:
Many cryptographic protocols, especially some more complex ZKP schemes, rely on
Scalar
exponentiation. Without this trait implementation, using this library in such protocols requires also implementing exponentiation for Scalar types. This leads to inconsistent implementations and suboptimal arithmetic (e.g. fast exponentiation).In many cases, simple iterative exponentiation is sufficient and easy to implement. In other cases, however, iterative exponentiation is costly and slows down the system.
num_traits::Pow
provides optimized "fast math" exponentiation for us, providing users an easy and repeatable way to get the most efficient exponentiation in all scenarios.Implementation notes:
I copied the
pow_impl!
macro fromnum_traits::Pow
, because they do not export this macro. I feel this provides the simplest/cleanest implementation, but please let me know if you would prefer to have this done some other way (or not at all).Cheers 🍻
P.S. great work on this library! I find myself recommending it to others all the time.