kokke / tiny-bignum-c

Small portable multiple-precision unsigned integer arithmetic in C
The Unlicense
419 stars 86 forks source link

Binary exponentiation #27

Open umnikos opened 3 years ago

umnikos commented 3 years ago

Also called "exponentiation by squaring". It uses O(log b) multiplications instead of the O(b) multiplications the previous algorithm needed. With a slight modification you can also make a bignum_binmod() version which takes a modulo of the result in each intermediate step of the exponentiation and is a key operation in RSA.