public interface Ring extends Structure, RepresentationRestorer
| Modifier and Type | Method and Description |
|---|---|
default RingGroup |
asAdditiveGroup()
Returns an object representing the additive group of this ring.
|
default RingGroup |
asUnitGroup()
Returns an object representing the (multiplicative) unit group of this ring.
|
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.
|
default java.util.ArrayList<RingElement> |
extendedEuclideanAlgorithm(java.util.List<RingElement> elements)
This function executes the extended euclidean algorithm of the passed elements.
|
default RingElement[] |
extendedEuclideanAlgorithm(RingElement a,
RingElement b)
This function executes the extended euclidean algorithm for the elements
a and b.
|
java.math.BigInteger |
getCharacteristic()
Returns the characteristic of the ring.
|
RingElement |
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\).
|
default RingElement |
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\).
|
RingElement |
getOneElement()
Returns the multiplicative neutral element of this ring.
|
RingElement |
getUniformlyRandomElement()
Returns an element of this structure that is drawn uniformly at random
using a cryptographically strong RNG.
|
default RingElementVector |
getUniformlyRandomElements(int n)
Returns n elements of this structure that are drawn uniformly and independently at random
using a cryptographically strong RNG.
|
default RingElement |
getUniformlyRandomNonzeroElement()
Generates a nonzero element from this ring uniformly at random using a cryptographically strong RNG.
|
default RingElementVector |
getUniformlyRandomNonzeroElements(int n)
Generates n nonzero elements from this ring uniformly and independently at random
using a cryptographically strong RNG.
|
default RingElement |
getUniformlyRandomUnit()
Generates an invertible element from this ring uniformly at random using a cryptographically strong RNG.
|
default RingElementVector |
getUniformlyRandomUnits(int n)
Generates n invertible elements from this ring uniformly and independently at random
using a cryptographically strong RNG.
|
RingElement |
getZeroElement()
Returns the additive neutral element of this ring.
|
boolean |
isCommutative()
Returns true if this ring is known to be commutative.
|
RingElement |
restoreElement(Representation repr)
Creates an element of this structure from its representation.
|
default java.lang.Object |
restoreFromRepresentation(java.lang.reflect.Type type,
Representation repr)
Takes a representation and creates an object of the given type from it if the type is supported by the restorer.
|
default RingElementVector |
restoreVector(Representation repr)
Restores a
RingElementVector containing ring elements from this Ring from a
Representation of that vector. |
java.math.BigInteger |
sizeUnitGroup()
Returns the number of units in this ring.
|
getUniqueByteLength, hasPrimeSize, sizegetRepresentationdefault RingGroup asAdditiveGroup()
default RingGroup asUnitGroup()
java.math.BigInteger sizeUnitGroup()
throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException - if size is unknown or is computationally too expensive to computeRingElement getZeroElement()
RingElement getOneElement()
RingElement restoreElement(Representation repr)
StructurerestoreElement in interface Structurerepr - the Representation returned by Representable.getRepresentation()default RingElementVector restoreVector(Representation repr)
RingElementVector containing ring elements from this Ring from a
Representation of that vector.repr - a representation of a RingElementVector
(obtained via RingElementVector.getRepresentation()).default java.lang.Object restoreFromRepresentation(java.lang.reflect.Type type,
Representation repr)
RepresentationRestorerrestoreFromRepresentation in interface RepresentationRestorertype - tells the restorer which type the restored object should haverepr - the representation to restore the object fromRingElement getUniformlyRandomElement() throws java.lang.UnsupportedOperationException
StructuregetUniformlyRandomElement in interface Structurejava.lang.UnsupportedOperationException - if the operation is not supporteddefault RingElementVector getUniformlyRandomElements(int n) throws java.lang.UnsupportedOperationException
StructuregetUniformlyRandomElements in interface Structurejava.lang.UnsupportedOperationException - if the operation is not supporteddefault RingElement getUniformlyRandomUnit() throws java.lang.UnsupportedOperationException
The 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!
java.lang.UnsupportedOperationException - if the ring does not support this methoddefault RingElementVector getUniformlyRandomUnits(int n) throws java.lang.UnsupportedOperationException
The 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!
java.lang.UnsupportedOperationException - if the ring does not support this methoddefault RingElement getUniformlyRandomNonzeroElement()
java.lang.UnsupportedOperationException - if the ring does not support this methoddefault RingElementVector getUniformlyRandomNonzeroElements(int n)
java.lang.UnsupportedOperationException - if the ring does not support this methodjava.math.BigInteger getCharacteristic()
throws java.lang.UnsupportedOperationException
The characteristic of a ring is defined to be the number n
such that there is a ring homomorphism from Zn to the ring.
java.lang.UnsupportedOperationException - if unknownRingElement getElement(java.math.BigInteger i)
i - the integer to mapdefault RingElement getElement(long i)
i - the integer to mapdefault RingElement[] extendedEuclideanAlgorithm(RingElement a, RingElement b)
Specifically, it computes an array \([x, y, gcd(a,b)]\) such that \(ax+by=gcd(a,b)\).
The gcd(a,b) is an element such that
This algorithm only works on euclidean domains, i.e. the RingElement in this ring must
implement divideWithRemainder.
a - First argument to the extended euclidean algorithm.b - Second argument to the extended euclidean algorithm.default java.util.ArrayList<RingElement> extendedEuclideanAlgorithm(java.util.List<RingElement> elements)
Specifically, it computes an array [x[0], x[1], ..., x[n-1], gcd(elements)] such that gcd(elements)=elements[0]*x[0]+elements[1]*x[1]+...+elements[n-1]*x[n-1].
The gcd(elements) is an element such that
This algorithm only works on euclidean domains i.e. the RingElement in this ring must
implement divideWithRemainder.
elements - List of elements to apply the extended euclidean algorithm todouble estimateCostInvPerOp()
2 would mean that an inversion costs half as much as a group operation, on average.double estimateCostNegPerOp()
2 would mean that a negation costs half as much as a group operation, on average.boolean isCommutative()