/** * Create the zero element. * * @param gf2n the finite field * @return the zero element in the given finite field */ public static GF2nONBElement ZERO(GF2nONBField gf2n) { long[] polynomial = new long[gf2n.getONBLength()]; return new GF2nONBElement(gf2n, polynomial); }
/** * Create the zero element. * * @param gf2n the finite field * @return the zero element in the given finite field */ public static GF2nONBElement ZERO(GF2nONBField gf2n) { long[] polynomial = new long[gf2n.getONBLength()]; return new GF2nONBElement(gf2n, polynomial); }
/** * Construct the element of the field <tt>gf2n</tt> with the specified * value <tt>val</tt>. * * @param gf2n the field * @param val the value in ONB representation */ private GF2nONBElement(GF2nONBField gf2n, long[] val) { mField = gf2n; mDegree = mField.getDegree(); mLength = gf2n.getONBLength(); mBit = gf2n.getONBBit(); mPol = val; }
/** * Construct the element of the field <tt>gf2n</tt> with the specified * value <tt>val</tt>. * * @param gf2n the field * @param val the value in ONB representation */ private GF2nONBElement(GF2nONBField gf2n, long[] val) { mField = gf2n; mDegree = mField.getDegree(); mLength = gf2n.getONBLength(); mBit = gf2n.getONBBit(); mPol = val; }
/** * Construct a random element over the field <tt>gf2n</tt>, using the * specified source of randomness. * * @param gf2n the field * @param rand the source of randomness */ public GF2nONBElement(GF2nONBField gf2n, Random rand) { mField = gf2n; mDegree = mField.getDegree(); mLength = gf2n.getONBLength(); mBit = gf2n.getONBBit(); mPol = new long[mLength]; if (mLength > 1) { for (int j = 0; j < mLength - 1; j++) { mPol[j] = rand.nextLong(); } long last = rand.nextLong(); mPol[mLength - 1] = last >>> (MAXLONG - mBit); } else { mPol[0] = rand.nextLong(); mPol[0] = mPol[0] >>> (MAXLONG - mBit); } }
/** * Construct a random element over the field <tt>gf2n</tt>, using the * specified source of randomness. * * @param gf2n the field * @param rand the source of randomness */ public GF2nONBElement(GF2nONBField gf2n, SecureRandom rand) { mField = gf2n; mDegree = mField.getDegree(); mLength = gf2n.getONBLength(); mBit = gf2n.getONBBit(); mPol = new long[mLength]; if (mLength > 1) { for (int j = 0; j < mLength - 1; j++) { mPol[j] = rand.nextLong(); } long last = rand.nextLong(); mPol[mLength - 1] = last >>> (MAXLONG - mBit); } else { mPol[0] = rand.nextLong(); mPol[0] = mPol[0] >>> (MAXLONG - mBit); } }
/** * Create the one element. * * @param gf2n the finite field * @return the one element in the given finite field */ 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] = 0xffffffffffffffffL; } polynomial[mLength - 1] = mMaxmask[gf2n.getONBBit() - 1]; return new GF2nONBElement(gf2n, polynomial); }
/** * Create the one element. * * @param gf2n the finite field * @return the one element in the given finite field */ 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] = 0xffffffffffffffffL; } polynomial[mLength - 1] = mMaxmask[gf2n.getONBBit() - 1]; return new GF2nONBElement(gf2n, polynomial); }
/** * Construct the element of the field <tt>gf2n</tt> with the specified * value <tt>val</tt>. * * @param gf2n the field * @param val the value represented by a BigInteger */ public GF2nONBElement(GF2nONBField gf2n, BigInteger val) { mField = gf2n; mDegree = mField.getDegree(); mLength = gf2n.getONBLength(); mBit = gf2n.getONBBit(); mPol = new long[mLength]; assign(val); }
/** * Construct a new GF2nONBElement from its encoding. * * @param gf2n the field * @param e the encoded element */ public GF2nONBElement(GF2nONBField gf2n, byte[] e) { mField = gf2n; mDegree = mField.getDegree(); mLength = gf2n.getONBLength(); mBit = gf2n.getONBBit(); mPol = new long[mLength]; assign(e); }
/** * Construct a new GF2nONBElement from its encoding. * * @param gf2n the field * @param e the encoded element */ public GF2nONBElement(GF2nONBField gf2n, byte[] e) { mField = gf2n; mDegree = mField.getDegree(); mLength = gf2n.getONBLength(); mBit = gf2n.getONBBit(); mPol = new long[mLength]; assign(e); }
/** * Construct the element of the field <tt>gf2n</tt> with the specified * value <tt>val</tt>. * * @param gf2n the field * @param val the value represented by a BigInteger */ public GF2nONBElement(GF2nONBField gf2n, BigInteger val) { mField = gf2n; mDegree = mField.getDegree(); mLength = gf2n.getONBLength(); mBit = gf2n.getONBBit(); mPol = new long[mLength]; assign(val); }
/** * Copy constructor. * * @param gf2n the field */ public GF2nONBElement(GF2nONBElement gf2n) { mField = gf2n.mField; mDegree = mField.getDegree(); mLength = ((GF2nONBField)mField).getONBLength(); mBit = ((GF2nONBField)mField).getONBBit(); mPol = new long[mLength]; assign(gf2n.getElement()); }
/** * Copy constructor. * * @param gf2n the field */ public GF2nONBElement(GF2nONBElement gf2n) { mField = gf2n.mField; mDegree = mField.getDegree(); mLength = ((GF2nONBField)mField).getONBLength(); mBit = ((GF2nONBField)mField).getONBBit(); mPol = new long[mLength]; assign(gf2n.getElement()); }