aboutsummaryrefslogtreecommitdiffstats
path: root/src/cli
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-03-08 07:21:43 -0500
committerJack Lloyd <[email protected]>2018-03-08 07:36:02 -0500
commit300cc7e5523396bae65f61485406a0bf392d8320 (patch)
treebd68ed9f7d5a6902247c9101544431b1e42dc75b /src/cli
parent34aa3778a0f426fb7487c62049570d504e447c2f (diff)
Add mixed (J+A) point addition, new scalar mul for base points
Adds PointGFp::force_affine(), ::add_affine(), and ::is_affine() Use a (very simple) technique for base point precomputations. Stick with fixed window for variable point inputs. Scalar blinding is now always enabled
Diffstat (limited to 'src/cli')
-rw-r--r--src/cli/speed.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/cli/speed.cpp b/src/cli/speed.cpp
index 209e8d68a..42cb10ca6 100644
--- a/src/cli/speed.cpp
+++ b/src/cli/speed.cpp
@@ -1258,28 +1258,35 @@ class Speed final : public Command
{
const Botan::EC_Group group(group_name);
- std::unique_ptr<Timer> mult_timer = make_timer(group_name + " scalar mult");
- std::unique_ptr<Timer> blinded_mult_timer = make_timer(group_name + " blinded scalar mult");
+ std::unique_ptr<Timer> mult_timer = make_timer(group_name + " Montgomery ladder");
+ std::unique_ptr<Timer> blinded_mult_timer = make_timer(group_name + " blinded comb");
+ std::unique_ptr<Timer> blinded_var_mult_timer = make_timer(group_name + " blinded window");
- const Botan::BigInt scalar(rng(), group.get_p_bits());
const Botan::PointGFp& base_point = group.get_base_point();
- const Botan::PointGFp_Blinded_Multiplier scalar_mult(base_point);
-
std::vector<Botan::BigInt> ws;
- while(blinded_mult_timer->under(runtime))
+ while(mult_timer->under(runtime) &&
+ blinded_mult_timer->under(runtime) &&
+ blinded_var_mult_timer->under(runtime))
{
+ const Botan::BigInt scalar(rng(), group.get_p_bits());
+
const Botan::PointGFp r1 = mult_timer->run([&]() { return base_point * scalar; });
const Botan::PointGFp r2 = blinded_mult_timer->run(
- [&]() { return scalar_mult.mul(scalar, group.get_order(), rng(), ws); });
+ [&]() { return group.blinded_base_point_multiply(scalar, rng(), ws); });
+
+ const Botan::PointGFp r3 = blinded_var_mult_timer->run(
+ [&]() { return group.blinded_var_point_multiply(base_point, scalar, rng(), ws); });
- BOTAN_ASSERT_EQUAL(r1, r2, "Same point computed by both methods");
+ BOTAN_ASSERT_EQUAL(r1, r2, "Same point computed by Montgomery and comb");
+ BOTAN_ASSERT_EQUAL(r1, r3, "Same point computed by Montgomery and window");
}
record_result(mult_timer);
record_result(blinded_mult_timer);
+ record_result(blinded_var_mult_timer);
}
}