Is there a library or other way to do 128-bit math operations?

一笑奈何 提交于 2019-12-11 05:29:43

问题


I am writing a cryptography application and need to work with 128 bit integers.

In addition to standard add, subtract, multiply, divide, and comparisons, I also need a power and modulo function as well.

Does anyone know of a library or other implementation that can do this? If not 128-bit, is there a 64-bit option available?


回答1:


Check out the GNU Multiple Precision Arithmetic Library.




回答2:


Most any modern compiler is going to provide at least 64 bit through the use of the long long type.




回答3:


gcc supports uint128_t, which is a 128-bit integer, though this isn't very portable.

Since I don't know any main stream cryptosystems that use 128-bit modular arithmetic, I'm wondering what scheme you are implementing.




回答4:


Look for the Montgomery algorithms for multiplication and powers in a finite field. I don't know any library but I am quiet sure there are.



来源:https://stackoverflow.com/questions/2604271/is-there-a-library-or-other-way-to-do-128-bit-math-operations

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!