Beispiel #1
0
 /// <summary>
 /// Computes the multiplicative inverse of this <see cref="BigNumber" />
 /// modulo <paramref name="modulo"/> and returns the result.
 ///
 /// Precisely, computes <c>z</c> such that <c>x * z % m = 1</c>, where
 /// <c>x</c> is the value of this <see cref="BigNumber" /> instance
 /// and <c>m</c> the value of <paramref name="modulo"/>.
 /// </summary>
 /// <param name="modulo">The modulo for computing the multiplicative inverse.</param>
 /// <returns>
 /// A <see cref="BigNumber" /> instance with value<c>z</c>.
 /// </returns>
 public BigNumber ModReciprocal(BigNumber modulo)
 {
     using (var ctx = BigNumberContextHandle.CreateSecure())
     {
         var result = new BigNumber();
         BigNumberHandle.ModInverse(result.Handle, Handle, modulo.Handle, ctx);
         return(result);
     }
 }