public class IntegerRing extends java.lang.Object implements Ring
| Constructor and Description |
|---|
IntegerRing() |
IntegerRing(Representation repr) |
| Modifier and Type | Method and Description |
|---|---|
static java.math.BigInteger[] |
decomposeIntoDigits(java.math.BigInteger number,
java.math.BigInteger base)
Decomposes a given number into digits with the given base.
|
static java.math.BigInteger[] |
decomposeIntoDigits(java.math.BigInteger number,
java.math.BigInteger base,
int numDigits)
Decomposes a given number into the given number of digits with the given base.
|
static java.math.BigInteger[] |
decomposeIntoDigits(java.math.BigInteger number,
long base)
Decomposes a given number into digits with the given base.
|
static java.math.BigInteger[] |
decomposeIntoDigits(java.math.BigInteger number,
long base,
int numDigits)
Decomposes a given number into the given number of digits with the given base.
|
boolean |
equals(java.lang.Object obj) |
double |
estimateCostInvPerOp()
Estimates the number of inversions that can be done per group operation for the same cost.
|
double |
estimateCostNegPerOp()
Estimates the number of negations (additive inversions) that can be done per group operation for the same cost.
|
java.math.BigInteger |
getCharacteristic()
Returns the characteristic of the ring.
|
IntegerElement |
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\).
|
IntegerElement |
getOneElement()
Returns the multiplicative neutral element of this ring.
|
Representation |
getRepresentation()
The representation of this object.
|
IntegerElement |
getUniformlyRandomElement()
Returns an element of this structure that is drawn uniformly at random
using a cryptographically strong RNG.
|
RingElement |
getUniformlyRandomUnit()
Generates an invertible element from this ring uniformly at random using a cryptographically strong RNG.
|
java.util.Optional<java.lang.Integer> |
getUniqueByteLength()
Returns the number of bytes returned by this structure's
UniqueByteRepresentable.getUniqueByteRepresentation(),
or an empty Optional if this structure's elements do not guarantee a fixed length. |
IntegerElement |
getZeroElement()
Returns the additive neutral element of this ring.
|
int |
hashCode() |
boolean |
isCommutative()
Returns true if this ring is known to be commutative.
|
IntegerElement |
restoreElement(Representation repr)
Creates an element of this structure from its representation.
|
java.math.BigInteger |
size()
Returns the number of elements in this structure (the size).
|
java.math.BigInteger |
sizeUnitGroup()
Returns the number of units in this ring.
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitasAdditiveGroup, asUnitGroup, extendedEuclideanAlgorithm, extendedEuclideanAlgorithm, getElement, getUniformlyRandomElements, getUniformlyRandomNonzeroElement, getUniformlyRandomNonzeroElements, getUniformlyRandomUnits, restoreFromRepresentation, restoreVectorhasPrimeSizepublic IntegerRing()
public IntegerRing(Representation repr)
public java.math.BigInteger size()
throws java.lang.UnsupportedOperationException
Structurepublic Representation getRepresentation()
RepresentableReprUtilgetRepresentation in interface RepresentableRepresentationpublic java.math.BigInteger sizeUnitGroup()
throws java.lang.UnsupportedOperationException
RingsizeUnitGroup in interface Ringjava.lang.UnsupportedOperationException - if size is unknown or is computationally too expensive to computepublic IntegerElement getZeroElement()
RinggetZeroElement in interface Ringpublic IntegerElement getOneElement()
RinggetOneElement in interface Ringpublic IntegerElement getElement(java.math.BigInteger i)
RinggetElement in interface Ringi - the integer to mappublic double estimateCostInvPerOp()
Ring2 would mean that an inversion costs half as much as a group operation, on average.estimateCostInvPerOp in interface Ringpublic double estimateCostNegPerOp()
Ring2 would mean that a negation costs half as much as a group operation, on average.estimateCostNegPerOp in interface Ringpublic IntegerElement restoreElement(Representation repr)
StructurerestoreElement in interface RingrestoreElement in interface Structurerepr - the Representation returned by Representable.getRepresentation()public IntegerElement getUniformlyRandomElement() throws java.lang.UnsupportedOperationException
StructuregetUniformlyRandomElement in interface RinggetUniformlyRandomElement in interface Structurejava.lang.UnsupportedOperationException - if the operation is not supportedpublic RingElement 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 Ringjava.lang.UnsupportedOperationException - if the ring does not support this methodpublic java.math.BigInteger getCharacteristic()
Ring
The characteristic of a ring is defined to be the number n
such that there is a ring homomorphism from Zn to the ring.
getCharacteristic in interface Ringpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.util.Optional<java.lang.Integer> getUniqueByteLength()
StructureUniqueByteRepresentable.getUniqueByteRepresentation(),
or an empty Optional if this structure's elements do not guarantee a fixed length.
For example, elements of Zp will always be represented by ceil(ceil(log(p))/8) bytes,
hence getUniqueByteLength() would return ceil(ceil(log(p))/8).
A polynomial ring would return an empty Optional since a polynomial's unique byte representation length
depends on its degree.
getUniqueByteLength in interface StructuregetUniqueByteRepresentation(),
or an empty Optional, if no guaranteepublic boolean isCommutative()
RingisCommutative in interface Ringpublic static java.math.BigInteger[] decomposeIntoDigits(java.math.BigInteger number,
java.math.BigInteger base)
For example, for base = 2, this does bit decomposition.
A containing values A[i] < base such that
\(\sum_i{ \text{A}[i] \cdot \text{base}^i} = \text{number}\)public static java.math.BigInteger[] decomposeIntoDigits(java.math.BigInteger number,
java.math.BigInteger base,
int numDigits)
For example, for base = 2, this does bit decomposition.
A containing values A[i] < base such that
\(\sum_i{ \text{A}[i] \cdot \text{base}^i} = \text{number}\)java.lang.IllegalArgumentException - if numDigits is not enough to represent the given numberpublic static java.math.BigInteger[] decomposeIntoDigits(java.math.BigInteger number,
long base)
For example, for base = 2, this does bit decomposition.
A containing values A[i] < base such that
\(\sum_i{ \text{A}[i] \cdot \text{base}^i} = \text{number}\)public static java.math.BigInteger[] decomposeIntoDigits(java.math.BigInteger number,
long base,
int numDigits)
For example, for base = 2, this does bit decomposition.
A containing values A[i] < base such that
\(\sum_i{ \text{A}[i] \cdot \text{base}^i} = \text{number}\)java.lang.IllegalArgumentException - if numDigits is not enough to represent the given number