public final class QuadraticExtensionField extends Object
[1] Multiplication and squaring in pairing friendly fields.
[2] G. Adj, F. Rodrigues-Henriquez. Square root computation over even extension fields.
public int getQuadraticCharacter(PrimeCharacteristicFieldElement e)
a
is a quadratic non-residue, a multiple of the modulus, or a
quadratic residue.e
- a field elemente
public QuadraticExtensionFieldElement multiply(ExtensionFieldElement a, PrimeFieldElement b)
ExtensionField
multiply
in interface ExtensionField
a
- extension field elementb
- prime field elementa
multiplied by the adjoint root.public QuadraticExtensionFieldElement multiplyOutOfPlace(ExtensionFieldElement a, PrimeFieldElement b)
public QuadraticExtensionFieldElement multiply(GenericFieldElement a, GenericFieldElement b)
GenericField
a
by b
, i.e. performs the operation
a *= b
.multiply
in interface ExtensionField
multiply
in interface GenericField
multiply
in interface PrimeCharacteristicField
a
- the first factorb
- the second factora
and b
public QuadraticExtensionFieldElement 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 GenericField
a
- the first factorb
- the second factora
and b
public QuadraticExtensionFieldElement multiply(GenericFieldElement a, BigInteger n)
GenericField
a
by n
, i.e. performs the operation
a *= n
.multiply
in interface ExtensionField
multiply
in interface GenericField
multiply
in interface PrimeCharacteristicField
a
- the first factorn
- the second factora
and n
public QuadraticExtensionFieldElement multiplyOutOfPlace(GenericFieldElement a, BigInteger n)
GenericField
a
by n
, i.e. performs the operation
a *= n
, where a new object holding the result is created.multiplyOutOfPlace
in interface GenericField
a
- the first factorn
- the second factora
and n
public QuadraticExtensionFieldElement square(GenericFieldElement a)
GenericField
a
, i.e. performs the operation a *= a
.square
in interface ExtensionField
square
in interface GenericField
square
in interface PrimeCharacteristicField
a
- the field elementa
public QuadraticExtensionFieldElement squareOutOfPlace(GenericFieldElement a)
GenericField
a
, i.e. performs the operation a*a
,
where a new object holding the result is created.squareOutOfPlace
in interface GenericField
a
- the field elementa
public QuadraticExtensionFieldElement squareRoot(ExtensionFieldElement a)
ExtensionField
squareRoot
in interface ExtensionField
a
- the field elementa
if it exists, null otherwisepublic QuadraticExtensionFieldElement squareRoot(ExtensionFieldElement a, boolean checkSquare)
ExtensionField
squareRoot
in interface ExtensionField
a
- the field elementcheckSquare
- check if a
is a square. If true
, the
return value is undefined for non-squares.a
if it exists, null otherwisepublic QuadraticExtensionFieldElement multiplyBy2(PrimeCharacteristicFieldElement a)
PrimeCharacteristicField
a
by 2
, which is a left-shift. Works in-place.multiplyBy2
in interface PrimeCharacteristicField
a
- the element to be shifteda
holding the resultpublic QuadraticExtensionFieldElement multiplyBy2OutOfPlace(PrimeCharacteristicFieldElement a)
PrimeCharacteristicField
a
by 2
, which is a left-shift and
returns a new object holding the result.multiplyBy2OutOfPlace
in interface PrimeCharacteristicField
a
- the element to be shifteda
holding the resultpublic QuadraticExtensionFieldElement multiplyBy3(PrimeCharacteristicFieldElement a)
PrimeCharacteristicField
a
by 3
, which is a left-shift plus an
addition. Works in-place.multiplyBy3
in interface PrimeCharacteristicField
a
- the element to multiplieda
holding the resultpublic QuadraticExtensionFieldElement multiplyBy3OutOfPlace(PrimeCharacteristicFieldElement a)
PrimeCharacteristicField
a
by 3
, which is a left-shift plus an
addition and returns a new object holding the result.multiplyBy3OutOfPlace
in interface PrimeCharacteristicField
a
- the element to multiplieda
holding the resultpublic QuadraticExtensionFieldElement multiplyByPowerOf2(PrimeCharacteristicFieldElement a, int exponent)
PrimeCharacteristicField
a
by a power of 2
, which is a
left-shift. Works in-place.multiplyByPowerOf2
in interface PrimeCharacteristicField
a
- the element to be shiftedexponent
- the power of 2a
holding the resultpublic QuadraticExtensionFieldElement multiplyByPowerOf2OutOfPlace(PrimeCharacteristicFieldElement a, int exponent)
PrimeCharacteristicField
a
by a power of 2
, which is a
left-shift and returns a new object holding the result.multiplyByPowerOf2OutOfPlace
in interface PrimeCharacteristicField
a
- the element to be shiftedexponent
- the power of 2a
holding the resultpublic QuadraticExtensionFieldElement invert(GenericFieldElement a)
GenericField
a
, i.e. performs the operation
a = a^(-1)
.invert
in interface ExtensionField
invert
in interface GenericField
invert
in interface PrimeCharacteristicField
a
- the field elementa
public PrimeFieldElement getNorm(ExtensionFieldElement a)
ExtensionField
a
- the field elementa
public QuadraticExtensionFieldElement newElement(Object b)
ExtensionField
BigInteger
-array
representation. Every component in the canonical representation of the
field's elements corresponds to an array dimension, in ascending order.b
- the BigInteger[]
public QuadraticExtensionFieldElement newElement(byte[] bytes)
GenericField
byte
-array representation.bytes
- the byte[]
in little-endian orderpublic QuadraticExtensionFieldElement newElement(PrimeFieldElement a, PrimeFieldElement b)
a
- a prime field elementb
- a prime field elementa + i b
public QuadraticExtensionFieldElement 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.bytes
- a byte[]
in little-endian orderpublic QuadraticExtensionFieldElement getUniformlyRandomElement()
PrimeCharacteristicField
public QuadraticExtensionFieldElement getUniformlyRandomNonZeroElement()
PrimeCharacteristicField
public BigInteger[] toBigIntegers(ExtensionFieldElement a)
ExtensionField
BigInteger
representation.a
- the field elementBigInteger
representationpublic QuadraticExtensionFieldElement newElementFromBaseField(PrimeFieldElement a)
ExtensionField
this
.a
- a prime field elementa
as element of this
public QuadraticExtensionFieldElement newElementFromSubField(PrimeCharacteristicFieldElement a)
ExtensionField
this
.a
- a sub field elementa
as element of this
public QuadraticExtensionFieldElement multiplyByAdjointRoot(ExtensionFieldElement a)
ExtensionField
a
by the root used to obtain the extension field.multiplyByAdjointRoot
in interface ExtensionField
a
- extension field elementa
multiplied by the adjoint root.public QuadraticExtensionFieldElement multiplyByAdjointRootOutOfPlace(ExtensionFieldElement a)
public QuadraticExtensionFieldElement applyFrobenius(ExtensionFieldElement a, int i)
ExtensionField
i
-th Frobenius of a
.applyFrobenius
in interface ExtensionField
a
- the element on which the Frobenius map should be applied.i
- number of times the Frobenius map should be applied.i
times to a
.public QuadraticExtensionFieldElement negate(GenericFieldElement a)
GenericField
a
, i.e. performs the operation b = -b
.a
- the field elementa
public QuadraticExtensionFieldElement negateOutOfPlace(GenericFieldElement a)
GenericField
a
, i.e. performs the operation b = -b
,
where a new object holding the result is created.a
- the field elementa
public QuadraticExtensionFieldElement add(GenericFieldElement a, GenericFieldElement b)
GenericField
b
to a
, i.e. performs the operation
a += b
.a
- the first addendb
- the second addenda
and b
public QuadraticExtensionFieldElement addOutOfPlace(PrimeCharacteristicFieldElement a, PrimeCharacteristicFieldElement b)
PrimeCharacteristicField
a
- first summandb
- second summandpublic QuadraticExtensionFieldElement subtract(GenericFieldElement a, GenericFieldElement b)
GenericField
b
from a
, i.e. performs the operation
a -= b
.a
- the minuendb
- the subtrahenda
and b
public QuadraticExtensionFieldElement subtractOutOfPlace(GenericFieldElement a, GenericFieldElement b)
PrimeCharacteristicField
b
from this
and returns a new object
holding the result.a
- the minuendb
- the subtrahenda
and b
public QuadraticExtensionFieldElement divide(GenericFieldElement a, GenericFieldElement b)
GenericField
a
by b
, i.e. performs the operation
a /= b
.a
- the dividendb
- the divisora
and b
public QuadraticExtensionFieldElement divideBy2(PrimeCharacteristicFieldElement a)
PrimeCharacteristicField
a
by 2.a
- the dividenda
and 2.public QuadraticExtensionFieldElement conjugate(ExtensionFieldElement b)
ExtensionField
b
- the element to be conjugatedb
public QuadraticExtensionFieldElement conjugate(ExtensionFieldElement b, int i)
ExtensionField
i
times.b
- the element to be conjugatedi
- number of times the element should be conjugatedb
conjugated i
timespublic QuadraticExtensionFieldElement getOne()
GenericField
public QuadraticExtensionFieldElement getZero()
GenericField
public GenericFieldElement getNonResidue()
public GenericFieldElement[] invertElements(GenericFieldElement[] elements)
GenericField
invertElements
in interface GenericField
elements
- the array of field elementspublic ExtensionFieldElement exponentiate(GenericFieldElement a, BigInteger n)
GenericField
a
to the power n
, i.e. performs the
operation a = a^n
.exponentiate
in interface ExtensionField
exponentiate
in interface GenericField
exponentiate
in interface PrimeCharacteristicField
a
- the field elementn
- the exponentn
th power of
a
public ExtensionFieldElement 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 ExtensionFieldElement exponentiateByPowerOf2(GenericFieldElement a, int n)
GenericField
a
to the power 2n
.exponentiateByPowerOf2
in interface ExtensionField
exponentiateByPowerOf2
in interface GenericField
exponentiateByPowerOf2
in interface PrimeCharacteristicField
a
- the field elementn
- the exponentpublic BigInteger getCardinality()
GenericField
getCardinality
in interface GenericField
BigInteger
holding the cardinalitypublic FieldTypes getFieldType()
GenericField
getFieldType
in interface GenericField
public int getFieldSize()
getFieldSize
in interface ECField
public int getDepth()
ExtensionField
getDepth
in interface ExtensionField
public int getDegree()
ExtensionField
getDegree
in interface ExtensionField
this
over its subfield.public int getDegreeOverBaseField()
ExtensionField
getDegreeOverBaseField
in interface ExtensionField
this
over its base field.public AbstractPrimeField getBaseField()
GenericField
getBaseField
in interface ExtensionField
getBaseField
in interface GenericField
public ExtensionField getSubField()
ExtensionField
null
if the subfield equals the base field, and the
subfield otherwise.getSubField
in interface ExtensionField
null
if the subfield equals the base field, and the
subfield otherwise.public int hashCode()
hashCode
in interface GenericField
hashCode
in class Object
public boolean equals(Object obj)
equals
in interface GenericField
equals
in class Object
Copyright © 2011–2022 Stiftung SIC. All rights reserved.