当前位置: 首页>>代码示例>>C#>>正文


C# IBigInteger.ModPow方法代码示例

本文整理汇总了C#中IBigInteger.ModPow方法的典型用法代码示例。如果您正苦于以下问题:C# IBigInteger.ModPow方法的具体用法?C# IBigInteger.ModPow怎么用?C# IBigInteger.ModPow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IBigInteger的用法示例。


在下文中一共展示了IBigInteger.ModPow方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CalculateAgreement

        /**
         * given a message from a given party and the corresponding public key
         * calculate the next message in the agreement sequence. In this case
         * this will represent the shared secret.
         */
        public IBigInteger CalculateAgreement(DHPublicKeyParameters pub, IBigInteger message)
        {
            if (pub == null)
                throw new ArgumentNullException("pub");
            if (message == null)
                throw new ArgumentNullException("message");

            if (!pub.Parameters.Equals(_dhParams))
            {
                throw new ArgumentException("Diffie-Hellman public key has wrong parameters.");
            }

            var p = _dhParams.P;
            return message.ModPow(_key.X, p).Multiply(pub.Y.ModPow(_privateValue, p)).Mod(p);
        }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:20,代码来源:DHAgreement.cs

示例2: ProcessBlock

        public IBigInteger ProcessBlock(
			IBigInteger input)
        {
            if (key is RsaPrivateCrtKeyParameters)
            {
                //
                // we have the extra factors, use the Chinese Remainder Theorem - the author
                // wishes to express his thanks to Dirk Bonekaemper at rtsffm.com for
                // advice regarding the expression of this.
                //
                RsaPrivateCrtKeyParameters crtKey = (RsaPrivateCrtKeyParameters)key;

                IBigInteger p = crtKey.P;;
                IBigInteger q = crtKey.Q;
                IBigInteger dP = crtKey.DP;
                IBigInteger dQ = crtKey.DQ;
                IBigInteger qInv = crtKey.QInv;

                IBigInteger mP, mQ, h, m;

                // mP = ((input Mod p) ^ dP)) Mod p
                mP = (input.Remainder(p)).ModPow(dP, p);

                // mQ = ((input Mod q) ^ dQ)) Mod q
                mQ = (input.Remainder(q)).ModPow(dQ, q);

                // h = qInv * (mP - mQ) Mod p
                h = mP.Subtract(mQ);
                h = h.Multiply(qInv);
                h = h.Mod(p);               // Mod (in Java) returns the positive residual

                // m = h * q + mQ
                m = h.Multiply(q);
                m = m.Add(mQ);

                return m;
            }

            return input.ModPow(key.Exponent, key.Modulus);
        }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:40,代码来源:RSACoreEngine.cs

示例3: CalculatePublicKey

 private static IBigInteger CalculatePublicKey(IBigInteger p, IBigInteger g, IBigInteger x)
 {
     return g.ModPow(x, p);
 }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:4,代码来源:DsaKeyPairGenerator.cs


注:本文中的IBigInteger.ModPow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。