• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ECFieldElement类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: SquarePlusProduct

        public override ECFieldElement SquarePlusProduct(ECFieldElement x, ECFieldElement y)
        {
            ulong[] ax = this.x;
            ulong[] xx = ((SecT233FieldElement)x).x, yx = ((SecT233FieldElement)y).x;

            ulong[] tt = Nat256.CreateExt64();
            SecT233Field.SquareAddToExt(ax, tt);
            SecT233Field.MultiplyAddToExt(xx, yx, tt);

            ulong[] z = Nat256.Create64();
            SecT233Field.Reduce(tt, z);
            return new SecT233FieldElement(z);
        }
开发者ID:ubberkid,项目名称:PeerATT,代码行数:13,代码来源:SecT233FieldElement.cs


示例17: Add

 public override ECFieldElement Add(ECFieldElement b)
 {
     ulong[] z = Nat256.Create64();
     SecT233Field.Add(x, ((SecT233FieldElement)b).x, z);
     return new SecT233FieldElement(z);
 }
开发者ID:ubberkid,项目名称:PeerATT,代码行数:6,代码来源:SecT233FieldElement.cs


示例18: ScaleXPointMap

		public ScaleXPointMap(ECFieldElement scale)
		{
			this.scale = scale;
		}
开发者ID:Nethereum,项目名称:Nethereum,代码行数:4,代码来源:ScaleXPointMap.cs


示例19: SquareMinusProduct

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


示例20: Add

 public override ECFieldElement Add(ECFieldElement b)
 {
     uint[] z = Nat.Create(17);
     SecP521R1Field.Add(x, ((SecP521R1FieldElement)b).x, z);
     return new SecP521R1FieldElement(z);
 }
开发者ID:ubberkid,项目名称:PeerATT,代码行数:6,代码来源:SecP521R1FieldElement.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ECPoint类代码示例发布时间:2022-05-24
下一篇:
C# ECCurve类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap