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


C# ECCurve.FromBigInteger方法代码示例

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


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

示例1: GetInitialZCoords

        protected static ECFieldElement[] GetInitialZCoords(ECCurve curve)
        {
            // Cope with null curve, most commonly used by implicitlyCa
            int coord = null == curve ? ECCurve.COORD_AFFINE : curve.CoordinateSystem;

            switch (coord)
            {
                case ECCurve.COORD_AFFINE:
                case ECCurve.COORD_LAMBDA_AFFINE:
                    return EMPTY_ZS;
                default:
                    break;
            }

            ECFieldElement one = curve.FromBigInteger(BigInteger.One);

            switch (coord)
            {
                case ECCurve.COORD_HOMOGENEOUS:
                case ECCurve.COORD_JACOBIAN:
                case ECCurve.COORD_LAMBDA_PROJECTIVE:
                    return new ECFieldElement[] { one };
                case ECCurve.COORD_JACOBIAN_CHUDNOVSKY:
                    return new ECFieldElement[] { one, one, one };
                case ECCurve.COORD_JACOBIAN_MODIFIED:
                    return new ECFieldElement[] { one, curve.A };
                default:
                    throw new ArgumentException("unknown coordinate system");
            }
        }
开发者ID:MBrekhof,项目名称:pleiobox-clients,代码行数:30,代码来源:ECPoint.cs

示例2: ImplSqrtTest

        private void ImplSqrtTest(ECCurve c)
        {
            if (ECAlgorithms.IsFpCurve(c))
            {
                BigInteger p = c.Field.Characteristic;
                BigInteger pMinusOne = p.Subtract(BigInteger.One);
                BigInteger legendreExponent = p.ShiftRight(1);

                int count = 0;
                while (count < 10)
                {
                    BigInteger nonSquare = BigIntegers.CreateRandomInRange(BigInteger.Two, pMinusOne, secRand);
                    if (!nonSquare.ModPow(legendreExponent, p).Equals(BigInteger.One))
                    {
                        ECFieldElement root = c.FromBigInteger(nonSquare).Sqrt();
                        Assert.IsNull(root);
                        ++count;
                    }
                }
            }
        }
开发者ID:jesusgarza,项目名称:bc-csharp,代码行数:21,代码来源:ECPointTest.cs

示例3: ImplSqrtTest

        private void ImplSqrtTest(ECCurve c)
        {
            if (ECAlgorithms.IsFpCurve(c))
            {
                BigInteger p = c.Field.Characteristic;
                BigInteger pMinusOne = p.Subtract(BigInteger.One);
                BigInteger legendreExponent = p.ShiftRight(1);

                int count = 0;
                while (count < 10)
                {
                    BigInteger nonSquare = BigIntegers.CreateRandomInRange(BigInteger.Two, pMinusOne, secRand);
                    if (!nonSquare.ModPow(legendreExponent, p).Equals(BigInteger.One))
                    {
                        ECFieldElement root = c.FromBigInteger(nonSquare).Sqrt();
                        Assert.IsNull(root);
                        ++count;
                    }
                }
            }
            else if (ECAlgorithms.IsF2mCurve(c))
            {
                int m = c.FieldSize;
                BigInteger x = new BigInteger(m, secRand);
                ECFieldElement fe = c.FromBigInteger(x);
                for (int i = 0; i < 100; ++i)
                {
                    ECFieldElement sq = fe.Square();
                    ECFieldElement check = sq.Sqrt();
                    Assert.AreEqual(fe, check);
                    fe = sq;
                }
            }
        }
开发者ID:KimikoMuffin,项目名称:bc-csharp,代码行数:34,代码来源:ECPointTest.cs


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