throws RuntimeException if (isZero()) return ZERO((GF2nPolynomialField)mField); return halfTrace(); GF2nPolynomialElement p = new GF2nPolynomialElement( (GF2nPolynomialField)mField, new Random()); z = ZERO((GF2nPolynomialField)mField); w = (GF2nPolynomialElement)p.clone(); z.squareThis(); w.squareThis(); z.addToThis(w.multiply(this)); w.addToThis(p); while (w.isZero()); // step 4. if (!equals(z.square().add(z)))
/** * Returns <tt>this</tt> element + 'one". * * @return <tt>this</tt> + 'one' */ public GF2nElement increase() { GF2nPolynomialElement result = new GF2nPolynomialElement(this); result.increaseThis(); return result; }
/** * Compute the multiplicative inverse of this element. * * @return <tt>this<sup>-1</sup></tt> (newly created) * @throws ArithmeticException if <tt>this</tt> is the zero element. * @see GF2nPolynomialElement#invertMAIA * @see GF2nPolynomialElement#invertEEA * @see GF2nPolynomialElement#invertSquare */ public GFElement invert() throws ArithmeticException { return invertMAIA(); }
/** * Compute the square root of this element and return the result in a new * {@link GF2nPolynomialElement}. * * @return <tt>this<sup>1/2</sup></tt> (newly created) */ public GF2nElement squareRoot() { GF2nPolynomialElement result = new GF2nPolynomialElement(this); result.squareRootThis(); return result; }
/** * Compute the sum of this element and <tt>addend</tt>. * * @param addend the addend * @return <tt>this + other</tt> (newly created) */ public GFElement add(GFElement addend) throws RuntimeException { GF2nPolynomialElement result = new GF2nPolynomialElement(this); result.addToThis(addend); return result; }
throws ArithmeticException if (isZero()) GF2Polynomial c = new GF2Polynomial(mDegree + 32); c.reduceN(); GF2Polynomial u = getGF2Polynomial(); GF2Polynomial v = mField.getFieldPolynomial(); GF2Polynomial h; return new GF2nPolynomialElement((GF2nPolynomialField)mField, b);
/** * 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; }
return new GF2nPolynomialElement(this); .ONE((GF2nPolynomialField)mField); if (k == 0) GF2nPolynomialElement x = new GF2nPolynomialElement(this); x.polynomial.expandN((x.mDegree << 1) + 32); // increase performance x.polynomial.reduceN(); result.multiplyThisBy(x); x.square();
int i, j, k, b; if (isZero()) n = new GF2nPolynomialElement(this); n.polynomial.expandN((mDegree << 1) + 32); // increase performance n.polynomial.reduceN(); u = new GF2nPolynomialElement(n); u.squareThisPreCalc(); n.multiplyThisBy(u); n.squareThisPreCalc(); n.multiplyThisBy(this); n.squareThisPreCalc(); return n;
/** * Squares this GF2nPolynomialElement by using precalculated values and * reducing. This is supposed to de fastest when using a trinomial or * pentanomial as field polynomial. Use squareMatrix when using a ordinary * polynomial as field polynomial. * * @return <tt>this<sup>2</sup></tt> (newly created) * @see GF2nPolynomialElement#squareMatrix * @see GF2Polynomial#squareThisPreCalc */ public GF2nPolynomialElement squarePreCalc() { GF2nPolynomialElement result = new GF2nPolynomialElement(this); result.squareThisPreCalc(); result.reduceThis(); return result; }
/** * Squares this GF2nPolynomialElement using GF2nField's squaring matrix. * This is supposed to be fast when using a polynomial (no tri- or * pentanomial) as fieldpolynomial. Use squarePreCalc when using a tri- or * pentanomial as fieldpolynomial instead. * * @return <tt>this<sup>2</sup></tt> (newly created) * @see GF2Polynomial#vectorMult * @see GF2nPolynomialElement#squarePreCalc * @see GF2nPolynomialElement#squareBitwise */ public GF2nPolynomialElement squareMatrix() { GF2nPolynomialElement result = new GF2nPolynomialElement(this); result.squareThisMatrix(); result.reduceThis(); return result; }
/** * Squares this GF2nPolynomialElement by shifting left its Bitstring and * reducing. This is supposed to be the slowest method. Use squarePreCalc or * squareMatrix instead. * * @return <tt>this<sup>2</sup></tt> (newly created) * @see GF2nPolynomialElement#squareMatrix * @see GF2nPolynomialElement#squarePreCalc * @see GF2Polynomial#squareThisBitwise */ public GF2nPolynomialElement squareBitwise() { GF2nPolynomialElement result = new GF2nPolynomialElement(this); result.squareThisBitwise(); result.reduceThis(); return result; }
/** * 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(); }
/** * 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; }
/** * Creates a new GF2nPolynomialElement by cloning this * GF2nPolynomialElement. * * @return a copy of this element */ public Object clone() { return new GF2nPolynomialElement(this); }
/** * Compute the product of this element and <tt>factor</tt>. * * @param factor the factor * @return <tt>this * factor</tt> (newly created) * @throws DifferentFieldsException if the elements are of different fields. */ public GFElement multiply(GFElement factor) throws RuntimeException { GF2nPolynomialElement result = new GF2nPolynomialElement(this); result.multiplyThisBy(factor); return result; }
u = new GF2nPolynomialElement(this, new Random()); ut = new GF2nPolynomial(2, GF2nPolynomialElement.ZERO(this));
res[i] = GF2nPolynomialElement.ZERO((GF2nPolynomialField)f);
.ONE((GF2nPolynomialField)B1);