doc: include number of squares and multiplications in results
kevaundray opened this issue · 6 comments
Perhaps add the number of squares and multiplications or doublings and additions alongside the chain length?
To clarify, are you talking about the results lists (readme and full results page)?
Yes, I agree with you on showing the add/double counts (equivalent to multiplication/square). It's common for other work on the subject to present it that way too, for example https://eprint.iacr.org/2018/1038.
When you say incorporate, do you mean use a weighting when selecting the best chain from a bunch of results?
Yep, I mean to use a weighting. For example, setting the weighting of a squaring operation to be 0.85 the weighting of a multiplication operation.
Right. I considered this a while back and forgot about it, so it didn't make it into the initial release, but I agree this would be a good feature. The fact that squares are cheaper is accounted for to some extent here:
addchain/internal/results/results_test.go
Lines 49 to 65 in fe56d67
That is, among the shortest chains it picks the one with the fewest adds (equivalently the most doubles). After that it sorts by algorithm name... that was just a way to ensure the result was deterministic!
One possible drawback, if it has utility, is that the actual weighting is implementation specific, so a blanket ratio may not be suitable.
Yes, agreed the exact weightings would need to be configurable.
I think there's an interesting question about what other heuristics you would use to choose the best chain, even among those that have the exact same number of adds and doubles. @briansmith in some private communication suggested both maximum number of live variables and pipeline stalls (dependencies between variables) as factors you might want to consider.
As long as you have some coarse score to narrow down to the top candidates, then you could just code generate the actual exponentiation function and benchmark it. I thought I remembered a paper that took this approach, maybe it was https://eprint.iacr.org/2019/403 but skimming it now I'm not sure.