docs: def inv(z):
      """$= z^{-1} \mod q$, for z != 0"""
      # Adapted from curve25519_athlon.c in djb's Curve25519.
      z = qdiv(z)
      z2 = z * z % PRIME  # 2
      z9 = pow2(z2, 2) * z % PRIME  # 9
      z11 = z9 * z2 % PRIME  # 11
      z2_5_0 = (z11*z11) % PRIME * z9 % PRIME  # 31 == 2^5 - 2^0
      z2_10_0 = pow2(z2_5_0, 5) * z2_5_0 % PRIME  # 2^10 - 2^0
      z2_20_0 = pow2(z2_10_0, 10) * z2_10_0 % PRIME  # ...
      z2_40_0 = pow2(z2_20_0, 20) * z2_20_0 % PRIME
      z2_50_0 = pow2(z2_40_0, 10) * z2_10_0 % PRIME
      z2_100_0 = pow2(z2_50_0, 50) * z2_50_0 % PRIME
      z2_200_0 = pow2(z2_100_0, 100) * z2_100_0 % PRIME
      z2_250_0 = pow2(z2_200_0, 50) * z2_50_0 % PRIME  # 2^250 - 2^0
      return pow2(z2_250_0, 5) * z11 % PRIME