Package org.gudy.bouncycastle.math.ec
Class ECFieldElement.F2m
- java.lang.Object
-
- org.gudy.bouncycastle.math.ec.ECFieldElement
-
- org.gudy.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 fieldF2m
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.gudy.bouncycastle.math.ec.ECFieldElement
ECFieldElement.F2m, ECFieldElement.Fp
-
-
Field Summary
Fields Modifier and Type Field Description static int
GNB
Indicates gaussian normal basis representation (GNB).private int
k1
TPB: The integerk
wherexm + xk + 1
represents the reduction polynomialf(z)
.
PPB: The integerk1
wherexm + xk3 + xk2 + xk1 + 1
represents the reduction polynomialf(z)
.private int
k2
TPB: Always set to0
PPB: The integerk2
wherexm + xk3 + xk2 + xk1 + 1
represents the reduction polynomialf(z)
.private int
k3
TPB: Always set to0
PPB: The integerk3
wherexm + xk3 + xk2 + xk1 + 1
represents the reduction polynomialf(z)
.private int
m
The exponentm
ofF2m
.static int
PPB
Indicates pentanomial basis representation (PPB).private int
representation
TPB or PPB.private int
t
The number ofint
s required to holdm
bits.static int
TPB
Indicates trinomial basis representation (TPB).private IntArray
x
TheIntArray
holding the bits.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ECFieldElement
add(ECFieldElement b)
static void
checkFieldElements(ECFieldElement a, ECFieldElement b)
Checks, if the ECFieldElementsa
andb
are elements of the same fieldF2m
(having the same representation).ECFieldElement
divide(ECFieldElement b)
boolean
equals(java.lang.Object anObject)
java.lang.String
getFieldName()
int
getFieldSize()
int
getK1()
int
getK2()
int
getK3()
int
getM()
int
getRepresentation()
int
hashCode()
ECFieldElement
invert()
ECFieldElement
multiply(ECFieldElement b)
ECFieldElement
negate()
ECFieldElement
sqrt()
ECFieldElement
square()
ECFieldElement
subtract(ECFieldElement b)
java.math.BigInteger
toBigInteger()
-
Methods inherited from class org.gudy.bouncycastle.math.ec.ECFieldElement
toString
-
-
-
-
Field Detail
-
GNB
public static final int GNB
Indicates 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 TPB
Indicates trinomial basis representation (TPB). Number chosen according to X9.62.- See Also:
- Constant Field Values
-
PPB
public static final int PPB
Indicates pentanomial basis representation (PPB). Number chosen according to X9.62.- See Also:
- Constant Field Values
-
representation
private int representation
TPB or PPB.
-
m
private int m
The exponentm
ofF2m
.
-
k1
private int k1
TPB: The integerk
wherexm + xk + 1
represents the reduction polynomialf(z)
.
PPB: The integerk1
wherexm + xk3 + xk2 + xk1 + 1
represents the reduction polynomialf(z)
.
-
k2
private int k2
TPB: Always set to0
PPB: The integerk2
wherexm + xk3 + xk2 + xk1 + 1
represents the reduction polynomialf(z)
.
-
k3
private int k3
TPB: Always set to0
PPB: The integerk3
wherexm + xk3 + xk2 + xk1 + 1
represents the reduction polynomialf(z)
.
-
x
private IntArray x
TheIntArray
holding the bits.
-
t
private int t
The number ofint
s required to holdm
bits.
-
-
Constructor Detail
-
F2m
public F2m(int m, int k1, int k2, int k3, java.math.BigInteger x)
Constructor for PPB.- Parameters:
m
- The exponentm
ofF2m
.k1
- The integerk1
wherexm + xk3 + xk2 + xk1 + 1
represents the reduction polynomialf(z)
.k2
- The integerk2
wherexm + xk3 + xk2 + xk1 + 1
represents the reduction polynomialf(z)
.k3
- The integerk3
wherexm + xk3 + xk2 + xk1 + 1
represents the reduction polynomialf(z)
.x
- The BigInteger representing the value of the field element.
-
F2m
public F2m(int m, int k, java.math.BigInteger x)
Constructor for TPB.- Parameters:
m
- The exponentm
ofF2m
.k
- The integerk
wherexm + xk + 1
represents the reduction polynomialf(z)
.x
- The BigInteger representing the value of the field element.
-
F2m
private F2m(int m, int k1, int k2, int k3, IntArray x)
-
-
Method Detail
-
toBigInteger
public java.math.BigInteger toBigInteger()
- Specified by:
toBigInteger
in classECFieldElement
-
getFieldName
public java.lang.String getFieldName()
- Specified by:
getFieldName
in classECFieldElement
-
getFieldSize
public int getFieldSize()
- Specified by:
getFieldSize
in classECFieldElement
-
checkFieldElements
public static void checkFieldElements(ECFieldElement a, ECFieldElement b)
Checks, if the ECFieldElementsa
andb
are elements of the same fieldF2m
(having the same representation).- Parameters:
a
- field element.b
- field element to be compared.- Throws:
java.lang.IllegalArgumentException
- ifa
andb
are not elements of the same fieldF2m
(having the same representation).
-
add
public ECFieldElement add(ECFieldElement b)
- Specified by:
add
in classECFieldElement
-
subtract
public ECFieldElement subtract(ECFieldElement b)
- Specified by:
subtract
in classECFieldElement
-
multiply
public ECFieldElement multiply(ECFieldElement b)
- Specified by:
multiply
in classECFieldElement
-
divide
public ECFieldElement divide(ECFieldElement b)
- Specified by:
divide
in classECFieldElement
-
negate
public ECFieldElement negate()
- Specified by:
negate
in classECFieldElement
-
square
public ECFieldElement square()
- Specified by:
square
in classECFieldElement
-
invert
public ECFieldElement invert()
- Specified by:
invert
in classECFieldElement
-
sqrt
public ECFieldElement sqrt()
- Specified by:
sqrt
in 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
m
of the reduction polynomialf(z)
.
-
getK1
public int getK1()
- Returns:
- TPB: The integer
k
wherexm + xk + 1
represents the reduction polynomialf(z)
.
PPB: The integerk1
wherexm + xk3 + xk2 + xk1 + 1
represents the reduction polynomialf(z)
.
-
getK2
public int getK2()
- Returns:
- TPB: Always returns
0
PPB: The integerk2
wherexm + xk3 + xk2 + xk1 + 1
represents the reduction polynomialf(z)
.
-
getK3
public int getK3()
- Returns:
- TPB: Always set to
0
PPB: The integerk3
wherexm + xk3 + xk2 + xk1 + 1
represents the reduction polynomialf(z)
.
-
equals
public boolean equals(java.lang.Object anObject)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-