Techniques are provided for performing modular arithmetic on a key composed
of many bits. One circuit implementation includes a distributor, one or more lookup
tables and a plurality of adders. The distributor segments the key into a plurality
of partitions. Each partition is based on a polynomial expression corresponding
to a fixed size key. Each of the bits contained within the partitions are routed
on a partition basis to one or more lookup tables, the routed bits acting as indices
into the one or more tables. The lookup tables store precomputed values based upon
the polynomial expression. The outputted precomputed values from one or more lookup
tables are outputted to the plurality of adders. The plurality of adders add the
bits from a portion of the routed partitions and the outputted precomputed values
from the one or more lookup tables to form the binary residue.