Skip to content

Instantly share code, notes, and snippets.

View Anupam9830's full-sized avatar
🎯
Focusing

Anupam Patra Anupam9830

🎯
Focusing
View GitHub Profile
@mildsunrise
mildsunrise / arithmetic.py
Last active December 10, 2023 23:47
Integer (and polynomial) modular arithmetic for Python!
"""
INTEGER MODULAR ARITHMETIC
These functions implement modular arithmetic-related functions (Z/nZ).
As an implied precondition, parameters are assumed to be integers unless otherwise noted.
This code is time-sensitive and thus NOT safe to use for online cryptography.
"""
from typing import Iterable, Tuple, NamedTuple
from functools import reduce