Package org.bouncycastle.math.ec
Class ECFieldElement.F2m
java.lang.Object
org.bouncycastle.math.ec.ECFieldElement
org.bouncycastle.math.ec.ECFieldElement.F2m
- All Implemented Interfaces:
ECConstants
- Enclosing class:
- ECFieldElement
public static class ECFieldElement.F2m extends ECFieldElement
Class representing the Elements of the finite field
F2m in polynomial basis (PB)
representation. Both trinomial (TPB) and pentanomial (PPB) polynomial
basis representations are supported. Gaussian normal basis (GNB)
representation is not supported.-
Nested Class Summary
Nested classes/interfaces inherited from class org.bouncycastle.math.ec.ECFieldElement
ECFieldElement.F2m, ECFieldElement.Fp -
Field Summary
-
Constructor Summary
Constructors Constructor Description F2m(int m, int k1, int k2, int k3, BigInteger x)Constructor for PPB.F2m(int m, int k, BigInteger x)Constructor for TPB. -
Method Summary
Modifier and Type Method Description ECFieldElementadd(ECFieldElement b)static voidcheckFieldElements(ECFieldElement a, ECFieldElement b)Checks, if the ECFieldElementsaandbare elements of the same fieldF2m(having the same representation).ECFieldElementdivide(ECFieldElement b)booleanequals(Object anObject)Compares this instance with the specified object and indicates if they are equal.StringgetFieldName()intgetFieldSize()intgetK1()intgetK2()intgetK3()intgetM()intgetRepresentation()inthashCode()Returns an integer hash code for this object.ECFieldElementinvert()ECFieldElementmultiply(ECFieldElement b)ECFieldElementnegate()ECFieldElementsqrt()ECFieldElementsquare()ECFieldElementsubtract(ECFieldElement b)BigIntegertoBigInteger()Methods inherited from class org.bouncycastle.math.ec.ECFieldElement
toString
-
Field Details
-
GNB
public static final int GNBIndicates gaussian normal basis representation (GNB). Number chosen according to X9.62. GNB is not implemented at present.- See Also:
- Constant Field Values
-
TPB
public static final int TPBIndicates trinomial basis representation (TPB). Number chosen according to X9.62.- See Also:
- Constant Field Values
-
PPB
public static final int PPBIndicates pentanomial basis representation (PPB). Number chosen according to X9.62.- See Also:
- Constant Field Values
-
-
Constructor Details
-
F2m
Constructor for PPB.- Parameters:
m- The exponentmofF2m.k1- The integerk1wherexm + xk3 + xk2 + xk1 + 1represents the reduction polynomialf(z).k2- The integerk2wherexm + xk3 + xk2 + xk1 + 1represents the reduction polynomialf(z).k3- The integerk3wherexm + xk3 + xk2 + xk1 + 1represents the reduction polynomialf(z).x- The BigInteger representing the value of the field element.
-
F2m
Constructor for TPB.- Parameters:
m- The exponentmofF2m.k- The integerkwherexm + xk + 1represents the reduction polynomialf(z).x- The BigInteger representing the value of the field element.
-
-
Method Details
-
toBigInteger
- Specified by:
toBigIntegerin classECFieldElement
-
getFieldName
- Specified by:
getFieldNamein classECFieldElement
-
getFieldSize
public int getFieldSize()- Specified by:
getFieldSizein classECFieldElement
-
checkFieldElements
Checks, if the ECFieldElementsaandbare elements of the same fieldF2m(having the same representation).- Parameters:
a- field element.b- field element to be compared.- Throws:
IllegalArgumentException- ifaandbare not elements of the same fieldF2m(having the same representation).
-
add
- Specified by:
addin classECFieldElement
-
subtract
- Specified by:
subtractin classECFieldElement
-
multiply
- Specified by:
multiplyin classECFieldElement
-
divide
- Specified by:
dividein classECFieldElement
-
negate
- Specified by:
negatein classECFieldElement
-
square
- Specified by:
squarein classECFieldElement
-
invert
- Specified by:
invertin classECFieldElement
-
sqrt
- Specified by:
sqrtin classECFieldElement
-
getRepresentation
public int getRepresentation()- Returns:
- the representation of the field
F2m, either of TPB (trinomial basis representation) or PPB (pentanomial basis representation).
-
getM
public int getM()- Returns:
- the degree
mof the reduction polynomialf(z).
-
getK1
public int getK1()- Returns:
- TPB: The integer
kwherexm + xk + 1represents the reduction polynomialf(z).
PPB: The integerk1wherexm + xk3 + xk2 + xk1 + 1represents the reduction polynomialf(z).
-
getK2
public int getK2()- Returns:
- TPB: Always returns
0
PPB: The integerk2wherexm + xk3 + xk2 + xk1 + 1represents the reduction polynomialf(z).
-
getK3
public int getK3()- Returns:
- TPB: Always set to
0
PPB: The integerk3wherexm + xk3 + xk2 + xk1 + 1represents the reduction polynomialf(z).
-
equals
Description copied from class:ObjectCompares this instance with the specified object and indicates if they are equal. In order to be equal,omust represent the same object as this instance using a class-specific comparison. The general contract is that this comparison should be reflexive, symmetric, and transitive. Also, no object reference other than null is equal to null.The default implementation returns
trueonly ifthis == o. See Writing a correctequalsmethod if you intend implementing your ownequalsmethod.The general contract for the
equalsandObject.hashCode()methods is that ifequalsreturnstruefor any two objects, thenhashCode()must return the same value for these objects. This means that subclasses ofObjectusually override either both methods or neither of them.- Overrides:
equalsin classObject- Parameters:
anObject- the object to compare this instance with.- Returns:
trueif the specified object is equal to thisObject;falseotherwise.- See Also:
Object.hashCode()
-
hashCode
public int hashCode()Description copied from class:ObjectReturns an integer hash code for this object. By contract, any two objects for whichObject.equals(java.lang.Object)returnstruemust return the same hash code value. This means that subclasses ofObjectusually override both methods or neither method.Note that hash values must not change over time unless information used in equals comparisons also changes.
See Writing a correct
hashCodemethod if you intend implementing your ownhashCodemethod.- Overrides:
hashCodein classObject- Returns:
- this object's hash code.
- See Also:
Object.equals(java.lang.Object)
-