diff options
author | Jack Lloyd <[email protected]> | 2018-04-14 09:01:45 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-04-14 09:01:45 -0400 |
commit | 7b466251c4260a0c822baeaa2857d54f8d0dbb1e (patch) | |
tree | 416eb9ee713482d8967297f9c7ecdfd2f00c2b96 /src/lib/pubkey/ec_group/point_gfp.h | |
parent | d208cc3ab74afce04b18c21d87e4927034ab726a (diff) | |
parent | f0c16e78ccdec810b57dc73e4727011f5a163798 (diff) |
Merge GH #1538 Minor ECC optimizations
Diffstat (limited to 'src/lib/pubkey/ec_group/point_gfp.h')
-rw-r--r-- | src/lib/pubkey/ec_group/point_gfp.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/lib/pubkey/ec_group/point_gfp.h b/src/lib/pubkey/ec_group/point_gfp.h index 2a9948fde..271d7383a 100644 --- a/src/lib/pubkey/ec_group/point_gfp.h +++ b/src/lib/pubkey/ec_group/point_gfp.h @@ -152,6 +152,13 @@ class BOTAN_PUBLIC_API(2,0) PointGFp final const BigInt& get_y() const { return m_coord_y; } const BigInt& get_z() const { return m_coord_z; } + void swap_coords(BigInt& new_x, BigInt& new_y, BigInt& new_z) + { + m_coord_x.swap(new_x); + m_coord_y.swap(new_y); + m_coord_z.swap(new_z); + } + /** * Force this point to affine coordinates */ @@ -236,6 +243,13 @@ class BOTAN_PUBLIC_API(2,0) PointGFp final void mult2(std::vector<BigInt>& workspace); /** + * Repeated point doubling + * @param i number of doublings to perform + * @param workspace temp space, at least WORKSPACE_SIZE elements + */ + void mult2i(size_t i, std::vector<BigInt>& workspace); + + /** * Point addition * @param other the point to add to *this * @param workspace temp space, at least WORKSPACE_SIZE elements @@ -249,6 +263,18 @@ class BOTAN_PUBLIC_API(2,0) PointGFp final } /** + * Point doubling + * @param workspace temp space, at least WORKSPACE_SIZE elements + * @return *this doubled + */ + PointGFp double_of(std::vector<BigInt>& workspace) const + { + PointGFp x = (*this); + x.mult2(workspace); + return x; + } + + /** * Return the zero (aka infinite) point associated with this curve */ PointGFp zero() const { return PointGFp(m_curve); } |