public class LazyGroup extends java.lang.Object implements Group
GroupImpl wrapper implementing deferred (lazy) evaluation for abelian groups with known finite order.
Allows for additional optimizations using information about the operations being applied. Specifically, multi-exponentiation techniques can be applied to significantly speed up computations.
For more information, see the documentation.
| Constructor and Description |
|---|
LazyGroup(GroupImpl impl) |
LazyGroup(GroupImpl impl,
int exponentiationWindowSize,
int precomputationWindowSize) |
LazyGroup(Representation repr) |
LazyGroup(Representation repr,
int exponentiationWindowSize,
int precomputationWindowSize) |
| Modifier and Type | Method and Description |
|---|---|
GroupElementImpl |
compute(GroupElementImpl base,
java.math.BigInteger exponent,
SmallExponentPrecomputation precomputation) |
GroupElementImpl |
compute(Multiexponentiation multiexp) |
boolean |
equals(java.lang.Object o) |
int |
getExponentiationWindowSize() |
GroupElement |
getGenerator()
Returns any generator of this group if the group is cyclic and it's feasible to compute a generator.
|
GroupImpl |
getImpl() |
GroupElement |
getNeutralElement()
Returns the neutral element for this group
|
int |
getPrecomputationWindowSize() |
Representation |
getRepresentation()
The representation of this object.
|
ExpAlgorithm |
getSelectedExpAlgorithm() |
MultiExpAlgorithm |
getSelectedMultiExpAlgorithm() |
GroupElement |
getUniformlyRandomElement()
Returns an element of this structure that is drawn uniformly at random
using a cryptographically strong RNG.
|
GroupElement |
getUniformlyRandomNonNeutral()
Generates a uniformly random non-neutral element of this group 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. |
Zn |
getZn()
Returns
Zn, where n == size(). |
int |
hashCode() |
boolean |
hasPrimeSize()
Checks if the structure has prime size.
|
boolean |
isCommutative()
Returns true if this group is known to be commutative.
|
GroupElement |
restoreElement(Representation repr)
Creates an element of this structure from its representation.
|
void |
setExponentiationWindowSize(int exponentiationWindowSize) |
void |
setPrecomputationWindowSize(int precomputationWindowSize) |
void |
setSelectedExpAlgorithm(ExpAlgorithm selectedExpAlgorithm) |
void |
setSelectedMultiExpAlgorithm(MultiExpAlgorithm selectedMultiExpAlgorithm) |
java.math.BigInteger |
size()
Returns the number of elements in this structure (the size).
|
java.lang.String |
toString() |
protected LazyGroupElement |
wrap(GroupElementImpl impl) |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitexpr, getUniformlyRandomElements, getUniformlyRandomExponent, getUniformlyRandomExponents, getUniformlyRandomNonNeutrals, getUniformlyRandomNonzeroExponent, getUniformlyRandomNonzeroExponents, getUniformlyRandomUnitExponent, getUniformlyRandomUnitExponents, restoreFromRepresentation, restoreVectorpublic LazyGroup(GroupImpl impl)
public LazyGroup(GroupImpl impl, int exponentiationWindowSize, int precomputationWindowSize)
public LazyGroup(Representation repr)
public LazyGroup(Representation repr, int exponentiationWindowSize, int precomputationWindowSize)
protected LazyGroupElement wrap(GroupElementImpl impl)
public GroupElement getNeutralElement()
GroupgetNeutralElement in interface Grouppublic java.math.BigInteger size()
throws java.lang.UnsupportedOperationException
Structurepublic boolean hasPrimeSize()
StructurehasPrimeSize in interface Structurepublic GroupElement getUniformlyRandomElement() throws java.lang.UnsupportedOperationException
StructuregetUniformlyRandomElement in interface GroupgetUniformlyRandomElement in interface Structurejava.lang.UnsupportedOperationException - if the operation is not supportedpublic GroupElement getUniformlyRandomNonNeutral() throws java.lang.UnsupportedOperationException
GroupgetUniformlyRandomNonNeutral in interface Groupjava.lang.UnsupportedOperationExceptionpublic GroupElement restoreElement(Representation repr)
StructurerestoreElement in interface GrouprestoreElement in interface Structurerepr - the Representation returned by Representable.getRepresentation()public GroupElement getGenerator() throws java.lang.UnsupportedOperationException
GroupRepeated calls may or may not always supply the same generator again (i.e. the output is not guaranteed to be random)!
getGenerator in interface Groupjava.lang.UnsupportedOperationException - if the group doesn't know or have a generatorpublic 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()
GroupisCommutative in interface Grouppublic Representation getRepresentation()
RepresentableReprUtilgetRepresentation in interface RepresentableRepresentationpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic GroupElementImpl compute(Multiexponentiation multiexp)
public GroupElementImpl compute(GroupElementImpl base, java.math.BigInteger exponent, SmallExponentPrecomputation precomputation)
public int getExponentiationWindowSize()
public void setExponentiationWindowSize(int exponentiationWindowSize)
public int getPrecomputationWindowSize()
public void setPrecomputationWindowSize(int precomputationWindowSize)
public MultiExpAlgorithm getSelectedMultiExpAlgorithm()
public void setSelectedMultiExpAlgorithm(MultiExpAlgorithm selectedMultiExpAlgorithm)
public ExpAlgorithm getSelectedExpAlgorithm()
public void setSelectedExpAlgorithm(ExpAlgorithm selectedExpAlgorithm)
public GroupImpl getImpl()