Skip to main content

Module bigint

Module bigint 

Source
Expand description

Big integer arithmetic for RSA (up to ~4096-bit numbers).

Represents large integers as little-endian Vec<u64> limbs. Provides addition, subtraction, multiplication, division, modular exponentiation (Montgomery ladder), extended GCD, and Miller-Rabin primality. BigInt is the underlying storage for every component of super::rsa::RsaPublicKey and super::rsa::RsaSecretKey and the workhorse of every operation in super::pkcs1, super::oaep and super::pss.

§Arithmetic layer (expert bricks — read before use)

Part of arcana’s public arithmetic layer (with crate::ecc::field and crate::ecc::curve) — structurally public because BigInt backs the fields of super::rsa::RsaPublicKey / super::rsa::RsaSecretKey. It is RSA-shaped glue, not a general-purpose bigint: heap Vec<u64> limbs, and — see the table below — variable-time operations. Do not use it on secret values outside the audited RSA paths until T1-E lands. Stability is best-effort pre-1.0 (T1-E will rework the core operations).

§Side-channel posture

Roadmap item T1-E (see arcana/doc/sca/countermeasures/ rsa.rst): the operations below need a CT audit before the evaluation pass, with the same core::hint::black_box shielding pattern as super::super::ecc::field (commit 76191c1).

OperationRiskAction
cmp_toVariable-iteration limb-by-limb compare leaks bitsRewrite to borrow-only branchless pattern
mont_mulConditional final subtract leaks (Walter 2002)Apply black_box mask shielding
mod_expSquare-and-multiply must be square-alwaysValidate Fermat ladder structure + black_box
mod_inv (extended GCD)Variable-time GCD historically Minerva targetPrefer Fermat (a^(p-2) mod p) for prime moduli
sub / addBorrow / carry propagationConfirm fixed iteration count

Once T1-E lands the layers above (RSA-CRT decrypt, PKCS#1, OAEP, PSS) inherit a CT bigint base; combined with T1-C Aumüller and T2-I message blinding it gives the full evaluation-grade RSA stack.

Structs§

BigInt
A big unsigned integer stored as little-endian 64-bit limbs.
MontParams
Parameters for Montgomery modular arithmetic.