IAIK ECC
version 2.18

iaik.security.ecc.math.field
Class FieldElement

java.lang.Object
  extended byiaik.security.ecc.math.field.FieldElement
All Implemented Interfaces:
java.lang.Cloneable

public class FieldElement
extends java.lang.Object
implements java.lang.Cloneable

Representation of an element over a specified field with a certain value. Use the factory to create the desired field and the field's newElement method to create a field element. To perform field arithmetics use the FieldElement methods. !!ATTENTION DON'T MIX UP FIELDELEMENTS OF DIFFERENT FIELDS !!


Field Summary
protected  Field field_
          A FieldElement constist of a value and an underlying field.
protected  iaik.security.ecc.math.field.Value value_
          A FieldElement constist of a value and an underlying field.
 
Method Summary
 FieldElement add(FieldElement b)
          Calculates: this += b
Calls the corresponding field method.
static FieldElement add(FieldElement a, FieldElement b)
          Use this static method if you want to create a new FieldElement with the value of a + b.
 java.lang.Object clone()
          Creates a new FieldElement with the value cloned over the same field.
 FieldElement divide(FieldElement b)
          Calculates: this *= invert(b)
Calls the corresponding field method.
static FieldElement divide(FieldElement a, FieldElement b)
          Use this static method if you want to create a new FieldElement with the value of a * invert(b).
 boolean equals(java.lang.Object other)
          Compares to FieldElements.
 Field getField()
          A FieldElement constist of a value and an underlying field.
 FieldElement half()
          Halfs ONLY a prime field element, binary fields are not supported.
 int hashCode()
          Returns the hash code of this field element.
 FieldElement invert()
          Inverts (multiplicative) the element.
static FieldElement invert(FieldElement a)
          Use this static method if you want to create a new FieldElement with the value of multiplicatice inverse of a.
static FieldElement[] invertSimultaneous(FieldElement[] a)
          Use this static method if you want to simultaneously invert an array of FieldElements.
 boolean isOne()
          Tests if the value is the ONE elemnt
 boolean isZero()
          Tests if the value is the ZERO elemnt
 FieldElement multiply(FieldElement b)
          Calculates: this *= b
Calls the corresponding field method.
static FieldElement multiply(FieldElement a, FieldElement b)
          Use this static method if you want to create a new FieldElement with the value of a * b.
 FieldElement negate()
          Negates the element (additive inverse).
static FieldElement negate(FieldElement a)
          Use this static method if you want to create a new FieldElement with the negative value of a.
 FieldElement square()
          Calculates: this squared
Calls the corresponding field method.
static FieldElement square(FieldElement a)
          Use this static method if you want to create a new FieldElement with the value of a squared.
 FieldElement sub(FieldElement b)
          Calculates: this -= b
Negates b and adds it to a.
static FieldElement sub(FieldElement a, FieldElement b)
          Use this static method if you want to create a new FieldElement with the value of a - b.
 boolean testBit(int bitPosition)
          Tests the specified bit.
 java.math.BigInteger toBigInt()
           
 byte[] toByteArray()
          Performs the Field Element to Octet String Conversion Primitive (FE2OSP) as defined in P1363.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

field_

protected Field field_
A FieldElement constist of a value and an underlying field. This reference corresponds to the underlying field


value_

protected iaik.security.ecc.math.field.Value value_
A FieldElement constist of a value and an underlying field. This reference corresponds to the value of the element

Method Detail

add

public static FieldElement add(FieldElement a,
                               FieldElement b)
Use this static method if you want to create a new FieldElement with the value of a + b. Make sure that both addends are defined over the same field.

Parameters:
a - one addend
b - the other addend
Returns:
a new FieldElement with the value of a + b

divide

public static FieldElement divide(FieldElement a,
                                  FieldElement b)
                           throws FieldException
Use this static method if you want to create a new FieldElement with the value of a * invert(b). Make sure that both parameters are defined over the same field.

Parameters:
a - the dividend
b - the divisor
Returns:
a new FieldElement with the value of this *= invert(b)
Throws:
FieldException - if the multiplicative inverse doesn't exist

invert

public static FieldElement invert(FieldElement a)
Use this static method if you want to create a new FieldElement with the value of multiplicatice inverse of a.

Parameters:
a - the field element
Returns:
a new FieldElement with the value of the multiplicative inverse.

invertSimultaneous

public static FieldElement[] invertSimultaneous(FieldElement[] a)
Use this static method if you want to simultaneously invert an array of FieldElements. For each element three extra multiplications are needed.

Parameters:
a - the field element array
Returns:
a the new FieldElement array with the value of the multiplicative inverse of each element.

multiply

public static FieldElement multiply(FieldElement a,
                                    FieldElement b)
Use this static method if you want to create a new FieldElement with the value of a * b. Make sure that both parameters are defined over the same field.

Parameters:
a - one factor
b - the other factor
Returns:
a new FieldElement with the value of a * b

negate

public static FieldElement negate(FieldElement a)
Use this static method if you want to create a new FieldElement with the negative value of a.

Parameters:
a - the field element
Returns:
a new FieldElement with the negative value of a.

square

public static FieldElement square(FieldElement a)
Use this static method if you want to create a new FieldElement with the value of a squared. Make sure that both parameters are defined over the same field.

Returns:
a new FieldElement with the value of a squared

sub

public static FieldElement sub(FieldElement a,
                               FieldElement b)
Use this static method if you want to create a new FieldElement with the value of a - b. Make sure that both parameters are defined over the same field.

Parameters:
a - the minuend
b - the subtrahend (negate b and add to a)
Returns:
a new FieldElement with the value of a - b

add

public FieldElement add(FieldElement b)
Calculates: this += b
Calls the corresponding field method.

Parameters:
b - the addend must be defined over the same field.
Returns:
a reference to this element (this) to enable chaining of arithmetic operations like: element.add(other).sub(another)
See Also:
Field.add(iaik.security.ecc.math.field.FieldElement, iaik.security.ecc.math.field.FieldElement)

clone

public java.lang.Object clone()
Creates a new FieldElement with the value cloned over the same field.

Returns:
the new field element.

divide

public FieldElement divide(FieldElement b)
Calculates: this *= invert(b)
Calls the corresponding field method.

Parameters:
b - the divisor must be defined over the same field.
Returns:
a reference to this element (this) to enable chaining of arithmetic operations like: element.add(other).sub(another)

equals

public boolean equals(java.lang.Object other)
Compares to FieldElements.

Returns:
true if the values are equal.

getField

public Field getField()
A FieldElement constist of a value and an underlying field.

Returns:
the underlying field

hashCode

public int hashCode()
Returns the hash code of this field element.

Returns:
the hash code of this field element.

half

public FieldElement half()
Halfs ONLY a prime field element, binary fields are not supported.

Returns:
a reference to this element (this) to enable chaining of arithmetic operations like: element.add(other).sub(another)

invert

public FieldElement invert()
Inverts (multiplicative) the element.

Returns:
a reference to this element (this) to enable chaining of arithmetic operations like: element.add(other).sub(another)

isOne

public boolean isOne()
Tests if the value is the ONE elemnt

Returns:
true if the value is the ONE element

isZero

public boolean isZero()
Tests if the value is the ZERO elemnt

Returns:
true if the value is the ZERO element

multiply

public FieldElement multiply(FieldElement b)
Calculates: this *= b
Calls the corresponding field method.

Parameters:
b - the factor must be defined over the same field.
Returns:
a reference to this element (this) to enable chaining of arithmetic operations like: element.add(other).sub(another)
See Also:
Field.multiply(iaik.security.ecc.math.field.FieldElement, iaik.security.ecc.math.field.FieldElement)

negate

public FieldElement negate()
Negates the element (additive inverse).

Returns:
a reference to this element (this) to enable chaining of arithmetic operations like: element.add(other).sub(another)
See Also:
Field.negate(iaik.security.ecc.math.field.FieldElement)

square

public FieldElement square()
Calculates: this squared
Calls the corresponding field method.

Returns:
a reference to this element (this) to enable chaining of arithmetic operations like: element.add(other).sub(another)
See Also:
Field.square(iaik.security.ecc.math.field.FieldElement)

sub

public FieldElement sub(FieldElement b)
Calculates: this -= b
Negates b and adds it to a.

Parameters:
b - the subtrahend must be defined over the same field.
Returns:
a reference to this element (this) to enable chaining of arithmetic operations like: element.add(other).sub(another)
See Also:
Field.add(iaik.security.ecc.math.field.FieldElement, iaik.security.ecc.math.field.FieldElement)

testBit

public boolean testBit(int bitPosition)
Tests the specified bit.

Parameters:
bitPosition - the bit to be tested, this parameter mustn't be negative
Returns:
true if the specified bit is '1' false otherwise.

toString

public java.lang.String toString()
Returns:
a human readable String containing the field and the value.

toBigInt

public java.math.BigInteger toBigInt()
Returns:
the field element as a BigInteger.

toByteArray

public byte[] toByteArray()
Performs the Field Element to Octet String Conversion Primitive (FE2OSP) as defined in P1363.

Returns:
the field element as byte array.

IAIK ECC
version 2.18

IAIK-ECC 2.18, (c) 2002 IAIK, (c) 2003 SIC