public final class BinaryFieldElement extends Object implements FieldElement
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.
FieldElement
,
BinaryField
Modifier and Type | Method and Description |
---|---|
BinaryFieldElement |
add(BinaryFieldElement b,
boolean preserveB)
Performs either the addition
a += b or b += a , if
preserveB is set to false . |
BinaryFieldElement |
add(GenericFieldElement b)
Adds
b to this . |
BinaryFieldElement |
addBase(GenericFieldElement b)
Adds
b to this where b is an element
of the underlying base field. |
BinaryFieldElement |
addOutOfPlace(GenericFieldElement b)
Adds
this with b which is an element of the base
field, where a new object holding the result is created. |
BinaryFieldElement |
clone()
Clones the value of this field element.
|
BinaryFieldElement |
divide(GenericFieldElement b)
Divides
this and another field elements. |
boolean |
equals(Object obj) |
BinaryFieldElement |
exponentiate(BigInteger n)
Raises
this to the power n . |
BinaryFieldElement |
exponentiate(int n)
Raises
this to the power n . |
BinaryFieldElement |
exponentiateByPowerOf2(int n)
Raises this element to the power
2n . |
BinaryFieldElement |
exponentiateOutOfPlace(BigInteger n)
Raises
this to the power n . |
BinaryFieldElement |
exponentiateOutOfPlace(int n)
Raises
this to the power n . |
int |
getBit(int index)
Returns the value of a certain bit of
this . |
PrecomputationData |
getExtendedPrecomputationData()
Compiles 256 precomputed values for the multiplication algorithm.
|
BinaryField |
getField()
Returns the associated finite field.
|
PrecomputationData |
getPrecomputationData()
Compiles 16 precomputed values for the multiplication algorithm.
|
int |
getTrace()
Determines the trace of
this . |
int |
hashCode() |
BinaryFieldElement |
invert()
Sets
this to its inverse. |
boolean |
isOne()
Determines whether
this is one. |
boolean |
isZero()
Determines whether
this is zero. |
BinaryFieldElement |
multiply(BigInteger n)
Multiples
this by n . |
BinaryFieldElement |
multiply(GenericFieldElement b)
Multiplies
this with b which is an element of the
same field. |
BinaryFieldElement |
multiply(PrecomputationData data)
Multiplies
this with the already available precomputation data
of b , where a new object holding the result is created. |
BinaryFieldElement |
multiplyByBase(GenericFieldElement b)
Multiplies
this with b which is an element of the
base field. |
BinaryFieldElement |
multiplyByBaseOutOfPlace(GenericFieldElement b)
Multiplies
this with b which is an element of the
base field, where a new object holding the result is created. |
BinaryFieldElement |
multiplyOutOfPlace(BigInteger n)
Multiples
this by n , where a new object holding
the result is created. |
BinaryFieldElement |
multiplyOutOfPlace(GenericFieldElement b)
Multiplies
this with b which is an element of the
same field, where a new object holding the result is created. |
BinaryFieldElement |
multiplyOutOfPlace(PrecomputationData data)
Multiplies
this with the already available precomputation data
of b . |
BinaryFieldElement |
negate()
Returns the negative of
this . |
BinaryFieldElement |
negateOutOfPlace()
Returns the negative of
this , where a new object holding the
result is created. |
BinaryFieldElement |
square()
Computes the square of
this in-place. |
BinaryFieldElement |
squareOutOfPlace()
Computes the square of
this , where a new object holding the
result is created. |
BinaryFieldElement |
squareRoot()
Computes the square root of
this . |
BinaryFieldElement |
subtract(GenericFieldElement b)
Subtracts
b from this . |
BinaryFieldElement |
subtractOutOfPlace(GenericFieldElement b)
Subtracts
b from this which is an element of the
base field, where a new object holding the result is created. |
boolean |
testBit(int index)
Tests whether a certain bit of
this is set. |
BigInteger |
toBigInteger()
Returns the
BigInteger -representation of this instance. |
byte[] |
toByteArray()
Returns the
byte[] representation of this instance. |
String |
toString() |
public BinaryFieldElement negate()
GenericFieldElement
this
. This functions works in-place.negate
in interface FieldElement
negate
in interface GenericFieldElement
this
public BinaryFieldElement negateOutOfPlace()
GenericFieldElement
this
, where a new object holding the
result is created.negateOutOfPlace
in interface GenericFieldElement
this
public BinaryFieldElement add(GenericFieldElement b)
GenericFieldElement
b
to this
. This functions works in-place.add
in interface FieldElement
add
in interface GenericFieldElement
b
- the second addendthis
and b
public BinaryFieldElement addOutOfPlace(GenericFieldElement b)
GenericFieldElement
this
with b
which is an element of the base
field, where a new object holding the result is created.addOutOfPlace
in interface GenericFieldElement
b
- the second factorthis
and b
public BinaryFieldElement addBase(GenericFieldElement b)
GenericFieldElement
b
to this
where b
is an element
of the underlying base field.addBase
in interface FieldElement
addBase
in interface GenericFieldElement
b
- the second addendthis
and b
public BinaryFieldElement add(BinaryFieldElement b, boolean preserveB)
a += b
or b += a
, if
preserveB
is set to false
. Otherwise, it acts as
add(GenericFieldElement)
.b
- the addendpreserveB
- if true, b
will be preserved, otherwise its content
may be exchanged by the resultpublic BinaryFieldElement subtract(GenericFieldElement b)
GenericFieldElement
b
from this
. This functions works in-place.subtract
in interface FieldElement
subtract
in interface GenericFieldElement
b
- the subtrahendthis
and b
public BinaryFieldElement subtractOutOfPlace(GenericFieldElement b)
GenericFieldElement
b
from this
which is an element of the
base field, where a new object holding the result is created.subtractOutOfPlace
in interface GenericFieldElement
b
- the second factorthis
and b
public BinaryFieldElement invert()
GenericFieldElement
this
to its inverse.invert
in interface FieldElement
invert
in interface GenericFieldElement
this
public BinaryFieldElement multiply(GenericFieldElement b)
GenericFieldElement
this
with b
which is an element of the
same field.multiply
in interface FieldElement
multiply
in interface GenericFieldElement
b
- the second factorthis
and b
public BinaryFieldElement multiplyOutOfPlace(GenericFieldElement b)
GenericFieldElement
this
with b
which is an element of the
same field, where a new object holding the result is created.multiplyOutOfPlace
in interface FieldElement
multiplyOutOfPlace
in interface GenericFieldElement
b
- the second factorthis
and b
public BinaryFieldElement multiply(BigInteger n)
GenericFieldElement
this
by n
.multiply
in interface FieldElement
multiply
in interface GenericFieldElement
n
- the factorthis
and n
public BinaryFieldElement multiplyOutOfPlace(BigInteger n)
GenericFieldElement
this
by n
, where a new object holding
the result is created.multiplyOutOfPlace
in interface FieldElement
multiplyOutOfPlace
in interface GenericFieldElement
n
- the factorthis
and n
public BinaryFieldElement multiplyByBase(GenericFieldElement b)
GenericFieldElement
this
with b
which is an element of the
base field.multiplyByBase
in interface FieldElement
multiplyByBase
in interface GenericFieldElement
b
- the second factorthis
and b
public BinaryFieldElement multiplyByBaseOutOfPlace(GenericFieldElement b)
GenericFieldElement
this
with b
which is an element of the
base field, where a new object holding the result is created.multiplyByBaseOutOfPlace
in interface FieldElement
multiplyByBaseOutOfPlace
in interface GenericFieldElement
b
- the second factorthis
and b
public BinaryFieldElement multiply(PrecomputationData data)
this
with the already available precomputation data
of b
, where a new object holding the result is created.data
- the precomputation data for the factor b
this
and b
public BinaryFieldElement multiplyOutOfPlace(PrecomputationData data)
this
with the already available precomputation data
of b
.data
- the precomputation data for the factor b
this
and b
public PrecomputationData getExtendedPrecomputationData()
this
is referenced inside the precomputation
data. Hence, if it is changed afterwards, also the precomputation data
changes!!public PrecomputationData getPrecomputationData()
this
is referenced inside the precomputation
data. Hence, if it is changed afterwards, also the precomputation data
changes!!public BinaryFieldElement divide(GenericFieldElement b)
GenericFieldElement
this
and another field elements.divide
in interface FieldElement
divide
in interface GenericFieldElement
b
- the divisorthis
and b
public BinaryFieldElement squareRoot()
FieldElement
this
.squareRoot
in interface FieldElement
squareRoot
in interface GenericFieldElement
this
public BinaryFieldElement square()
GenericFieldElement
this
in-place.square
in interface FieldElement
square
in interface GenericFieldElement
this
public BinaryFieldElement squareOutOfPlace()
GenericFieldElement
this
, where a new object holding the
result is created.squareOutOfPlace
in interface FieldElement
squareOutOfPlace
in interface GenericFieldElement
this
public BinaryFieldElement exponentiate(BigInteger n)
GenericFieldElement
this
to the power n
.
Works in-place.exponentiate
in interface FieldElement
exponentiate
in interface GenericFieldElement
n
- the exponentn
th power of this
public BinaryFieldElement exponentiate(int n)
GenericFieldElement
this
to the power n
.
Works in-place.exponentiate
in interface GenericFieldElement
n
- the exponentn
th power of this
public BinaryFieldElement exponentiateOutOfPlace(BigInteger n)
GenericFieldElement
this
to the power n
.exponentiateOutOfPlace
in interface GenericFieldElement
n
- the exponentn
th power of this
public BinaryFieldElement exponentiateOutOfPlace(int n)
GenericFieldElement
this
to the power n
.exponentiateOutOfPlace
in interface GenericFieldElement
n
- the exponentn
th power of this
public BinaryFieldElement exponentiateByPowerOf2(int n)
2n
.exponentiateByPowerOf2
in interface GenericFieldElement
n
- the power of 22n
th power of this
public int getTrace()
this
.t
in F2
of
this
public BinaryField getField()
GenericFieldElement
getField
in interface GenericFieldElement
public boolean testBit(int index)
FieldElement
this
is set.testBit
in interface FieldElement
index
- the index of the bitpublic int getBit(int index)
FieldElement
this
.getBit
in interface FieldElement
index
- the index of the bitpublic boolean isOne()
GenericFieldElement
this
is one.isOne
in interface GenericFieldElement
this
is the one elementpublic boolean isZero()
GenericFieldElement
this
is zero.isZero
in interface GenericFieldElement
this
is the zero elementpublic BigInteger toBigInteger()
FieldElement
BigInteger
-representation of this instance.toBigInteger
in interface FieldElement
BigInteger
-representationpublic byte[] toByteArray()
GenericFieldElement
byte[]
representation of this instance.toByteArray
in interface GenericFieldElement
byte[]
representationpublic BinaryFieldElement clone()
FieldElement
clone
in interface FieldElement
clone
in interface GenericFieldElement
clone
in class Object
public boolean equals(Object obj)
equals
in interface GenericFieldElement
equals
in class Object
public int hashCode()
hashCode
in interface GenericFieldElement
hashCode
in class Object
public String toString()
toString
in interface GenericFieldElement
toString
in class Object
Copyright © 2011–2022 Stiftung SIC. All rights reserved.