public class Zp extends Zn implements Field
| Modifier and Type | Class and Description |
|---|---|
class |
Zp.ZpElement
The elements of
Zp. |
Zn.ZnElement| Constructor and Description |
|---|
Zp(java.math.BigInteger p)
Construct the field
Zp using a given prime p. |
Zp(Representation repr) |
| Modifier and Type | Method and Description |
|---|---|
Zp.ZpElement |
createZnElement(java.math.BigInteger v)
Creates an element from a
BigInteger (formally, the projection of \(v\) from \(\mathbb{Z}\)
to \(\mathbb{Z}_n\)). |
protected Zp.ZpElement |
createZnElementUnsafe(java.math.BigInteger vBetween0andN)
Instantiates a
ZnElement without checking that the given representative is within the proper range. |
Zp.ZpElement |
getElement(java.math.BigInteger i)
Maps the integer i into this ring \(R\), such that this map is a
ring homomorphism \(\mathbb{Z}_{\text{getCharacteristic()}} \rightarrow R\).
|
Zp.ZpElement |
getElement(long i)
Maps the integer i into this ring \(R\), such that this map is a
ring homomorphism \(\mathbb{Z}_{\text{getCharacteristic()}} \rightarrow R\).
|
Zp.ZpElement |
getOneElement()
Returns the multiplicative neutral element of this ring.
|
Zp.ZpElement |
getPrimitiveElement()
If this is a finite field, returns a generator of the field's unit group.
|
Zp.ZpElement |
getUniformlyRandomElement()
Returns an element of this structure that is drawn uniformly at random
using a cryptographically strong RNG.
|
Zp.ZpElement |
getUniformlyRandomNonzeroElement()
Generates a nonzero element from this ring uniformly at random using a cryptographically strong RNG.
|
Zp.ZpElement |
getUniformlyRandomUnit()
Generates an invertible element from this ring uniformly at random using a cryptographically strong RNG.
|
Zp.ZpElement |
getZeroElement()
Returns the additive neutral element of this ring.
|
boolean |
hasPrimeSize()
Checks if the structure has prime size.
|
Zp.ZpElement |
injectiveValueOf(byte[] bytes)
For all
k < floor((n.bitLength()-1)/8), this is an injective map byte^k -> Zn. |
Zp.ZpElement |
restoreElement(Representation repr)
Creates an element of this structure from its representation.
|
java.math.BigInteger |
sizeUnitGroup()
Returns the number of units in this ring.
|
Zp.ZpElement |
valueOf(java.math.BigInteger representative)
Creates the corresponding element mod n.
|
static Zp.ZpElement |
valueOf(java.math.BigInteger representative,
java.math.BigInteger modulus)
Create the element "representative mod modulus"
|
Zp.ZpElement |
valueOf(long representative)
Creates the corresponding element mod n.
|
static Zp.ZpElement |
valueOf(long representative,
java.math.BigInteger modulus)
Create the element "representative mod modulus"
|
static Zp.ZpElement |
valueOf(long representative,
long modulus)
Create the element "representative mod modulus"
|
equals, getCharacteristic, getRepresentation, getUniqueByteLength, hashCode, isCommutative, size, toString, upperBoundForUniqueRepresentationclone, finalize, getClass, notify, notifyAll, wait, wait, waitisCommutativeasAdditiveGroup, asUnitGroup, extendedEuclideanAlgorithm, extendedEuclideanAlgorithm, getCharacteristic, getUniformlyRandomElements, getUniformlyRandomNonzeroElements, getUniformlyRandomUnits, restoreFromRepresentation, restoreVectorgetUniqueByteLength, sizegetRepresentationpublic Zp(java.math.BigInteger p)
Zp using a given prime p.p - a prime number (is checked probabilistically)java.lang.IllegalArgumentException - if p is not primepublic Zp(Representation repr)
public java.math.BigInteger sizeUnitGroup()
RingsizeUnitGroup in interface FieldsizeUnitGroup in interface RingsizeUnitGroup in class Znpublic boolean hasPrimeSize()
throws java.lang.UnsupportedOperationException
StructurehasPrimeSize in interface StructurehasPrimeSize in class Znjava.lang.UnsupportedOperationException - if the primality of the size cannot be determinedpublic Zp.ZpElement getUniformlyRandomUnit() throws java.lang.UnsupportedOperationException
RingThe default implementation generates random ring elements until it hits a unit. Implementors should override if this is not feasible or if there is a better way!
getUniformlyRandomUnit in interface FieldgetUniformlyRandomUnit in interface RinggetUniformlyRandomUnit in class Znjava.lang.UnsupportedOperationException - if the ring does not support this methodpublic Zp.ZpElement getUniformlyRandomNonzeroElement()
RinggetUniformlyRandomNonzeroElement in interface RinggetUniformlyRandomNonzeroElement in class Znpublic Zp.ZpElement getUniformlyRandomElement() throws java.lang.UnsupportedOperationException
StructuregetUniformlyRandomElement in interface FieldgetUniformlyRandomElement in interface RinggetUniformlyRandomElement in interface StructuregetUniformlyRandomElement in class Znjava.lang.UnsupportedOperationException - if the operation is not supportedpublic Zp.ZpElement getOneElement()
RinggetOneElement in interface FieldgetOneElement in interface RinggetOneElement in class Znpublic Zp.ZpElement getZeroElement()
RinggetZeroElement in interface FieldgetZeroElement in interface RinggetZeroElement in class Znpublic Zp.ZpElement getPrimitiveElement() throws java.lang.UnsupportedOperationException
FieldgetPrimitiveElement in interface Fieldjava.lang.UnsupportedOperationException - if operation is not feasible or undefinedpublic Zp.ZpElement restoreElement(Representation repr)
StructurerestoreElement in interface FieldrestoreElement in interface RingrestoreElement in interface StructurerestoreElement in class Znrepr - the Representation returned by Representable.getRepresentation()public Zp.ZpElement getElement(long i)
RinggetElement in interface FieldgetElement in interface Ringi - the integer to mappublic Zp.ZpElement createZnElement(java.math.BigInteger v)
ZnBigInteger (formally, the projection of \(v\) from \(\mathbb{Z}\)
to \(\mathbb{Z}_n\)).
Implementation detail: This factory method allows the subclass Zp to use its own kind of elements
while reusing the Zn implementation.
createZnElement in class Znprotected Zp.ZpElement createZnElementUnsafe(java.math.BigInteger vBetween0andN)
ZnZnElement without checking that the given representative is within the proper range.createZnElementUnsafe in class ZnvBetween0andN - the representative of the element to instantiate.
Must be between 0 (inclusive) and n (exclusive).public Zp.ZpElement getElement(java.math.BigInteger i)
RinggetElement in interface FieldgetElement in interface RinggetElement in class Zni - the integer to mappublic Zp.ZpElement injectiveValueOf(byte[] bytes) throws java.lang.IllegalArgumentException
Znk < floor((n.bitLength()-1)/8), this is an injective map byte^k -> Zn.
Note that there may be collisions between injectiveValueOf(bytes1) and injectiveValueOf(bytes2)
if bytes1.length != bytes2.length.
injectiveValueOf in class Znbytes - the bytes to map injectively into Zn.java.lang.IllegalArgumentException - if the byte array is too longpublic static Zp.ZpElement valueOf(java.math.BigInteger representative, java.math.BigInteger modulus)
representative - the integer representative of the elementmodulus - the ring sizepublic static Zp.ZpElement valueOf(long representative, java.math.BigInteger modulus)
representative - the integer representative of the elementmodulus - the ring sizepublic static Zp.ZpElement valueOf(long representative, long modulus)
representative - the integer representative of the elementmodulus - the ring sizepublic Zp.ZpElement valueOf(long representative)
Znpublic Zp.ZpElement valueOf(java.math.BigInteger representative)
Zn