-
Notifications
You must be signed in to change notification settings - Fork 481
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 public-facing ops traits on all combos of &T/T #101
Conversation
The public-facing types with arithmetic operations are: - `Scalar`s - `ExtendedPoint`s - `RistrettoPoint`s For these types we define operators with all combinations of borrowed and non-borrowed inputs, to avoid forcing API consumers to write extra ampersands. Since all of the operations involved with these types are expensive relative to the cost of an unnecessary copy, this isn't a big deal. The `MontgomeryPoint` struct isn't included in the above because it's only useful for scalar multiplication. This commit is based on work by @UnlawfulMonad.
|
||
/// Define borrow and non-borrow variants of `Add`. | ||
macro_rules! define_add_variants { | ||
(LHS = $lhs:ty, RHS = $rhs:ty, Output = $out:ty) => { |
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.
macros are cool
Just to reiterate what we talked about in person, so that it's recorded here for posterity:
|
Oh, I guess there's another @rust-lang wishlist item… (I have no idea if there's already a way to do this in Rust) I'd like a way to spit out a programming warning (not really "warning", since IMHO compiler warnings shouldn't really be ignored, so maybe more like "a programming info") at compile time, just once, so that if we see someone compiling something which depends on our types and they've got an |
clippy plugins? /cc @Manishearth |
People can't use the other curve models, since those types are specific to a particular backend, and are (intentionally) not exported as part of the public API. Just my 2c, but I don't feel that this is a significant performance issue, and I'd rather focus on making API that removes the need for people to try to micro-optimize their borrows, which are probably going to be elided by the compiler anyways. |
The public-facing types with arithmetic operations are:
Scalar
sExtendedPoint
sRistrettoPoint
sFor these types we define operators with all combinations of borrowed and
non-borrowed inputs, to avoid forcing API consumers to write extra ampersands.
Since all of the operations involved with these types are expensive relative to
the cost of an unnecessary copy, this isn't a big deal.
The
MontgomeryPoint
struct isn't included in the above because it's onlyuseful for scalar multiplication.
This commit is based on work by @UnlawfulMonad, and this PR supersedes #57 (which I think doesn't apply anymore).