aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey/eckcdsa
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/eckcdsa
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/eckcdsa')
-rw-r--r--src/lib/pubkey/eckcdsa/eckcdsa.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/lib/pubkey/eckcdsa/eckcdsa.cpp b/src/lib/pubkey/eckcdsa/eckcdsa.cpp
index f16fb027e..90716228a 100644
--- a/src/lib/pubkey/eckcdsa/eckcdsa.cpp
+++ b/src/lib/pubkey/eckcdsa/eckcdsa.cpp
@@ -8,6 +8,7 @@
#include <botan/eckcdsa.h>
#include <botan/internal/pk_ops_impl.h>
+#include <botan/internal/point_mul.h>
#include <botan/keypair.h>
#include <botan/reducer.h>
#include <botan/emsa.h>
@@ -113,11 +114,11 @@ class ECKCDSA_Verification_Operation final : public PK_Ops::Verification_with_EM
const std::string& emsa) :
PK_Ops::Verification_with_EMSA(emsa),
m_group(eckcdsa.domain()),
- m_public_point(eckcdsa.public_point()),
+ m_gy_mul(m_group.get_base_point(), eckcdsa.public_point()),
m_prefix()
{
- const BigInt public_point_x = m_public_point.get_affine_x();
- const BigInt public_point_y = m_public_point.get_affine_y();
+ const BigInt public_point_x = eckcdsa.public_point().get_affine_x();
+ const BigInt public_point_y = eckcdsa.public_point().get_affine_y();
m_prefix.resize(public_point_x.bytes() + public_point_y.bytes());
public_point_x.binary_encode(&m_prefix[0]);
@@ -136,7 +137,7 @@ class ECKCDSA_Verification_Operation final : public PK_Ops::Verification_with_EM
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;
secure_vector<uint8_t> m_prefix;
};
@@ -169,7 +170,7 @@ bool ECKCDSA_Verification_Operation::verify(const uint8_t msg[], size_t,
BigInt w(r_xor_e.data(), r_xor_e.size());
w = m_group.mod_order(w);
- const PointGFp q = m_group.point_multiply(w, m_public_point, s);
+ const PointGFp q = m_gy_mul.multi_exp(w, s);
const BigInt q_x = q.get_affine_x();
secure_vector<uint8_t> c(q_x.bytes());
q_x.binary_encode(c.data());