public class MakwaDelegation
extends java.lang.Object
A MakwaDelegation
instance contains the parameters needed
to perform work delegation to an external system (the "delegation
server"). Such a set of parameters is specific to a given modulus
and work factor. Under normal conditions, it is expected that sets
of parameters are created once, then saved in encoded format
(as returned by export()
), and decoded again at application
start-up.
A new set of parameters (for a newly created modulus, or an hitherto
unused work factor) can be obtained with generate(byte[], int)
. The modulus
is provided as either an encoded modulus, or an encoded Makwa private
key. Since generating a set of parameters has a cost similar to computing
Makwa 300 times, it is recommended to use a Makwa private key, which
enables the "fast path".
Instances are immutable and thread-safe.
Constructor and Description |
---|
MakwaDelegation(byte[] params)
Create an instance by decoding a set of delegation parameters.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
export()
Encode this set of parameters.
|
static MakwaDelegation |
generate(byte[] mparam,
int workFactor)
Generate a new set of delegation parameters.
|
java.math.BigInteger |
getModulus()
Get the modulus used by this set of delegation parameters.
|
int |
getWorkFactor()
Get the work factor for which this set of parameters was created.
|
public MakwaDelegation(byte[] params)
params
- the encoded parametersMakwaException
- on decoding errorpublic byte[] export()
public java.math.BigInteger getModulus()
public int getWorkFactor()
public static MakwaDelegation generate(byte[] mparam, int workFactor)
mparam
argument must contains an encoded Makwa modulus, or an
encoded Makwa private key (the latter is recommended; otherwise,
the generation can be computationally expensive).mparam
- the Makwa modulus or private keyworkFactor
- the work factorMakwaException
- on error