/** * Returns the half-trace of this GF2nPolynomialElement. * * @return a GF2nPolynomialElement representing the half-trace of this * GF2nPolynomialElement. * @throws DegreeIsEvenException if the degree of this GF2nPolynomialElement is even. */ private GF2nPolynomialElement halfTrace() throws RuntimeException { if ((mDegree & 0x01) == 0) { throw new RuntimeException(); } int i; GF2nPolynomialElement h = new GF2nPolynomialElement(this); for (i = 1; i <= ((mDegree - 1) >> 1); i++) { h.squareThis(); h.squareThis(); h.addToThis(this); } return h; }
/** * Returns the half-trace of this GF2nPolynomialElement. * * @return a GF2nPolynomialElement representing the half-trace of this * GF2nPolynomialElement. */ private GF2nPolynomialElement halfTrace() throws RuntimeException { if ((mDegree & 0x01) == 0) { throw new RuntimeException(); } int i; GF2nPolynomialElement h = new GF2nPolynomialElement(this); for (i = 1; i <= ((mDegree - 1) >> 1); i++) { h.squareThis(); h.squareThis(); h.addToThis(this); } return h; }
/** * 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(); } }
/** * Compute <tt>this * factor</tt> (overwrite <tt>this</tt>). * * @param factor the factor */ public void multiplyThisBy(GFElement factor) throws RuntimeException { if (!(factor instanceof GF2nPolynomialElement)) { throw new RuntimeException(); } if (!mField.equals(((GF2nPolynomialElement)factor).mField)) { throw new RuntimeException(); } if (equals(factor)) { squareThis(); return; } polynomial = polynomial .multiply(((GF2nPolynomialElement)factor).polynomial); reduceThis(); }
/** * Compute <tt>this * factor</tt> (overwrite <tt>this</tt>). * * @param factor the factor * @throws DifferentFieldsException if the elements are of different fields. */ public void multiplyThisBy(GFElement factor) throws RuntimeException { if (!(factor instanceof GF2nPolynomialElement)) { throw new RuntimeException(); } if (!mField.equals(((GF2nPolynomialElement)factor).mField)) { throw new RuntimeException(); } if (equals(factor)) { squareThis(); return; } polynomial = polynomial .multiply(((GF2nPolynomialElement)factor).polynomial); reduceThis(); }
/** * Returns the trace of this GF2nPolynomialElement. * * @return the trace of this GF2nPolynomialElement */ public int trace() { GF2nPolynomialElement t = new GF2nPolynomialElement(this); int i; for (i = 1; i < mDegree; i++) { t.squareThis(); t.addToThis(this); } if (t.isOne()) { return 1; } return 0; }
/** * Returns the trace of this GF2nPolynomialElement. * * @return the trace of this GF2nPolynomialElement */ public int trace() { GF2nPolynomialElement t = new GF2nPolynomialElement(this); int i; for (i = 1; i < mDegree; i++) { t.squareThis(); t.addToThis(this); } if (t.isOne()) { return 1; } return 0; }
z.squareThis(); w.squareThis(); z.addToThis(w.multiply(this)); w.addToThis(p);
z.squareThis(); w.squareThis(); z.addToThis(w.multiply(this)); w.addToThis(p);