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


C# EC.ECPoint类代码示例

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


ECPoint类属于Org.BouncyCastle.Math.EC命名空间,在下文中一共展示了ECPoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ECPublicBcpgKey

 protected ECPublicBcpgKey(
     DerObjectIdentifier oid,
     ECPoint point)
 {
     this.point = new BigInteger(1, point.GetEncoded());
     this.oid = oid;
 }
开发者ID:ALange,项目名称:OutlookPrivacyPlugin,代码行数:7,代码来源:ECPublicBCPGKey.cs

示例2: TestSumOfTwoMultiplies

        public void TestSumOfTwoMultiplies()
        {
            foreach (X9ECParameters x9 in GetTestCurves())
            {
                ECPoint p = GetRandomPoint(x9);
                BigInteger a = GetRandomScalar(x9);

                for (int i = 0; i < SCALE; ++i)
                {
                    ECPoint q = GetRandomPoint(x9);
                    BigInteger b = GetRandomScalar(x9);

                    ECPoint u = p.Multiply(a).Add(q.Multiply(b));
                    ECPoint v = ECAlgorithms.ShamirsTrick(p, a, q, b);
                    ECPoint w = ECAlgorithms.SumOfTwoMultiplies(p, a, q, b);

                    ECPoint[] results = new ECPoint[] { u, v, w };
                    x9.Curve.NormalizeAll(results);

                    AssertPointsEqual("ECAlgorithms.ShamirsTrick is incorrect", results[0], results[1]);
                    AssertPointsEqual("ECAlgorithms.SumOfTwoMultiplies is incorrect", results[0], results[2]);

                    p = q;
                    a = b;
                }
            }
        }
开发者ID:andibadra,项目名称:bc-csharp,代码行数:27,代码来源:ECAlgorithmsTest.cs

示例3: ECDHPublicKeyParameters

 /// <summary>
 /// Initializes a new instance of the <see cref="ECDHPublicKeyParameters" /> class.
 /// </summary>
 /// <param name="q">The q.</param>
 /// <param name="publicKeyParamSet">The public key param set.</param>
 /// <param name="hashAlgorithm">The hash algorithm.</param>
 /// <param name="symmetricKeyAlgorithm">The symmetric key algorithm.</param>
 public ECDHPublicKeyParameters(ECPoint q, DerObjectIdentifier publicKeyParamSet, HashAlgorithmTag hashAlgorithm,
                                SymmetricKeyAlgorithmTag symmetricKeyAlgorithm)
     : base("ECDH", q, publicKeyParamSet)
 {
     this.HashAlgorithm = hashAlgorithm;
     this.SymmetricKeyAlgorithm = symmetricKeyAlgorithm;
 }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:14,代码来源:ECDHPublicKeyParameters.cs

示例4: SumOfMultiplies

        public static ECPoint SumOfMultiplies(ECPoint[] ps, BigInteger[] ks)
        {
            if (ps == null || ks == null || ps.Length != ks.Length || ps.Length < 1)
                throw new ArgumentException("point and scalar arrays should be non-null, and of equal, non-zero, length");

            int count = ps.Length;
            switch (count)
            {
                case 1:
                    return ps[0].Multiply(ks[0]);
                case 2:
                    return SumOfTwoMultiplies(ps[0], ks[0], ps[1], ks[1]);
                default:
                    break;
            }

            ECPoint p = ps[0];
            ECCurve c = p.Curve;

            ECPoint[] imported = new ECPoint[count];
            imported[0] = p;
            for (int i = 1; i < count; ++i)
            {
                imported[i] = ImportPoint(c, ps[i]);
            }

            GlvEndomorphism glvEndomorphism = c.GetEndomorphism() as GlvEndomorphism;
            if (glvEndomorphism != null)
            {
                return ImplSumOfMultipliesGlv(imported, ks, glvEndomorphism);
            }

            return ImplSumOfMultiplies(imported, ks);
        }
开发者ID:MBrekhof,项目名称:pleiobox-clients,代码行数:34,代码来源:ECAlgorithms.cs

示例5: TestSumOfMultiplies

        public void TestSumOfMultiplies()
        {
            foreach (X9ECParameters x9 in GetTestCurves())
            {
                ECPoint[] points = new ECPoint[SCALE];
                BigInteger[] scalars = new BigInteger[SCALE];
                for (int i = 0; i < SCALE; ++i)
                {
                    points[i] = GetRandomPoint(x9);
                    scalars[i] = GetRandomScalar(x9);
                }

                ECPoint u = x9.Curve.Infinity;
                for (int i = 0; i < SCALE; ++i)
                {
                    u = u.Add(points[i].Multiply(scalars[i]));

                    ECPoint v = ECAlgorithms.SumOfMultiplies(CopyPoints(points, i + 1), CopyScalars(scalars, i + 1));

                    ECPoint[] results = new ECPoint[] { u, v };
                    x9.Curve.NormalizeAll(results);

                    AssertPointsEqual("ECAlgorithms.SumOfMultiplies is incorrect", results[0], results[1]);
                }
            }
        }
开发者ID:andibadra,项目名称:bc-csharp,代码行数:26,代码来源:ECAlgorithmsTest.cs

示例6: ImplShamirsTrick

		private static ECPoint ImplShamirsTrick(ECPoint P, BigInteger k,
			ECPoint Q, BigInteger l)
		{
			int m = System.Math.Max(k.BitLength, l.BitLength);
			ECPoint Z = P.Add(Q);
			ECPoint R = P.Curve.Infinity;

			for (int i = m - 1; i >= 0; --i)
			{
				R = R.Twice();

				if (k.TestBit(i))
				{
					if (l.TestBit(i))
					{
						R = R.Add(Z);
					}
					else
					{
						R = R.Add(P);
					}
				}
				else
				{
					if (l.TestBit(i))
					{
						R = R.Add(Q);
					}
				}
			}

			return R;
		}
开发者ID:nicecai,项目名称:iTextSharp-4.1.6,代码行数:33,代码来源:ECAlgorithms.cs

示例7: ECDomainParameters

		public ECDomainParameters(
            ECCurve     curve,
            ECPoint     g,
            BigInteger  n)
			: this(curve, g, n, BigInteger.One)
        {
        }
开发者ID:VimalKumarS,项目名称:mono-tls,代码行数:7,代码来源:ECDomainParameters.cs

示例8: X9ECParameters

		public X9ECParameters(
            ECCurve		curve,
            ECPoint		g,
            BigInteger	n)
            : this(curve, g, n, BigInteger.One, null)
        {
        }
开发者ID:NelsonSantos,项目名称:fyiReporting-Android,代码行数:7,代码来源:X9ECParameters.cs

示例9: ImplShamirsTrick

        private static ECPoint ImplShamirsTrick(ECPoint p, IBigInteger k, ECPoint q, IBigInteger l)
        {
            var m = System.Math.Max(k.BitLength, l.BitLength);
            var z = p.Add(q);
            var r = p.Curve.Infinity;

            for (var i = m - 1; i >= 0; --i)
            {
                r = r.Twice();

                if (k.TestBit(i))
                {
                    r = r.Add(l.TestBit(i) ? z : p);
                }
                else
                {
                    if (l.TestBit(i))
                    {
                        r = r.Add(q);
                    }
                }
            }

            return r;
        }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:25,代码来源:ECAlgorithms.cs

示例10: ShamirsTrick

        /*
        * "Shamir's Trick", originally due to E. G. Straus
        * (Addition chains of vectors. American Mathematical Monthly,
        * 71(7):806-808, Aug./Sept. 1964)
        *
        * Input: The points P, Q, scalar k = (km?, ... , k1, k0)
        * and scalar l = (lm?, ... , l1, l0).
        * Output: R = k * P + l * Q.
        * 1: Z <- P + Q
        * 2: R <- O
        * 3: for i from m-1 down to 0 do
        * 4:        R <- R + R        {point doubling}
        * 5:        if (ki = 1) and (li = 0) then R <- R + P end if
        * 6:        if (ki = 0) and (li = 1) then R <- R + Q end if
        * 7:        if (ki = 1) and (li = 1) then R <- R + Z end if
        * 8: end for
        * 9: return R
        */
        public static ECPoint ShamirsTrick(ECPoint p, BigInteger k, ECPoint q, BigInteger l)
        {
            if (!p.Curve.Equals(q.Curve))
                throw new ArgumentException("P and Q must be on same curve");

            return ImplShamirsTrick(p, k, q, l);
        }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:25,代码来源:ECAlgorithms.cs

示例11: SetVerifier

 protected void SetVerifier(ECPoint pub)
 {
     Verifier = new ECDsaSigner();
     ECPublicKeyParameters parameters = new ECPublicKeyParameters(
         pub, Secp256K1.Parameters());
     Verifier.Init(false, parameters);
 }
开发者ID:sublimator,项目名称:ripple-dot-net,代码行数:7,代码来源:K256VerifyingKey.cs

示例12: X9ECParameters

 public X9ECParameters(
     ECCurve		curve,
     ECPoint		g,
     IBigInteger n,
     IBigInteger h)
     : this(curve, g, n, h, null)
 {
 }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:8,代码来源:X9ECParameters.cs

示例13: CreateKey

        public static byte[] CreateKey(PublicKeyPacket pubKeyData, ECPoint s)
        {
            byte[] userKeyingMaterial = CreateUserKeyingMaterial(pubKeyData);

            ECDHPublicBcpgKey ecKey = (ECDHPublicBcpgKey)pubKeyData.Key;

            return Kdf(ecKey.HashAlgorithm, s, GetKeyLength(ecKey.SymmetricKeyAlgorithm), userKeyingMaterial);
        }
开发者ID:KimikoMuffin,项目名称:bc-csharp,代码行数:8,代码来源:Rfc6637Utilities.cs

示例14: ECPublicKeyParameters

        public ECPublicKeyParameters(string algorithm, ECPoint q, DerObjectIdentifier publicKeyParamSet)
            : base(algorithm, false, publicKeyParamSet)
        {
            if (q == null)
                throw new ArgumentNullException("q");

            _q = q;
        }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:8,代码来源:ECPublicKeyParameters.cs

示例15: X9ECParameters

 public X9ECParameters(
     ECCurve		curve,
     ECPoint		g,
     BigInteger	n,
     BigInteger	h,
     byte[]		seed)
     : this(curve, new X9ECPoint(g), n, h, seed)
 {
 }
开发者ID:martijn00,项目名称:BouncyCastle-PCL,代码行数:9,代码来源:X9ECParameters.cs


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