This pull request gives an option to reduce the precomputed table size for the signing context (ctx
) by setting #define ECMULT_GEN_PREC_BITS [N_BITS]
.
Motivation: Per #251 and #254, the static table can be reduced to 64kB. However, this is still too big for some of my embedded applications. Setting #define ECMULT_GEN_PREC_BITS 2
produces a 32kB table at a tradeoff of about 75% of the signing speed. Not defining this value will default to the existing implementation of 4 bits. Statistics:
0ECMULT_GEN_PREC_BITS = 1
1Precomputed table size: 32kB
2./bench_sign
3ecdsa_sign: min 195us / avg 200us / max 212us
4
5ECMULT_GEN_PREC_BITS = 2
6Precomputed table size: 32kB
7./bench_sign
8ecdsa_sign: min 119us / avg 126us / max 134us
9
10ECMULT_GEN_PREC_BITS = 4 (default)
11Precomputed table size: 64kB
12./bench_sign
13ecdsa_sign: min 83.5us / avg 89.6us / max 95.3us
14
15ECMULT_GEN_PREC_BITS = 8
16Precomputed table size: 512kB
17./bench_sign
18ecdsa_sign: min 96.4us / avg 99.4us / max 104us
Only values of 2 and 4 make sense. 8 bits causes a larger table size with no increase in speed. 1 bit runs, actually, but does not reduce table size and is slower than 2 bits.