public class BasicGroupElement extends java.lang.Object implements GroupElement
GroupElementImpl wrapper where operations are evaluated naively, i.e. operation by operation.| Modifier and Type | Field and Description |
|---|---|
protected BasicGroup |
group |
protected GroupElementImpl |
impl |
protected SmallExponentPrecomputation |
precomputedSmallExponents |
| Constructor and Description |
|---|
BasicGroupElement(BasicGroup group,
GroupElementImpl impl) |
| Modifier and Type | Method and Description |
|---|---|
GroupElement |
compute()
Hint that the concrete value of this GroupElement will be accessed soon
(e.g., via
getRepresentation() or equals()). |
GroupElement |
computeSync()
Will compute stuff synchronously (this call blocks) so that the next call
requiring the concrete value of this group element can immediately retrieve it.
|
boolean |
equals(java.lang.Object o) |
GroupElementImpl |
getConcreteGroupElement() |
SmallExponentPrecomputation |
getPrecomputedSmallExponents() |
Representation |
getRepresentation()
The representation of this object.
|
Group |
getStructure()
Returns the
Structure that this Element belongs to. |
int |
hashCode() |
GroupElement |
inv()
Calculates the inverse of this group element.
|
boolean |
isComputed()
Returns true if a concrete value has already been computed.
|
boolean |
isNeutralElement()
Returns true iff this is the neutral element of the group.
|
GroupElement |
op(Element e)
Calculates the result of
this.op(e). |
GroupElement |
pow(java.math.BigInteger exponent)
Calculates the result of applying the group operation k times.
|
GroupElement |
precomputePow()
Advises the
GroupElement to prepare it for later pow() calls. |
GroupElement |
precomputePow(int windowSize)
Advises the
GroupElement to prepare it for later pow() calls. |
GroupElement |
square()
Computes
this.op(this). |
java.lang.String |
toString() |
ByteAccumulator |
updateAccumulator(ByteAccumulator accumulator)
Updates the ByteAccumulator with the unique byte representation of this object.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, waitexpr, op, op, pow, pow, pow, pow, pow, powgetUniqueByteRepresentationprotected BasicGroup group
protected GroupElementImpl impl
protected SmallExponentPrecomputation precomputedSmallExponents
public BasicGroupElement(BasicGroup group, GroupElementImpl impl)
public Group getStructure()
ElementStructure that this Element belongs to.getStructure in interface ElementgetStructure in interface GroupElementpublic GroupElement inv()
GroupElementinv in interface GroupElementx such that x.op(this).equals(getStructure().getNeutralElement())public GroupElement op(Element e) throws java.lang.IllegalArgumentException
GroupElementthis.op(e).op in interface GroupElemente - right hand side of the operationjava.lang.IllegalArgumentException - if e is of the wrong typepublic GroupElement square()
GroupElementthis.op(this).
Useful if this group allows squaring to be more efficiently implemented than general exponentiation as is the case for elliptic curves.
square in interface GroupElementpublic GroupElement pow(java.math.BigInteger exponent)
GroupElementthis.inv().pow(-k).pow in interface GroupElementpublic boolean isNeutralElement()
GroupElementisNeutralElement in interface GroupElementpublic GroupElement precomputePow()
GroupElementGroupElement to prepare it for later pow() calls.
This will take some time and should only be done ahead of time.
That is, the usual usage pattern should be:
//Setting up your encryption scheme (or whatever)
GroupElement g = group.getUniformlyRandomElement().precomputePow();
//Then (maybe even multiple) future calls of
GroupElement encrypt(GroupElement m) {
return m.op(g.pow(sk)).compute();
}
Don't use g.precomputePow().pow(x).compute();
unless you're planning to do more exponentiations of g in the future.
Uses a reasonable default for the memory consumed by this.
Use GroupElement.precomputePow(int) to customize.precomputePow in interface GroupElementpublic GroupElement precomputePow(int windowSize)
GroupElementGroupElement to prepare it for later pow() calls.
This will take some time and should only be done ahead of time.
That is, the usual usage pattern should be:
//Setting up your encryption scheme (or whatever)
GroupElement g = group.getUniformlyRandomElement().precomputePow();
//Then (maybe even multiple) future calls of
GroupElement encrypt(GroupElement m) {
return m.op(g.pow(sk)).compute();
}
Don't use g.precomputePow().pow(x).compute();
unless you're planning to do more exponentiations of g in the future.precomputePow in interface GroupElementwindowSize - an indicator for how much memory you're willing to invest.
Precomputation will take up space of roughly 2^(windowSize) group elements.public SmallExponentPrecomputation getPrecomputedSmallExponents()
public GroupElement compute()
GroupElementgetRepresentation() or equals()). Will start computing stuff in the background.compute in interface GroupElementpublic GroupElement computeSync()
GroupElementcompute()
which does the same, but asynchronously (i.e. concurrently).computeSync in interface GroupElementpublic GroupElementImpl getConcreteGroupElement()
public boolean isComputed()
GroupElementisComputed in interface GroupElementpublic boolean equals(java.lang.Object o)
public int hashCode()
public ByteAccumulator updateAccumulator(ByteAccumulator accumulator)
UniqueByteRepresentableThe input to the accumulators update function is an injective (with respect to a given domain) byte encoding of this object.
For many use-cases, the AnnotatedUbrUtil can be used to quickly implement this method.
updateAccumulator in interface UniqueByteRepresentablepublic Representation getRepresentation()
RepresentableReprUtilgetRepresentation in interface RepresentableRepresentationpublic java.lang.String toString()
toString in class java.lang.Object