示例#1
0
 /// <summary>
 /// Computes this <see cref="BigNumber" /> to the power
 /// of <paramref name="exponent"/> modulo <paramref name="modulo"/>
 /// and returns the result.
 ///
 /// Precisely, the returned value is <c>z = x^y % m</c>, where
 /// <c>x</c> is the value of this <see cref="BigNumber" /> instance,
 /// <c>y</c> the value of <paramref name="exponent"/> and <c>m</c> the
 /// value of <paramref name="modulo"/>.
 ///
 /// The computation is not secure. For a secure variant see
 /// <see cref="BigNumber.ModExp(SecureBigNumber, BigNumber)" />.
 /// </summary>
 /// <param name="exponent">The exponent which to raise this <see cref="BigNumber" /> to.</param>
 /// <param name="modulo">The modulo for the exponentiation.</param>
 /// <returns>
 /// A <see cref="BigNumber" /> instance with value<c>z</c>.
 /// </returns>
 public BigNumber ModExp(BigNumber exponent, BigNumber modulo)
 {
     using (var ctx = BigNumberContextHandle.CreateSecure())
     {
         var result = new BigNumber();
         BigNumberHandle.ModExp(result.Handle, Handle, exponent.Handle, modulo.Handle, ctx);
         return(result);
     }
 }