Nimony

The road to Nim 3

bignum

nimony/lib/std/crypto/bignum.nim

Fixed-capacity unsigned big integers and Montgomery arithmetic, for SIGNATURE VERIFICATION.

Everything a verifier computes is public — the signature, the message digest, the public key — so this module is deliberately not constant time: modExp skips zero bits and sub branches on a comparison. Do not use it with a secret.

A number is at most MaxBits wide (RSA-4096 plus headroom for the Montgomery product), held in a fixed array of 32-bit limbs together with a range-typed limb count, which is what lets every index in here be proven rather than checked.