scipr-lab / libff

C++ library for Finite Fields and Elliptic Curves
Other
153 stars 86 forks source link

Change fp_model's mulreduce to not check limbsize in run-time #74

Open ValarDragon opened 3 years ago

ValarDragon commented 3 years ago

The multiplication function in a finite field currently checks in runtime what the limb size is, when its instead known at compile time as its a template parameter.

Line where we check this: https://github.com/scipr-lab/libff/blob/52d77c3ee213b0f1fb49402374f1cf099bb972dd/libff/algebra/fields/fp.tcc#L27

I don't know if this is optimized out by the compiler on all platforms, but if it isn't this is potentially quite bad for the instruction cache (in addition to slight overhead due to the branch-predicted conditional)