★ Why do you want to do this
I was interested in cryptography as early as my freshman day. At that time in the computer introduction to see the principle of RSA encryption, it is very interesting, so I would like to implement a RSA encryption, but I soon gave up, because I really can not get that super long integer calculation. The longest integer type in C is also 64 bits, which is not even a fraction of the 1024-bit RSA key. To accomplish this goal, I began to figure out a library for calculating large integers. Originally I also intended to use other people have already written a large number of libraries, but ultimately decided to do one, because the high efficiency of the large number of fast library (OpenSSL, crypto++, GMP), or the use of data structure is very complex, or coding style is more wonderful, For the just learning programming of my level and patience are really limited, so that can not fully understand these things, there are some I can see the code, the implementation of the way is relatively naïve, inefficient and slow to a complete mess, and finally think, do one of their own words can not only understand how to achieve the large integer calculation, And also by the way to improve their coding ability, why not?
★ Use
To do a project, clear positioning or is very necessary, otherwise it is easy to deviate from their original intention. For this large integer library, my location is for cryptography (to be precise, public-key cryptography), only to do integer calculations, do not do floating-point calculation (that is for scientific computing, encryption is completely useless)
★ Request
While the computational overhead of a large integer algorithm is greater than that of other algorithms, most of the overhead can be maintained at a smaller level through careful optimization. For my own library, as long as I can close to the efficiency of OpenSSL, I am satisfied, but the code as far as possible to be concise and understandable, do not like OpenSSL or GMP is too complex. Programming uses C language, for some key places, consider using inline assembly for optimization.
★ Content of this series blog
This series of blog, mainly introduces the implementation of large integer algorithm, share some of the programming experience, incidentally speaking of the algorithm behind a little bit of theory.
★ Reference Information This article by the sentences Daquan www.zaojuzi.com finishing release
Handbook of Applied Cryptography (HAC)
Bignum math-implementing Cryptographic multiple Precision arithmetic
Openssl
Polarssl
Libtommath
★ End
This large integer library began in early 2014, took a large half of the time to do, is now completed, although compared with other libraries may still have some shortcomings, but I spent on the top of the effort is still very large, so decided to write some blog to share some of their own experience.
to facilitate reading, the catalogue of this series of posts is organized as follows
01. Representation of large integers and related definitions
02. Basic operation (Maintenance algorithm)
03. Compare Operations
04. Bit SET operation
05. Shift Operation
06. Absolute Value Addition
07. Absolute Subtraction
08. Signed Addition and subtraction
Comba multiplication
Ten. Karatsuba multiplication
11. Symbolic multiplication
Comba Square
Karatsuba Square
14. Signed Square
15. Divide with remainder
To be Continued ...
This article by the sentence Daquan www.zaojuzi.com finishing Release
Large integer algorithm [00] Overview