public class DebugGroupImpl extends java.lang.Object implements GroupImpl
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.Boolean |
enableExpCounting
Whether to count exponentiations as a single unit.
|
protected java.lang.Boolean |
enableMultiExpCounting
Whether to count multi-exponentiations as a single unit.
|
protected java.util.List<java.lang.Integer> |
multiExpTermNumbers
Contains number of terms for each multi-exponentiation performed.
|
protected java.lang.String |
name
Name of this group.
|
protected long |
numExps
The counted number of exponentiations.
|
protected long |
numInversions
The counted number of inversions.
|
protected long |
numOps
The counted number of operations.
|
protected long |
numRetrievedRepresentations
Number of retrieved representations for elements of this group.
|
protected long |
numSquarings
The counted number of squarings.
|
protected Zn |
zn
The Zn underlying this group.
|
| Constructor and Description |
|---|
DebugGroupImpl(Representation repr) |
DebugGroupImpl(java.lang.String name,
java.math.BigInteger n)
Instantiates this group with the given name and group size and to not count (multi-)exponentiations
explicitly (instead only total group operations are counted).
|
DebugGroupImpl(java.lang.String name,
java.math.BigInteger n,
boolean enableExpCounting,
boolean enableMultiExpCounting)
Instantiates this group with the given name, group size, and counting configuration.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addMultiExpBaseNumber(int numTerms)
Tracks the fact that a multi-exponentiation with the given number of terms was done.
|
boolean |
equals(java.lang.Object other) |
double |
estimateCostInvPerOp()
Estimates the number of inversions that can be done per group operation for the same cost.
|
GroupElementImpl |
exp(GroupElementImpl base,
java.math.BigInteger exponent,
SmallExponentPrecomputation precomputation)
Can be overwritten to implement a custom exponentiation algorithm for the group.
|
GroupElementImpl |
getGenerator()
Returns any generator of this group if the group is cyclic and it's feasible to compute a generator.
|
java.util.List<java.lang.Integer> |
getMultiExpTermNumbers() |
GroupElementImpl |
getNeutralElement()
Returns the neutral element of this group.
|
long |
getNumExps() |
long |
getNumInversions() |
long |
getNumOps() |
long |
getNumRetrievedRepresentations() |
long |
getNumSquarings() |
Representation |
getRepresentation()
The representation of this object.
|
GroupElementImpl |
getUniformlyRandomElement()
Generates a uniformly random element of this group.
|
GroupElementImpl |
getUniformlyRandomNonNeutral()
Generates a uniformly random non-neutral element of this group.
|
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. |
int |
hashCode() |
boolean |
hasPrimeSize()
Returns true if the size of this structure is known and prime.
|
boolean |
implementsOwnExp()
Indicates whether this group implements its own custom exponentiation algorithm by overwriting
GroupImpl.exp(org.cryptimeleon.math.structures.groups.GroupElementImpl, java.math.BigInteger, org.cryptimeleon.math.structures.groups.exp.SmallExponentPrecomputation). |
boolean |
implementsOwnMultiExp()
Indicates whether this group implements its own multi-exponentiation algorithm
by overwriting
GroupImpl.multiexp(Multiexponentiation). |
protected void |
incrementNumExps() |
protected void |
incrementNumInversions() |
protected void |
incrementNumOps() |
protected void |
incrementNumRetrievedRepresentations() |
protected void |
incrementNumSquarings() |
boolean |
isCommutative()
Returns true if this group is known to be commutative.
|
GroupElementImpl |
multiexp(Multiexponentiation mexp)
Can be overwritten to implement a custom multi-exponentiation algorithm for the group.
|
void |
resetCounters() |
void |
resetExpsCounter() |
void |
resetInvsCounter() |
void |
resetMultiExpTermNumbers() |
void |
resetOpsCounter() |
void |
resetRetrievedRepresentationsCounter() |
void |
resetSquaringsCounter() |
GroupElementImpl |
restoreElement(Representation repr)
Restores a group element from its representation.
|
java.math.BigInteger |
size()
Retrieves number of elements in the group if possible.
|
java.lang.String |
toString() |
DebugGroupElementImpl |
wrap(Zn.ZnElement elem)
Wraps a
ZnElement in a CountingGroupElementImpl belonging to this group. |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitrestoreFromRepresentationprotected java.lang.String name
CountingGroupElementImpl instances only allow for group
operations if the groups' names match.protected Zn zn
protected java.lang.Boolean enableExpCounting
protected java.lang.Boolean enableMultiExpCounting
protected long numInversions
protected long numOps
protected long numSquarings
protected long numExps
protected long numRetrievedRepresentations
protected java.util.List<java.lang.Integer> multiExpTermNumbers
public DebugGroupImpl(java.lang.String name,
java.math.BigInteger n)
name - a unique name for this group. group operations are only compatible between groups of the same name
and nn - the size of this grouppublic DebugGroupImpl(java.lang.String name,
java.math.BigInteger n,
boolean enableExpCounting,
boolean enableMultiExpCounting)
name - a unique name for this group. group operations are only compatible between groups of the same name
and nn - the size of this groupenableExpCounting - if true, exponentiations in G1, G2 and GT are counted as a single unit
and group operations within exponentiations are not counted; otherwise the former is
not done and group operations within exponentiations are added to the total countenableMultiExpCounting - if true, number of terms in each multi-exponentiation is tracked and
group operations within multi-exponentiations are not counted; otherwise
the former is not done and group operations within multi-exponentiations
are added to the total countpublic DebugGroupImpl(Representation repr)
public Representation getRepresentation()
RepresentableReprUtilgetRepresentation in interface RepresentableRepresentationpublic GroupElementImpl getNeutralElement()
GroupImplgetNeutralElement in interface GroupImplpublic GroupElementImpl getUniformlyRandomElement() throws java.lang.UnsupportedOperationException
GroupImplgetUniformlyRandomElement in interface GroupImpljava.lang.UnsupportedOperationException - if the random generation cannot be donepublic GroupElementImpl getUniformlyRandomNonNeutral() throws java.lang.UnsupportedOperationException
GroupImplgetUniformlyRandomNonNeutral in interface GroupImpljava.lang.UnsupportedOperationException - if the random generation cannot be donepublic GroupElementImpl restoreElement(Representation repr)
GroupImplrestoreElement in interface GroupImplpublic GroupElementImpl getGenerator() throws java.lang.UnsupportedOperationException
GroupImplRepeated calls may or may not always supply the same generator again (i.e. the output is not guaranteed to be random)!
getGenerator in interface GroupImpljava.lang.UnsupportedOperationException - if group is not cyclic or it's too hard to compute a generatorpublic java.util.Optional<java.lang.Integer> getUniqueByteLength()
GroupImplUniqueByteRepresentable.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 GroupImplgetUniqueByteRepresentation(),
or an empty Optional, if no guaranteepublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object other)
equals in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic boolean isCommutative()
GroupImplisCommutative in interface GroupImplpublic java.math.BigInteger size()
throws java.lang.UnsupportedOperationException
GroupImplpublic boolean hasPrimeSize()
throws java.lang.UnsupportedOperationException
GroupImplhasPrimeSize in interface GroupImpljava.lang.UnsupportedOperationExceptionpublic boolean implementsOwnExp()
GroupImplGroupImpl.exp(org.cryptimeleon.math.structures.groups.GroupElementImpl, java.math.BigInteger, org.cryptimeleon.math.structures.groups.exp.SmallExponentPrecomputation).implementsOwnExp in interface GroupImplGroupImpl.exp(org.cryptimeleon.math.structures.groups.GroupElementImpl, java.math.BigInteger, org.cryptimeleon.math.structures.groups.exp.SmallExponentPrecomputation), else falsepublic GroupElementImpl exp(GroupElementImpl base, java.math.BigInteger exponent, SmallExponentPrecomputation precomputation)
GroupImplpublic boolean implementsOwnMultiExp()
GroupImplGroupImpl.multiexp(Multiexponentiation).implementsOwnMultiExp in interface GroupImplpublic GroupElementImpl multiexp(Multiexponentiation mexp)
GroupImplpublic DebugGroupElementImpl wrap(Zn.ZnElement elem)
ZnElement in a CountingGroupElementImpl belonging to this group.public double estimateCostInvPerOp()
GroupImpl2 would mean that an inversion costs half as much as a group operation, on average.estimateCostInvPerOp in interface GroupImplprotected void incrementNumOps()
protected void incrementNumInversions()
protected void incrementNumSquarings()
protected void incrementNumExps()
protected void addMultiExpBaseNumber(int numTerms)
numTerms - the number of terms (bases) in the multi-exponentiationprotected void incrementNumRetrievedRepresentations()
public long getNumInversions()
public long getNumOps()
public long getNumSquarings()
public long getNumExps()
public java.util.List<java.lang.Integer> getMultiExpTermNumbers()
public long getNumRetrievedRepresentations()
public void resetOpsCounter()
public void resetInvsCounter()
public void resetSquaringsCounter()
public void resetExpsCounter()
public void resetMultiExpTermNumbers()
public void resetRetrievedRepresentationsCounter()
public void resetCounters()