/** * Creates a new GF2nPolynomialElement using the given field and Bitstring. * * @param f the GF2nPolynomialField to use * @param bs the desired value as Bitstring */ public GF2nPolynomialElement(GF2nPolynomialField f, GF2Polynomial bs) { mField = f; mDegree = mField.getDegree(); polynomial = new GF2Polynomial(bs); polynomial.expandN(mDegree); }
/** * Creates a new GF2nPolynomialElement using the given field and Bitstring. * * @param f the GF2nPolynomialField to use * @param bs the desired value as Bitstring */ public GF2nPolynomialElement(GF2nPolynomialField f, GF2Polynomial bs) { mField = f; mDegree = mField.getDegree(); polynomial = new GF2Polynomial(bs); polynomial.expandN(mDegree); }
/** * Create a new random GF2nPolynomialElement using the given field and * source of randomness. * * @param f the GF2nField to use * @param rand the source of randomness */ public GF2nPolynomialElement(GF2nPolynomialField f, Random rand) { mField = f; mDegree = mField.getDegree(); polynomial = new GF2Polynomial(mDegree); randomize(rand); }
/** * 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; }
/** * Creates a new GF2nPolynomialElement using the given field <i>f</i> and * int[] <i>is</i> as value. * * @param f the GF2nField to use * @param is the integer string to assign to this GF2nPolynomialElement */ public GF2nPolynomialElement(GF2nPolynomialField f, int[] is) { mField = f; mDegree = mField.getDegree(); polynomial = new GF2Polynomial(mDegree, is); polynomial.expandN(f.mDegree); }
/** * Create a new random GF2nPolynomialElement using the given field and * source of randomness. * * @param f the GF2nField to use * @param rand the source of randomness */ public GF2nPolynomialElement(GF2nPolynomialField f, Random rand) { mField = f; mDegree = mField.getDegree(); polynomial = new GF2Polynomial(mDegree); randomize(rand); }
/** * Creates a new GF2nPolynomialElement using the given field <i>f</i> and * int[] <i>is</i> as value. * * @param f the GF2nField to use * @param is the integer string to assign to this GF2nPolynomialElement */ public GF2nPolynomialElement(GF2nPolynomialField f, int[] is) { mField = f; mDegree = mField.getDegree(); polynomial = new GF2Polynomial(mDegree, is); polynomial.expandN(f.mDegree); }
/** * Creates a new GF2nPolynomialElement using the given field <i>f</i> and * byte[] <i>os</i> as value. The conversion is done according to 1363. * * @param f the GF2nField to use * @param os the octet string to assign to this GF2nPolynomialElement * @see "P1363 5.5.5 p23, OS2FEP/OS2BSP" */ public GF2nPolynomialElement(GF2nPolynomialField f, byte[] os) { mField = f; mDegree = mField.getDegree(); polynomial = new GF2Polynomial(mDegree, os); polynomial.expandN(mDegree); }
/** * Creates a new GF2nPolynomialElement using the given field <i>f</i> and * byte[] <i>os</i> as value. The conversion is done according to 1363. * * @param f the GF2nField to use * @param os the octet string to assign to this GF2nPolynomialElement * @see "P1363 5.5.5 p23, OS2FEP/OS2BSP" */ public GF2nPolynomialElement(GF2nPolynomialField f, byte[] os) { mField = f; mDegree = mField.getDegree(); polynomial = new GF2Polynomial(mDegree, os); polynomial.expandN(mDegree); }
/** * 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, 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); } }
/** * 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); } }
/** * Compute the square root of this element. */ public void squareRootThis() { // increase performance polynomial.expandN((mDegree << 1) + 32); polynomial.reduceN(); for (int i = 0; i < mField.getDegree() - 1; i++) { squareThis(); } }
/** * Compute the square root of this element. */ public void squareRootThis() { // increase performance polynomial.expandN((mDegree << 1) + 32); polynomial.reduceN(); for (int i = 0; i < mField.getDegree() - 1; i++) { squareThis(); } }
/** * 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()); }