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, getReductionPolynomial
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getFieldSize
public 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)
GenericField
a
, i.e. performs the operation b = -b
.negate
in interface Field
negate
in interface GenericField
a
- the field elementa
public BinaryFieldElement negateOutOfPlace(GenericFieldElement a)
GenericField
a
, i.e. performs the operation b = -b
,
where a new object holding the result is created.negateOutOfPlace
in interface Field
negateOutOfPlace
in interface GenericField
a
- the field elementa
public BinaryFieldElement add(GenericFieldElement a, GenericFieldElement b)
GenericField
b
to a
, i.e. performs the operation
a += b
.add
in interface Field
add
in interface GenericField
a
- the first addendb
- the second addenda
and b
public 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 b
public BinaryFieldElement subtract(GenericFieldElement a, GenericFieldElement b)
GenericField
b
from a
, i.e. performs the operation
a -= b
.subtract
in interface Field
subtract
in interface GenericField
a
- the minuendb
- the subtrahenda
and b
public BinaryFieldElement subtractOutOfPlace(GenericFieldElement a, GenericFieldElement b)
a
- the first valueb
- the other valuepublic BinaryFieldElement invert(GenericFieldElement a)
GenericField
a
, i.e. performs the operation
a = a^(-1)
.invert
in interface Field
invert
in interface GenericField
a
- the field elementa
public GenericFieldElement[] invertElements(GenericFieldElement[] elements)
GenericField
invertElements
in interface GenericField
elements
- the array of field elementspublic BinaryFieldElement divide(GenericFieldElement a, GenericFieldElement b)
GenericField
a
by b
, i.e. performs the operation
a /= b
.divide
in interface Field
divide
in interface GenericField
a
- the dividendb
- the divisora
and b
public BinaryFieldElement multiply(GenericFieldElement a, GenericFieldElement b)
GenericField
a
by b
, i.e. performs the operation
a *= b
.multiply
in interface Field
multiply
in interface GenericField
a
- the first factorb
- the second factora
and b
public BinaryFieldElement multiplyOutOfPlace(GenericFieldElement a, GenericFieldElement b)
GenericField
a
by b
, i.e. performs the operation
a *= b
, where a new object holding the result is created.multiplyOutOfPlace
in interface Field
multiplyOutOfPlace
in interface GenericField
a
- the first factorb
- the second factora
and b
public BinaryFieldElement multiply(GenericFieldElement a, BigInteger b)
GenericField
a
by n
, i.e. performs the operation
a *= n
.multiply
in interface Field
multiply
in interface GenericField
a
- the first factorb
- the second factora
and n
public BinaryFieldElement multiplyOutOfPlace(GenericFieldElement a, BigInteger b)
GenericField
a
by n
, i.e. performs the operation
a *= n
, where a new object holding the result is created.multiplyOutOfPlace
in interface Field
multiplyOutOfPlace
in interface GenericField
a
- the first factorb
- the second factora
and n
public 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 b
public 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 b
public BinaryFieldElement square(GenericFieldElement a)
GenericField
a
, i.e. performs the operation a *= a
.square
in interface Field
square
in interface GenericField
a
- the field elementa
public BinaryFieldElement squareOutOfPlace(GenericFieldElement a)
GenericField
a
, i.e. performs the operation a*a
,
where a new object holding the result is created.squareOutOfPlace
in interface Field
squareOutOfPlace
in interface GenericField
a
- the field elementa
public 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)
Field
squareRoot
in interface Field
a
- the field elementa
public BinaryFieldElement exponentiate(GenericFieldElement a, BigInteger n)
GenericField
a
to the power n
, i.e. performs the
operation a = a^n
.exponentiate
in interface Field
exponentiate
in interface GenericField
a
- the field elementn
- the exponentn
th power of
a
public BinaryFieldElement exponentiate(GenericFieldElement a, int n)
GenericField
a
to the power n
, i.e. performs the
operation a = a^n
.exponentiate
in interface GenericField
a
- the field elementn
- the exponentn
th power of
a
public BinaryFieldElement exponentiateByPowerOf2(GenericFieldElement a, int n)
GenericField
a
to the power 2n
.exponentiateByPowerOf2
in interface Field
exponentiateByPowerOf2
in interface GenericField
a
- the field elementn
- the exponentpublic BinaryFieldElement newElement(BigInteger b)
Field
BigInteger
representation.newElement
in interface Field
b
- the BigInteger
public final BinaryFieldElement newElement(byte[] bytes)
Field
byte[]
.newElement
in interface Field
newElement
in interface GenericField
bytes
- the element encoded as byte[]
in little-endian orderpublic final BinaryFieldElement toElement(byte[] bytes)
GenericField
byte
-array. Unlike
GenericField.newElement(byte[])
, this method does not assume the
input to be a valid encoding of a field element.toElement
in interface GenericField
bytes
- a byte[]
in little-endian orderpublic final BinaryFieldElement getOne()
GenericField
getOne
in interface Field
getOne
in interface GenericField
public final BinaryFieldElement getZero()
GenericField
getZero
in interface Field
getZero
in interface GenericField
public final BinaryFieldElement getGenerator()
public final BinaryFieldElement getTraceOneElement()
public int getTrace(BinaryFieldElement a)
a
- the field elementa
public final BigInteger getCardinality()
GenericField
getCardinality
in interface GenericField
BigInteger
holding the cardinalitypublic final FieldTypes getFieldType()
GenericField
getFieldType
in interface GenericField
public final Field getBaseField()
this
, although base field would be F_2.getBaseField
in interface GenericField
public 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)
Field
byte[]
representation.toByteArray
in interface Field
a
- 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 Field
public final boolean equals(Object obj)
equals
in interface GenericField
equals
in class ECFieldF2m
public final int hashCode()
hashCode
in interface GenericField
hashCode
in class ECFieldF2m
Copyright © 2011–2022 Stiftung SIC. All rights reserved.