|
1 | 1 | //! Scalar field arithmetic. |
2 | 2 |
|
3 | | -use crate::{ |
4 | | - FieldBytes, NonZeroScalar, ORDER, ORDER_HEX, Secp256k1, WideBytes, |
5 | | - arithmetic::{AffinePoint, ProjectivePoint}, |
6 | | -}; |
7 | | -use core::{ |
8 | | - iter::{Product, Sum}, |
9 | | - ops::{Add, AddAssign, Mul, MulAssign, Neg, Shr, ShrAssign, Sub, SubAssign}, |
10 | | -}; |
| 3 | +use crate::{FieldBytes, NonZeroScalar, ORDER, ORDER_HEX, Secp256k1, WideBytes}; |
| 4 | +use core::iter::{Product, Sum}; |
11 | 5 | use elliptic_curve::{ |
12 | 6 | Curve, Error, Generate, ScalarValue, |
13 | 7 | bigint::{ArrayEncoding, Limb, U256, U512, Word, cpubits, modular::Retrieve}, |
14 | 8 | ctutils, |
15 | 9 | ff::{self, Field, FromUniformBytes, PrimeField}, |
16 | | - ops::{Invert, Reduce, ReduceNonZero}, |
| 10 | + ops::{ |
| 11 | + Add, AddAssign, Invert, Mul, MulAssign, Neg, Reduce, ReduceNonZero, Shr, ShrAssign, Sub, |
| 12 | + SubAssign, |
| 13 | + }, |
17 | 14 | rand_core::{CryptoRng, TryCryptoRng, TryRng}, |
18 | 15 | scalar::{FromUintUnchecked, IsHigh}, |
19 | 16 | subtle::{ |
@@ -615,77 +612,7 @@ impl Mul<&Scalar> for Scalar { |
615 | 612 | } |
616 | 613 | } |
617 | 614 |
|
618 | | -impl Mul<AffinePoint> for Scalar { |
619 | | - type Output = ProjectivePoint; |
620 | | - |
621 | | - #[inline] |
622 | | - fn mul(self, rhs: AffinePoint) -> ProjectivePoint { |
623 | | - rhs * self |
624 | | - } |
625 | | -} |
626 | | - |
627 | | -impl Mul<&AffinePoint> for Scalar { |
628 | | - type Output = ProjectivePoint; |
629 | | - |
630 | | - #[inline] |
631 | | - fn mul(self, rhs: &AffinePoint) -> ProjectivePoint { |
632 | | - *rhs * self |
633 | | - } |
634 | | -} |
635 | | - |
636 | | -impl Mul<AffinePoint> for &Scalar { |
637 | | - type Output = ProjectivePoint; |
638 | | - |
639 | | - #[inline] |
640 | | - fn mul(self, rhs: AffinePoint) -> ProjectivePoint { |
641 | | - rhs * self |
642 | | - } |
643 | | -} |
644 | | - |
645 | | -impl Mul<&AffinePoint> for &Scalar { |
646 | | - type Output = ProjectivePoint; |
647 | | - |
648 | | - #[inline] |
649 | | - fn mul(self, rhs: &AffinePoint) -> ProjectivePoint { |
650 | | - *rhs * self |
651 | | - } |
652 | | -} |
653 | | - |
654 | | -impl Mul<ProjectivePoint> for Scalar { |
655 | | - type Output = ProjectivePoint; |
656 | | - |
657 | | - #[inline] |
658 | | - fn mul(self, rhs: ProjectivePoint) -> ProjectivePoint { |
659 | | - rhs * self |
660 | | - } |
661 | | -} |
662 | | - |
663 | | -impl Mul<&ProjectivePoint> for Scalar { |
664 | | - type Output = ProjectivePoint; |
665 | | - |
666 | | - #[inline] |
667 | | - fn mul(self, rhs: &ProjectivePoint) -> ProjectivePoint { |
668 | | - rhs * &self |
669 | | - } |
670 | | -} |
671 | | - |
672 | | -impl Mul<ProjectivePoint> for &Scalar { |
673 | | - type Output = ProjectivePoint; |
674 | | - |
675 | | - #[inline] |
676 | | - fn mul(self, rhs: ProjectivePoint) -> ProjectivePoint { |
677 | | - rhs * self |
678 | | - } |
679 | | -} |
680 | | - |
681 | | -impl Mul<&ProjectivePoint> for &Scalar { |
682 | | - type Output = ProjectivePoint; |
683 | | - |
684 | | - #[inline] |
685 | | - fn mul(self, rhs: &ProjectivePoint) -> ProjectivePoint { |
686 | | - rhs * self |
687 | | - } |
688 | | -} |
| 615 | +elliptic_curve::scalar_mul_impls!(Secp256k1, Scalar); |
689 | 616 |
|
690 | 617 | impl MulAssign<Scalar> for Scalar { |
691 | 618 | fn mul_assign(&mut self, rhs: Scalar) { |
|
0 commit comments