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


C# ECFieldElement类代码示例

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


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

示例1: TestMultiply2

        public void TestMultiply2()
        {
            int COUNT = 100;
            ECFieldElement[] inputs = new ECFieldElement[COUNT];
            BigInteger[] INPUTS = new BigInteger[COUNT];

            for (int i = 0; i < inputs.Length; ++i)
            {
                inputs[i] = GenerateMultiplyInput_Random();
                INPUTS[i] = inputs[i].ToBigInteger();
            }

            for (int j = 0; j < inputs.Length; ++j)
            {
                for (int k = 0; k < inputs.Length; ++k)
                {
                    BigInteger R = INPUTS[j].Multiply(INPUTS[k]).Mod(Q);

                    ECFieldElement z = inputs[j].Multiply(inputs[k]);
                    BigInteger Z = z.ToBigInteger();

                    Assert.AreEqual(R, Z);
                }
            }
        }
开发者ID:bcgit,项目名称:bc-csharp,代码行数:25,代码来源:SecP256R1FieldTest.cs

示例2: Divide

 public override ECFieldElement Divide(ECFieldElement b)
 {
     //return Multiply(b.Invert());
     uint[] z = Nat256.Create();
     Mod.Invert(Curve25519Field.P, ((Curve25519FieldElement)b).x, z);
     Curve25519Field.Multiply(z, x, z);
     return new Curve25519FieldElement(z);
 }
开发者ID:bitcoinkit,项目名称:BitcoinKit-CSharp,代码行数:8,代码来源:Curve25519FieldElement.cs

示例3: Divide

 public override ECFieldElement Divide(ECFieldElement b)
 {
     //return Multiply(b.Invert());
     uint[] z = Nat.Create(12);
     Mod.Invert(SecP384R1Field.P, ((SecP384R1FieldElement)b).x, z);
     SecP384R1Field.Multiply(z, x, z);
     return new SecP384R1FieldElement(z);
 }
开发者ID:bitcoinkit,项目名称:BitcoinKit-CSharp,代码行数:8,代码来源:SecP384R1FieldElement.cs

示例4: ECCurve

 private ECCurve(BigInteger Q, BigInteger A, BigInteger B, BigInteger N, byte[] G)
 {
     this.Q = Q;
     this.A = new ECFieldElement(A, this);
     this.B = new ECFieldElement(B, this);
     this.N = N;
     this.Infinity = new ECPoint(null, null, this);
     this.G = ECPoint.DecodePoint(G, this);
 }
开发者ID:erikzhang,项目名称:IceWallet,代码行数:9,代码来源:ECCurve.cs

示例5: CreateRawPoint

 protected internal override ECPoint CreateRawPoint(ECFieldElement x, ECFieldElement y, bool withCompression)
 {
     return new SecT163R2Point(this, x, y, withCompression);
 }
开发者ID:JohnMalmsteen,项目名称:mobile-apps-tower-defense,代码行数:4,代码来源:SecT163R2Curve.cs

示例6: Multiply

 public override ECFieldElement Multiply(ECFieldElement b)
 {
     uint[] z = Nat.Create(12);
     SecP384R1Field.Multiply(x, ((SecP384R1FieldElement)b).x, z);
     return new SecP384R1FieldElement(z);
 }
开发者ID:MBrekhof,项目名称:pleiobox-clients,代码行数:6,代码来源:SecP384R1FieldElement.cs

示例7: Equals

 public override bool Equals(ECFieldElement other)
 {
     return Equals(other as SecP384R1FieldElement);
 }
开发者ID:MBrekhof,项目名称:pleiobox-clients,代码行数:4,代码来源:SecP384R1FieldElement.cs

示例8: MultiplyMinusProduct

 public override ECFieldElement MultiplyMinusProduct(ECFieldElement b, ECFieldElement x, ECFieldElement y)
 {
     return MultiplyPlusProduct(b, x, y);
 }
开发者ID:ALange,项目名称:OutlookPrivacyPlugin,代码行数:4,代码来源:SecT113FieldElement.cs

示例9: Subtract

 public override ECFieldElement Subtract(ECFieldElement b)
 {
     // Addition and Subtraction are the same in F2m
     return Add(b);
 }
开发者ID:ALange,项目名称:OutlookPrivacyPlugin,代码行数:5,代码来源:SecT113FieldElement.cs

示例10: Divide

 public override ECFieldElement Divide(ECFieldElement b)
 {
     return Multiply(b.Invert());
 }
开发者ID:ALange,项目名称:OutlookPrivacyPlugin,代码行数:4,代码来源:SecT113FieldElement.cs

示例11: Add


//.........这里部分代码省略.........
            bool Z1IsOne = Z1.IsOne;
            uint[] U2, S2;
            if (Z1IsOne)
            {
                U2 = X2.x;
                S2 = Y2.x;
            }
            else
            {
                S2 = t3;
                Curve25519Field.Square(Z1.x, S2);

                U2 = t2;
                Curve25519Field.Multiply(S2, X2.x, U2);

                Curve25519Field.Multiply(S2, Z1.x, S2);
                Curve25519Field.Multiply(S2, Y2.x, S2);
            }

            bool Z2IsOne = Z2.IsOne;
            uint[] U1, S1;
            if (Z2IsOne)
            {
                U1 = X1.x;
                S1 = Y1.x;
            }
            else
            {
                S1 = t4;
                Curve25519Field.Square(Z2.x, S1);

                U1 = tt1;
                Curve25519Field.Multiply(S1, X1.x, U1);

                Curve25519Field.Multiply(S1, Z2.x, S1);
                Curve25519Field.Multiply(S1, Y1.x, S1);
            }

            uint[] H = Nat256.Create();
            Curve25519Field.Subtract(U1, U2, H);

            uint[] R = t2;
            Curve25519Field.Subtract(S1, S2, R);

            // Check if b == this or b == -this
            if (Nat256.IsZero(H))
            {
                if (Nat256.IsZero(R))
                {
                    // this == b, i.e. this must be doubled
                    return this.Twice();
                }

                // this == -b, i.e. the result is the point at infinity
                return curve.Infinity;
            }

            uint[] HSquared = Nat256.Create();
            Curve25519Field.Square(H, HSquared);

            uint[] G = Nat256.Create();
            Curve25519Field.Multiply(HSquared, H, G);

            uint[] V = t3;
            Curve25519Field.Multiply(HSquared, U1, V);

            Curve25519Field.Negate(G, G);
            Nat256.Mul(S1, G, tt1);

            c = Nat256.AddBothTo(V, V, G);
            Curve25519Field.Reduce27(c, G);

            Curve25519FieldElement X3 = new Curve25519FieldElement(t4);
            Curve25519Field.Square(R, X3.x);
            Curve25519Field.Subtract(X3.x, G, X3.x);

            Curve25519FieldElement Y3 = new Curve25519FieldElement(G);
            Curve25519Field.Subtract(V, X3.x, Y3.x);
            Curve25519Field.MultiplyAddToExt(Y3.x, R, tt1);
            Curve25519Field.Reduce(tt1, Y3.x);

            Curve25519FieldElement Z3 = new Curve25519FieldElement(H);
            if (!Z1IsOne)
            {
                Curve25519Field.Multiply(Z3.x, Z1.x, Z3.x);
            }
            if (!Z2IsOne)
            {
                Curve25519Field.Multiply(Z3.x, Z2.x, Z3.x);
            }

            uint[] Z3Squared = (Z1IsOne && Z2IsOne) ? HSquared : null;

            // TODO If the result will only be used in a subsequent addition, we don't need W3
            Curve25519FieldElement W3 = CalculateJacobianModifiedW((Curve25519FieldElement)Z3, Z3Squared);

            ECFieldElement[] zs = new ECFieldElement[] { Z3, W3 };

            return new Curve25519Point(curve, X3, Y3, zs, IsCompressed);
        }
开发者ID:bitcoinkit,项目名称:BitcoinKit-CSharp,代码行数:101,代码来源:Curve25519Point.cs

示例12: Curve25519Point

 /**
  * Create a point which encodes with point compression.
  *
  * @param curve the curve to use
  * @param x affine x co-ordinate
  * @param y affine y co-ordinate
  *
  * @deprecated Use ECCurve.CreatePoint to construct points
  */
 public Curve25519Point(ECCurve curve, ECFieldElement x, ECFieldElement y)
     : this(curve, x, y, false)
 {
 }
开发者ID:bitcoinkit,项目名称:BitcoinKit-CSharp,代码行数:13,代码来源:Curve25519Point.cs

示例13: SecP256K1Point

		public SecP256K1Point(ECCurve curve, ECFieldElement x, ECFieldElement y, ECFieldElement[] zs,
			bool withCompression)
			: base(curve, x, y, zs, withCompression)
		{
		}
开发者ID:Nethereum,项目名称:Nethereum,代码行数:5,代码来源:SecP256K1Point.cs

示例14: Multiply

 public override ECFieldElement Multiply(ECFieldElement b)
 {
     uint[] z = Nat256.Create();
     SecP256K1Field.Multiply(x, ((SecP256K1FieldElement)b).x, z);
     return new SecP256K1FieldElement(z);
 }
开发者ID:andibadra,项目名称:bc-csharp,代码行数:6,代码来源:SecP256K1FieldElement.cs

示例15: Subtract

 public override ECFieldElement Subtract(ECFieldElement b)
 {
     uint[] z = Nat256.Create();
     SecP256K1Field.Subtract(x, ((SecP256K1FieldElement)b).x, z);
     return new SecP256K1FieldElement(z);
 }
开发者ID:andibadra,项目名称:bc-csharp,代码行数:6,代码来源:SecP256K1FieldElement.cs


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