aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-05-27 11:41:57 -0400
committerJack Lloyd <[email protected]>2018-05-27 11:41:57 -0400
commit804cad526303be7d75c3ad4c06dc1c8ffbbd1ba7 (patch)
tree4bc4340f4151c9fff38f7b72c81e52eeacf847e6 /src
parentf256e603ab93e2587fe0e38bcf06c437fcd41abf (diff)
Avoid repeated allocations in XMSS chain function
This is the core hotspot of XMSS signatures. Avoiding the secure_vector allocation for the PRF output improves performance quite noticably. Before: XMSS_SHA2-256_W16_H10 1940.74 ms/op XMSS_SHA2-512_W16_H10 3985.98 ms/op XMSS_SHAKE128_W16_H10 1910.48 ms/op XMSS_SHAKE256_W16_H10 4074.65 ms/op After: XMSS_SHA2-256_W16_H10 1204.34 ms/op XMSS_SHA2-512_W16_H10 2498.17 ms/op XMSS_SHAKE128_W16_H10 1176.55 ms/op XMSS_SHAKE256_W16_H10 2689.76 ms/op
Diffstat (limited to 'src')
-rw-r--r--src/lib/pubkey/xmss/xmss_wots_publickey.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/lib/pubkey/xmss/xmss_wots_publickey.cpp b/src/lib/pubkey/xmss/xmss_wots_publickey.cpp
index c944d6b10..9207a2c57 100644
--- a/src/lib/pubkey/xmss/xmss_wots_publickey.cpp
+++ b/src/lib/pubkey/xmss/xmss_wots_publickey.cpp
@@ -20,6 +20,8 @@ XMSS_WOTS_PublicKey::chain(secure_vector<uint8_t>& result,
const secure_vector<uint8_t>& seed,
XMSS_Hash& hash)
{
+ secure_vector<uint8_t> prf_output(hash.output_length());
+
for(size_t i = start_idx;
i < (start_idx + steps) && i < m_wots_params.wots_parameter();
i++)
@@ -34,7 +36,8 @@ XMSS_WOTS_PublicKey::chain(secure_vector<uint8_t>& result,
adrs.set_key_mask_mode(XMSS_Address::Key_Mask::Key_Mode);
//Calculate f(key, tmp XOR bitmask)
- hash.f(result, hash.prf(seed, adrs.bytes()), result);
+ hash.prf(prf_output, seed, adrs.bytes());
+ hash.f(result, prf_output, result);
}
}