This commit adds functions to verify and compare numbers in signed{30,62} notation, and uses that to do more extensive bounds checking on various variables in the modinv code.
Partial backport of secp256k1#831:
https://github.com/bitcoin-core/secp256k1/pull/831/commits/08d54964e51f318ef0cc4ef09d64cfa5ec143c5c
Depends on D9402.