C++中的密码学多精度算法-并行计算和击败手工优化汇编的运行时间性能
Multiprecision Arithmetic for Cryptology in C++ - Compile-Time Computations and Beating the Performance of Hand-Optimized Assembly at Run-Time
摘要:
我们描述了一个新的C++库,用于100- 500位数量级的多精度算术,即,用几个肢体就能表现出来该库是用“优化编译器友好”的C++编写的,重点是使用固定大小的数组和特定的函数参数传递样式(包括避免裸指针),以允许在堆栈甚至寄存器中分配肢体。根据特定的功能,我们接近或大大超过现有的多精度算法库的性能,这些库采用手工优化的汇编代码。库中的大多数函数都是常数时间的,这对于加密协议的安全实现是必要的。除了良好的运行时性能外,据作者所知,我们的库是第一个在编译时提供大整数计算的库。例如,当实现具有固定模的有限域算术时,此功能可以自动预先计算(在编译时)Barrett和Montgomery约简所需的特殊模相关常数。另一个应用是解析(在编译时)一个以10为基数编码的大整数文字。
英文摘要:
We describe a new C++ library for multiprecision arithmetic for numbers in the order of 100--500 bits, i.e., representable with just a few limbs. The library is written in "optimizing-compiler-friendly" C++, with an emphasis on the use of fixed-size arrays and particular function-argument-passing styles (including the avoidance of naked pointers) to allow the limbs to be allocated on the stack or even in registers. Depending on the particular functionality, we get close to, or significantly beat the performance of existing libraries for multiprecision arithmetic that employ hand-optimized assembly code. Most functions in the library are constant-time, which is a necessity for secure implementations of cryptographic protocols. Beyond the favorable runtime performance, our library is, to the best of the author's knowledge, the first library that offers big-integer computations during compile-time. For example, when implementing finite-field arithmetic with a fixed modulus, this feature enables the automatic precomputation (at compile time) of the special modulus-dependent constants required for Barrett and Montgomery reduction. Another application is to parse (at compile-time) a base-10-encoded big-integer literal.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。