public class BinaryField extends ECFieldF2m implements Field
Note that due to reasons of performance the arithmetical methods of this class do not check, whether the inputs are valid elements of this field.
Also note that (almost) all methods in this class work in-place. So, there is no guarantee that values input to methods in this class will not be overridden. In case of doubt and if values need to be reused, always clone the value, before inputting it to a method.
References:
[1] Darrel Hankerson, Alfred J. Menezes and Scott Vanstone. Guide to Elliptic Curve Cryptography. Springer-Verlag New York, Inc. (2003)
[2] Henri Cohen and Gerhard Frey. Handbook of Elliptic and Hyperelliptic Curve Cryptography. Chapman & Hall/CRC (2005)
[3] J. von zur Gathen and M. Noecker. Polynomial and normal bases for finite fields. J. Cryptology (2005)
[4] Omran Ahmadi and Alfred Menezes. On the Number of Trace-One Elements in Polynomial Bases. In Designs, Codes and Cryptography, Springer Netherlands (2005)
PrimeField,
BinaryFieldElement,
BinaryFieldByIrreducibleFactory,
BinaryFieldByBitLengthFactory| Modifier and Type | Field and Description |
|---|---|
static String |
BINARY_FIELD_OID
Object Identifier for a binary field for ASN.1 encoding.
|
static iaik.asn1.ObjectID |
CHARACTERISTIC_TWO_GN_BASIS_OID
Object Identifiers for the Gaussian normal basis
|
static iaik.asn1.ObjectID |
CHARACTERISTIC_TWO_PP_BASIS_OID
Object Identifiers for the pentamonial basis
|
static iaik.asn1.ObjectID |
CHARACTERISTIC_TWO_TP_BASIS_OID
Object Identifiers for the trinomial basis
|
| Modifier and Type | Method and Description |
|---|---|
static BinaryFieldElement |
add(FieldElement a,
FieldElement b,
boolean preserveB)
Adds two field elements.
|
BinaryFieldElement |
add(GenericFieldElement a,
GenericFieldElement b)
Adds
b to a, i.e. |
BinaryFieldElement |
addOutOfPlace(GenericFieldElement a,
GenericFieldElement b)
Adds two elements and returns a new object holding the result.
|
BinaryFieldElement |
divide(GenericFieldElement a,
GenericFieldElement b)
Divides
a by b, i.e. |
boolean |
equals(Object obj) |
BinaryFieldElement |
exponentiate(GenericFieldElement a,
BigInteger n)
Raises
a to the power n, i.e. |
BinaryFieldElement |
exponentiate(GenericFieldElement a,
int n)
Raises
a to the power n, i.e. |
BinaryFieldElement |
exponentiateByPowerOf2(GenericFieldElement a,
int n)
Raises
a to the power 2n. |
Field |
getBaseField()
Returns
this, although base field would be F_2. |
BigInteger |
getCardinality()
Returns the cardinality of this field.
|
static PrecomputationData |
getExtendedPrecomputationData(BinaryFieldElement b)
Compiles 256 precomputed values for the multiplication algorithm.
|
FieldTypes |
getFieldType()
Returns the field type of the underlying implementation.
|
BinaryFieldElement |
getGenerator()
Returns the generator of this binary field.
|
BinaryFieldElement |
getOne()
Returns the one element.
|
static PrecomputationData |
getPrecomputationData(BinaryFieldElement b)
Compiles 16 precomputed values for the multiplication algorithm.
|
int |
getTrace(BinaryFieldElement a)
Determines the trace of a field element in constant time (see [2, Remarks
11.57 (ii)] and [4]).
|
BinaryFieldElement |
getTraceOneElement()
Returns an element of trace 1.
|
BinaryFieldElement |
getZero()
Returns the zero element.
|
int |
hashCode() |
BinaryFieldElement |
invert(GenericFieldElement a)
Inverts
a, i.e. |
GenericFieldElement[] |
invertElements(GenericFieldElement[] elements)
Simultaneously inverts an an array of field elements.
|
BinaryFieldElement |
multiply(BinaryFieldElement a,
PrecomputationData b)
Multiplies the field element
a with another element
b, where the latter is given as precomputation data. |
BinaryFieldElement |
multiply(GenericFieldElement a,
BigInteger b)
Multiplies
a by n, i.e. |
BinaryFieldElement |
multiply(GenericFieldElement a,
GenericFieldElement b)
Multiplies
a by b, i.e. |
BinaryFieldElement |
multiplyOutOfPlace(BinaryFieldElement a,
PrecomputationData b)
Multiplies the field element
a with another element
b, where the latter is given as precomputation data, where a
new object holding the result is created. |
BinaryFieldElement |
multiplyOutOfPlace(GenericFieldElement a,
BigInteger b)
Multiplies
a by n, i.e. |
BinaryFieldElement |
multiplyOutOfPlace(GenericFieldElement a,
GenericFieldElement b)
Multiplies
a by b, i.e. |
BinaryFieldElement |
negate(GenericFieldElement a)
Negates
a, i.e. |
BinaryFieldElement |
negateOutOfPlace(GenericFieldElement a)
Negates
a, i.e. |
BinaryFieldElement |
newElement(BigInteger b)
Creates a new field element from its
BigInteger representation. |
BinaryFieldElement |
newElement(byte[] bytes)
Creates a new field element from a
byte[]. |
BinaryFieldElement[] |
solveEquation(BinaryFieldElement c)
This method finds a solution to the equation X2 + X = c.
|
BinaryFieldElement[] |
solveEquation(BinaryFieldElement a,
BinaryFieldElement b)
This method finds solutions to the equation X2 + aX = b.
|
BinaryFieldElement |
square(GenericFieldElement a)
Squares
a, i.e. |
BinaryFieldElement |
squareOutOfPlace(GenericFieldElement a)
Squares
a, i.e. |
BinaryFieldElement |
squareRoot(FieldElement a)
Computes the square root of a field element.
|
BinaryFieldElement |
subtract(GenericFieldElement a,
GenericFieldElement b)
Subtracts
b from a, i.e. |
BinaryFieldElement |
subtractOutOfPlace(GenericFieldElement a,
GenericFieldElement b)
Subtract two elements and returns a new object holding the result.
|
iaik.asn1.SEQUENCE |
toASN1Object()
Compiles and returns the ASN.1 representation of this binary field, which
is:
|
byte[] |
toByteArray(FieldElement a)
Converts a field element to its raw
byte[] representation. |
BinaryFieldElement |
toElement(byte[] bytes)
Create new field element from a
byte-array. |
String |
toString() |
getFieldSize, getM, getMidTermsOfReductionPolynomial, getReductionPolynomialclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetFieldSizepublic static final String BINARY_FIELD_OID
public static final iaik.asn1.ObjectID CHARACTERISTIC_TWO_GN_BASIS_OID
public static final iaik.asn1.ObjectID CHARACTERISTIC_TWO_TP_BASIS_OID
public static final iaik.asn1.ObjectID CHARACTERISTIC_TWO_PP_BASIS_OID
public BinaryFieldElement negate(GenericFieldElement a)
GenericFielda, i.e. performs the operation b = -b.negate in interface Fieldnegate in interface GenericFielda - the field elementapublic BinaryFieldElement negateOutOfPlace(GenericFieldElement a)
GenericFielda, i.e. performs the operation b = -b,
where a new object holding the result is created.negateOutOfPlace in interface FieldnegateOutOfPlace in interface GenericFielda - the field elementapublic BinaryFieldElement add(GenericFieldElement a, GenericFieldElement b)
GenericFieldb to a, i.e. performs the operation
a += b.add in interface Fieldadd in interface GenericFielda - the first addendb - the second addenda and bpublic BinaryFieldElement addOutOfPlace(GenericFieldElement a, GenericFieldElement b)
a - the first valueb - the other valuepublic static BinaryFieldElement add(FieldElement a, FieldElement b, boolean preserveB)
preserveB is set to
false it overwrites the value of b, if the raw
value of b is longer than that of a.a - the first addendb - the second addendpreserveB - determines whether b can be overwrittena and bpublic BinaryFieldElement subtract(GenericFieldElement a, GenericFieldElement b)
GenericFieldb from a, i.e. performs the operation
a -= b.subtract in interface Fieldsubtract in interface GenericFielda - the minuendb - the subtrahenda and bpublic BinaryFieldElement subtractOutOfPlace(GenericFieldElement a, GenericFieldElement b)
a - the first valueb - the other valuepublic BinaryFieldElement invert(GenericFieldElement a)
GenericFielda, i.e. performs the operation
a = a^(-1).invert in interface Fieldinvert in interface GenericFielda - the field elementapublic GenericFieldElement[] invertElements(GenericFieldElement[] elements)
GenericFieldinvertElements in interface GenericFieldelements - the array of field elementspublic BinaryFieldElement divide(GenericFieldElement a, GenericFieldElement b)
GenericFielda by b, i.e. performs the operation
a /= b.divide in interface Fielddivide in interface GenericFielda - the dividendb - the divisora and bpublic BinaryFieldElement multiply(GenericFieldElement a, GenericFieldElement b)
GenericFielda by b, i.e. performs the operation
a *= b.multiply in interface Fieldmultiply in interface GenericFielda - the first factorb - the second factora and bpublic BinaryFieldElement multiplyOutOfPlace(GenericFieldElement a, GenericFieldElement b)
GenericFielda by b, i.e. performs the operation
a *= b, where a new object holding the result is created.multiplyOutOfPlace in interface FieldmultiplyOutOfPlace in interface GenericFielda - the first factorb - the second factora and bpublic BinaryFieldElement multiply(GenericFieldElement a, BigInteger b)
GenericFielda by n, i.e. performs the operation
a *= n.multiply in interface Fieldmultiply in interface GenericFielda - the first factorb - the second factora and npublic BinaryFieldElement multiplyOutOfPlace(GenericFieldElement a, BigInteger b)
GenericFielda by n, i.e. performs the operation
a *= n, where a new object holding the result is created.multiplyOutOfPlace in interface FieldmultiplyOutOfPlace in interface GenericFielda - the first factorb - the second factora and npublic BinaryFieldElement multiply(BinaryFieldElement a, PrecomputationData b)
a with another element
b, where the latter is given as precomputation data.a - the first factorb - the second factora and bpublic BinaryFieldElement multiplyOutOfPlace(BinaryFieldElement a, PrecomputationData b)
a with another element
b, where the latter is given as precomputation data, where a
new object holding the result is created.a - the first factorb - the second factora and bpublic BinaryFieldElement square(GenericFieldElement a)
GenericFielda, i.e. performs the operation a *= a.square in interface Fieldsquare in interface GenericFielda - the field elementapublic BinaryFieldElement squareOutOfPlace(GenericFieldElement a)
GenericFielda, i.e. performs the operation a*a,
where a new object holding the result is created.squareOutOfPlace in interface FieldsquareOutOfPlace in interface GenericFielda - the field elementapublic static PrecomputationData getExtendedPrecomputationData(BinaryFieldElement b)
b is referenced inside the precomputation data.
Hence, if it is changed afterwards, also the precomputation data changes!!b - the value for which the precomputation data will be createdpublic static PrecomputationData getPrecomputationData(BinaryFieldElement b)
b is referenced inside the precomputation data.
Hence, if it is changed afterwards, also the precomputation data changes!!b - the value for which the precomputation data will be createdpublic BinaryFieldElement squareRoot(FieldElement a)
FieldsquareRoot in interface Fielda - the field elementapublic BinaryFieldElement exponentiate(GenericFieldElement a, BigInteger n)
GenericFielda to the power n, i.e. performs the
operation a = a^n.exponentiate in interface Fieldexponentiate in interface GenericFielda - the field elementn - the exponentnth power of
apublic BinaryFieldElement exponentiate(GenericFieldElement a, int n)
GenericFielda to the power n, i.e. performs the
operation a = a^n.exponentiate in interface GenericFielda - the field elementn - the exponentnth power of
apublic BinaryFieldElement exponentiateByPowerOf2(GenericFieldElement a, int n)
GenericFielda to the power 2n.exponentiateByPowerOf2 in interface FieldexponentiateByPowerOf2 in interface GenericFielda - the field elementn - the exponentpublic BinaryFieldElement newElement(BigInteger b)
FieldBigInteger representation.newElement in interface Fieldb - the BigIntegerpublic final BinaryFieldElement newElement(byte[] bytes)
Fieldbyte[].newElement in interface FieldnewElement in interface GenericFieldbytes - the element encoded as byte[] in little-endian orderpublic final BinaryFieldElement toElement(byte[] bytes)
GenericFieldbyte-array. Unlike
GenericField.newElement(byte[]), this method does not assume the
input to be a valid encoding of a field element.toElement in interface GenericFieldbytes - a byte[] in little-endian orderpublic final BinaryFieldElement getOne()
GenericFieldgetOne in interface FieldgetOne in interface GenericFieldpublic final BinaryFieldElement getZero()
GenericFieldgetZero in interface FieldgetZero in interface GenericFieldpublic final BinaryFieldElement getGenerator()
public final BinaryFieldElement getTraceOneElement()
public int getTrace(BinaryFieldElement a)
a - the field elementapublic final BigInteger getCardinality()
GenericFieldgetCardinality in interface GenericFieldBigInteger holding the cardinalitypublic final FieldTypes getFieldType()
GenericFieldgetFieldType in interface GenericFieldpublic final Field getBaseField()
this, although base field would be F_2.getBaseField in interface GenericFieldpublic final BinaryFieldElement[] solveEquation(BinaryFieldElement c)
c - the constantnull if there is no solution, otherwise an array
holding the two solutionspublic final BinaryFieldElement[] solveEquation(BinaryFieldElement a, BinaryFieldElement b)
a - the coefficient of the linear termb - the constantnull if there is no solution, otherwise an array
holding the two solutionspublic byte[] toByteArray(FieldElement a)
Fieldbyte[] representation.toByteArray in interface Fielda - the field elementbyte[]public iaik.asn1.SEQUENCE toASN1Object()
Compiles and returns the ASN.1 representation of this binary field, which is:
FieldID ::= SEQUENCE {
fieldType OBJECT IDENTIFIER,
parameters ANY DEFINED BY fieldType
}
toASN1Object in interface Fieldpublic final boolean equals(Object obj)
equals in interface GenericFieldequals in class ECFieldF2mpublic final int hashCode()
hashCode in interface GenericFieldhashCode in class ECFieldF2mCopyright © 2011–2022 Stiftung SIC. All rights reserved.