示例#1
0
 public override ECFieldElement Invert()
 {
     return(new SecT239FieldElement(
                AbstractF2mCurve.Inverse(239, new int[] { 158 }, ToBigInteger())));
 }
示例#2
0
 public override ECFieldElement Invert()
 {
     return(new SecT283FieldElement(
                AbstractF2mCurve.Inverse(283, new int[] { 5, 7, 12 }, ToBigInteger())));
 }
示例#3
0
文件: Tnaf.cs 项目: crowar/NBitcoin
		/**
        * Computes the auxiliary values <code>s<sub>0</sub></code> and
        * <code>s<sub>1</sub></code> used for partial modular reduction. 
        * @param curve The elliptic curve for which to compute
        * <code>s<sub>0</sub></code> and <code>s<sub>1</sub></code>.
        * @throws ArgumentException if <code>curve</code> is not a
        * Koblitz curve (Anomalous Binary Curve, ABC).
        */
		public static BigInteger[] GetSi(AbstractF2mCurve curve)
		{
			if(!curve.IsKoblitz)
				throw new ArgumentException("si is defined for Koblitz curves only");

			int m = curve.FieldSize;
			int a = curve.A.ToBigInteger().IntValue;
			sbyte mu = GetMu(a);
			int shifts = GetShiftsForCofactor(curve.Cofactor);
			int index = m + 3 - a;
			BigInteger[] ui = GetLucas(mu, index, false);

			if(mu == 1)
			{
				ui[0] = ui[0].Negate();
				ui[1] = ui[1].Negate();
			}

			BigInteger dividend0 = BigInteger.One.Add(ui[1]).ShiftRight(shifts);
			BigInteger dividend1 = BigInteger.One.Add(ui[0]).ShiftRight(shifts).Negate();

			return new BigInteger[] { dividend0, dividend1 };
		}
示例#4
0
文件: Tnaf.cs 项目: crowar/NBitcoin
		/**
        * Returns the parameter <code>&#956;</code> of the elliptic curve.
        * @param curve The elliptic curve from which to obtain <code>&#956;</code>.
        * The curve must be a Koblitz curve, i.e. <code>a</code> Equals
        * <code>0</code> or <code>1</code> and <code>b</code> Equals
        * <code>1</code>. 
        * @return <code>&#956;</code> of the elliptic curve.
        * @throws ArgumentException if the given ECCurve is not a Koblitz
        * curve.
        */
		public static sbyte GetMu(AbstractF2mCurve curve)
		{
			BigInteger a = curve.A.ToBigInteger();

			sbyte mu;
			if(a.SignValue == 0)
			{
				mu = -1;
			}
			else if(a.Equals(BigInteger.One))
			{
				mu = 1;
			}
			else
			{
				throw new ArgumentException("No Koblitz curve (ABC), TNAF multiplication not possible");
			}
			return mu;
		}
示例#5
0
 public override ECFieldElement Invert()
 {
     return(new SecT571FieldElement(
                AbstractF2mCurve.Inverse(571, new int[] { 2, 5, 10 }, ToBigInteger())));
 }
示例#6
0
 public override ECFieldElement Invert()
 {
     return(new SecT163FieldElement(
                AbstractF2mCurve.Inverse(163, new int[] { 3, 6, 7 }, ToBigInteger())));
 }
 public override ECFieldElement Invert()
 {
     return new SecT113FieldElement(
         AbstractF2mCurve.Inverse(113, new int[]{ 9 }, ToBigInteger()));
 }