lib: add modulo library

Support some modulo arithmetic, including gcd, Euclidean algorithm for
finding Bezout coefficients, and modular inverse.