maths/routines
This module contains mathematical routines.
Functions
Calculate n to the power of e modulo q using the exponentiation by
squaring method. At each multiplication a modulo is calculated, allowing
very large n and e values.
routines.powmod(3, 2, 5)
Convert a integer n into some base q. This method
should scale with any integer and any logical base.
routines.base_q(123, 7)
Convert a hexadecimal bytearray into its base 10 representation. This only works with even length bytearrays so arbitrary numbers in hexadecimal form will not in general work.
routines.to_int(#"acab")
Convert a integer into a hexadecimal bytearray. This works for all integers
but odd length bytearrays will be prefixed with a zero. This function
combined with the to_int function allows a string to represent a number
and still be used for calculations, pushing the 2^64 - 1 integer boundary.
routines.from_int(44203)