public interface Structure extends StandaloneRepresentable
Implementations should override equals() and hashCode().
Structures implement StandaloneRepresentable,
i.e. they must supply a constructor with a single Representation argument.
Hence, their Representation must contain all the information necessary to recreate the structure.
| Modifier and Type | Method and Description |
|---|---|
Element |
getUniformlyRandomElement()
Returns an element of this structure that is drawn uniformly at random
using a cryptographically strong RNG.
|
Vector<? extends Element> |
getUniformlyRandomElements(int n)
Returns n elements of this structure that are drawn uniformly and independently 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. |
default boolean |
hasPrimeSize()
Checks if the structure has prime size.
|
Element |
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).
|
getRepresentationjava.math.BigInteger size()
throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException - if the number of elements is unknown or too expensive to computedefault boolean hasPrimeSize()
java.lang.UnsupportedOperationException - if the primality of the size cannot be determinedElement getUniformlyRandomElement() throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException - if the operation is not supportedVector<? extends Element> getUniformlyRandomElements(int n) throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException - if the operation is not supportedElement restoreElement(Representation repr)
repr - the Representation returned by Representable.getRepresentation()java.util.Optional<java.lang.Integer> getUniqueByteLength()
UniqueByteRepresentable.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.
getUniqueByteRepresentation(),
or an empty Optional, if no guarantee