|
3 | 3 | use crate::{ |
4 | 4 | CurveArithmetic, Error, FieldBytes, PrimeCurve, Scalar, ScalarPrimitive, SecretKey, |
5 | 5 | ops::{Invert, Reduce, ReduceNonZero}, |
| 6 | + point::NonIdentity, |
6 | 7 | scalar::IsHigh, |
7 | 8 | }; |
8 | 9 | use base16ct::HexDisplay; |
@@ -258,6 +259,54 @@ where |
258 | 259 | } |
259 | 260 | } |
260 | 261 |
|
| 262 | +impl<C, P> Mul<NonIdentity<P>> for NonZeroScalar<C> |
| 263 | +where |
| 264 | + C: CurveArithmetic, |
| 265 | + NonIdentity<P>: Mul<NonZeroScalar<C>, Output = NonIdentity<P>>, |
| 266 | +{ |
| 267 | + type Output = NonIdentity<P>; |
| 268 | + |
| 269 | + fn mul(self, rhs: NonIdentity<P>) -> Self::Output { |
| 270 | + rhs * self |
| 271 | + } |
| 272 | +} |
| 273 | + |
| 274 | +impl<C, P> Mul<&NonIdentity<P>> for NonZeroScalar<C> |
| 275 | +where |
| 276 | + C: CurveArithmetic, |
| 277 | + for<'a> &'a NonIdentity<P>: Mul<NonZeroScalar<C>, Output = NonIdentity<P>>, |
| 278 | +{ |
| 279 | + type Output = NonIdentity<P>; |
| 280 | + |
| 281 | + fn mul(self, rhs: &NonIdentity<P>) -> Self::Output { |
| 282 | + rhs * self |
| 283 | + } |
| 284 | +} |
| 285 | + |
| 286 | +impl<C, P> Mul<NonIdentity<P>> for &NonZeroScalar<C> |
| 287 | +where |
| 288 | + C: CurveArithmetic, |
| 289 | + for<'a> NonIdentity<P>: Mul<&'a NonZeroScalar<C>, Output = NonIdentity<P>>, |
| 290 | +{ |
| 291 | + type Output = NonIdentity<P>; |
| 292 | + |
| 293 | + fn mul(self, rhs: NonIdentity<P>) -> Self::Output { |
| 294 | + rhs * self |
| 295 | + } |
| 296 | +} |
| 297 | + |
| 298 | +impl<C, P> Mul<&NonIdentity<P>> for &NonZeroScalar<C> |
| 299 | +where |
| 300 | + C: CurveArithmetic, |
| 301 | + for<'a> &'a NonIdentity<P>: Mul<&'a NonZeroScalar<C>, Output = NonIdentity<P>>, |
| 302 | +{ |
| 303 | + type Output = NonIdentity<P>; |
| 304 | + |
| 305 | + fn mul(self, rhs: &NonIdentity<P>) -> Self::Output { |
| 306 | + rhs * self |
| 307 | + } |
| 308 | +} |
| 309 | + |
261 | 310 | impl<C> PartialEq for NonZeroScalar<C> |
262 | 311 | where |
263 | 312 | C: CurveArithmetic, |
|
0 commit comments