Exemplo n.º 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);
     }
 }
Exemplo n.º 2
0
 /// <inheritdoc />
 public ECPoint MultiplyScalar(ECPoint e, SecureBigNumber k)
 {
     using (var ctx = BigNumberContextHandle.CreateSecure())
     {
         var res = new ECPoint(Handle);
         ECPointHandle.Multiply(Handle, res.Handle, BigNumberHandle.Null, e.Handle, k.Handle, ctx);
         return(res);
     }
 }
Exemplo n.º 3
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);
     }
 }
Exemplo n.º 4
0
 /// <inheritdoc />
 public ECPoint GenerateElement(SecureBigNumber index)
 {
     using (var ctx = BigNumberContextHandle.CreateSecure())
     {
         var res = new ECPoint(Handle);
         ECPointHandle.Multiply(Handle, res.Handle, index.Handle, ECPointHandle.Null, BigNumberHandle.Null, ctx);
         return(res);
     }
 }