aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-03-15 12:43:50 -0400
committerJack Lloyd <[email protected]>2018-03-15 12:43:50 -0400
commite11d00a6cb0abb3e29fd1eff4654208a4c423a50 (patch)
tree66801c3d61cf486f902d90556bc272a30438b51f /src/lib/pubkey
parent680ac534d5365b7d503340b712df83d3ea8c991f (diff)
Add multiexponentation interface to DL_Group
Diffstat (limited to 'src/lib/pubkey')
-rw-r--r--src/lib/pubkey/dl_group/dl_group.cpp8
-rw-r--r--src/lib/pubkey/dl_group/dl_group.h12
2 files changed, 17 insertions, 3 deletions
diff --git a/src/lib/pubkey/dl_group/dl_group.cpp b/src/lib/pubkey/dl_group/dl_group.cpp
index ff8ba3727..9bd9d2462 100644
--- a/src/lib/pubkey/dl_group/dl_group.cpp
+++ b/src/lib/pubkey/dl_group/dl_group.cpp
@@ -45,6 +45,9 @@ class DL_Group_Data final
return m_mod_p.multiply(x, y);
}
+ std::shared_ptr<const Montgomery_Params> monty_params() const
+ { return m_monty_params; }
+
size_t p_bits() const { return m_p_bits; }
size_t p_bytes() const { return (m_p_bits + 7) / 8; }
@@ -422,6 +425,11 @@ BigInt DL_Group::multiply_mod_p(const BigInt& x, const BigInt& y) const
return data().multiply_mod_p(x, y);
}
+BigInt DL_Group::multi_exponentiate(const BigInt& x, const BigInt& y, const BigInt& z) const
+ {
+ return monty_multi_exp(data().monty_params(), get_g(), x, y, z);
+ }
+
BigInt DL_Group::power_g_p(const BigInt& x) const
{
return data().power_g_p(x);
diff --git a/src/lib/pubkey/dl_group/dl_group.h b/src/lib/pubkey/dl_group/dl_group.h
index a3dcfbdf0..14ef3c088 100644
--- a/src/lib/pubkey/dl_group/dl_group.h
+++ b/src/lib/pubkey/dl_group/dl_group.h
@@ -166,13 +166,13 @@ class BOTAN_PUBLIC_API(2,0) DL_Group final
*/
std::vector<uint8_t> DER_encode(Format format) const;
- /*
+ /**
* Reduce an integer modulo p
* @return x % p
*/
BigInt mod_p(const BigInt& x) const;
- /*
+ /**
* Multiply and reduce an integer modulo p
* @return (x*y) % p
*/
@@ -180,13 +180,19 @@ class BOTAN_PUBLIC_API(2,0) DL_Group final
BigInt inverse_mod_p(const BigInt& x) const;
- /*
+ /**
* Modular exponentiation
* @return (g^x) % p
*/
BigInt power_g_p(const BigInt& x) const;
/**
+ * Multi-exponentiate
+ * Return (g^x * y^z) % p
+ */
+ BigInt multi_exponentiate(const BigInt& x, const BigInt& y, const BigInt& z) const;
+
+ /**
* Return the size of p in bits
* Same as get_p().bits()
*/