public class DebugGroup extends java.lang.Object implements Group
This counting capability is realized by using two LazyGroups that each wrap a DebugGroupImpl.
One counts total group operations and squarings, and the other counts (multi-)exponentiations as a single unit
(not including group operations and squarings done inside (multi-)exponentiations).
| Modifier and Type | Field and Description |
|---|---|
protected org.cryptimeleon.math.structures.groups.debug.CountingNamespace |
countingNamespace
Determines which namespace's buckets this group is using.
|
protected LazyGroup |
groupNoExpMultiExp
Does not track group operations done in (multi-)exp algorithms, but instead tracks number of exponentiations
and multi-exponentiation data.
|
protected LazyGroup |
groupTotal
Tracks total numbers, meaning that group operations done in (multi-)exp algorithms are also tracked.
|
| Constructor and Description |
|---|
DebugGroup(LazyGroup groupTotal,
LazyGroup groupExpMultiExp)
This constructor allows instantiating the
DebugGroup with specific LazyGroup instances. |
DebugGroup(Representation repr) |
DebugGroup(java.lang.String name,
java.math.BigInteger size)
Initializes the counting group with a given name and size.
|
DebugGroup(java.lang.String name,
long size) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object o) |
java.lang.String |
formatCounterData()
Formats the count data of the default bucket for printing.
|
java.lang.String |
formatCounterData(java.lang.String bucketName)
Formats the count data of the bucket with the given name for printing.
|
java.lang.String |
formatCounterDataAllBuckets()
Formats the count data of all buckets for printing.
|
java.lang.String |
formatCounterDataAllBuckets(boolean summaryOnly)
Formats the counter data of all buckets for printing.
|
int |
getExponentiationWindowSize()
Returns the window size used for the non-cached precomputations computed during the exponentiation algorithm.
|
java.util.List<java.lang.Integer> |
getMultiExpTermNumbers()
Retrieves number of terms of each multi-exponentiation done from the default bucket.
|
java.util.List<java.lang.Integer> |
getMultiExpTermNumbers(java.lang.String bucketName)
Retrieves number of terms of each multi-exponentiation done from the bucket with the given name.
|
java.util.List<java.lang.Integer> |
getMultiExpTermNumbersAllBuckets()
Retrieves number of terms of each multi-exponentiation done across all buckets.
|
GroupElement |
getNeutralElement()
Returns the neutral element for this group
|
long |
getNumExps()
Retrieves number of group exponentiations done from the default bucket.
|
long |
getNumExps(java.lang.String bucketName)
Retrieves number of group exponentiations done from the bucket with the given name.
|
long |
getNumExpsAllBuckets()
Retrieves number of group exponentiations done summed up across all buckets.
|
long |
getNumInversionsNoExpMultiExp()
Retrieves number of group inversions not including ones done in (multi-)exponentiation algorithms
from the default bucket.
|
long |
getNumInversionsNoExpMultiExp(java.lang.String bucketName)
Retrieves number of group inversions not including ones done in (multi-)exponentiation algorithms
from the bucket with the given name.
|
long |
getNumInversionsNoExpMultiExpAllBuckets()
Retrieves number of group inversions not including ones done in (multi-)exponentiation algorithms
summed up across all buckets.
|
long |
getNumInversionsTotal()
Retrieves number of group inversions including ones done in (multi-)exponentiation algorithms
from the default bucket.
|
long |
getNumInversionsTotal(java.lang.String bucketName)
Retrieves number of group inversions including ones done in (multi-)exponentiation algorithms
from the bucket with the given name.
|
long |
getNumInversionsTotalAllBuckets()
Retrieves number of group inversions including ones done in (multi-)exponentiation algorithms
summed up across all buckets.
|
long |
getNumOpsNoExpMultiExp()
Retrieves number of group ops not including ones done in (multi-)exponentiation algorithms
from the default bucket.
|
long |
getNumOpsNoExpMultiExp(java.lang.String bucketName)
Retrieves number of group ops not including ones done in (multi-)exponentiation algorithms
from the bucket with the given name.
|
long |
getNumOpsNoExpMultiExpAllBuckets()
Retrieves number of group ops not including ones done in (multi-)exponentiation algorithms
summed up across all buckets.
|
long |
getNumOpsTotal()
Retrieves number of group ops including ones done in (multi-)exponentiation algorithms
from the default bucket.
|
long |
getNumOpsTotal(java.lang.String bucketName)
Retrieves number of group ops including ones done in (multi-)exponentiation algorithms
from the bucket with the given name.
|
long |
getNumOpsTotalAllBuckets()
Retrieves number of group ops including ones done in (multi-)exponentiation algorithms
summed up across all buckets.
|
long |
getNumRetrievedRepresentations()
Retrieves number of retrieved representations of group elements for this group (via
getRepresentation())
from the default bucket. |
long |
getNumRetrievedRepresentations(java.lang.String bucketName)
Retrieves number of retrieved representations of group elements for this group (via
getRepresentation())
from the bucket with the given name. |
long |
getNumRetrievedRepresentationsAllBuckets()
Retrieves number of retrieved representations of group elements for this group (via
getRepresentation())
summed up across all buckets. |
long |
getNumSquaringsNoExpMultiExp()
Retrieves number of group squarings not including ones done in (multi-)exponentiation algorithms
from the default bucket.
|
long |
getNumSquaringsNoExpMultiExp(java.lang.String bucketName)
Retrieves number of group squarings not including ones done in (multi-)exponentiation algorithms
from the bucket with the given name.
|
long |
getNumSquaringsNoExpMultiExpAllBuckets()
Retrieves number of group squarings not including ones done in (multi-)exponentiation algorithms
summed up across all buckets.
|
long |
getNumSquaringsTotal()
Retrieves number of group squarings including ones done in (multi-)exponentiation algorithms
from the default bucket.
|
long |
getNumSquaringsTotal(java.lang.String bucketName)
Retrieves number of group squarings including ones done in (multi-)exponentiation algorithms
from the bucket with the given name.
|
long |
getNumSquaringsTotalAllBuckets()
Retrieves number of group squarings including ones done in (multi-)exponentiation algorithms
summed up across all buckets.
|
int |
getPrecomputationWindowSize()
Returns the window size used for the precomputations.
|
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.
|
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 |
isCommutative()
Returns true if this group is known to be commutative.
|
void |
resetCounters()
Resets all counters for the default bucket.
|
void |
resetCounters(java.lang.String bucketName)
Resets all counters for the bucket with the given name.
|
void |
resetCountersAllBuckets()
Resets counters for all buckets.
|
GroupElement |
restoreElement(Representation repr)
Creates an element of this structure from its representation.
|
void |
setBucket(java.lang.String name)
Sets the currently used operation count storage bucket to the one with the given name.
|
void |
setExponentiationWindowSize(int exponentiationWindowSize)
Sets the window size used for used for the non-cached precomputations computed during the
exponentiation algorithm.
|
void |
setPrecomputationWindowSize(int precomputationWindowSize)
Sets the window size used for the cached precomputations.
|
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() |
DebugGroupElement |
wrap(Zn.ZnElement elem) |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitexpr, getGenerator, getUniformlyRandomElements, getUniformlyRandomExponent, getUniformlyRandomExponents, getUniformlyRandomNonNeutral, getUniformlyRandomNonNeutrals, getUniformlyRandomNonzeroExponent, getUniformlyRandomNonzeroExponents, getUniformlyRandomUnitExponent, getUniformlyRandomUnitExponents, restoreFromRepresentation, restoreVectorhasPrimeSizeprotected LazyGroup groupTotal
protected LazyGroup groupNoExpMultiExp
protected org.cryptimeleon.math.structures.groups.debug.CountingNamespace countingNamespace
public DebugGroup(java.lang.String name,
java.math.BigInteger size)
name - the name of the groupsize - the desired size of the grouppublic DebugGroup(java.lang.String name,
long size)
public DebugGroup(LazyGroup groupTotal, LazyGroup groupExpMultiExp)
DebugGroup with specific LazyGroup instances.
This can, for example, be used to change the choice of (multi-)exponentiation algorithm by configuring
the LazyGroup instances to use a different (multi-)exponentiation algorithm.public DebugGroup(Representation repr)
public GroupElement getNeutralElement()
GroupgetNeutralElement in interface Grouppublic java.math.BigInteger size()
throws java.lang.UnsupportedOperationException
Structurepublic GroupElement getUniformlyRandomElement() throws java.lang.UnsupportedOperationException
StructuregetUniformlyRandomElement in interface GroupgetUniformlyRandomElement in interface Structurejava.lang.UnsupportedOperationException - if the operation is not supportedpublic GroupElement restoreElement(Representation repr)
StructurerestoreElement in interface GrouprestoreElement in interface Structurerepr - the Representation returned by Representable.getRepresentation()public DebugGroupElement wrap(Zn.ZnElement elem)
public 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 void setBucket(java.lang.String name)
All operations executed after setting a bucket will be counted within that bucket only.
name - the name of the bucket to enablepublic long getNumSquaringsTotal(java.lang.String bucketName)
bucketName - the name of the bucket to retrieve number of squarings frompublic long getNumInversionsTotal(java.lang.String bucketName)
bucketName - the name of the bucket to retrieve number of inversions frompublic long getNumOpsTotal(java.lang.String bucketName)
bucketName - the name of the bucket to retrieve number of operations frompublic long getNumSquaringsNoExpMultiExp(java.lang.String bucketName)
bucketName - the name of the bucket to retrieve number of squarings frompublic long getNumInversionsNoExpMultiExp(java.lang.String bucketName)
bucketName - the name of the bucket to retrieve number of inversions frompublic long getNumOpsNoExpMultiExp(java.lang.String bucketName)
bucketName - the name of the bucket to retrieve number of operations frompublic long getNumExps(java.lang.String bucketName)
bucketName - the name of the bucket to retrieve number of exponentiations frompublic java.util.List<java.lang.Integer> getMultiExpTermNumbers(java.lang.String bucketName)
bucketName - the name of the bucket to retrieve multi-exponentiation term numbers frompublic long getNumRetrievedRepresentations(java.lang.String bucketName)
getRepresentation())
from the bucket with the given name.bucketName - the name of the bucket to retrieve number of retrieved representations frompublic long getNumSquaringsTotal()
public long getNumInversionsTotal()
public long getNumOpsTotal()
public long getNumSquaringsNoExpMultiExp()
public long getNumInversionsNoExpMultiExp()
public long getNumOpsNoExpMultiExp()
public long getNumExps()
public java.util.List<java.lang.Integer> getMultiExpTermNumbers()
public long getNumRetrievedRepresentations()
getRepresentation())
from the default bucket.public long getNumSquaringsTotalAllBuckets()
public long getNumInversionsTotalAllBuckets()
public long getNumOpsTotalAllBuckets()
public long getNumSquaringsNoExpMultiExpAllBuckets()
public long getNumInversionsNoExpMultiExpAllBuckets()
public long getNumOpsNoExpMultiExpAllBuckets()
public long getNumExpsAllBuckets()
public java.util.List<java.lang.Integer> getMultiExpTermNumbersAllBuckets()
public long getNumRetrievedRepresentationsAllBuckets()
getRepresentation())
summed up across all buckets.public void resetCounters(java.lang.String bucketName)
public void resetCounters()
public void resetCountersAllBuckets()
public java.lang.String formatCounterData(java.lang.String bucketName)
bucketName - the name of the bucket whose data to format for printingpublic java.lang.String formatCounterData()
public java.lang.String formatCounterDataAllBuckets(boolean summaryOnly)
summaryOnly - if true, only formats the summed up results across all buckets; otherwise, outputs results
of every bucket plus the summarypublic java.lang.String formatCounterDataAllBuckets()
public int getExponentiationWindowSize()
public void setExponentiationWindowSize(int exponentiationWindowSize)
A larger window size leads to an exponential increase in the number of precomputations done during exponentiation. As the precomputations affected by this variable are only temporarily stored during execution of the exponentiation algorithm, we do not recommend setting this too high as the cost of computing the whole window quickly exceeds its performance benefits during the actual exponentiation.
If you want to change the number of cached precomputations, use setPrecomputationWindowSize(int).
public int getPrecomputationWindowSize()
public void setPrecomputationWindowSize(int precomputationWindowSize)
A larger window size leads to an exponential increase in the number of cached precomputations done but can also improve the performance of later exponentiations.
public MultiExpAlgorithm getSelectedMultiExpAlgorithm()
public void setSelectedMultiExpAlgorithm(MultiExpAlgorithm selectedMultiExpAlgorithm)
public ExpAlgorithm getSelectedExpAlgorithm()
public void setSelectedExpAlgorithm(ExpAlgorithm selectedExpAlgorithm)
public 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.Object