/// <summary> /// Construct the element of the field <c>Gf2n</c> with the specified value <c>Value</c> /// </summary> /// /// <param name="Gf2n">The field</param> /// <param name="Value">The value in ONB representation</param> private GF2nONBElement(GF2nONBField Gf2n, long[] Value) { m_Field = Gf2n; m_Degree = m_Field.Degree; m_Length = Gf2n.GetONBLength(); m_Bit = Gf2n.GetONBBit(); m_Pol = Value; }
/// <summary> /// Construct the element of the field <c>Gf2n</c> with the specified value <c>Value</c> /// </summary> /// /// <param name="Gf2n">The field</param> /// <param name="Value">The value in ONB representation</param> private GF2nONBElement(GF2nONBField Gf2n, long[] Value) { mField = Gf2n; mDegree = mField.Degree; _mLength = Gf2n.GetONBLength(); _mBit = Gf2n.GetONBBit(); _mPol = Value; }
/// <summary> /// Construct the element of the field <c>Gf2n</c> with the specified value <c>Value</c> /// </summary> /// /// <param name="Gf2n">The field</param> /// <param name="Value">The value represented by a BigInteger</param> public GF2nONBElement(GF2nONBField Gf2n, BigInteger Value) { m_Field = Gf2n; m_Degree = m_Field.Degree; m_Length = Gf2n.GetONBLength(); m_Bit = Gf2n.GetONBBit(); m_Pol = new long[m_Length]; Assign(Value); }
/// <summary> /// Construct a new GF2nONBElement from its encoding /// </summary> /// /// <param name="Gf2n">The field</param> /// <param name="Encoded">The encoded element</param> public GF2nONBElement(GF2nONBField Gf2n, byte[] Encoded) { m_Field = Gf2n; m_Degree = m_Field.Degree; m_Length = Gf2n.GetONBLength(); m_Bit = Gf2n.GetONBBit(); m_Pol = new long[m_Length]; Assign(Encoded); }
/// <summary> /// Construct the element of the field <c>Gf2n</c> with the specified value <c>Value</c> /// </summary> /// /// <param name="Gf2n">The field</param> /// <param name="Value">The value represented by a BigInteger</param> public GF2nONBElement(GF2nONBField Gf2n, BigInteger Value) { mField = Gf2n; mDegree = mField.Degree; _mLength = Gf2n.GetONBLength(); _mBit = Gf2n.GetONBBit(); _mPol = new long[_mLength]; Assign(Value); }
/// <summary> /// Construct a new GF2nONBElement from its encoding /// </summary> /// /// <param name="Gf2n">The field</param> /// <param name="Encoded">The encoded element</param> public GF2nONBElement(GF2nONBField Gf2n, byte[] Encoded) { mField = Gf2n; mDegree = mField.Degree; _mLength = Gf2n.GetONBLength(); _mBit = Gf2n.GetONBBit(); _mPol = new long[_mLength]; Assign(Encoded); }
/// <summary> /// Create the one element /// </summary> /// /// <param name="Gf2n">The finite field</param> /// /// <returns>Returns the one element in the given finite field</returns> public static GF2nONBElement One(GF2nONBField Gf2n) { int mLength = Gf2n.GetONBLength(); long[] polynomial = new long[mLength]; // fill m_Degree coefficients with one's for (int i = 0; i < mLength - 1; i++) { polynomial[i] = unchecked ((long)0xffffffffffffffffL); } polynomial[mLength - 1] = _mMaxmask[Gf2n.GetONBBit() - 1]; return(new GF2nONBElement(Gf2n, polynomial)); }
/// <summary> /// Construct a random element over the field <c>gf2n</c>, using the specified source of randomness /// </summary> /// /// <param name="Gf2n">The field</param> /// <param name="SecRnd">The source of randomness</param> public GF2nONBElement(GF2nONBField Gf2n, IRandom SecRnd) { m_Field = Gf2n; m_Degree = m_Field.Degree; m_Length = Gf2n.GetONBLength(); m_Bit = Gf2n.GetONBBit(); m_Pol = new long[m_Length]; if (m_Length > 1) { for (int j = 0; j < m_Length - 1; j++) { m_Pol[j] = SecRnd.NextLong(); //ju next long? } long last = SecRnd.Next(); m_Pol[m_Length - 1] = IntUtils.URShift(last, (MAXLONG - m_Bit)); } else { m_Pol[0] = SecRnd.NextLong(); m_Pol[0] = IntUtils.URShift(m_Pol[0], (MAXLONG - m_Bit)); } }
/// <summary> /// Construct a random element over the field <c>gf2n</c>, using the specified source of randomness /// </summary> /// /// <param name="Gf2n">The field</param> /// <param name="SecRnd">The source of randomness</param> public GF2nONBElement(GF2nONBField Gf2n, IRandom SecRnd) { mField = Gf2n; mDegree = mField.Degree; _mLength = Gf2n.GetONBLength(); _mBit = Gf2n.GetONBBit(); _mPol = new long[_mLength]; if (_mLength > 1) { for (int j = 0; j < _mLength - 1; j++) { _mPol[j] = SecRnd.NextLong(); //ju next long? } long last = SecRnd.Next(); _mPol[_mLength - 1] = IntUtils.URShift(last, (MAXLONG - _mBit)); } else { _mPol[0] = SecRnd.NextLong(); _mPol[0] = IntUtils.URShift(_mPol[0], (MAXLONG - _mBit)); } }
/// <summary> /// Create the zero element /// </summary> /// /// <param name="Gf2n">The finite field</param> /// /// <returns>The zero element in the given finite field</returns> public static GF2nONBElement Zero(GF2nONBField Gf2n) { long[] polynomial = new long[Gf2n.GetONBLength()]; return(new GF2nONBElement(Gf2n, polynomial)); }
/// <summary> /// Create the zero element /// </summary> /// /// <param name="Gf2n">The finite field</param> /// /// <returns>The zero element in the given finite field</returns> public static GF2nONBElement Zero(GF2nONBField Gf2n) { long[] polynomial = new long[Gf2n.GetONBLength()]; return new GF2nONBElement(Gf2n, polynomial); }
/// <summary> /// Create the one element /// </summary> /// /// <param name="Gf2n">The finite field</param> /// /// <returns>Returns the one element in the given finite field</returns> public static GF2nONBElement One(GF2nONBField Gf2n) { int mLength = Gf2n.GetONBLength(); long[] polynomial = new long[mLength]; // fill mDegree coefficients with one's for (int i = 0; i < mLength - 1; i++) polynomial[i] = unchecked((long)0xffffffffffffffffL); polynomial[mLength - 1] = _mMaxmask[Gf2n.GetONBBit() - 1]; return new GF2nONBElement(Gf2n, polynomial); }
/// <summary> /// Construct a random element over the field <c>gf2n</c>, using the specified source of randomness /// </summary> /// /// <param name="Gf2n">The field</param> /// <param name="SecRnd">The source of randomness</param> public GF2nONBElement(GF2nONBField Gf2n, IRandom SecRnd) { mField = Gf2n; mDegree = mField.Degree; _mLength = Gf2n.GetONBLength(); _mBit = Gf2n.GetONBBit(); _mPol = new long[_mLength]; if (_mLength > 1) { for (int j = 0; j < _mLength - 1; j++) _mPol[j] = SecRnd.NextLong(); //ju next long? long last = SecRnd.Next(); _mPol[_mLength - 1] = IntUtils.URShift(last, (MAXLONG - _mBit)); } else { _mPol[0] = SecRnd.NextLong(); _mPol[0] = IntUtils.URShift(_mPol[0], (MAXLONG - _mBit)); } }