diff options
author | Jack Lloyd <[email protected]> | 2018-12-14 07:32:55 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-12-14 07:32:55 -0500 |
commit | 5be9a0c16d68f9967564b2d46fe0cc4fc6d63b85 (patch) | |
tree | e9bdb91a703da8743791be1f7ca4b5844256d2de /src/lib/pubkey | |
parent | a2e1e5cbf4ff2c00894b8b816c4b20634f13b023 (diff) |
Simplify the const time lookup in ECC scalar mul
Code is easier to understand and it may let the CPU interleave the
loads and logical ops better. Slightly faster on my machine.
Diffstat (limited to 'src/lib/pubkey')
-rw-r--r-- | src/lib/pubkey/ec_group/point_mul.cpp | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/src/lib/pubkey/ec_group/point_mul.cpp b/src/lib/pubkey/ec_group/point_mul.cpp index 49d2f7be6..f5b621dda 100644 --- a/src/lib/pubkey/ec_group/point_mul.cpp +++ b/src/lib/pubkey/ec_group/point_mul.cpp @@ -141,18 +141,15 @@ PointGFp PointGFp_Base_Point_Precompute::mul(const BigInt& k, for(size_t j = 0; j != elem_size; ++j) { - const word w1 = m_W[base_addr + 0*elem_size + j]; - const word w2 = m_W[base_addr + 1*elem_size + j]; - const word w3 = m_W[base_addr + 2*elem_size + j]; - const word w4 = m_W[base_addr + 3*elem_size + j]; - const word w5 = m_W[base_addr + 4*elem_size + j]; - const word w6 = m_W[base_addr + 5*elem_size + j]; - const word w7 = m_W[base_addr + 6*elem_size + j]; - - const word wl = w_is_1.select(w1, w_is_2.select(w2, w_is_3.select(w3, 0))); - const word wr = w_is_4.select(w4, w_is_5.select(w5, w_is_6.select(w6, w_is_7.select(w7, 0)))); - - Wt[j] = wl | wr; + const word w1 = w_is_1.if_set_return(m_W[base_addr + 0*elem_size + j]); + const word w2 = w_is_2.if_set_return(m_W[base_addr + 1*elem_size + j]); + const word w3 = w_is_3.if_set_return(m_W[base_addr + 2*elem_size + j]); + const word w4 = w_is_4.if_set_return(m_W[base_addr + 3*elem_size + j]); + const word w5 = w_is_5.if_set_return(m_W[base_addr + 4*elem_size + j]); + const word w6 = w_is_6.if_set_return(m_W[base_addr + 5*elem_size + j]); + const word w7 = w_is_7.if_set_return(m_W[base_addr + 6*elem_size + j]); + + Wt[j] = w1 | w2 | w3 | w4 | w5 | w6 | w7; } R.add_affine(&Wt[0], m_p_words, &Wt[m_p_words], m_p_words, ws); |