-
Notifications
You must be signed in to change notification settings - Fork 118
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
Enforce that Fr of Engine is the scalar for curve points #66
Conversation
… downstream abstractions.
Actually, it can't be solved with a where bound yet in Rust. rust-lang/rust#20041 So, I think we need this in |
Amusingly, |
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.
ACK
@bmerge r+ |
📌 Commit 471db6a has been approved by |
Enforce that Fr of Engine is the scalar for curve points In bellman, I want to write: ```rust pub struct Point<C: CurveProjective>(pub C); impl<C: CurveProjective> Copy for Point<C> { } impl<C: CurveProjective> Clone for Point<C> { fn clone(&self) -> Point<C> { *self } } impl<C: CurveProjective> Group<C::Engine> for Point<C> { fn group_zero() -> Self { Point(C::zero()) } fn group_mul_assign(&mut self, by: &C::Scalar) { self.0.mul_assign(by.into_repr()); } fn group_add_assign(&mut self, other: &Self) { self.0.add_assign(&other.0); } fn group_sub_assign(&mut self, other: &Self) { self.0.sub_assign(&other.0); } } ``` However, this doesn't typecheck because the compiler cannot know that the `Engine`'s `Fr` type (as dictated by the `Group` trait) is the same as the `Scalar` type of the `CurveProjective` point. This can be solved with a where bound over the trait (for now), but it is generally a good idea for this to be constrained in `pairing`.
☀️ Test successful - pairing-linux32-auto, pairing-linux64-auto, pairing-windows32msvc-auto, pairing-windows64msvc-auto |
Block header parsing and transaction ID computation
In bellman, I want to write:
However, this doesn't typecheck because the compiler cannot know that the
Engine
'sFr
type (as dictated by theGroup
trait) is the same as theScalar
type of theCurveProjective
point. This can be solved with a where bound over the trait (for now), but it is generally a good idea for this to be constrained inpairing
.