public final class PrimeFieldElement extends Object implements FieldElement, PrimeCharacteristicFieldElement
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,
AbstractPrimeField| Modifier and Type | Method and Description |
|---|---|
PrimeFieldElement |
add(GenericFieldElement b)
Adds
b to this. |
PrimeFieldElement |
addBase(GenericFieldElement b)
Adds
b to this where b is an element
of the underlying base field. |
PrimeFieldElement |
addOutOfPlace(GenericFieldElement b)
Adds
this with b which is an element of the base
field, where a new object holding the result is created. |
PrimeFieldElement |
addOutOfPlace(PrimeCharacteristicFieldElement b)
Adds two elements and returns a new object holding the result.
|
PrimeFieldElement |
clone()
Clones the value of this field element.
|
PrimeFieldElement |
divide(GenericFieldElement b)
Divides
this and another field elements. |
PrimeFieldElement |
divideBy2()
Divides
this by 2. |
boolean |
equals(Object obj) |
PrimeFieldElement |
exponentiate(BigInteger n)
Raises
this to the power n. |
PrimeFieldElement |
exponentiate(int n)
Raises
this to the power n. |
PrimeFieldElement |
exponentiateByPowerOf2(int n)
Raise
this to the power of 2^n. |
PrimeFieldElement |
exponentiateOutOfPlace(BigInteger n)
Raises
this to the power n. |
PrimeFieldElement |
exponentiateOutOfPlace(int n)
Raises
this to the power n. |
int |
getBit(int index)
Returns the value of a certain bit of
this. |
AbstractPrimeField |
getField()
Returns the associated finite field.
|
int |
getQuadraticCharacter()
Implements a quadratic character, which returns -1,0,1 depending on whether
this is a quadratic non-residue modulo the prime
p, a multiple of the characteristic, or a quadratic residue. |
int |
hashCode() |
PrimeFieldElement |
invert()
Sets
this to its inverse. |
boolean |
isOne()
Determines whether
this is one. |
boolean |
isQthResidue(int q)
Returns whether
this is a q-th residue mod p. |
boolean |
isZero()
Determines whether
this is zero. |
PrimeFieldElement |
multiply(BigInteger n)
Multiples
this by n. |
PrimeFieldElement |
multiply(GenericFieldElement b)
Multiplies
this with b which is an element of the
same field. |
PrimeFieldElement |
multiplyBy2()
Multiplies
this with 2. |
PrimeFieldElement |
multiplyBy2OutOfPlace()
Multiplies
this with 2 and returns a new object holding the
result. |
PrimeFieldElement |
multiplyBy3()
Multiplies
this with 3. |
PrimeFieldElement |
multiplyBy3OutOfPlace()
Multiplies
this with 3 and returns a new object holding the
result. |
PrimeFieldElement |
multiplyByBase(GenericFieldElement b)
Multiplies
this with b which is an element of the
base field. |
PrimeFieldElement |
multiplyByBaseOutOfPlace(GenericFieldElement b)
Multiplies
this with b which is an element of the
base field, where a new object holding the result is created. |
PrimeFieldElement |
multiplyByPowerOf2(int exponent)
Multiplies
this by 2^n. |
PrimeFieldElement |
multiplyByPowerOf2OutOfPlace(int exponent)
Multiplies
this by 2^n and returns a new object
holding the result. |
PrimeFieldElement |
multiplyOutOfPlace(BigInteger n)
Multiples
this by n, where a new object holding
the result is created. |
PrimeFieldElement |
multiplyOutOfPlace(GenericFieldElement b)
Multiplies
this with b which is an element of the
same field, where a new object holding the result is created. |
PrimeFieldElement |
negate()
Returns the negative of
this. |
PrimeFieldElement |
negateOutOfPlace()
Returns the negative of
this, where a new object holding the
result is created. |
PrimeFieldElement |
square()
Computes the square of
this in-place. |
PrimeFieldElement |
squareOutOfPlace()
Computes the square of
this, where a new object holding the
result is created. |
PrimeFieldElement |
squareRoot()
Computes the square root of
this. |
PrimeFieldElement |
squareRoot(boolean checkSquare)
Computes the square root of
this. |
PrimeFieldElement |
subtract(GenericFieldElement b)
Subtracts
b from this. |
PrimeFieldElement |
subtractOutOfPlace(GenericFieldElement b)
Subtracts
b from this which is an element of the
base field, where a new object holding the result is created. |
PrimeFieldElement |
subtractOutOfPlace(PrimeCharacteristicFieldElement b)
Subtracts
b from this and returns a new object
holding the result. |
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. |
byte[] |
toLEByteArray()
Returns the
byte[] representation of this instance in little
endian. |
String |
toString() |
public PrimeFieldElement negate()
GenericFieldElementthis. This functions works in-place.negate in interface FieldElementnegate in interface GenericFieldElementnegate in interface PrimeCharacteristicFieldElementthispublic PrimeFieldElement negateOutOfPlace()
GenericFieldElementthis, where a new object holding the
result is created.negateOutOfPlace in interface GenericFieldElementnegateOutOfPlace in interface PrimeCharacteristicFieldElementthispublic PrimeFieldElement add(GenericFieldElement b)
GenericFieldElementb to this. This functions works in-place.add in interface FieldElementadd in interface GenericFieldElementadd in interface PrimeCharacteristicFieldElementb - the second addendthis and bpublic PrimeFieldElement addOutOfPlace(GenericFieldElement b)
GenericFieldElementthis with b which is an element of the base
field, where a new object holding the result is created.addOutOfPlace in interface GenericFieldElementaddOutOfPlace in interface PrimeCharacteristicFieldElementb - the second factorthis and bpublic PrimeFieldElement addOutOfPlace(PrimeCharacteristicFieldElement b)
PrimeCharacteristicFieldElementaddOutOfPlace in interface PrimeCharacteristicFieldElementb - the other valuepublic PrimeFieldElement addBase(GenericFieldElement b)
GenericFieldElementb to this where b is an element
of the underlying base field.addBase in interface FieldElementaddBase in interface GenericFieldElementaddBase in interface PrimeCharacteristicFieldElementb - the second addendthis and bpublic PrimeFieldElement subtract(GenericFieldElement b)
GenericFieldElementb from this. This functions works in-place.subtract in interface FieldElementsubtract in interface GenericFieldElementsubtract in interface PrimeCharacteristicFieldElementb - the subtrahendthis and bpublic PrimeFieldElement subtractOutOfPlace(GenericFieldElement b)
GenericFieldElementb from this which is an element of the
base field, where a new object holding the result is created.subtractOutOfPlace in interface GenericFieldElementsubtractOutOfPlace in interface PrimeCharacteristicFieldElementb - the second factorthis and bpublic PrimeFieldElement subtractOutOfPlace(PrimeCharacteristicFieldElement b)
PrimeCharacteristicFieldElementb from this and returns a new object
holding the result.subtractOutOfPlace in interface PrimeCharacteristicFieldElementb - the subtrahendthis and bpublic PrimeFieldElement invert()
GenericFieldElementthis to its inverse.invert in interface FieldElementinvert in interface GenericFieldElementinvert in interface PrimeCharacteristicFieldElementthispublic PrimeFieldElement multiply(GenericFieldElement b)
GenericFieldElementthis with b which is an element of the
same field.multiply in interface FieldElementmultiply in interface GenericFieldElementmultiply in interface PrimeCharacteristicFieldElementb - the second factorthis and bpublic PrimeFieldElement multiplyOutOfPlace(GenericFieldElement b)
GenericFieldElementthis with b which is an element of the
same field, where a new object holding the result is created.multiplyOutOfPlace in interface FieldElementmultiplyOutOfPlace in interface GenericFieldElementmultiplyOutOfPlace in interface PrimeCharacteristicFieldElementb - the second factorthis and bpublic PrimeFieldElement multiply(BigInteger n)
GenericFieldElementthis by n.multiply in interface FieldElementmultiply in interface GenericFieldElementmultiply in interface PrimeCharacteristicFieldElementn - the factorthis and npublic PrimeFieldElement multiplyOutOfPlace(BigInteger n)
GenericFieldElementthis by n, where a new object holding
the result is created.multiplyOutOfPlace in interface FieldElementmultiplyOutOfPlace in interface GenericFieldElementmultiplyOutOfPlace in interface PrimeCharacteristicFieldElementn - the factorthis and npublic PrimeFieldElement multiplyByBase(GenericFieldElement b)
GenericFieldElementthis with b which is an element of the
base field.multiplyByBase in interface FieldElementmultiplyByBase in interface GenericFieldElementmultiplyByBase in interface PrimeCharacteristicFieldElementb - the second factorthis and bpublic PrimeFieldElement multiplyByBaseOutOfPlace(GenericFieldElement b)
GenericFieldElementthis with b which is an element of the
base field, where a new object holding the result is created.multiplyByBaseOutOfPlace in interface FieldElementmultiplyByBaseOutOfPlace in interface GenericFieldElementmultiplyByBaseOutOfPlace in interface PrimeCharacteristicFieldElementb - the second factorthis and bpublic PrimeFieldElement multiplyBy2()
PrimeCharacteristicFieldElementthis with 2.multiplyBy2 in interface PrimeCharacteristicFieldElementthis and 2public PrimeFieldElement multiplyBy2OutOfPlace()
PrimeCharacteristicFieldElementthis with 2 and returns a new object holding the
result.multiplyBy2OutOfPlace in interface PrimeCharacteristicFieldElementthis and 2public PrimeFieldElement multiplyBy3()
PrimeCharacteristicFieldElementthis with 3.multiplyBy3 in interface PrimeCharacteristicFieldElementthis and 3public PrimeFieldElement multiplyBy3OutOfPlace()
PrimeCharacteristicFieldElementthis with 3 and returns a new object holding the
result.multiplyBy3OutOfPlace in interface PrimeCharacteristicFieldElementthis and 3public PrimeFieldElement multiplyByPowerOf2(int exponent)
PrimeCharacteristicFieldElementthis by 2^n.multiplyByPowerOf2 in interface PrimeCharacteristicFieldElementexponent - the exponentthis and 2^npublic PrimeFieldElement multiplyByPowerOf2OutOfPlace(int exponent)
PrimeCharacteristicFieldElementthis by 2^n and returns a new object
holding the result.multiplyByPowerOf2OutOfPlace in interface PrimeCharacteristicFieldElementexponent - the exponentthis and 2^npublic PrimeFieldElement divide(GenericFieldElement b)
this and another field elements.
You have no guarantee that b remains unchanged.
divide in interface FieldElementdivide in interface GenericFieldElementdivide in interface PrimeCharacteristicFieldElementb - the divisorthis and bpublic PrimeFieldElement divideBy2()
PrimeCharacteristicFieldElementthis by 2.divideBy2 in interface PrimeCharacteristicFieldElementthis divided by 2.public PrimeFieldElement square()
GenericFieldElementthis in-place.square in interface FieldElementsquare in interface GenericFieldElementsquare in interface PrimeCharacteristicFieldElementthispublic PrimeFieldElement squareOutOfPlace()
GenericFieldElementthis, where a new object holding the
result is created.squareOutOfPlace in interface FieldElementsquareOutOfPlace in interface GenericFieldElementsquareOutOfPlace in interface PrimeCharacteristicFieldElementthispublic AbstractPrimeField getField()
GenericFieldElementgetField in interface GenericFieldElementpublic boolean testBit(int index)
FieldElementthis is set.testBit in interface FieldElementindex - the index of the bitpublic int getBit(int index)
FieldElementthis.getBit in interface FieldElementindex - the index of the bitpublic boolean isOne()
GenericFieldElementthis is one.isOne in interface GenericFieldElementthis is the one elementpublic boolean isZero()
GenericFieldElementthis is zero.isZero in interface GenericFieldElementthis is the zero elementpublic PrimeFieldElement exponentiate(BigInteger n)
GenericFieldElementthis to the power n.
Works in-place.exponentiate in interface FieldElementexponentiate in interface GenericFieldElementexponentiate in interface PrimeCharacteristicFieldElementn - the exponentnth power of thispublic PrimeFieldElement exponentiate(int n)
GenericFieldElementthis to the power n.
Works in-place.exponentiate in interface GenericFieldElementexponentiate in interface PrimeCharacteristicFieldElementn - the exponentnth power of thispublic PrimeFieldElement exponentiateOutOfPlace(BigInteger n)
GenericFieldElementthis to the power n.exponentiateOutOfPlace in interface GenericFieldElementn - the exponentnth power of thispublic PrimeFieldElement exponentiateOutOfPlace(int n)
GenericFieldElementthis to the power n.exponentiateOutOfPlace in interface GenericFieldElementn - the exponentnth power of thispublic PrimeFieldElement exponentiateByPowerOf2(int n)
GenericFieldElementthis to the power of 2^n.exponentiateByPowerOf2 in interface GenericFieldElementexponentiateByPowerOf2 in interface PrimeCharacteristicFieldElementn - the exponentn-th power of this.public PrimeFieldElement squareRoot()
FieldElementthis.squareRoot in interface FieldElementsquareRoot in interface GenericFieldElementsquareRoot in interface PrimeCharacteristicFieldElementthispublic PrimeFieldElement squareRoot(boolean checkSquare)
PrimeCharacteristicFieldElementthis.squareRoot in interface PrimeCharacteristicFieldElementcheckSquare - check if a is a square. If true, the
return value is undefined for non-squares.thispublic int getQuadraticCharacter()
this is a quadratic non-residue modulo the prime
p, a multiple of the characteristic, or a quadratic residue.
In this case this is the Legendre symbol according to [2, Algorithm 11.19].getQuadraticCharacter in interface PrimeCharacteristicFieldElement(this/p)public BigInteger toBigInteger()
FieldElementBigInteger-representation of this instance.toBigInteger in interface FieldElementBigInteger-representationpublic byte[] toByteArray()
GenericFieldElementbyte[] representation of this instance.toByteArray in interface GenericFieldElementbyte[] representationpublic byte[] toLEByteArray()
byte[] representation of this instance in little
endian.byte[] representationpublic int hashCode()
hashCode in interface GenericFieldElementhashCode in class Objectpublic boolean equals(Object obj)
equals in interface GenericFieldElementequals in class Objectpublic PrimeFieldElement clone()
FieldElementclone in interface FieldElementclone in interface GenericFieldElementclone in interface PrimeCharacteristicFieldElementclone in class Objectpublic String toString()
toString in interface GenericFieldElementtoString in class Objectpublic boolean isQthResidue(int q)
this is a q-th residue mod p.q - the exponenttrue if this is a q-th
residue mod p.Copyright © 2011–2022 Stiftung SIC. All rights reserved.