aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey/ecgdsa
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-04-17 17:58:04 -0400
committerJack Lloyd <[email protected]>2018-04-17 18:00:37 -0400
commit4ef7125afe98fafa261cec0b083b69a029aaf678 (patch)
tree75e42ec01c8b18a0726ed5a50c6d78aa79457597 /src/lib/pubkey/ecgdsa
parent86247ee70e14c03fd09933e1e869c445caf5949f (diff)
Precompute for multiexponentation when verifying ECC signatures
ECDSA already did this. Improves repeated ECGDSA, ECKCDSA, SM2, and GOST signature verification by 10-15%
Diffstat (limited to 'src/lib/pubkey/ecgdsa')
-rw-r--r--src/lib/pubkey/ecgdsa/ecgdsa.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/lib/pubkey/ecgdsa/ecgdsa.cpp b/src/lib/pubkey/ecgdsa/ecgdsa.cpp
index 062bb524d..192d999a8 100644
--- a/src/lib/pubkey/ecgdsa/ecgdsa.cpp
+++ b/src/lib/pubkey/ecgdsa/ecgdsa.cpp
@@ -10,6 +10,7 @@
#include <botan/keypair.h>
#include <botan/reducer.h>
#include <botan/internal/pk_ops_impl.h>
+#include <botan/internal/point_mul.h>
namespace Botan {
@@ -86,7 +87,7 @@ class ECGDSA_Verification_Operation final : public PK_Ops::Verification_with_EMS
const std::string& emsa) :
PK_Ops::Verification_with_EMSA(emsa),
m_group(ecgdsa.domain()),
- m_public_point(ecgdsa.public_point())
+ m_gy_mul(m_group.get_base_point(), ecgdsa.public_point())
{
}
@@ -98,7 +99,7 @@ class ECGDSA_Verification_Operation final : public PK_Ops::Verification_with_EMS
const uint8_t sig[], size_t sig_len) override;
private:
const EC_Group m_group;
- const PointGFp& m_public_point;
+ const PointGFp_Multi_Point_Precompute m_gy_mul;
};
bool ECGDSA_Verification_Operation::verify(const uint8_t msg[], size_t msg_len,
@@ -119,7 +120,7 @@ bool ECGDSA_Verification_Operation::verify(const uint8_t msg[], size_t msg_len,
const BigInt u1 = m_group.multiply_mod_order(e, w);
const BigInt u2 = m_group.multiply_mod_order(s, w);
- const PointGFp R = m_group.point_multiply(u1, m_public_point, u2);
+ const PointGFp R = m_gy_mul.multi_exp(u1, u2);
if(R.is_zero())
return false;