public class BasicGroup extends java.lang.Object implements Group
GroupImpl wrapper where operations are evaluated naively, i.e. operation by operation.
Useful for groups with very efficient operations.
| Modifier and Type | Field and Description |
|---|---|
protected GroupImpl |
impl |
protected boolean |
isPrimeOrder |
protected java.math.BigInteger |
size |
protected Zn |
zn |
| Constructor and Description |
|---|
BasicGroup(GroupImpl impl) |
BasicGroup(Representation repr) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object o) |
GroupElement |
getGenerator()
Returns any generator of this group if the group is cyclic and it's feasible to compute a generator.
|
GroupElement |
getNeutralElement()
Returns the neutral element for this group
|
Representation |
getRepresentation()
The representation of this object.
|
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.
|
java.math.BigInteger |
size()
Returns the number of elements in this structure (the size).
|
protected BasicGroupElement |
wrap(GroupElementImpl impl) |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitexpr, getUniformlyRandomElements, getUniformlyRandomExponent, getUniformlyRandomExponents, getUniformlyRandomNonNeutrals, getUniformlyRandomNonzeroExponent, getUniformlyRandomNonzeroExponents, getUniformlyRandomUnitExponent, getUniformlyRandomUnitExponents, restoreFromRepresentation, restoreVectorprotected GroupImpl impl
protected java.math.BigInteger size
protected boolean isPrimeOrder
protected Zn zn
public BasicGroup(GroupImpl impl)
public BasicGroup(Representation repr)
protected BasicGroupElement 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()
GroupgetUniformlyRandomNonNeutral in interface Grouppublic 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.Object