org.bouncycastle.pqc.legacy.math.linearalgebra.GF2nElement Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcprov-debug-jdk15to18 Show documentation
Show all versions of bcprov-debug-jdk15to18 Show documentation
The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.5 to JDK 1.8.
The newest version!
package org.bouncycastle.pqc.legacy.math.linearalgebra;
/**
* This abstract class implements an element of the finite field GF(2)n
* in either optimal normal basis representation (ONB)
* or in polynomial representation. It is extended by the classes GF2nONBElement and GF2nPolynomialElement .
*
* @see GF2nPolynomialElement
* @see GF2nONBElement
* @see GF2nONBField
*/
public abstract class GF2nElement
implements GFElement
{
// /////////////////////////////////////////////////////////////////////
// member variables
// /////////////////////////////////////////////////////////////////////
/**
* holds a pointer to this element's corresponding field.
*/
protected GF2nField mField;
/**
* holds the extension degree n of this element's corresponding
* field.
*/
protected int mDegree;
// /////////////////////////////////////////////////////////////////////
// pseudo-constructors
// /////////////////////////////////////////////////////////////////////
/**
* @return a copy of this GF2nElement
*/
public abstract Object clone();
// /////////////////////////////////////////////////////////////////////
// assignments
// /////////////////////////////////////////////////////////////////////
/**
* Assign the value 0 to this element.
*/
abstract void assignZero();
/**
* Assigns the value 1 to this element.
*/
abstract void assignOne();
// /////////////////////////////////////////////////////////////////////
// access
// /////////////////////////////////////////////////////////////////////
/**
* Returns whether the rightmost bit of the bit representation is set. This
* is needed for data conversion according to 1363.
*
* @return true if the rightmost bit of this element is set
*/
public abstract boolean testRightmostBit();
/**
* Checks whether the indexed bit of the bit representation is set
*
* @param index the index of the bit to test
* @return true if the indexed bit is set
*/
abstract boolean testBit(int index);
/**
* Returns the field of this element.
*
* @return the field of this element
*/
public final GF2nField getField()
{
return mField;
}
// /////////////////////////////////////////////////////////////////////
// arithmetic
// /////////////////////////////////////////////////////////////////////
/**
* Returns this element + 1.
*
* @return this + 1
*/
public abstract GF2nElement increase();
/**
* Increases this element by one.
*/
public abstract void increaseThis();
/**
* Compute the difference of this element and minuend.
*
* @param minuend the minuend
* @return this - minuend (newly created)
*/
public final GFElement subtract(GFElement minuend)
{
return add(minuend);
}
/**
* Compute the difference of this element and minuend,
* overwriting this element.
*
* @param minuend the minuend
*/
public final void subtractFromThis(GFElement minuend)
{
addToThis(minuend);
}
/**
* Returns this element to the power of 2.
*
* @return this2
*/
public abstract GF2nElement square();
/**
* Squares this element.
*/
public abstract void squareThis();
/**
* Compute the square root of this element and return the result in a new
* {@link GF2nElement}.
*
* @return this1/2 (newly created)
*/
public abstract GF2nElement squareRoot();
/**
* Compute the square root of this element.
*/
public abstract void squareRootThis();
/**
* Performs a basis transformation of this element to the given GF2nField
* basis.
*
* @param basis the GF2nField representation to transform this element to
* @return this element in the representation of basis
*/
public final GF2nElement convert(GF2nField basis)
{
return mField.convert(this, basis);
}
/**
* Returns the trace of this element.
*
* @return the trace of this element
*/
public abstract int trace();
/**
* Solves a quadratic equation.
* Let z2 + z = this. Then this method returns z.
*
* @return z with z2 + z = this
*/
public abstract GF2nElement solveQuadraticEquation()
throws RuntimeException;
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy